[PATCH] Emit "expected unqualified-id" message on same line as declarator.
Richard Trieu
rtrieu at google.com
Mon Jul 1 13:44:24 PDT 2013
Remove unneeded note.
http://llvm-reviews.chandlerc.com/D1032
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1032?vs=2550&id=2636#toc
Files:
lib/Parse/ParseDecl.cpp
test/Parser/cxx-decl.cpp
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4737,8 +4737,15 @@
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());
Index: test/Parser/cxx-decl.cpp
===================================================================
--- test/Parser/cxx-decl.cpp
+++ test/Parser/cxx-decl.cpp
@@ -187,6 +187,21 @@
// Ensure we produce at least some diagnostic for attributes in C++98.
[[]] struct S; // expected-error 2{{}}
+namespace test7 {
+ struct Foo {
+ int a();
+ int b();
+ };
+
+ int Foo::
+ // Comment!
+ a() {}
+
+
+ int Foo:: // expected-error {{expected unqualified-id}}
+ // Comment!
+}
+
// PR8380
extern "" // expected-error {{unknown linkage language}}
test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1032.3.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130701/c9090640/attachment.bin>
More information about the cfe-commits
mailing list