aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-05-05 22:07:40 -0400
committerJason Merrill <jason@gcc.gnu.org>2015-05-05 22:07:40 -0400
commitf8aa3dd388ad8726e23c20e50bd7d4561fd0bc38 (patch)
tree7710d662fe230129dd213b781da2e5b51c49160e
parentb8dd691344db6be88a843242d1686e7266de631b (diff)
downloadgcc-f8aa3dd388ad8726e23c20e50bd7d4561fd0bc38.zip
gcc-f8aa3dd388ad8726e23c20e50bd7d4561fd0bc38.tar.gz
gcc-f8aa3dd388ad8726e23c20e50bd7d4561fd0bc38.tar.bz2
decl.c (start_decl): Don't push the plain VAR_DECL for a variable template.
* decl.c (start_decl): Don't push the plain VAR_DECL for a variable template. From-SVN: r222837
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c7
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/var-templ24.C5
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3276b76..04e6a50 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6ec1579..261a12d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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
index 0000000..d8f7cbf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ24.C
@@ -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>;