aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck2.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/init9.C12
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c602721..7b91727 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-02 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/20140
+ * typeck2.c (digest_init_r): Use copy_init when initializing
+ an array of chars.
+
2012-01-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/16603
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 4648e75..a1b4274 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -902,7 +902,11 @@ digest_init_r (tree type, tree init, bool nested, int flags,
}
}
- TREE_TYPE (init) = type;
+ if (type != TREE_TYPE (init))
+ {
+ init = copy_node (init);
+ TREE_TYPE (init) = type;
+ }
if (TYPE_DOMAIN (type) != 0 && TREE_CONSTANT (TYPE_SIZE (type)))
{
int size = TREE_INT_CST_LOW (TYPE_SIZE (type));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dd29a88..ea547a3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-02 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/20140
+ * g++.dg/template/init9.C: New.
+
2012-01-02 Richard Sandiford <rdsandiford@googlemail.com>
* gcc.dg/memcpy-4.c: Add nomips16 attribute for MIPS targets.
diff --git a/gcc/testsuite/g++.dg/template/init9.C b/gcc/testsuite/g++.dg/template/init9.C
new file mode 100644
index 0000000..d33c7da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/init9.C
@@ -0,0 +1,12 @@
+// PR c++/20140
+
+template<typename T> void foo()
+{
+ unsigned char s[] = "";
+}
+
+int main()
+{
+ foo<char>();
+ foo<int>();
+}