]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not accept `ref' and `out' expressions outside of arguments, fixes bug
authorJürg Billeter <j@bitron.ch>
Fri, 9 Jan 2009 18:22:13 +0000 (18:22 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 9 Jan 2009 18:22:13 +0000 (18:22 +0000)
2009-01-09  Jürg Billeter  <j@bitron.ch>

* vala/valaparser.vala:

Do not accept `ref' and `out' expressions outside of arguments,
fixes bug 548418

svn path=/trunk/; revision=2306

ChangeLog
vala/valaparser.vala

index b65882ba25ec87da835bf86fcd71fcdc17599a64..7aebcc66a4ac92d45f0c55a1b9659ec88f6df49a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-09  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaparser.vala:
+
+       Do not accept `ref' and `out' expressions outside of arguments,
+       fixes bug 548418
+
 2009-01-09  Jürg Billeter  <j@bitron.ch>
 
        * vala/valalambdaexpression.vala:
index a5a20fdff06e9181b2b46679841d0ecf9bfecc8f..040fa58fef04ca69b810b1e05ddaba60c489acb4 100644 (file)
@@ -445,12 +445,26 @@ public class Vala.Parser : CodeVisitor {
                var list = new ArrayList<Expression> ();
                if (current () != TokenType.CLOSE_PARENS) {
                        do {
-                               list.add (parse_expression ());
+                               list.add (parse_argument ());
                        } while (accept (TokenType.COMMA));
                }
                return list;
        }
 
+       Expression parse_argument () throws ParseError {
+               var begin = get_location ();
+
+               if (accept (TokenType.REF)) {
+                       var inner = parse_expression ();
+                       return new UnaryExpression (UnaryOperator.REF, inner, get_src (begin));
+               } else if (accept (TokenType.OUT)) {
+                       var inner = parse_expression ();
+                       return new UnaryExpression (UnaryOperator.OUT, inner, get_src (begin));
+               } else {
+                       return parse_expression ();
+               }
+       }
+
        Expression parse_primary_expression () throws ParseError {
                var begin = get_location ();
 
@@ -777,8 +791,6 @@ public class Vala.Parser : CodeVisitor {
                case TokenType.TILDE:  return UnaryOperator.BITWISE_COMPLEMENT;
                case TokenType.OP_INC: return UnaryOperator.INCREMENT;
                case TokenType.OP_DEC: return UnaryOperator.DECREMENT;
-               case TokenType.REF:    return UnaryOperator.REF;
-               case TokenType.OUT:    return UnaryOperator.OUT;
                default:               return UnaryOperator.NONE;
                }
        }
@@ -2092,7 +2104,7 @@ public class Vala.Parser : CodeVisitor {
                var initializer = new InitializerList (get_src (begin));
                if (current () != TokenType.CLOSE_BRACE) {
                        do {
-                               var init = parse_expression ();
+                               var init = parse_argument ();
                                initializer.append (init);
                        } while (accept (TokenType.COMMA));
                }