diff options
| author | Serge Pavlov <sepavloff@gmail.com> | 2013-08-10 12:00:21 +0000 |
|---|---|---|
| committer | Serge Pavlov <sepavloff@gmail.com> | 2013-08-10 12:00:21 +0000 |
| commit | 074a518f03cb8a2254796b86268e473b8f739dd3 (patch) | |
| tree | f09110910cda0bb4ec70e720624e3a29ba816de2 | |
| parent | d3a039fed2c36d735ae4bbd43e0934d0303226af (diff) | |
| download | bcm5719-llvm-074a518f03cb8a2254796b86268e473b8f739dd3.tar.gz bcm5719-llvm-074a518f03cb8a2254796b86268e473b8f739dd3.zip | |
Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope")
Differential Revision: http://llvm-reviews.chandlerc.com/D920
llvm-svn: 188137
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/recovery-crash.cpp | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index ce7684c9edb..315a405c6d3 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4063,6 +4063,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, isa<TemplateTemplateParmDecl>(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<LabelDecl>(D)); diff --git a/clang/test/SemaTemplate/recovery-crash.cpp b/clang/test/SemaTemplate/recovery-crash.cpp index b5a0e1fa13f..78f6db40d5c 100644 --- a/clang/test/SemaTemplate/recovery-crash.cpp +++ b/clang/test/SemaTemplate/recovery-crash.cpp @@ -22,3 +22,16 @@ namespace PR16134 { template <class P> struct S // expected-error {{expected ';'}} template <> static S<Q>::f() // expected-error +{{}} } + +namespace PR16225 { + template <typename T> void f(); + template<typename C> void g(C*) { + struct LocalStruct : UnknownBase<Mumble, C> { }; // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use of undeclared identifier 'Mumble'}} + f<LocalStruct>(); // expected-warning {{template argument uses local type 'LocalStruct'}} + } + struct S; + void h() { + g<S>(0); // expected-note {{in instantiation of function template specialization}} + } +} |

