]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
parser: Do not accept "static class"-members instead of ignoring "class"
authorFlorian Brosch <flo.brosch@gmail.com>
Mon, 15 Sep 2014 20:35:58 +0000 (22:35 +0200)
committerLuca Bruno <luca.bruno@immobiliare.it>
Tue, 23 Sep 2014 09:42:03 +0000 (11:42 +0200)
vala/valaparser.vala

index 1f08f52a7a847da4103b2a113d3772a266388246..3a67021778d4203028d6afffed1d82371d821f88 100644 (file)
@@ -2579,7 +2579,9 @@ public class Vala.Parser : CodeVisitor {
                f.access = access;
 
                set_attributes (f, attrs);
-               if (ModifierFlags.STATIC in flags) {
+               if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
+                       Report.error (f.source_reference, "only one of `static' or `class' may be specified");
+               } else if (ModifierFlags.STATIC in flags) {
                        f.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        f.binding = MemberBinding.CLASS;
@@ -2640,7 +2642,9 @@ public class Vala.Parser : CodeVisitor {
                foreach (TypeParameter type_param in type_param_list) {
                        method.add_type_parameter (type_param);
                }
-               if (ModifierFlags.STATIC in flags) {
+               if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
+                       Report.error (method.source_reference, "only one of `static' or `class' may be specified");
+               } else if (ModifierFlags.STATIC in flags) {
                        method.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        method.binding = MemberBinding.CLASS;
@@ -2731,7 +2735,9 @@ public class Vala.Parser : CodeVisitor {
                var prop = new Property (id, type, null, null, get_src (begin), comment);
                prop.access = access;
                set_attributes (prop, attrs);
-               if (ModifierFlags.STATIC in flags) {
+               if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
+                       Report.error (prop.source_reference, "only one of `static' or `class' may be specified");
+               } else if (ModifierFlags.STATIC in flags) {
                        prop.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        prop.binding = MemberBinding.CLASS;
@@ -2898,7 +2904,9 @@ public class Vala.Parser : CodeVisitor {
                        throw new ParseError.SYNTAX (get_error ("`new' modifier not allowed on constructor"));
                }
                var c = new Constructor (get_src (begin));
-               if (ModifierFlags.STATIC in flags) {
+               if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
+                       Report.error (c.source_reference, "only one of `static' or `class' may be specified");
+               } else if (ModifierFlags.STATIC in flags) {
                        c.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        c.binding = MemberBinding.CLASS;
@@ -2922,7 +2930,9 @@ public class Vala.Parser : CodeVisitor {
                if (identifier != parent.name) {
                        Report.error (d.source_reference, "destructor and parent symbol name do not match");
                }
-               if (ModifierFlags.STATIC in flags) {
+               if (ModifierFlags.STATIC in flags && ModifierFlags.CLASS in flags) {
+                       Report.error (d.source_reference, "only one of `static' or `class' may be specified");
+               } else if (ModifierFlags.STATIC in flags) {
                        d.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        d.binding = MemberBinding.CLASS;