re PR c++/55419 (ICE in gimplify_init_ctor_preeval, at gimplify.c:3587)
authorJason Merrill <jason@redhat.com>
Sat, 8 Dec 2012 03:31:25 +0000 (22:31 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 8 Dec 2012 03:31:25 +0000 (22:31 -0500)
PR c++/55419
* tree.c (build_target_expr): Don't set TREE_CONSTANT.

From-SVN: r194317

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C [new file with mode: 0644]

index cee5db6c9ecdb175fb168ba9dde97b3ba3dc520e..78e7d40d4a50729d998a8c9aeb83046cad6df21e 100644 (file)
@@ -1,3 +1,8 @@
+2012-12-07  Jason Merrill  <jason@redhat.com>
+
+       PR c++/55419
+       * tree.c (build_target_expr): Don't set TREE_CONSTANT.
+
 2012-12-07  Aldy Hernandez  <aldyh@redhat.com>
 
        PR c++/55513
index ca209eb91e3ae0cdce457ccee5698e88e834eeff..00fe53f521477d55374eaac89037b88d6989b62f 100644 (file)
@@ -329,8 +329,6 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
      side-effects, then the optimizer should be able to get rid of
      whatever code is generated anyhow.  */
   TREE_SIDE_EFFECTS (t) = 1;
-  if (literal_type_p (type))
-    TREE_CONSTANT (t) = TREE_CONSTANT (value);
 
   return t;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist6.C
new file mode 100644 (file)
index 0000000..6b822a1
--- /dev/null
@@ -0,0 +1,27 @@
+// PR c++/55419
+// { dg-options -std=c++11 }
+
+struct P
+{
+  P () = default;
+  explicit constexpr P (int x) : p (x) {}
+  int p;
+};
+
+struct Q
+{
+  constexpr Q () : q (0x7f) {}
+  int q;
+};
+
+struct R
+{
+  Q q;
+  P p;
+};
+
+void
+foo (R *x)
+{
+  *x = {};
+}