Skip to content

Commit

Permalink
Attach more misplaced attributes in full ast. Fixes mono#3947
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Mar 19, 2012
1 parent 26a9ba9 commit da07d66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions mcs/mcs/class.cs
Expand Up @@ -85,14 +85,13 @@ public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, M
}
}

#if FULL_AST
//
// Any unattached attributes during parsing get added here.
// Any unattached attributes during parsing get added here. User
// by FULL_AST mode
//
public Attributes UnattachedAttributes {
get; set;
}
#endif

public virtual void AddCompilerGeneratedClass (CompilerGeneratedContainer c)
{
Expand Down
9 changes: 4 additions & 5 deletions mcs/mcs/cs-parser.jay
Expand Up @@ -391,6 +391,8 @@ outer_declaration
Attributes attrs = (Attributes) $4;
report.Error (1730, attrs.Attrs [0].Location,
"Assembly and module attributes must precede all other elements except using clauses and extern alias declarations");

current_namespace.UnattachedAttributes = attrs;
}
}
| opt_extern_alias_directives opt_using_directives attribute_sections
Expand Down Expand Up @@ -608,9 +610,7 @@ namespace_or_type_declaration
current_namespace.DeclarationFound = true;
}
| attribute_sections CLOSE_BRACE {
#if FULL_AST
current_namespace.UnattachedAttributes = (Attributes) $1;
#endif
report.Error (1518, lexer.Location, "Attributes must be attached to class, delegate, enum, interface or struct");
lexer.putback ('}');
}
Expand Down Expand Up @@ -2450,10 +2450,9 @@ event_accessor_block
;

attributes_without_members
: attribute_sections CLOSE_BRACE {
#if FULL_AST
: attribute_sections CLOSE_BRACE
{
current_type.UnattachedAttributes = (Attributes) $1;
#endif
report.Error (1519, GetLocation ($1), "An attribute is missing member declaration");
lexer.putback ('}');
}
Expand Down

0 comments on commit da07d66

Please sign in to comment.