aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-06-02 09:09:48 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-06-02 09:09:48 +0000
commit58fb06b4a11160c4c6191b6c89f3c1b3a3bd0787 (patch)
tree3bef40413e1c02198cbe7dcb8919b06a068781fb /gcc
parentccb4e87e83e9f1e21ba9c79ce21f2d31dcf16a51 (diff)
downloadgcc-58fb06b4a11160c4c6191b6c89f3c1b3a3bd0787.zip
gcc-58fb06b4a11160c4c6191b6c89f3c1b3a3bd0787.tar.gz
gcc-58fb06b4a11160c4c6191b6c89f3c1b3a3bd0787.tar.bz2
re PR c++/20350 (extern template and struct initializer and specification for a static variable)
cp: PR c++/20350 * decl.c (duplicate_decls): Copy all of DECL_USE_TEMPLATE. testsuite: PR c++/20350 * g++.dg/template/spec24.C: New. From-SVN: r100486
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c15
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/spec24.C22
4 files changed, 36 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 884d346..1314bcf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2005-06-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/20350
+ * decl.c (duplicate_decls): Copy all of DECL_USE_TEMPLATE.
+
PR c++/21151
* name-lookup.c (pushtag): Push local class even in a template.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7f919d5..83bd6fc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1672,13 +1672,14 @@ duplicate_decls (tree newdecl, tree olddecl)
DECL_COMDAT (newdecl) |= DECL_COMDAT (olddecl);
DECL_TEMPLATE_INSTANTIATED (newdecl)
|= DECL_TEMPLATE_INSTANTIATED (olddecl);
- /* If the OLDDECL is an implicit instantiation, then the NEWDECL
- must be too. But, it may not yet be marked as such if the
- caller has created NEWDECL, but has not yet figured out that
- it is a redeclaration. */
- if (DECL_IMPLICIT_INSTANTIATION (olddecl)
- && !DECL_USE_TEMPLATE (newdecl))
- SET_DECL_IMPLICIT_INSTANTIATION (newdecl);
+
+ /* If the OLDDECL is an instantiation and/or specialization,
+ then the NEWDECL must be too. But, it may not yet be marked
+ as such if the caller has created NEWDECL, but has not yet
+ figured out that it is a redeclaration. */
+ if (!DECL_USE_TEMPLATE (newdecl))
+ DECL_USE_TEMPLATE (newdecl) = DECL_USE_TEMPLATE (olddecl);
+
/* Don't really know how much of the language-specific
values we should copy from old to new. */
DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 07ab9b9..4735903 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2005-06-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/20350
+ * g++.dg/template/spec24.C: New.
+
PR c++/21151
* g++.dg/pch/local-1.C: New.
* g++.dg/pch/local-1.Hs: New.
diff --git a/gcc/testsuite/g++.dg/template/spec24.C b/gcc/testsuite/g++.dg/template/spec24.C
new file mode 100644
index 0000000..0884895
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/spec24.C
@@ -0,0 +1,22 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 1 June 2005 <nathan@codesourcery.com>
+
+// PR 20350: ICE on member specialization with later initialization
+// Origin: Carlo Wood carlo@gcc.gnu.org
+
+template <int i> struct Mutex
+{
+ static int mutex;
+};
+
+template <int i>
+int Mutex<i>::mutex = {1};
+
+template <> int Mutex<0>::mutex;
+template <> int Mutex<0>::mutex = 0;
+
+void g()
+{
+ Mutex<0>::mutex = 0;
+}
+