re PR debug/85252 (ICE with -g for static zero-length array initialization)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Apr 2018 17:28:54 +0000 (19:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Apr 2018 17:28:54 +0000 (19:28 +0200)
PR debug/85252
* dwarf2out.c (rtl_for_decl_init): For STRING_CST initializer only
build CONST_STRING if TYPE_MAX_VALUE is non-NULL and is INTEGER_CST.

* gcc.dg/debug/pr85252.c: New test.

From-SVN: r259183

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/pr85252.c [new file with mode: 0644]

index 1a8fcf692d5eb249021f614ce781f77e7ac6a8e7..c82d2bc57f874fe4c566fa7516436d279211276e 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/85252
+       * dwarf2out.c (rtl_for_decl_init): For STRING_CST initializer only
+       build CONST_STRING if TYPE_MAX_VALUE is non-NULL and is INTEGER_CST.
+
        PR rtl-optimization/84872
        * cfgloopmanip.c (create_preheader): Use make_forwarder_block even if
        nentry == 1 when CP_FALLTHRU_PREHEADERS and single_entry is
index 793305484df0351f183ea5df02ab9bb3df46b615..50a41c56091fc7ddffe6e1505fed647a7b67f2a4 100644 (file)
@@ -19596,6 +19596,8 @@ rtl_for_decl_init (tree init, tree type)
       if (is_int_mode (TYPE_MODE (enttype), &mode)
          && GET_MODE_SIZE (mode) == 1
          && domain
+         && TYPE_MAX_VALUE (domain)
+         && TREE_CODE (TYPE_MAX_VALUE (domain)) == INTEGER_CST
          && integer_zerop (TYPE_MIN_VALUE (domain))
          && compare_tree_int (TYPE_MAX_VALUE (domain),
                               TREE_STRING_LENGTH (init) - 1) == 0
index 25cda5027acb42f722f0d9133584a56bc10ee648..4ab768d2fc497e326b645387dadc19c5a03d38cc 100644 (file)
@@ -1,5 +1,8 @@
 2018-04-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/85252
+       * gcc.dg/debug/pr85252.c: New test.
+
        PR rtl-optimization/84872
        * gcc.dg/graphite/pr84872.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/debug/pr85252.c b/gcc/testsuite/gcc.dg/debug/pr85252.c
new file mode 100644 (file)
index 0000000..6e5ca85
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR debug/85252 */
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  static char a[0] = "";
+  static char b[0] = "b";      /* { dg-warning "initializer-string for array of chars is too long" } */
+  static char c[1] = "c";
+  static char d[1] = "de";     /* { dg-warning "initializer-string for array of chars is too long" } */
+}