From 07a67f7b09745a86d8890f09b7d1260da6f41103 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 17 Nov 2016 16:40:48 -0500 Subject: [PATCH] PR c++/78369 - {} as default argument * call.c (build_special_member_call): Handle CONSTRUCTOR. From-SVN: r242562 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/call.c | 3 ++- gcc/testsuite/g++.dg/overload/defarg11.C | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/overload/defarg11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5775ba64ac4..50d0ae21aad 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-11-17 Jason Merrill + 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f6f45905162..d25e2e79f0b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8317,7 +8317,8 @@ build_special_member_call (tree instance, tree name, vec **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 index 00000000000..26fac6ebe12 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/defarg11.C @@ -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; +} -- 2.30.2