Seems I've missed one thing, as the first hunk in
https://github.com/cplusplus/draft/commit/
c8e68ed202b4a9260616bcee8a9768b5dca4bbca
changes the wording so that only potentially-evaluated id-expressions that
denote immediate functions must appear only in the specified contexts.
That IMO means that in unevaluated contexts there aren't such restrictions
anymore, so I think in unevaluated contexts one should be able to take the
address of an immediate function.
2020-02-28 Jakub Jelinek <jakub@redhat.com>
P1937R2 - Fixing inconsistencies between const{expr,eval} functions
* typeck.c (cp_build_addr_expr_1): Allow taking address of immediate
functions in unevaluated contexts.
* g++.dg/cpp2a/consteval3.C: Change dg-error about taking address of
immediate function in unevaluated contexts into dg-bogus.
* g++.dg/cpp2a/consteval16.C: New test.
+2020-02-28 Jakub Jelinek <jakub@redhat.com>
+
+ P1937R2 - Fixing inconsistencies between const{expr,eval} functions
+ * typeck.c (cp_build_addr_expr_1): Allow taking address of immediate
+ functions in unevaluated contexts.
+
2020-02-27 Nathan Sidwell <nathan@acm.org>
PR c++/93933
tree stripped_arg = tree_strip_any_location_wrapper (arg);
if (TREE_CODE (stripped_arg) == FUNCTION_DECL
&& DECL_IMMEDIATE_FUNCTION_P (stripped_arg)
+ && cp_unevaluated_operand == 0
&& (current_function_decl == NULL_TREE
|| !DECL_IMMEDIATE_FUNCTION_P (current_function_decl)))
{
2020-02-28 Jakub Jelinek <jakub@redhat.com>
+ P1937R2 - Fixing inconsistencies between const{expr,eval} functions
+ * g++.dg/cpp2a/consteval3.C: Change dg-error about taking address of
+ immediate function in unevaluated contexts into dg-bogus.
+ * g++.dg/cpp2a/consteval16.C: New test.
+
PR middle-end/92152
* g++.dg/torture/pr92152.C (size_t): Use decltype (sizeof (0)) instead
of hardcoding unsigned long.
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=c++2a" }
+
+consteval int foo () { return 0; }
+int bar (int (*) ());
+auto sz = sizeof (bar (foo)); // { dg-bogus "taking address of an immediate function" }
+decltype (bar (foo)) baz; // { dg-bogus "taking address of an immediate function" }
struct U { consteval ~U () {} }; // { dg-error "a destructor cannot be 'consteval'" }
struct V { consteval int v = 5; }; // { dg-error "non-static data member 'v' declared 'consteval'" }
struct W { consteval static int w; }; // { dg-error "static data member 'w' declared 'consteval'" }
-int i = sizeof (&f6); // { dg-error "taking address of an immediate function 'consteval int f6\\(int\\)'" }
-using j = decltype (&f6); // { dg-error "taking address of an immediate function 'consteval int f6\\(int\\)'" }
+int i = sizeof (&f6); // { dg-bogus "taking address of an immediate function 'consteval int f6\\(int\\)'" }
+using j = decltype (&f6); // { dg-bogus "taking address of an immediate function 'consteval int f6\\(int\\)'" }
int k = sizeof (f6 (d)); // { dg-bogus "the value of 'd' is not usable in a constant expression" }
using l = decltype (f6 (d)); // { dg-bogus "the value of 'd' is not usable in a constant expression" }
bool m = noexcept (f6 (d)); // { dg-bogus "the value of 'd' is not usable in a constant expression" }