From: Jason Merrill Date: Fri, 16 Feb 2018 20:05:28 +0000 (-0500) Subject: PR c++/83835 - C++17 error with constructor ctors. X-Git-Tag: basepoints/gcc-9~1147 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b76f3abcd617a8dd38437464d867516962bca5cc;p=thirdparty%2Fgcc.git PR c++/83835 - C++17 error with constructor ctors. * call.c (build_special_member_call): Set TARGET_EXPR_DIRECT_INIT_P. From-SVN: r257757 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07f093a1e30a..076b8f93c479 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-02-16 Jason Merrill + PR c++/83835 - C++17 error with constructor ctors. + * call.c (build_special_member_call): Set TARGET_EXPR_DIRECT_INIT_P. + PR c++/82664 - ICE with reference to function template parm. * pt.c (convert_nontype_argument_function): Avoid obfuscationg NOP_EXPRs. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5698ff60a4d1..d3d0966f65ca 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8834,6 +8834,9 @@ build_special_member_call (tree instance, tree name, vec **args, { if (is_dummy_object (instance)) return arg; + else if (TREE_CODE (arg) == TARGET_EXPR) + TARGET_EXPR_DIRECT_INIT_P (arg) = true; + if ((complain & tf_error) && (flags & LOOKUP_DELEGATING_CONS)) check_self_delegation (arg); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor21.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor21.C new file mode 100644 index 000000000000..4bf57b9e8976 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor21.C @@ -0,0 +1,15 @@ +// PR c++/83835 +// { dg-do compile { target c++11 } } + +struct Z +{ + void const * p_; + constexpr Z( void const * p ): p_( p ) {} + ~Z(); +}; + +struct Y +{ + Z z_; + constexpr Y() noexcept: z_( this ) {} +};