From: Serge Pavlov Date: Sat, 10 Aug 2013 12:00:21 +0000 (+0000) Subject: Fix to PR16225 (Assert-on-invalid: isa(D) && "declaration not instantiated... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29a46e63490176608efe13f13b293a6ce9862059;p=clang Fix to PR16225 (Assert-on-invalid: isa(D) && "declaration not instantiated in this scope") Differential Revision: http://llvm-reviews.chandlerc.com/D920 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index ce7684c9ed..315a405c6d 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4063,6 +4063,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, isa(D)) return D; + if (D->isInvalidDecl()) + return 0; + // If we didn't find the decl, then we must have a label decl that hasn't // been found yet. Lazily instantiate it and return it now. assert(isa(D)); diff --git a/test/SemaTemplate/recovery-crash.cpp b/test/SemaTemplate/recovery-crash.cpp index b5a0e1fa13..78f6db40d5 100644 --- a/test/SemaTemplate/recovery-crash.cpp +++ b/test/SemaTemplate/recovery-crash.cpp @@ -22,3 +22,16 @@ namespace PR16134 { template struct S // expected-error {{expected ';'}} template <> static S::f() // expected-error +{{}} } + +namespace PR16225 { + template void f(); + template void g(C*) { + struct LocalStruct : UnknownBase { }; // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use of undeclared identifier 'Mumble'}} + f(); // expected-warning {{template argument uses local type 'LocalStruct'}} + } + struct S; + void h() { + g(0); // expected-note {{in instantiation of function template specialization}} + } +}