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
This commit is contained in:
Serge Pavlov 2013-08-10 12:00:21 +00:00
parent d3a039fed2
commit 074a518f03
2 changed files with 16 additions and 0 deletions

View File

@ -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));

View File

@ -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}}
}
}