<div dir="ltr">On Mon, Jun 24, 2013 at 5:13 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Mon, Jun 24, 2013 at 4:58 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br>
</div></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 '}'.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D1032" target="_blank">http://llvm-reviews.chandlerc.com/D1032</a><br>
<br>
Files:<br>
lib/Parse/ParseDecl.cpp<br>
test/Parser/cxx-decl.cpp<br>
include/clang/Basic/DiagnosticParseKinds.td<br>
<br>
Index: lib/Parse/ParseDecl.cpp<br>
===================================================================<br>
--- lib/Parse/ParseDecl.cpp<br>
+++ lib/Parse/ParseDecl.cpp<br>
@@ -4737,8 +4737,14 @@<br>
else if (getLangOpts().CPlusPlus) {<br>
if (Tok.is(tok::period) || Tok.is(tok::arrow))<br>
Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);<br>
- else<br>
+ else {<br>
Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;<br>
+ if (Tok.isAtStartOfLine()) {<br>
+ SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();<br>
+ if (Loc.isValid())<br>
+ Diag(PP.getLocForEndOfToken(Loc), diag::note_after_here);<br>
+ }<br>
+ }<br>
} else<br>
Diag(Tok, diag::err_expected_ident_lparen);<br>
D.SetIdentifier(0, Tok.getLocation());<br>
Index: test/Parser/cxx-decl.cpp<br>
===================================================================<br>
--- test/Parser/cxx-decl.cpp<br>
+++ test/Parser/cxx-decl.cpp<br>
@@ -187,6 +187,22 @@<br>
// Ensure we produce at least some diagnostic for attributes in C++98.<br>
[[]] struct S; // expected-error 2{{}}<br>
<br>
+namespace test7 {<br>
+ struct Foo {<br>
+ int a();<br>
+ int b();<br>
+ };<br>
+<br>
+ int Foo::<br>
+ // Comment!<br>
+ a() {}<br>
+<br>
+<br>
+ int Foo::<br>
+ // expected-note@-1 {{after here}}<br>
+ // Comment!<br>
+} // expected-error {{expected unqualified-id}}<br>
<br></blockquote><div><br></div></div></div><div>Why don't we just point the error at the first location?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Eli</div></font></span></div></div></div>
</blockquote></div><br></div><div class="gmail_extra">That sounds like it would work too. My first thought was to add a note, but moving the caret is also a solution to this problem.</div></div>