From 98045aa38c5f99972a98387469f2fcfcc28ee5e9 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 10 Sep 2014 00:59:37 +0000 Subject: [PATCH] Don't crash on access decls with invalid scope specifier, PR20887. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217472 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDeclCXX.cpp | 5 +++++ test/Parser/cxx-class.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 497f7e06dd..b252ed5865 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2072,6 +2072,11 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false); + if (SS.isInvalid()) { + SkipUntil(tok::semi); + return; + } + // Try to parse an unqualified-id. SourceLocation TemplateKWLoc; UnqualifiedId Name; diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 7e820f17aa..b6eb1b46db 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -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}} -- 2.40.0