Author: nicholas Date: Mon Aug 10 16:54:08 2015 New Revision: 244515 URL: http://llvm.org/viewvc/llvm-project?rev=244515&view=rev Log: If a variable template is inside a context with template arguments that is being instantiated, and that instantiation fails, fail our instantiation instead of crashing. Errors have already been emitted.
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=244515&r1=244514&r2=244515&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Aug 10 16:54:08 2015 @@ -1143,6 +1143,7 @@ Decl *TemplateDeclInstantiator::VisitVar VarDecl *VarInst = cast_or_null<VarDecl>(VisitVarDecl(Pattern, /*InstantiatingVarTemplate=*/true)); + if (!VarInst) return nullptr; DeclContext *DC = Owner; Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp?rev=244515&r1=244514&r2=244515&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Mon Aug 10 16:54:08 2015 @@ -327,3 +327,14 @@ struct S { static int f : I; // expected-error {{static member 'f' cannot be a bit-field}} }; } + +namespace b20896909 { + // This used to crash. + template<typename T> struct helper {}; + template<typename T> class A { + template <typename> static helper<typename T::error> x; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} + }; + void test() { + A<int> ai; // expected-note {{in instantiation of}} + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits