From: Argyrios Kyrtzidis Date: Fri, 22 Apr 2011 18:52:25 +0000 (+0000) Subject: Don't enter a qualified scope for an invalid decl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b65abda449dfb17aba39794be6ce41111d40fda0;p=clang Don't enter a qualified scope for an invalid decl. Fixes assertion later on. rdar://9122937 & http://llvm.org/PR9459 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130006 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 88193f5464..53a7c73998 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -7639,7 +7639,7 @@ bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) { /// class X. void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { // If there is no declaration, there was an error parsing it. - if (D == 0) return; + if (D == 0 || D->isInvalidDecl()) return; // We should only get called for declarations with scope specifiers, like: // int foo::bar; @@ -7651,7 +7651,7 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) { /// initializer for the out-of-line declaration 'D'. void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl *D) { // If there is no declaration, there was an error parsing it. - if (D == 0) return; + if (D == 0 || D->isInvalidDecl()) return; assert(D->isOutOfLine()); ExitDeclaratorContext(S); diff --git a/test/SemaCXX/PR9459.cpp b/test/SemaCXX/PR9459.cpp new file mode 100644 index 0000000000..33cb2e5bc2 --- /dev/null +++ b/test/SemaCXX/PR9459.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Don't crash. + +templatestruct ae_same; // expected-note {{declared here}} +templatestruct ts{}ap() +{ts::ap::&ae_same<>>::p(a); }; // expected-error 2 {{undeclared identifier}} \ + // expected-error 2 {{expected}} expected-error {{a space is required}} \ + // expected-error 2 {{global}} expected-error {{too few}}