]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60367 (Default argument object is not getting constructed)
authorJason Merrill <jason@redhat.com>
Mon, 10 Mar 2014 21:06:59 +0000 (17:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 10 Mar 2014 21:06:59 +0000 (17:06 -0400)
PR c++/60367
* call.c (convert_default_arg): Remove special handling for
CONSTRUCTOR.

From-SVN: r208465

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

index 8e184bc5222e6255d17689d936842cd66a81b1e3..4aa90ee4008600acd311c9283702b8b032305491 100644 (file)
@@ -1,5 +1,9 @@
 2014-03-10  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60367
+       * call.c (convert_default_arg): Remove special handling for
+       CONSTRUCTOR.
+
        PR c++/53492
        * parser.c (cp_parser_class_head): Also check PRIMARY_TEMPLATE_P
        when deciding whether to call push_template_decl for a member class.
index b58c072dfbc55d1d6cdf7642e79def2f41c579e7..184e92226cce0c16421ea5c5dafc8ee6770d14fb 100644 (file)
@@ -6531,20 +6531,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();
+}