aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-01-02 16:15:49 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-01-02 16:15:49 +0000
commit7d510a821a48a208b224a0f5e73fb2a3e48a583e (patch)
tree516d2d3ac80dc9fde5f8af03f294a9a58e24a64e /gcc/cp
parent842322d3aa7b61a5a2349f67d507509b2577efdb (diff)
downloadgcc-7d510a821a48a208b224a0f5e73fb2a3e48a583e.zip
gcc-7d510a821a48a208b224a0f5e73fb2a3e48a583e.tar.gz
gcc-7d510a821a48a208b224a0f5e73fb2a3e48a583e.tar.bz2
re PR c++/20140 (template function complains about "char-array initialized from wide string")
/cp 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. /testsuite 2012-01-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/20140 * g++.dg/template/init9.C: New. From-SVN: r182805
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck2.c6
2 files changed, 11 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));