From: Jakub Jelinek Date: Sun, 27 Feb 2005 18:10:41 +0000 (+0100) Subject: re PR c++/20175 (Warnings are issued when initializing struct members with "strings") X-Git-Tag: releases/gcc-3.4.4~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ef0b1ff3d2c8cb9ef61884a7c25e40a584c199c;p=thirdparty%2Fgcc.git re PR c++/20175 (Warnings are issued when initializing struct members with "strings") PR c++/20175 * decl.c (reshape_init): Don't warn about missing braces if STRING_CST initializes a char/wchar_t array. * g++.dg/warn/Wbraces2.C: New test. From-SVN: r95626 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d463c0c80f85..003cff3cf844 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-02-24 Jakub Jelinek + + PR c++/20175 + * decl.c (reshape_init): Don't warn about missing braces if STRING_CST + initializes a char/wchar_t array. + 2005-02-21 Alexandre Oliva PR c++/20028 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e8bcead6f39c..397b60d56441 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4276,6 +4276,7 @@ reshape_init (tree type, tree *initp) tree old_init_value; tree new_init; bool brace_enclosed_p; + bool string_init_p; old_init = *initp; old_init_value = (TREE_CODE (*initp) == TREE_LIST @@ -4340,6 +4341,7 @@ reshape_init (tree type, tree *initp) return old_init; } + string_init_p = false; if (TREE_CODE (old_init_value) == STRING_CST && TREE_CODE (type) == ARRAY_TYPE && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)))) @@ -4354,6 +4356,7 @@ reshape_init (tree type, tree *initp) /* Move past the initializer. */ *initp = TREE_CHAIN (old_init); TREE_CHAIN (old_init) = NULL_TREE; + string_init_p = true; } else { @@ -4448,7 +4451,7 @@ reshape_init (tree type, tree *initp) { if (brace_enclosed_p) error ("too many initializers for `%T'", type); - else if (warn_missing_braces) + else if (warn_missing_braces && !string_init_p) warning ("missing braces around initializer"); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fe0f23b6b396..86bf512dcda6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-02-24 Jakub Jelinek + + PR c++/20175 + * g++.dg/warn/Wbraces2.C: New test. + 2005-02-21 Alexandre Oliva PR c++/20028