From bec1da64aec26a490a6de5a9aa4ee667805e8445 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 19 Mar 2019 22:43:10 +0000 Subject: 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 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'gcc/c') 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 + + PR tree-optimization/89688 + * c-decl.c (finish_decl): Call braced_lists_to_string for more + kinds of initializers. + 2019-03-19 Jakub Jelinek 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)) { -- cgit v1.1