Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2013-03-22 12:06:26 +0400
committerMarek Safar <marek.safar@gmail.com>2013-03-22 13:06:10 +0400
commit8209756fd0f550df18bb26eb88611b70670ff9aa (patch)
treec2183fd42ab7c2aacf7b3ceb373c256ea6bd4c73 /mcs
parent12f8dd310a6253827be2f997ec2e0c9b90be642d (diff)
Try to recover incomplete member declaration which looks like field. Fixes #7521
Diffstat (limited to 'mcs')
-rw-r--r--mcs/errors/cs1519-5.cs7
-rw-r--r--mcs/mcs/cs-parser.jay20
2 files changed, 26 insertions, 1 deletions
diff --git a/mcs/errors/cs1519-5.cs b/mcs/errors/cs1519-5.cs
new file mode 100644
index 00000000000..0ebf40667ed
--- /dev/null
+++ b/mcs/errors/cs1519-5.cs
@@ -0,0 +1,7 @@
+// CS1519: Unexpected symbol `}' in class, struct, or interface member declaration
+// Line: 7
+
+public class Foo
+{
+ public f
+} \ No newline at end of file
diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay
index eeadc8039b6..c65a7ae5e72 100644
--- a/mcs/mcs/cs-parser.jay
+++ b/mcs/mcs/cs-parser.jay
@@ -901,13 +901,14 @@ class_member_declaration
| destructor_declaration
| type_declaration
| attributes_without_members
+ | incomplete_member
| error
{
report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration",
GetSymbolName (yyToken));
$$ = null;
lexer.parsing_generic_declaration = false;
- }
+ }
;
struct_declaration
@@ -2526,6 +2527,23 @@ attributes_without_members
lexer.putback ('}');
}
;
+
+// For full ast try to recover incomplete ambiguous member
+// declaration in form on class X { public int }
+incomplete_member
+ : opt_attributes opt_modifiers member_type CLOSE_BRACE
+ {
+ report.Error (1519, lexer.Location, "Unexpected symbol `}' in class, struct, or interface member declaration");
+
+ lexer.putback ('}');
+
+ lexer.parsing_generic_declaration = false;
+ FullNamedExpression type = (FullNamedExpression) $3;
+ current_field = new Field (current_type, type, (Modifiers) $2, MemberName.Null, (Attributes) $1);
+ current_type.AddField (current_field);
+ $$ = current_field;
+ }
+ ;
enum_declaration
: opt_attributes