]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60367 (Default argument object is not getting constructed)
authorJason Merrill <jason@redhat.com>
Tue, 13 May 2014 16:05:01 +0000 (12:05 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 May 2014 16:05:01 +0000 (12:05 -0400)
PR c++/60367
* call.c (convert_default_arg): Remove special handling for
CONSTRUCTOR.

From-SVN: r210381

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/overload/defarg8.C [new file with mode: 0644]

index b21c15f462fcb0104ca99158e5a46eba43e0d067..d1b4ed1b765e23a8f4f56ec70b64998a1c5f291a 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60367
+       * call.c (convert_default_arg): Remove special handling for
+       CONSTRUCTOR.
+
 2014-04-28  Daniel Gutson  <daniel.gutson@tallertechnologies.com>
 
        * typeck.c (build_reinterpret_cast_1): Pass proper argument to
index ca7d3edebdc64aa670abd658e51e0b1ff312f5ec..db5a17fdf5692682f12b43eef6d70d82fabcb303 100644 (file)
@@ -6423,20 +6423,10 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum,
   /* We must make a copy of ARG, in case subsequent processing
      alters any part of it.  */
   arg = break_out_target_exprs (arg);
-  if (TREE_CODE (arg) == CONSTRUCTOR)
-    {
-      arg = digest_init (type, arg, complain);
-      arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
-                                       ICR_DEFAULT_ARGUMENT, fn, parmnum,
-                                        complain);
-    }
-  else
-    {
-      arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
-                                       ICR_DEFAULT_ARGUMENT, fn, parmnum,
-                                        complain);
-      arg = convert_for_arg_passing (type, arg, complain);
-    }
+  arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT,
+                                   ICR_DEFAULT_ARGUMENT, fn, parmnum,
+                                   complain);
+  arg = convert_for_arg_passing (type, arg, complain);
   pop_deferring_access_checks();
 
   pop_defarg_context ();
diff --git a/gcc/testsuite/g++.dg/overload/defarg8.C b/gcc/testsuite/g++.dg/overload/defarg8.C
new file mode 100644 (file)
index 0000000..b3ddfbb
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/60367
+// { dg-do run { target c++11 } }
+
+extern "C" int printf (const char *, ...);
+extern "C" void abort();
+
+void *p;
+struct foo {
+  foo() { p = this; }
+  foo (const foo &) { abort(); }
+  ~foo() { if (p != this) abort(); }
+};
+
+void do_something( foo f = {} )
+{
+  if (&f != p) abort();
+}
+
+int main()
+{
+ do_something();
+}