r190029 - For "expected unqualified-id" errors after a double colon, and the double colon
Richard Trieu
rtrieu at google.com
Wed Sep 4 19:31:33 PDT 2013
Author: rtrieu
Date: Wed Sep 4 21:31:33 2013
New Revision: 190029
URL: http://llvm.org/viewvc/llvm-project?rev=190029&view=rev
Log:
For "expected unqualified-id" errors after a double colon, and the double colon
is at the end of the line, point to the location after the double colon instead
of at the next token. There is more context to be given this way. In addition,
the next token can be several lines later.
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=190029&r1=190028&r2=190029&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Sep 4 21:31:33 2013
@@ -4779,8 +4779,15 @@ void Parser::ParseDirectDeclarator(Decla
else if (getLangOpts().CPlusPlus) {
if (Tok.is(tok::period) || Tok.is(tok::arrow))
Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
- else
- Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;
+ else {
+ SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
+ if (Tok.isAtStartOfLine() && Loc.isValid())
+ Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
+ << getLangOpts().CPlusPlus;
+ else
+ Diag(Tok, diag::err_expected_unqualified_id)
+ << getLangOpts().CPlusPlus;
+ }
} else
Diag(Tok, diag::err_expected_ident_lparen);
D.SetIdentifier(0, Tok.getLocation());
Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=190029&r1=190028&r2=190029&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Wed Sep 4 21:31:33 2013
@@ -187,6 +187,21 @@ namespace PR15017 {
// Ensure we produce at least some diagnostic for attributes in C++98.
[[]] struct S; // expected-error 2{{}}
+namespace test7 {
+ struct Foo {
+ void a();
+ void b();
+ };
+
+ void Foo::
+ // Comment!
+ a() {}
+
+
+ void Foo:: // expected-error {{expected unqualified-id}}
+ // Comment!
+}
+
namespace PR5066 {
template<typename T> struct X {};
X<int N> x; // expected-error {{type-id cannot have a name}}
More information about the cfe-commits
mailing list