PR20716 - Crash when recovering from type in known dependent base.

llvm-svn: 216352
This commit is contained in:
Nikola Smiljanic 2014-08-24 23:28:47 +00:00
parent 4627679cec
commit 92516a8e7a
3 changed files with 25 additions and 2 deletions

View File

@ -236,7 +236,7 @@ protected:
TemplateParams(nullptr) {}
// Construct a template decl with the given name and parameters.
// Used when there is not templated element (tt-params, alias?).
// Used when there is not templated element (tt-params).
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName Name, TemplateParameterList *Params)
: NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),

View File

@ -152,7 +152,10 @@ static ParsedType recoverFromTypeInKnownDependentBase(Sema &S,
auto *TD = TST->getTemplateName().getAsTemplateDecl();
if (!TD)
continue;
auto *BasePrimaryTemplate = cast<CXXRecordDecl>(TD->getTemplatedDecl());
auto *BasePrimaryTemplate =
dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl());
if (!BasePrimaryTemplate)
continue;
// FIXME: Allow lookup into non-dependent bases of dependent bases, possibly
// by calling or integrating with the main LookupQualifiedName mechanism.
for (NamedDecl *ND : BasePrimaryTemplate->lookup(&II)) {

View File

@ -470,3 +470,23 @@ void f() {
UndefVar.method(); // expected-error {{use of undeclared identifier 'UndefVar'}}
}
}
namespace PR20716 {
template <template <typename T> class A>
struct B : A<int>
{
XXX x; // expected-error {{unknown type name}}
};
template <typename T>
struct C {};
template <typename T>
using D = C<T>;
template <typename T>
struct E : D<T>
{
XXX x; // expected-error {{unknown type name}}
};
}