aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-12-21 17:54:25 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-12-21 17:54:25 +0000
commit7a8380aebb80b0f567b218204d6e926105b9d305 (patch)
treef5295c69fc8f09f127b9123926fef7ac163cb383 /gcc/cp/decl.c
parent38b3627d6fcedf4e1b99e988440c1c366f6dba10 (diff)
downloadgcc-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.c6
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;
}
}