From: Nico Weber Date: Fri, 30 Jan 2015 04:05:15 +0000 (+0000) Subject: Follow-up to r217302: Don't crash on ~A::A() if A is undeclared. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=814aa7c5c3a3b158948541f7c8af5c0835d0ddbb;p=clang Follow-up to r217302: Don't crash on ~A::A() if A is undeclared. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227555 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 422b486c7b..a753b0ff27 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -2516,7 +2516,8 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, } if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext)) return true; - if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon)) { + if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon) || + SS.isInvalid()) { Diag(TildeLoc, diag::err_destructor_tilde_scope); return true; } diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 9d68cd96b0..7c5c4ecf58 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -157,6 +157,8 @@ namespace DtorErrors { struct D { struct X {}; ~D() throw(X); }; ~D::D() throw(X) {} // expected-error {{'~' in destructor name should be after nested name specifier}} + + ~Undeclared::Undeclared() {} // expected-error {{use of undeclared identifier 'Undeclared'}} expected-error {{'~' in destructor name should be after nested name specifier}} } namespace BadFriend {