r217472 - Don't crash on access decls with invalid scope specifier, PR20887.

Nico Weber nicolasweber at gmx.de
Tue Sep 9 17:59:37 PDT 2014


Author: nico
Date: Tue Sep  9 19:59:37 2014
New Revision: 217472

URL: http://llvm.org/viewvc/llvm-project?rev=217472&view=rev
Log:
Don't crash on access decls with invalid scope specifier, PR20887.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=217472&r1=217471&r2=217472&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Sep  9 19:59:37 2014
@@ -2072,6 +2072,11 @@ void Parser::ParseCXXClassMemberDeclarat
       ParseOptionalCXXScopeSpecifier(SS, ParsedType(), 
                                      /*EnteringContext=*/false);
 
+      if (SS.isInvalid()) {
+        SkipUntil(tok::semi);
+        return;
+      }
+
       // Try to parse an unqualified-id.
       SourceLocation TemplateKWLoc;
       UnqualifiedId Name;

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=217472&r1=217471&r2=217472&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Tue Sep  9 19:59:37 2014
@@ -174,6 +174,11 @@ class PR20760_b {
   int f = d // expected-warning {{extension}} expected-error {{expected ';'}}
 };
 
+namespace PR20887 {
+class X1 { a::operator=; }; // expected-error {{undeclared identifier 'a'}}
+class X2 { a::a; }; // expected-error {{undeclared identifier 'a'}}
+}
+
 // PR11109 must appear at the end of the source file
 class pr11109r3 { // expected-note{{to match this '{'}}
   public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}





More information about the cfe-commits mailing list