<p dir="ltr">Looks like the wrong change for this commit message (either the patch content or the commit message are wrong?)?</p>
<div class="gmail_quote">On Feb 15, 2015 12:50 AM, "Larisse Voufo" <<a href="mailto:lvoufo@google.com">lvoufo@google.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: lvoufo<br>
Date: Sun Feb 15 02:47:30 2015<br>
New Revision: 229293<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=229293&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=229293&view=rev</a><br>
Log:<br>
Don't crash on `struct ::, struct ::` (and the same for enums).<br>
<br>
The first part of that line doesn't parse correctly and ParseClassSpecifier() for<br>
some reason skips to tok::comma to recover, and then<br>
ParseDeclarationSpecifiers() sees the next struct and calls<br>
ParseClassSpecifier() again with the same DeclSpec object.<br>
<br>
However, the first call already called ActOnCXXGlobalScopeSpecifier() on the<br>
DeclSpec's CXXScopeSpec, and sema gets confused when this gets called again.<br>
<br>
As a fix, let ParseClassSpecifier() (and ParseEnumSpecifier()) call<br>
ParseOptionalCXXScopeSpec() with a temporary CXXScopeSpec object, and only<br>
copy it into the DeclSpec if things work out.  (This is also how all the other<br>
functions that set the DeclSpec's TypeSpecScope set it.)<br>
<br>
Found by SLi's bot.<br>
<br>
Modified:<br>
    cfe/trunk/test/Parser/recovery.cpp<br>
<br>
Modified: cfe/trunk/test/Parser/recovery.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.cpp?rev=229293&r1=229292&r2=229293&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.cpp?rev=229293&r1=229292&r2=229293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Parser/recovery.cpp (original)<br>
+++ cfe/trunk/test/Parser/recovery.cpp Sun Feb 15 02:47:30 2015<br>
@@ -1,214 +0,0 @@<br>
-// RUN: %clang_cc1 -verify -std=c++11 -fms-extensions %s<br>
-<br>
-8gi///===--- recovery.cpp ---===// // expected-error {{unqualified-id}}<br>
-namespace Std { // expected-note {{here}}<br>
-  typedef int Important;<br>
-}<br>
-<br>
-/ redeclare as an inline namespace // expected-error {{unqualified-id}}<br>
-inline namespace Std { // expected-error {{cannot be reopened as inline}}<br>
-  Important n;<br>
-} / end namespace Std // expected-error {{unqualified-id}}<br>
-int x;<br>
-Std::Important y;<br>
-<br>
-extenr "C" { // expected-error {{did you mean 'extern'}}<br>
-  void f();<br>
-}<br>
-void g() {<br>
-  z = 1; // expected-error {{undeclared}}<br>
-  f();<br>
-}<br>
-<br>
-struct S {<br>
-  int a, b, c;<br>
-  S();<br>
-  int x // expected-error {{expected ';'}}<br>
-  friend void f()<br>
-};<br>
-8S::S() : a{ 5 }, b{ 6 }, c{ 2 } { // expected-error {{unqualified-id}}<br>
-  return;<br>
-}<br>
-int k;<br>
-int l = k // expected-error {{expected ';'}}<br>
-constexpr int foo();<br>
-<br>
-5int m = { l }, n = m; // expected-error {{unqualified-id}}<br>
-<br>
-namespace MissingBrace {<br>
-  struct S { // expected-error {{missing '}' at end of definition of 'MissingBrace::S'}}<br>
-    int f();<br>
-  // };<br>
-<br>
-  namespace N { int g(); } // expected-note {{still within definition of 'MissingBrace::S' here}}<br>
-<br>
-  int k1 = S().h(); // expected-error {{no member named 'h' in 'MissingBrace::S'}}<br>
-  int k2 = S().f() + N::g();<br>
-<br>
-  template<typename T> struct PR17949 { // expected-error {{missing '}' at end of definition of 'MissingBrace::PR17949'}}<br>
-<br>
-  namespace X { // expected-note {{still within definition of 'MissingBrace::PR17949' here}}<br>
-  }<br>
-}<br>
-<br>
-namespace N {<br>
-  int<br>
-} // expected-error {{unqualified-id}}<br>
-<br>
-strcut Uuuu { // expected-error {{did you mean 'struct'}} \<br>
-              // expected-note {{'Uuuu' declared here}}<br>
-} *u[3];<br>
-uuuu v; // expected-error {{did you mean 'Uuuu'}}<br>
-<br>
-struct Redefined { // expected-note {{previous}}<br>
-  Redefined() {}<br>
-};<br>
-struct Redefined { // expected-error {{redefinition}}<br>
-  Redefined() {}<br>
-};<br>
-<br>
-struct MissingSemi5;<br>
-namespace N {<br>
-  typedef int afterMissingSemi4;<br>
-  extern MissingSemi5 afterMissingSemi5;<br>
-}<br>
-<br>
-struct MissingSemi1 {} // expected-error {{expected ';' after struct}}<br>
-static int afterMissingSemi1();<br>
-<br>
-class MissingSemi2 {} // expected-error {{expected ';' after class}}<br>
-MissingSemi1 *afterMissingSemi2;<br>
-<br>
-enum MissingSemi3 {} // expected-error {{expected ';' after enum}}<br>
-::MissingSemi1 afterMissingSemi3;<br>
-<br>
-extern N::afterMissingSemi4 afterMissingSemi4b;<br>
-union MissingSemi4 { MissingSemi4(int); } // expected-error {{expected ';' after union}}<br>
-N::afterMissingSemi4 (afterMissingSemi4b);<br>
-<br>
-int afterMissingSemi5b;<br>
-struct MissingSemi5 { MissingSemi5(int); } // ok, no missing ';' here<br>
-N::afterMissingSemi5 (afterMissingSemi5b);<br>
-<br>
-template<typename T> struct MissingSemiT {<br>
-} // expected-error {{expected ';' after struct}}<br>
-MissingSemiT<int> msi;<br>
-<br>
-struct MissingSemiInStruct {<br>
-  struct Inner1 {} // expected-error {{expected ';' after struct}}<br>
-  static MissingSemi5 ms1;<br>
-<br>
-  struct Inner2 {} // ok, no missing ';' here<br>
-  static MissingSemi1;<br>
-<br>
-  struct Inner3 {} // expected-error {{expected ';' after struct}}<br>
-  static MissingSemi5 *p;<br>
-};<br>
-<br>
-void MissingSemiInFunction() {<br>
-  struct Inner1 {} // expected-error {{expected ';' after struct}}<br>
-  if (true) {}<br>
-<br>
-  // FIXME: It would be nice to at least warn on this.<br>
-  struct Inner2 { Inner2(int); } // ok, no missing ';' here<br>
-  k = l;<br>
-<br>
-  struct Inner3 {} // expected-error {{expected ';' after struct}}<br>
-  Inner1 i1;<br>
-<br>
-  struct Inner4 {} // ok, no missing ';' here<br>
-  Inner5;<br>
-}<br>
-<br>
-namespace NS {<br>
-  template<typename T> struct Foo {};<br>
-}<br>
-struct MissingSemiThenTemplate1 {} // expected-error {{expected ';' after struct}}<br>
-NS::Foo<int> missingSemiBeforeFunctionReturningTemplateId1();<br>
-<br>
-using NS::Foo;<br>
-struct MissingSemiThenTemplate2 {} // expected-error {{expected ';' after struct}}<br>
-Foo<int> missingSemiBeforeFunctionReturningTemplateId2();<br>
-<br>
-namespace PR17084 {<br>
-enum class EnumID {};<br>
-template <typename> struct TempID;<br>
-template <> struct TempID<BadType> : BadType, EnumID::Garbage; // expected-error{{use of undeclared identifier 'BadType'}}<br>
-}<br>
-<br>
-namespace pr15133 {<br>
-  namespace ns {<br>
-    const int V1 = 1;   // expected-note {{declared here}}<br>
-  }<br>
-  struct C1 {<br>
-    enum E1 { V2 = 2 }; // expected-note {{declared here}}<br>
-    static const int V3 = 3; // expected-note {{declared here}}<br>
-  };<br>
-  enum E2 {<br>
-    V4 = 4,   // expected-note {{declared here}}<br>
-    V6        // expected-note {{declared here}}<br>
-  };<br>
-  enum class EC3 { V0 = 0, V5 = 5 }; // expected-note {{declared here}}<br>
-  void func_3();<br>
-<br>
-  void func_1(int x) {<br>
-    switch(x) {<br>
-    case 0: break;<br>
-    case ns::V1:: break; // expected-error{{'V1' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    case C1::V2:: break; // expected-error{{'V2' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    case C1::V3:: break; // expected-error{{'V3' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    case V4:: break; // expected-error{{'V4' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    case V6:: func_3();   // expected-error{{'V6' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    }<br>
-  }<br>
-  void func_2(EC3 x) {<br>
-    switch(x) {<br>
-    case EC3::V0:  break;<br>
-    case EC3::V5:: break; // expected-error{{'V5' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-    }<br>
-  }<br>
-<br>
-  template<class T> struct TS1 {<br>
-    typedef int A;<br>
-  };<br>
-  template<class T> void func(int x) {<br>
-    switch(x) {<br>
-    case TS1<T>::A:: break;  // expected-error{{expected unqualified-id}}<br>
-    }<br>
-  };<br>
-  void mainf() {<br>
-    func<int>(1);<br>
-  }<br>
-<br>
-  struct S {<br>
-    static int n;  // expected-note{{declared here}}<br>
-    int nn;        // expected-note 2 {{declared here}}<br>
-  };<br>
-<br>
-  int func_3(int x) {<br>
-    return x ? S::n :: 0;  // expected-error{{'n' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-  }<br>
-  int func_4(int x, S &s) {<br>
-    return x ? s.nn :: x;  // expected-error{{'nn' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-  }<br>
-  int func_5(int x, S &s) {<br>
-    return x ? s.nn :: S::n;  // expected-error{{'nn' cannot appear before '::' because it is not a class, namespace, or enumeration; did you mean ':'?}}<br>
-  }<br>
-<br>
-  struct S2 {<br>
-    struct S3;<br>
-  };<br>
-<br>
-  struct S2 :: S3 :: public S2 {  // expected-error{{'public' cannot be a part of nested name specifier; did you mean ':'?}}<br>
-  };<br>
-}<br>
-<br>
-namespace InvalidEmptyNames {<br>
-// These shouldn't crash, the diagnostics aren't important.<br>
-struct ::, struct ::; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}}<br>
-enum ::, enum ::; // expected-error 2 {{expected identifier}} expected-warning {{declaration does not declare anything}}<br>
-struct ::__super, struct ::__super; // expected-error 2 {{expected identifier}} expected-error 2 {{expected '::' after '__super'}}<br>
-struct ::template foo, struct ::template bar; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}}<br>
-struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} expected-error {{declaration of anonymous struct must be a definition}}<br>
-class :: : {} a;  // expected-error {{expected identifier}} expected-error {{expected class name}}<br>
-}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">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>