summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-09-05 02:31:33 +0000
committerRichard Trieu <rtrieu@google.com>2013-09-05 02:31:33 +0000
commit2f58696ddd0b0e247b0b9bb8479900fa5c8ee765 (patch)
tree7a838f82fc3755cab0fdedab10772e1c474057ab
parent6ad0686da876d706b22336aa85f4a724a5130ca5 (diff)
downloadbcm5719-llvm-2f58696ddd0b0e247b0b9bb8479900fa5c8ee765.tar.gz
bcm5719-llvm-2f58696ddd0b0e247b0b9bb8479900fa5c8ee765.zip
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. llvm-svn: 190029
-rw-r--r--clang/lib/Parse/ParseDecl.cpp11
-rw-r--r--clang/test/Parser/cxx-decl.cpp15
2 files changed, 24 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 5d47d3d9b80..48a30a15b1b 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4779,8 +4779,15 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
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());
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
index e3f3957d564..281e33b20f8 100644
--- a/clang/test/Parser/cxx-decl.cpp
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -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}}
OpenPOWER on IntegriCloud