Skip to content

Commit

Permalink
fix Issue 13609 - better error message for missing '}'
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Oct 13, 2014
1 parent 183a24d commit 164821c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/parse.c
Expand Up @@ -2174,15 +2174,17 @@ Dsymbol *Parser::parseAggregate()
//printf("Parser::parseAggregate()\n");
nextToken();
if (token.value != TOKidentifier)
{ id = NULL;
{
id = NULL;
}
else
{ id = token.ident;
{
id = token.ident;
nextToken();

if (token.value == TOKlparen)
{ // Class template declaration.

{
// Class template declaration.
// Gather template parameter list
tpl = parseTemplateParameterList();
constraint = parseConstraint();
Expand Down Expand Up @@ -2249,15 +2251,16 @@ Dsymbol *Parser::parseAggregate()
break;
}
if (a && token.value == TOKsemicolon)
{ nextToken();
{
nextToken();
}
else if (token.value == TOKlcurly)
{
//printf("aggregate definition\n");
nextToken();
Dsymbols *decl = parseDeclDefs(0);
if (token.value != TOKrcurly)
error("} expected following member declarations in aggregate");
error("} expected following members in %s declaration at %s", Token::toChars(tok), loc.toChars());
nextToken();
if (anon)
{
Expand All @@ -2270,7 +2273,7 @@ Dsymbol *Parser::parseAggregate()
}
else
{
error("{ } expected following aggregate declaration");
error("{ } expected following %s declaration", Token::toChars(tok));
a = new StructDeclaration(loc, NULL);
}

Expand Down
10 changes: 10 additions & 0 deletions test/fail_compilation/diag13609a.d
@@ -0,0 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag13609a.d(11): Error: } expected following members in class declaration at fail_compilation/diag13609a.d(8)
---
*/

class C
{
void foo() {}
9 changes: 9 additions & 0 deletions test/fail_compilation/diag13609b.d
@@ -0,0 +1,9 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag13609b.d(9): Error: { } expected following struct declaration
fail_compilation/diag13609b.d(9): Error: Declaration expected, not ':'
---
*/

struct S :

0 comments on commit 164821c

Please sign in to comment.