diff options
author | Richard Trieu <rtrieu@google.com> | 2012-01-21 02:59:18 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2012-01-21 02:59:18 +0000 |
commit | 65ba94814f667e6ea1fcbf0896ad496bb7010335 (patch) | |
tree | e742f78953a4a2926074bfc32d1bb05d839fb989 /lib/Parse/ParseDeclCXX.cpp | |
parent | 8c345c0fc321ada7336ee13b0cd815b91553edaf (diff) |
Fix code so that a SkipUntil will ignore semicolons when skipping a
function body. This keeps the brace count accurate to prevent
additional errors. Also, moved the caret from the brace to the function
name.
Code:
class F{ int Foo{ return 1; } };
Fixed error:
parameters.cc:1:14: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
^
1 error generated.
Old errors:
parameters.cc:1:17: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
^
parameters.cc:1:30: error: expected ';' after class
class F{ int Foo{ return 1; } };
^
;
parameters.cc:1:31: error: expected external declaration
class F{ int Foo{ return 1; } };
^
3 errors generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index c31c55ba5b..050b1b19c4 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1849,9 +1849,9 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, if (DefinitionKind) { if (!DeclaratorInfo.isFunctionDeclarator()) { - Diag(Tok, diag::err_func_def_no_params); + Diag(DeclaratorInfo.getIdentifierLoc(), diag::err_func_def_no_params); ConsumeBrace(); - SkipUntil(tok::r_brace, true); + SkipUntil(tok::r_brace, /*StopAtSemi*/false); // Consume the optional ';' if (Tok.is(tok::semi)) @@ -1860,12 +1860,13 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { - Diag(Tok, diag::err_function_declared_typedef); + Diag(DeclaratorInfo.getIdentifierLoc(), + diag::err_function_declared_typedef); // This recovery skips the entire function body. It would be nice // to simply call ParseCXXInlineMethodDef() below, however Sema // assumes the declarator represents a function, not a typedef. ConsumeBrace(); - SkipUntil(tok::r_brace, true); + SkipUntil(tok::r_brace, /*StopAtSemi*/false); // Consume the optional ';' if (Tok.is(tok::semi)) |