PR c++/83835 - C++17 error with constructor ctors.
authorJason Merrill <jason@redhat.com>
Fri, 16 Feb 2018 20:05:28 +0000 (15:05 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Feb 2018 20:05:28 +0000 (15:05 -0500)
* call.c (build_special_member_call): Set TARGET_EXPR_DIRECT_INIT_P.

From-SVN: r257757

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/constexpr-ctor21.C [new file with mode: 0644]

index 07f093a1e30a7e4e41639b554b652d1dff18b83e..076b8f93c4793f4f4101e16275b9b3f9571a41f3 100644 (file)
@@ -1,5 +1,8 @@
 2018-02-16  Jason Merrill  <jason@redhat.com>
 
+       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.
index 5698ff60a4d151692aeb7d6e7a763be83f8d9936..d3d0966f65ca66d93be7882240154c2e32cc3cba 100644 (file)
@@ -8834,6 +8834,9 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **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 (file)
index 0000000..4bf57b9
--- /dev/null
@@ -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 ) {}
+};