Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?  Maybe
16 too although the testcase will have to account for the pre-P4101
"consteval-only type" error.

-- >8 --
This should fail:

  using info = decltype(^^void);
  struct M { info i = ^^int; M(); };
  M::M() = default;

because CWG 3153 added "non-user-provided", and a function defaulted on
a declaration other than its first is user-provided.

        PR c++/126970

gcc/cp/ChangeLog:

        * cp-gimplify.cc (immediate_escalating_function_p): Check
        !user_provided_p.

gcc/testsuite/ChangeLog:

        * g++.dg/reflect/cwg3153-2.C: New test.
---
 gcc/cp/cp-gimplify.cc                    |  4 ++--
 gcc/testsuite/g++.dg/reflect/cwg3153-2.C | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/reflect/cwg3153-2.C

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index c8f40413891..0fc44592cd2 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -507,9 +507,9 @@ immediate_escalating_function_p (tree fn)
         specifier  */
   if (LAMBDA_FUNCTION_P (fn))
     return true;
-  /* -- a defaulted function that is not declared with the
+  /* -- a non-user-provided defaulted function that is not declared with the
        consteval specifier  */
-  if (DECL_DEFAULTED_FN (fn))
+  if (DECL_DEFAULTED_FN (fn) && !user_provided_p (fn))
     return true;
   /* -- a function that results from the instantiation of a templated entity
        defined with the constexpr specifier.  */
diff --git a/gcc/testsuite/g++.dg/reflect/cwg3153-2.C 
b/gcc/testsuite/g++.dg/reflect/cwg3153-2.C
new file mode 100644
index 00000000000..d5f30f1520a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/reflect/cwg3153-2.C
@@ -0,0 +1,10 @@
+// PR c++/126970
+// CWG3153
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+using info = decltype(^^void);
+struct M {
+  info i = ^^int; M(); // { dg-error "consteval-only value outside an 
immediate function context" }
+};
+M::M() = default;

base-commit: 22d710cc5f40d79aab104ec5fb5fe97386d56d8a
-- 
2.55.0

Reply via email to