re PR middle-end/17411 (ICE in immed_double_const)
authorRoger Sayle <roger@eyesopen.com>
Sat, 11 Sep 2004 23:44:21 +0000 (23:44 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 11 Sep 2004 23:44:21 +0000 (23:44 +0000)
PR middle-end/17411
* tree-sra.c (generate_element_zero): Revert recent build_int_cst
change. elt->type may be a floating point type, so use fold_convert.

* g++.dg/opt/pr17411-1.C: New test case.

From-SVN: r87377

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr17411-1.C [new file with mode: 0644]
gcc/tree-sra.c

index 24b9efb8e7c423d9588d2b98bc8c8ee8d75c12c8..7316abd0135798cadd165951e621d2f915471ccb 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-11  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/17411
+       * tree-sra.c (generate_element_zero): Revert recent build_int_cst
+       change. elt->type may be a floating point type, so use fold_convert.
+
 2004-09-11  Geoffrey Keating  <geoffk@apple.com>
 
        * config/darwin.c (machopic_validate_stub_or_non_lazy_ptr): Mark
index e48d3015326f9fd01abb6d57c7712aba1c0478e5..c47b9f8935a2b91fa3d43cbf277192243768c696 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-11  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/17411
+       * g++.dg/opt/pr17411-1.C: New test case.
+
 2004-09-11  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        * gcc.dg/declspec-4.c, gcc.dg/declspec-5.c, gcc.dg/declspec-6.c,
diff --git a/gcc/testsuite/g++.dg/opt/pr17411-1.C b/gcc/testsuite/g++.dg/opt/pr17411-1.C
new file mode 100644 (file)
index 0000000..62b57a5
--- /dev/null
@@ -0,0 +1,21 @@
+// PR middle-end/17411
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct CalibData {
+  float mean_pedestal;
+};
+
+struct pair
+{
+  CalibData second;
+  pair(const CalibData& __b) : second(__b) { }
+};
+
+void insert(const pair& __x);
+
+void foo()
+{
+  insert(pair(CalibData()));
+}
+
index b8ec2e1ff89178a31475b7c1bdc6e7c878160350..cde865ad28559f13d49f51e575bc79698f37feb8 100644 (file)
@@ -1534,7 +1534,7 @@ generate_element_zero (struct sra_elt *elt, tree *list_p)
       tree t;
 
       gcc_assert (elt->is_scalar);
-      t = build_int_cst (elt->type, 0);
+      t = fold_convert (elt->type, integer_zero_node);
 
       t = build (MODIFY_EXPR, void_type_node, elt->replacement, t);
       append_to_statement_list (t, list_p);