aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2019-03-19 22:43:10 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2019-03-19 16:43:10 -0600
commitbec1da64aec26a490a6de5a9aa4ee667805e8445 (patch)
tree0d5363919c319be1c5f4edf1f375d47e39dbecf1 /gcc/c
parent026216a753ef0a757a9e368a59fa667ea422cf09 (diff)
downloadgcc-bec1da64aec26a490a6de5a9aa4ee667805e8445.zip
gcc-bec1da64aec26a490a6de5a9aa4ee667805e8445.tar.gz
gcc-bec1da64aec26a490a6de5a9aa4ee667805e8445.tar.bz2
PR tree-optimization/89688 - -Wstringop-overflow confused by const 2D array of char
gcc/c/ChangeLog: PR tree-optimization/89688 * c-decl.c (finish_decl): Call braced_lists_to_string for more kinds of initializers. gcc/c-family/ChangeLog: PR tree-optimization/89688 * c-common.c (braced_list_to_string): Make static. (braced_lists_to_strings): Define new function. * c-common.h (braced_list_to_string): Remove. (braced_lists_to_strings): Declare. gcc/cp/ChangeLog: PR tree-optimization/89688 * typeck2.c (store_init_value): Call braced_lists_to_string for more kinds of initializers. gcc/testsuite/ChangeLog: PR tree-optimization/89688 * gcc.dg/strlenopt-61.c: New test. * g++.dg/warn/Wstringop-overflow-2.C: New test. From-SVN: r269814
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c9
2 files changed, 10 insertions, 5 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index fd3d009..fc8049e 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-19 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/89688
+ * c-decl.c (finish_decl): Call braced_lists_to_string for more
+ kinds of initializers.
+
2019-03-19 Jakub Jelinek <jakub@redhat.com>
PR c/89734
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e8b7ca4..8d5c35a 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5165,11 +5165,10 @@ finish_decl (tree decl, location_t init_loc, tree init,
relayout_decl (decl);
}
- if (TREE_CODE (type) == ARRAY_TYPE
- && TYPE_STRING_FLAG (TREE_TYPE (type))
- && DECL_INITIAL (decl)
- && TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR)
- DECL_INITIAL (decl) = braced_list_to_string (type, DECL_INITIAL (decl));
+ /* Look for braced array initializers for character arrays and
+ recursively convert them into STRING_CSTs. */
+ if (tree init = DECL_INITIAL (decl))
+ DECL_INITIAL (decl) = braced_lists_to_strings (type, init);
if (VAR_P (decl))
{