On Mon, Jun 24, 2013 at 4:58 PM, Richard Trieu <[email protected]> wrote:
> When the error message "expected unqualified-id" appears in the middle of > parsing a declarator, and the token pointed to begins a new line, add a > note that points back to the rest of the declarator. This is to prevent > the confusing case where an "expected unqualified-id" message shows up and > points to a line of code where there is a single '}'. > > http://llvm-reviews.chandlerc.com/D1032 > > Files: > lib/Parse/ParseDecl.cpp > test/Parser/cxx-decl.cpp > include/clang/Basic/DiagnosticParseKinds.td > > Index: lib/Parse/ParseDecl.cpp > =================================================================== > --- lib/Parse/ParseDecl.cpp > +++ lib/Parse/ParseDecl.cpp > @@ -4737,8 +4737,14 @@ > 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 > + else { > Diag(Tok, diag::err_expected_unqualified_id) << > getLangOpts().CPlusPlus; > + if (Tok.isAtStartOfLine()) { > + SourceLocation Loc = D.getCXXScopeSpec().getEndLoc(); > + if (Loc.isValid()) > + Diag(PP.getLocForEndOfToken(Loc), diag::note_after_here); > + } > + } > } 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,22 @@ > // 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-note@-1 {{after here}} > + // Comment! > +} // expected-error {{expected unqualified-id}} > > Why don't we just point the error at the first location? -Eli
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
