]> granicus.if.org Git - clang/commitdiff
Fix crash-on-invalid if a :: is followed by two or more open parentheses (and then...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 19 Dec 2015 02:40:19 +0000 (02:40 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 19 Dec 2015 02:40:19 +0000 (02:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256080 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/colon-colon-parentheses.cpp

index 4039f2ac2a3f34123b53ece6a8304533e0d8006b..c85ea4a11fe0aed47a9c39f7b7619de66fed8f23 100644 (file)
@@ -5198,6 +5198,15 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
       }
       goto PastIdentifier;
     }
+
+    if (D.getCXXScopeSpec().isNotEmpty()) {
+      // We have a scope specifier but no following unqualified-id.
+      Diag(PP.getLocForEndOfToken(D.getCXXScopeSpec().getEndLoc()),
+           diag::err_expected_unqualified_id)
+          << /*C++*/1;
+      D.SetIdentifier(nullptr, Tok.getLocation());
+      goto PastIdentifier;
+    }
   } else if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
     assert(!getLangOpts().CPlusPlus &&
            "There's a C++-specific check for tok::identifier above");
index e031ce2e9045162f4f59328060a8087de15a812a..b3db4fbed2f11e28aa7af84308966ea764356fde 100644 (file)
@@ -22,9 +22,9 @@ void foo() {
 }
 
 #ifdef PR21815
-// expected-error@+4{{C++ requires a type specifier for all declarations}}
-// expected-error@+3{{expected unqualified-id}}
-// expected-error@+3{{expected expression}}
-// expected-error@+1{{expected ';' after top level declarator}}
-a (::(
+// expected-error@+2{{C++ requires a type specifier for all declarations}}
+// expected-error@+1{{expected unqualified-id}}
+a (::( ));
+
+::((c )); // expected-error{{expected unqualified-id}}
 #endif