diff options
author | Jason Merrill <jason@redhat.com> | 2014-06-05 16:55:44 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-06-05 16:55:44 -0400 |
commit | 40e3a2ab9b4d9867c7a98643305c73c325ffa792 (patch) | |
tree | a12dc21d5de9cb936073d5697a672350f71093ed /gcc/cp | |
parent | 9bac5cbb2bfbf362682e103b726bd2f1f433a8ef (diff) | |
download | gcc-40e3a2ab9b4d9867c7a98643305c73c325ffa792.zip gcc-40e3a2ab9b4d9867c7a98643305c73c325ffa792.tar.gz gcc-40e3a2ab9b4d9867c7a98643305c73c325ffa792.tar.bz2 |
re PR c++/43453 (Initialization of char array with string literal fails in mem-initializer)
PR c++/43453
* decl.c (check_initializer): Collapse a TREE_LIST here.
* typeck2.c (store_init_value): Not here.
From-SVN: r211290
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 17 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 9 |
3 files changed, 16 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 45e1012..053155a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-06-05 Jason Merrill <jason@redhat.com> + + PR c++/43453 + * decl.c (check_initializer): Collapse a TREE_LIST here. + * typeck2.c (store_init_value): Not here. + 2014-06-05 Richard Biener <rguenther@suse.de> Paolo Carlini <paolo.carlini@oracle.com> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b068df8..b4d26b7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5758,13 +5758,16 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups) check_narrowing (type, init); } } - else if (TREE_CODE (type) == ARRAY_TYPE - && TREE_CODE (init) == TREE_LIST - && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type))) - && list_length (init) == 1 - && TREE_CODE (TREE_VALUE (init)) == STRING_CST) - /* We get here with code like `char s[] ("abc");' */ - init = TREE_VALUE (init); + else if (TREE_CODE (init) == TREE_LIST + && TREE_TYPE (init) != unknown_type_node + && !MAYBE_CLASS_TYPE_P (type)) + { + gcc_assert (TREE_CODE (decl) != RESULT_DECL); + + /* We get here with code like `int a (2);' */ + init = build_x_compound_expr_from_list (init, ELK_INIT, + tf_warning_or_error); + } /* If DECL has an array type without a specific bound, deduce the array size from the initializer. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3ed5c1d..a620f22 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -780,15 +780,6 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) init = build_constructor_from_list (init_list_type_node, nreverse (init)); } } - else if (TREE_CODE (init) == TREE_LIST - && TREE_TYPE (init) != unknown_type_node) - { - gcc_assert (TREE_CODE (decl) != RESULT_DECL); - - /* We get here with code like `int a (2);' */ - init = build_x_compound_expr_from_list (init, ELK_INIT, - tf_warning_or_error); - } /* End of special C++ code. */ |