[mcs] The parser can now track in FULL_AST mode dangling attributes at the end of...
authorMiguel de Icaza <miguel@gnome.org>
Tue, 14 Feb 2012 02:55:25 +0000 (21:55 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 14 Feb 2012 02:55:25 +0000 (21:55 -0500)
mcs/mcs/class.cs
mcs/mcs/cs-parser.jay

index cc1cc614d419432a8ba110d966e53c980463e567..15e1833e786f7b989af64c674279f2f828942058 100644 (file)
@@ -53,6 +53,11 @@ namespace Mono.CSharp
 
                protected bool is_defined;
 
+#if FULL_AST
+               // Any unattached attributes during parsing get added here.
+               public Attribute [] UnattachedAttributes;
+#endif
+
                public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind)
                        : base (parent, name, attrs)
                {
index 1473dec460b5b6c1e8b25e2437a4bd6255f8fd97..d47865df794f813b83b0b9ee44c06713df0e278a 100644 (file)
@@ -868,6 +868,7 @@ class_member_declaration
        | constructor_declaration
        | destructor_declaration
        | type_declaration
+       | attributes_without_members
        | error
          {
                report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration",
@@ -2424,6 +2425,16 @@ event_accessor_block
        | block;
        ;
 
+attributes_without_members
+       : attribute_sections CLOSE_BRACE {
+#if FULL_AST
+               current_type.AddUnattachedAttributes (((List<Attribute>) $1).ToArray ());
+#endif
+               report.Error (1519, lexer.Location, "Attribute not attached to any member.   Unexpected symbol `{0}' in class, struct, or interface member declaration. ");
+               lexer.putback ('}');
+         }
+       ;
+         
 enum_declaration
        : opt_attributes
          opt_modifiers