<div dir="ltr">Done in r224945.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 29, 2014 at 7:18 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">LGTM. "expected identifier before '{'" would also work; I don't think this needs its own custom diagnostic.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On 29 Dec 2014 10:05, "David Majnemer" <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Perhaps something like the following?<br></div><div><div><br></div><div>diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td</div><div>index f39c2b8..f176370 100644</div><div>--- a/include/clang/Basic/DiagnosticParseKinds.td</div><div>+++ b/include/clang/Basic/DiagnosticParseKinds.td</div><div>@@ -374,6 +374,8 @@ def warn_cxx98_compat_static_assert : Warning<</div><div>   InGroup<CXX98Compat>, DefaultIgnore;</div><div> def err_paren_after_colon_colon : Error<</div><div>   "unexpected parenthesis after '::'">;</div><div>+def err_brace_after_colon_colon : Error<</div><div>+  "unexpected brace after '::'">;</div><div> def err_function_definition_not_allowed : Error<</div><div>   "function definition is not allowed here">;</div><div> def err_expected_end_of_enumerator : Error<</div><div>diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp</div><div>index dad1f0d..7968a01 100644</div><div>--- a/lib/Parse/ParseExprCXX.cpp</div><div>+++ b/lib/Parse/ParseExprCXX.cpp</div><div>@@ -219,13 +219,20 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,</div><div>     if (NextKind == tok::kw_new || NextKind == tok::kw_delete)</div><div>       return false;</div><div> </div><div>-    // '::' - Global scope qualifier.</div><div>-    if (Actions.ActOnCXXGlobalScopeSpecifier(ConsumeToken(), SS))</div><div>-      return true;</div><div>+    if (NextKind == tok::l_brace) {</div><div>+      // It is invalid to have :: {, consume the scope qualifier and pretend</div><div>+      // like we never saw it.</div><div>+      SourceLocation ColonColonLoc = ConsumeToken();</div><div>+      Diag(ColonColonLoc, diag::err_brace_after_colon_colon);</div><div>+    } else {</div><div>+      // '::' - Global scope qualifier.</div><div>+      if (Actions.ActOnCXXGlobalScopeSpecifier(ConsumeToken(), SS))</div><div>+        return true;</div><div> </div><div>-    CheckForLParenAfterColonColon();</div><div>+      CheckForLParenAfterColonColon();</div><div> </div><div>-    HasScopeSpecifier = true;</div><div>+      HasScopeSpecifier = true;</div><div>+    }</div><div>   }</div><div> </div><div>   if (Tok.is(tok::kw___super)) {</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 29, 2014 at 12:53 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Perhaps we should drop the qualifier in the parser in this case; this doesn't match the grammar and it doesn't make a lot of sense to propagate this weird broken state all the way into the AST.</p><div><div>
<div class="gmail_quote">On 29 Dec 2014 05:21, "David Majnemer" <<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sun Dec 28 23:17:46 2014<br>
New Revision: 224912<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=224912&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=224912&view=rev</a><br>
Log:<br>
Sema: Don't crash when solitary :: token appears before { in struct def<br>
<br>
hasDeclaratorForAnonDecl, getDeclaratorForAnonDecl and<br>
getTypedefNameForAnonDecl are expected to handle the case where<br>
NamedDeclOrQualifier holds the wrong type or nothing at all.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/Decl.h<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
    cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Decl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=224912&r1=224911&r2=224912&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=224912&r1=224911&r2=224912&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Decl.h (original)<br>
+++ cfe/trunk/include/clang/AST/Decl.h Sun Dec 28 23:17:46 2014<br>
@@ -2823,16 +2823,18 @@ public:<br>
<br>
   bool hasDeclaratorForAnonDecl() const {<br>
     return dyn_cast_or_null<DeclaratorDecl>(<br>
-        NamedDeclOrQualifier.get<NamedDecl *>());<br>
+        NamedDeclOrQualifier.dyn_cast<NamedDecl *>());<br>
   }<br>
   DeclaratorDecl *getDeclaratorForAnonDecl() const {<br>
-    return hasExtInfo() ? nullptr : dyn_cast_or_null<DeclaratorDecl>(<br>
-                                  NamedDeclOrQualifier.get<NamedDecl *>());<br>
+    return hasExtInfo() ? nullptr<br>
+                        : dyn_cast_or_null<DeclaratorDecl>(<br>
+                              NamedDeclOrQualifier.dyn_cast<NamedDecl *>());<br>
   }<br>
<br>
   TypedefNameDecl *getTypedefNameForAnonDecl() const {<br>
-    return hasExtInfo() ? nullptr : dyn_cast_or_null<TypedefNameDecl>(<br>
-                                  NamedDeclOrQualifier.get<NamedDecl *>());<br>
+    return hasExtInfo() ? nullptr<br>
+                        : dyn_cast_or_null<TypedefNameDecl>(<br>
+                              NamedDeclOrQualifier.dyn_cast<NamedDecl *>());<br>
   }<br>
<br>
   void setDeclaratorForAnonDecl(DeclaratorDecl *DD) { NamedDeclOrQualifier = DD; }<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=224912&r1=224911&r2=224912&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=224912&r1=224911&r2=224912&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Dec 28 23:17:46 2014<br>
@@ -11790,7 +11790,7 @@ CreateNewDecl:<br>
       // CheckMemberSpecialization, below.<br>
       if (!isExplicitSpecialization &&<br>
           (TUK == TUK_Definition || TUK == TUK_Declaration) &&<br>
-          diagnoseQualifiedDeclaration(SS, DC, OrigName, NameLoc))<br>
+          diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc))<br>
         Invalid = true;<br>
<br>
       New->setQualifierInfo(SS.getWithLocInContext(Context));<br>
<br>
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp?rev=224912&r1=224911&r2=224912&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp?rev=224912&r1=224911&r2=224912&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp (original)<br>
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1.cpp Sun Dec 28 23:17:46 2014<br>
@@ -43,3 +43,6 @@ namespace NS {<br>
   template<typename T> struct NS::Y { }; // expected-warning{{extra qualification on member 'Y'}}<br>
   template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}<br>
 }<br>
+<br>
+// expected-warning@+1{{extra qualification on member}}<br>
+struct ::{} a; // expected-error{{expected identifier}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>
</blockquote></div>
</div></div></blockquote></div><br></div>