PR c++/78369 - {} as default argument
authorJason Merrill <jason@redhat.com>
Thu, 17 Nov 2016 21:40:48 +0000 (16:40 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 17 Nov 2016 21:40:48 +0000 (16:40 -0500)
* call.c (build_special_member_call): Handle CONSTRUCTOR.

From-SVN: r242562

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

index 5775ba64ac4ad6fceddc34f0a03e0c0c6633627d..50d0ae21aadbff4c184384428d4ef1abb3e981e7 100644 (file)
@@ -1,5 +1,8 @@
 2016-11-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/78369 - {} as default argument
+       * call.c (build_special_member_call): Handle CONSTRUCTOR.
+
        PR c++/68377
        * parser.c (cp_parser_fold_expression): Check TREE_NO_WARNING.
 
index f6f45905162e61df64ca80485d27c0c75457225a..d25e2e79f0b5bf20635cbb814019cd3b3949c285 100644 (file)
@@ -8317,7 +8317,8 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args,
       if (!reference_related_p (class_type, TREE_TYPE (arg)))
        arg = perform_implicit_conversion_flags (class_type, arg,
                                                 tf_warning, flags);
-      if (TREE_CODE (arg) == TARGET_EXPR
+      if ((TREE_CODE (arg) == TARGET_EXPR
+          || TREE_CODE (arg) == CONSTRUCTOR)
          && (same_type_ignoring_top_level_qualifiers_p
              (class_type, TREE_TYPE (arg))))
        {
diff --git a/gcc/testsuite/g++.dg/overload/defarg11.C b/gcc/testsuite/g++.dg/overload/defarg11.C
new file mode 100644 (file)
index 0000000..26fac6e
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/78369
+// { dg-do compile { target c++11 } }
+
+struct A { };
+inline void f(struct A a = {})  {}
+
+int main()
+{
+  f();
+  return 0;
+}