diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-04 22:30:39 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-04 22:30:39 +0000 |
commit | 40196b7832598b0a0298d7a8bc5b8a4c723c80aa (patch) | |
tree | b9756029ec20b53787ad1ff9ea1241b49d180f5a /gcc/cp/typeck.c | |
parent | 6da874c959d47a18ec635dea755a88e6831e5508 (diff) | |
download | gcc-40196b7832598b0a0298d7a8bc5b8a4c723c80aa.tar.gz |
/cp
2014-06-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/43453
* typeck.c (cp_build_modify_expr): Handle array of characters
initialized by a string literal.
* decl.c (check_initializer): Handle parenthesized string literal
as initializer.
* typeck2.c (store_init_value): Remove redundant check.
/testsuite
2014-06-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/43453
* g++.dg/init/pr43453.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211248 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index aa96fb49318..4a876f94888 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7511,6 +7511,18 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, return error_mark_node; } + /* C++11 8.5/17: "If the destination type is an array of characters, + an array of char16_t, an array of char32_t, or an array of wchar_t, + and the initializer is a string literal...". */ + else if (TREE_CODE (newrhs) == STRING_CST + && char_type_p (TREE_TYPE (TYPE_MAIN_VARIANT (lhstype))) + && modifycode == INIT_EXPR) + { + newrhs = digest_init (lhstype, newrhs, complain); + if (newrhs == error_mark_node) + return error_mark_node; + } + else if (!same_or_base_type_p (TYPE_MAIN_VARIANT (lhstype), TYPE_MAIN_VARIANT (TREE_TYPE (newrhs)))) { |