OSDN Git Service

PR c++/47041
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2011 22:30:26 +0000 (22:30 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jan 2011 22:30:26 +0000 (22:30 +0000)
* semantics.c (build_constexpr_constructor_member_initializers):
Handle trivial copy.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169108 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 0e7bcb0..81e4457 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47041
+       * semantics.c (build_constexpr_constructor_member_initializers):
+       Handle trivial copy.
+
 2011-01-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/47388
index ba90515..dc29c7a 100644 (file)
@@ -5607,7 +5607,20 @@ build_constexpr_constructor_member_initializers (tree type, tree body)
     body = STATEMENT_LIST_HEAD (body)->stmt;
   body = BIND_EXPR_BODY (body);
   if (TREE_CODE (body) == CLEANUP_POINT_EXPR)
-    ok = build_data_member_initialization (body, &vec);
+    {
+      body = TREE_OPERAND (body, 0);
+      if (TREE_CODE (body) == EXPR_STMT)
+       body = TREE_OPERAND (body, 0);
+      if (TREE_CODE (body) == INIT_EXPR
+         && (same_type_ignoring_top_level_qualifiers_p
+             (TREE_TYPE (TREE_OPERAND (body, 0)),
+              current_class_type)))
+       {
+         /* Trivial copy.  */
+         return TREE_OPERAND (body, 1);
+       }
+      ok = build_data_member_initialization (body, &vec);
+    }
   else if (TREE_CODE (body) == STATEMENT_LIST)
     {
       tree_stmt_iterator i;
index 5e1539b..95d0a77 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47041
+       * g++.dg/cpp0x/constexpr-ctor6.C: New.
+
 2011-01-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/47388
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor6.C
new file mode 100644 (file)
index 0000000..4f86f73
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/47041
+// { dg-options "-std=c++0x -fno-elide-constructors" }
+
+struct S
+{
+  int i;
+};
+
+S s = S ();