]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/70095
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Mar 2016 19:37:37 +0000 (19:37 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Mar 2016 19:37:37 +0000 (19:37 +0000)
* pt.c (instantiate_decl): Fix call to variable_template_p.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234231 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1y/var-templ50.C [new file with mode: 0644]

index 9ace01eddbaa51a06e574baa090ae65cab733601..eff989b160febe5efb95bae2f175f3452a102f1d 100644 (file)
@@ -1,5 +1,8 @@
 2016-03-15  Jason Merrill  <jason@redhat.com>
 
+       PR c++/70095
+       * pt.c (instantiate_decl): Fix call to variable_template_p.
+
        PR c++/70141
        * pt.c (for_each_template_parm_r): Always walk into TYPENAME_TYPE.
 
index 724d6e9944135c33ca1af0613c05e14de6eb2cd0..e8cfb660ad06e110522a407b19c1998089ab7057 100644 (file)
@@ -21935,7 +21935,7 @@ instantiate_decl (tree d, int defer_ok,
       if (enter_context)
         pop_nested_class ();
 
-      if (variable_template_p (td))
+      if (variable_template_p (gen_tmpl))
        note_variable_template_instantiation (d);
     }
   else if (TREE_CODE (d) == FUNCTION_DECL && DECL_DEFAULTED_FN (code_pattern))
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ50.C b/gcc/testsuite/g++.dg/cpp1y/var-templ50.C
new file mode 100644 (file)
index 0000000..138a399
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/70095
+// { dg-do link { target c++14 } }
+
+template <typename T> struct Foo;
+template <typename T> int variable_template         = 0;
+template <typename T> int variable_template<Foo<T>> = 0;
+template <typename T> int get_variable_template() { return variable_template<T>; }
+
+int main() {
+  get_variable_template<Foo<int>>();
+}