Author: nikola Date: Sun Aug 24 18:28:47 2014 New Revision: 216352 URL: http://llvm.org/viewvc/llvm-project?rev=216352&view=rev Log: PR20716 - Crash when recovering from type in known dependent base.
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp Modified: cfe/trunk/include/clang/AST/DeclTemplate.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=216352&r1=216351&r2=216352&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclTemplate.h (original) +++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Aug 24 18:28:47 2014 @@ -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), Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=216352&r1=216351&r2=216352&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Aug 24 18:28:47 2014 @@ -152,7 +152,10 @@ static ParsedType recoverFromTypeInKnown 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)) { Modified: cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp?rev=216352&r1=216351&r2=216352&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp (original) +++ cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp Sun Aug 24 18:28:47 2014 @@ -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}} +}; +} _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits