]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR debug/85252 (ICE with -g for static zero-length array initialization)
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 21:08:00 +0000 (23:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 21:08:00 +0000 (23:08 +0200)
Backported from mainline
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.

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

From-SVN: r261950

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

index dd6bc807df06b65c7d700f46cab758f3ec39c74c..27d2c31947b1b4077cb013b534a82d6ea96b51a1 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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.
+
        2018-04-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/85167
index 43bb121fb21ccde6f5d49007ae9ee4365c8ff318..7e1ce9e152a766708542d8c58a2e63c9dddd0c49 100644 (file)
@@ -18749,6 +18749,8 @@ rtl_for_decl_init (tree init, tree type)
 
       if (GET_MODE_CLASS (mode) == MODE_INT && 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 0fd38c54cbe9a151ea3f8b8866749963073dbd8e..42d07edd3f0b0a0304d6e94fc7544e0e707229a9 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2018-04-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/85252
+       * gcc.dg/debug/pr85252.c: New test.
+
        PR c++/85210
        * g++.dg/cpp1z/decomp42.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" } */
+}