diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2004-12-21 17:54:25 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2004-12-21 17:54:25 +0000 |
commit | 7a8380aebb80b0f567b218204d6e926105b9d305 (patch) | |
tree | f5295c69fc8f09f127b9123926fef7ac163cb383 /gcc/cp/decl.c | |
parent | 38b3627d6fcedf4e1b99e988440c1c366f6dba10 (diff) | |
download | gcc-7a8380aebb80b0f567b218204d6e926105b9d305.zip gcc-7a8380aebb80b0f567b218204d6e926105b9d305.tar.gz gcc-7a8380aebb80b0f567b218204d6e926105b9d305.tar.bz2 |
re PR c++/14075 (("foo") accepted as char[] initializer)
cp:
PR c++/14075
* decl.c (check_initializer): Check string initializer of array is
not parenthesized.
* cp-tree.h (PAREN_STRING_LITERAL_P): New.
* semantics.c (finish_parenthesized_expr): Mark a STRING_CST.
* error.c (dump_expr): <STRING_CST case> Add parens, if needed.
testsuite:
PR c++/14075
* g++.dg/init/string1.C: New.
From-SVN: r92464
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index dbaf23e..515bb2c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4596,6 +4596,12 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) if (TREE_CODE (init) != TREE_VEC) { init_code = store_init_value (decl, init); + if (pedantic && TREE_CODE (type) == ARRAY_TYPE + && DECL_INITIAL (decl) + && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST + && PAREN_STRING_LITERAL_P (DECL_INITIAL (decl))) + warning ("array %qD initialized by parenthesized string literal %qE", + decl, DECL_INITIAL (decl)); init = NULL; } } |