]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (start_decl): Don't push the plain VAR_DECL for a variable template.
authorJason Merrill <jason@redhat.com>
Wed, 6 May 2015 02:07:40 +0000 (22:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 6 May 2015 02:07:40 +0000 (22:07 -0400)
* decl.c (start_decl): Don't push the plain VAR_DECL for a
variable template.

From-SVN: r222837

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

index 3276b76bbb392d69e09a3d429fe7c8bb0d6317b9..04e6a50b1904f394cd36acfacee3d728d041be44 100644 (file)
@@ -1,5 +1,8 @@
 2015-05-05  Jason Merrill  <jason@redhat.com>
 
+       * decl.c (start_decl): Don't push the plain VAR_DECL for a
+       variable template.
+
        DR 1518
        DR 1630
        PR c++/54835
index 6ec157912af9771ab11319fd978d58ca4bd139d1..261a12d61162d0d6b33e81f17d9c7487152c36de 100644 (file)
@@ -4825,8 +4825,11 @@ start_decl (const cp_declarator *declarator,
 
   was_public = TREE_PUBLIC (decl);
 
-  /* Enter this declaration into the symbol table.  */
-  decl = maybe_push_decl (decl);
+  /* Enter this declaration into the symbol table.  Don't push the plain
+     VAR_DECL for a variable template.  */
+  if (!template_parm_scope_p ()
+      || TREE_CODE (decl) != VAR_DECL)
+    decl = maybe_push_decl (decl);
 
   if (processing_template_decl)
     decl = push_template_decl (decl);
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ24.C b/gcc/testsuite/g++.dg/cpp1y/var-templ24.C
new file mode 100644 (file)
index 0000000..d8f7cbf
--- /dev/null
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++14 } }
+
+template <class T> bool Foo = Foo<int>;
+template <> bool Foo<int> = true;
+int i = Foo<char>;