]> granicus.if.org Git - clang/commitdiff
If a variable template is inside a context with template arguments that is being...
authorNick Lewycky <nicholas@mxc.ca>
Mon, 10 Aug 2015 21:54:08 +0000 (21:54 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 10 Aug 2015 21:54:08 +0000 (21:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244515 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/cxx1y-variable-templates_in_class.cpp

index 4fa54257ee48c1be2582c5381cc1032c8d985741..c8a067658bff57c87e826fe78edc7c0988083ebd 100644 (file)
@@ -1143,6 +1143,7 @@ Decl *TemplateDeclInstantiator::VisitVarTemplateDecl(VarTemplateDecl *D) {
   VarDecl *VarInst =
       cast_or_null<VarDecl>(VisitVarDecl(Pattern,
                                          /*InstantiatingVarTemplate=*/true));
+  if (!VarInst) return nullptr;
 
   DeclContext *DC = Owner;
 
index 123fcfff7f7ac6202af74509d8aedf116bf511c2..65e2d6b608c2b3b45e1c38e0b1982d966bfeec33 100644 (file)
@@ -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}}
+  }
+}