]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/32914 (ICE in rtl_for_decl_init with -g option)
authorJakub Jelinek <jakub@redhat.com>
Fri, 31 Aug 2007 07:25:20 +0000 (09:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 31 Aug 2007 07:25:20 +0000 (09:25 +0200)
PR debug/32914
* dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR
initializer, use build_vector_from_ctor if possible to create
VECTOR_CST out of it.  If vector initializer is not VECTOR_CST
even after this, return NULL.

* d++.dg/debug/const3.C: New test.
* d++.dg/debug/const4.C: New test.

From-SVN: r127958

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/const3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/const4.C [new file with mode: 0644]

index 0a5af766e0d8208f61da72e322d42b5be896607a..30b9539200c5e76d8123d8b115943a8fbaa8e18c 100644 (file)
@@ -1,3 +1,11 @@
+2007-08-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/32914
+       * dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR
+       initializer, use build_vector_from_ctor if possible to create
+       VECTOR_CST out of it.  If vector initializer is not VECTOR_CST
+       even after this, return NULL.
+
 2007-08-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/31337
index 15b49a05b8aa9a6dedd1420faa63472a224181ba..4416fd645b188ba0eef967a6a6e9fc223e8d1776 100644 (file)
@@ -10065,6 +10065,43 @@ rtl_for_decl_init (tree init, tree type)
   else if (initializer_constant_valid_p (init, type)
           && ! walk_tree (&init, reference_to_unused, NULL, NULL))
     {
+      /* Convert vector CONSTRUCTOR initializers to VECTOR_CST if
+        possible.  */
+      if (TREE_CODE (type) == VECTOR_TYPE)
+       switch (TREE_CODE (init))
+         {
+         case VECTOR_CST:
+           break;
+         case CONSTRUCTOR:
+           if (TREE_CONSTANT (init))
+             {
+               VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init);
+               bool constant_p = true;
+               tree value;
+               unsigned HOST_WIDE_INT ix;
+
+               /* Even when ctor is constant, it might contain non-*_CST
+                  elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
+                  belong into VECTOR_CST nodes.  */
+               FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value)
+                 if (!CONSTANT_CLASS_P (value))
+                   {
+                     constant_p = false;
+                     break;
+                   }
+
+               if (constant_p)
+                 {
+                   init = build_vector_from_ctor (type, elts);
+                   break;
+                 }
+             }
+           /* FALLTHRU */
+
+         default:
+           return NULL;
+         }
+
       rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
 
       /* If expand_expr returns a MEM, it wasn't immediate.  */
index e4782da3a19921fb3ae166a9485cc52bc226d900..756ee3a1592339e5a63286334cbd0ef901c35f2b 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/32914
+       * d++.dg/debug/const3.C: New test.
+       * d++.dg/debug/const4.C: New test.
+
 2007-08-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/32912
diff --git a/gcc/testsuite/g++.dg/debug/const3.C b/gcc/testsuite/g++.dg/debug/const3.C
new file mode 100644 (file)
index 0000000..375c548
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+typedef float FloatVect __attribute__((__vector_size__(16)));
+const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 };
diff --git a/gcc/testsuite/g++.dg/debug/const4.C b/gcc/testsuite/g++.dg/debug/const4.C
new file mode 100644 (file)
index 0000000..ec8133d
--- /dev/null
@@ -0,0 +1,2 @@
+/* { dg-do compile } */
+const __complex__ int x = 2i;