From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4F2E13858D39 for ; Thu, 25 Nov 2021 15:49:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F2E13858D39 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-525-NJgc4IxUMBK1MRFG1ewc5w-1; Thu, 25 Nov 2021 10:49:24 -0500 X-MC-Unique: NJgc4IxUMBK1MRFG1ewc5w-1 Received: by mail-qt1-f199.google.com with SMTP id h20-20020ac85e14000000b002b2e9555bb1so7019719qtx.3 for ; Thu, 25 Nov 2021 07:49:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mj+k/ORR0fiTg8dwtYqbQk3a9VlMahEXM2SQTKRBD2Q=; b=3FcIDtIhHVVGbQnzPcaAI1d2j2YKRDJerepN8FYdnGLHpg1SRTZsc2y1CBYgMsGLOS gUWo/7hWVasjVAmrz3KiXyMDaFFzM1+W9PE48Nqv+QNCAfcuyGFMaV+Bk9dauLUaJna/ QhulguXM4dgMUUHLcgr2N42aUhtz2Ky0U1H9S4d5dKlLBwrWq8v0x4GBM0/u31RWcb7r HqcGoS0Wdq0Wb5VlY73HW22Nnkob8EDO974g1r1tZCITWKNCZpnhVhFsybwNuX19T78u Y3Vy/cWQCGhc7wqB/KoFObXCuIoE3kx0pybXxz/TR8gupV4W45iNZcTQwMW5YG2s7gBF i1dw== X-Gm-Message-State: AOAM533H+ZYkcqufoJ/t+ECSZosNhRgq4bkqFOBcuGy/Z682CPH7V8lx 8QAcU7p5kQpFqO/Pkg3jNcE99HP7VwgXaajO4rECSzqS0/FvFmUjtQDjxDUWdnDbYu4zKgIZnlO Okg8voS6nSF4Kkjt51A== X-Received: by 2002:ac8:7d46:: with SMTP id h6mr18379948qtb.379.1637855363950; Thu, 25 Nov 2021 07:49:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKDkq+F6L07FyOp89QDD3jUhT5MxYIyc/73bVg2m7rA63KACNeWk1W4sMsW1UFRubV+1ewXw== X-Received: by 2002:ac8:7d46:: with SMTP id h6mr18379871qtb.379.1637855363328; Thu, 25 Nov 2021 07:49:23 -0800 (PST) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id k16sm1730948qtx.92.2021.11.25.07.49.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Nov 2021 07:49:22 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 10:49:21 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH] c++, v3: Fix up diagnostics about taking address of an immediate member function [PR102753] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20211021111742.GG304296@tucnak> <20211029152444.GB304296@tucnak> <1f3b346d-2d4e-a4f1-15ef-b536a162a7e6@redhat.com> <20211124160203.GO2646553@tucnak> <20211124180257.GP2646553@tucnak> <6b01cee0-91b2-7292-c95e-c774fc426eb4@redhat.com> <20211124224228.GV2646553@tucnak> <20211125143840.GC2646553@tucnak> From: Jason Merrill In-Reply-To: <20211125143840.GC2646553@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 15:49:29 -0000 On 11/25/21 09:38, Jakub Jelinek wrote: > On Wed, Nov 24, 2021 at 09:07:48PM -0500, Jason Merrill wrote: >>> --- gcc/cp/tree.c.jj 2021-11-24 15:05:23.371927735 +0100 >>> +++ gcc/cp/tree.c 2021-11-24 17:09:05.348164621 +0100 >>> @@ -5167,6 +5167,7 @@ make_ptrmem_cst (tree type, tree member) >>> tree ptrmem_cst = make_node (PTRMEM_CST); >>> TREE_TYPE (ptrmem_cst) = type; >>> PTRMEM_CST_MEMBER (ptrmem_cst) = member; >>> + PTRMEM_CST_LOCATION (ptrmem_cst) = input_location; >>> return ptrmem_cst; >>> } >> >> Please also change build_x_unary_op to improve PTRMEM_CST_LOCATION instead >> of adding a wrapper, and teach cp_expr_location about PTRMEM_CST_LOCATION. > > Done. Though, had to also change convert_for_assignment from > EXPR_LOC_OR_LOC to cp_expr_loc_or_input_loc and expand_ptrmemfunc_cst > to copy over location to ADDR_EXPR from PTRMEM_CST. > >>> --- gcc/cp/pt.c.jj 2021-11-24 15:05:23.336928234 +0100 >>> +++ gcc/cp/pt.c 2021-11-24 15:34:29.018014159 +0100 >>> @@ -17012,6 +17012,12 @@ tsubst_copy (tree t, tree args, tsubst_f >>> r = build1 (code, type, op0); >> >> This should become build1_loc (EXPR_LOCATION (t), ... > > Done. >> >>> if (code == ALIGNOF_EXPR) >>> ALIGNOF_EXPR_STD_P (r) = ALIGNOF_EXPR_STD_P (t); >>> + /* For addresses of immediate functions ensure we have EXPR_LOCATION >>> + set for possible later diagnostics. */ >>> + if (code == ADDR_EXPR >>> + && TREE_CODE (op0) == FUNCTION_DECL >>> + && DECL_IMMEDIATE_FUNCTION_P (op0)) >>> + SET_EXPR_LOCATION (r, input_location); >> >> ...and then do this only if t didn't have a location. > > And this too. > > 2021-11-25 Jakub Jelinek > > PR c++/102753 > * cp-tree.h (struct ptrmem_cst): Add locus member. > (PTRMEM_CST_LOCATION): Define. > * tree.c (make_ptrmem_cst): Set PTRMEM_CST_LOCATION to input_location. > (cp_expr_location): Return PTRMEM_CST_LOCATION for PTRMEM_CST. > * typeck.c (build_x_unary_op): Overwrite PTRMEM_CST_LOCATION for > PTRMEM_CST instead of calling maybe_wrap_with_location. > (cp_build_addr_expr_1): Don't diagnose taking address of > immediate functions here. Instead when taking their address make > sure the returned ADDR_EXPR has EXPR_LOCATION set. > (expand_ptrmemfunc_cst): Copy over PTRMEM_CST_LOCATION to > ADDR_EXPR if taking address of immediate member function. > (convert_for_assignment): Use cp_expr_loc_or_input_loc instead of > EXPR_LOC_OR_LOC. > * pt.c (tsubst_copy): Use build1_loc instead of build1. Ensure > ADDR_EXPR of immediate function has EXPR_LOCATION set. > * cp-gimplify.c (cp_fold_r): Diagnose taking address of immediate > functions here. For consteval if don't walk THEN_CLAUSE. > (cp_genericize_r): Move evaluation of calls to > std::source_location::current from here to... > (cp_fold): ... here. Don't assert calls to immediate functions must > be source_location_current_p, instead only constant evaluate > calls to source_location_current_p. > > * g++.dg/cpp2a/consteval20.C: Add some extra tests. > * g++.dg/cpp2a/consteval23.C: Likewise. > * g++.dg/cpp2a/consteval25.C: New test. > * g++.dg/cpp2a/srcloc20.C: New test. > > --- gcc/cp/cp-tree.h.jj 2021-11-25 08:35:39.856073838 +0100 > +++ gcc/cp/cp-tree.h 2021-11-25 14:25:33.411081733 +0100 > @@ -703,6 +703,7 @@ struct GTY(()) template_parm_index { > struct GTY(()) ptrmem_cst { > struct tree_common common; > tree member; > + location_t locus; > }; > typedef struct ptrmem_cst * ptrmem_cst_t; > > @@ -4726,6 +4727,11 @@ more_aggr_init_expr_args_p (const aggr_i > #define PTRMEM_CST_MEMBER(NODE) \ > (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member) > > +/* For a pointer-to-member constant `X::Y' this is a location where > + the address of the member has been taken. */ > +#define PTRMEM_CST_LOCATION(NODE) \ > + (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->locus) > + > /* The expression in question for a TYPEOF_TYPE. */ > #define TYPEOF_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (TYPEOF_TYPE_CHECK (NODE))) > > --- gcc/cp/tree.c.jj 2021-11-25 08:35:39.942072610 +0100 > +++ gcc/cp/tree.c 2021-11-25 14:31:32.784899701 +0100 > @@ -5196,6 +5196,7 @@ make_ptrmem_cst (tree type, tree member) > tree ptrmem_cst = make_node (PTRMEM_CST); > TREE_TYPE (ptrmem_cst) = type; > PTRMEM_CST_MEMBER (ptrmem_cst) = member; > + PTRMEM_CST_LOCATION (ptrmem_cst) = input_location; > return ptrmem_cst; > } > > @@ -6040,6 +6041,8 @@ cp_expr_location (const_tree t_) > return STATIC_ASSERT_SOURCE_LOCATION (t); > case TRAIT_EXPR: > return TRAIT_EXPR_LOCATION (t); > + case PTRMEM_CST: > + return PTRMEM_CST_LOCATION (t); > default: > return EXPR_LOCATION (t); > } > --- gcc/cp/typeck.c.jj 2021-11-25 08:32:50.585489416 +0100 > +++ gcc/cp/typeck.c 2021-11-25 15:22:25.554996949 +0100 > @@ -6497,7 +6497,7 @@ build_x_unary_op (location_t loc, enum t > exp = cp_build_addr_expr_strict (xarg, complain); > > if (TREE_CODE (exp) == PTRMEM_CST) > - exp = maybe_wrap_with_location (exp, loc); > + PTRMEM_CST_LOCATION (exp) = loc; > else > protected_set_expr_location (exp, loc); > } > @@ -6780,16 +6780,6 @@ cp_build_addr_expr_1 (tree arg, bool str > return error_mark_node; > } > > - if (TREE_CODE (t) == FUNCTION_DECL > - && DECL_IMMEDIATE_FUNCTION_P (t) > - && !in_immediate_context ()) > - { > - if (complain & tf_error) > - error_at (loc, "taking address of an immediate function %qD", > - t); > - return error_mark_node; > - } > - > type = build_ptrmem_type (context_for_name_lookup (t), > TREE_TYPE (t)); > t = make_ptrmem_cst (type, t); > @@ -6816,15 +6806,6 @@ cp_build_addr_expr_1 (tree arg, bool str > { > tree stripped_arg = tree_strip_any_location_wrapper (arg); > if (TREE_CODE (stripped_arg) == FUNCTION_DECL > - && DECL_IMMEDIATE_FUNCTION_P (stripped_arg) > - && !in_immediate_context ()) > - { > - if (complain & tf_error) > - error_at (loc, "taking address of an immediate function %qD", > - stripped_arg); > - return error_mark_node; > - } > - if (TREE_CODE (stripped_arg) == FUNCTION_DECL > && !mark_used (stripped_arg, complain) && !(complain & tf_error)) > return error_mark_node; > val = build_address (arg); > @@ -6865,6 +6846,13 @@ cp_build_addr_expr_1 (tree arg, bool str > complain); > } > > + /* For addresses of immediate functions ensure we have EXPR_LOCATION > + set for possible later diagnostics. */ > + if (TREE_CODE (val) == ADDR_EXPR > + && TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL > + && DECL_IMMEDIATE_FUNCTION_P (TREE_OPERAND (val, 0))) > + SET_EXPR_LOCATION (val, input_location); > + > return val; > } > > @@ -9571,8 +9559,13 @@ expand_ptrmemfunc_cst (tree cst, tree *d > /*c_cast_p=*/0, tf_warning_or_error); > > if (!DECL_VIRTUAL_P (fn)) > - *pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), > - build_addr_func (fn, tf_warning_or_error)); > + { > + tree t = build_addr_func (fn, tf_warning_or_error); > + if (TREE_CODE (t) == ADDR_EXPR > + && DECL_IMMEDIATE_FUNCTION_P (fn)) Let's do this regardless of DECL_IMMEDIATE_FUNCTION_P. OK with that change. > + SET_EXPR_LOCATION (t, PTRMEM_CST_LOCATION (cst)); > + *pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), t); > + } > else > { > /* If we're dealing with a virtual function, we have to adjust 'this' > @@ -9665,7 +9658,7 @@ convert_for_assignment (tree type, tree > tree rhstype; > enum tree_code coder; > > - location_t rhs_loc = EXPR_LOC_OR_LOC (rhs, input_location); > + location_t rhs_loc = cp_expr_loc_or_input_loc (rhs); > bool has_loc = EXPR_LOCATION (rhs) != UNKNOWN_LOCATION; > /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue, > but preserve location wrappers. */ > --- gcc/cp/pt.c.jj 2021-11-25 08:39:32.000775006 +0100 > +++ gcc/cp/pt.c 2021-11-25 14:34:36.499250617 +0100 > @@ -17012,9 +17012,16 @@ tsubst_copy (tree t, tree args, tsubst_f > { > tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); > tree op0 = tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl); > - r = build1 (code, type, op0); > + r = build1_loc (EXPR_LOCATION (t), code, type, op0); > if (code == ALIGNOF_EXPR) > ALIGNOF_EXPR_STD_P (r) = ALIGNOF_EXPR_STD_P (t); > + /* For addresses of immediate functions ensure we have EXPR_LOCATION > + set for possible later diagnostics. */ > + if (code == ADDR_EXPR > + && EXPR_LOCATION (r) == UNKNOWN_LOCATION > + && TREE_CODE (op0) == FUNCTION_DECL > + && DECL_IMMEDIATE_FUNCTION_P (op0)) > + SET_EXPR_LOCATION (r, input_location); > return r; > } > > --- gcc/cp/cp-gimplify.c.jj 2021-11-25 08:32:50.403492014 +0100 > +++ gcc/cp/cp-gimplify.c 2021-11-25 14:25:33.420081603 +0100 > @@ -900,8 +900,39 @@ struct cp_genericize_data > static tree > cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data) > { > - tree stmt; > - enum tree_code code; > + tree stmt = *stmt_p; > + enum tree_code code = TREE_CODE (stmt); > + > + switch (code) > + { > + case PTRMEM_CST: > + if (TREE_CODE (PTRMEM_CST_MEMBER (stmt)) == FUNCTION_DECL > + && DECL_IMMEDIATE_FUNCTION_P (PTRMEM_CST_MEMBER (stmt))) > + { > + if (!((hash_set *) data)->add (stmt)) > + error_at (PTRMEM_CST_LOCATION (stmt), > + "taking address of an immediate function %qD", > + PTRMEM_CST_MEMBER (stmt)); > + stmt = *stmt_p = build_zero_cst (TREE_TYPE (stmt)); > + break; > + } > + break; > + > + case ADDR_EXPR: > + if (TREE_CODE (TREE_OPERAND (stmt, 0)) == FUNCTION_DECL > + && DECL_IMMEDIATE_FUNCTION_P (TREE_OPERAND (stmt, 0))) > + { > + error_at (EXPR_LOCATION (stmt), > + "taking address of an immediate function %qD", > + TREE_OPERAND (stmt, 0)); > + stmt = *stmt_p = build_zero_cst (TREE_TYPE (stmt)); > + break; > + } > + break; > + > + default: > + break; > + } > > *stmt_p = stmt = cp_fold (*stmt_p); > > @@ -917,12 +948,16 @@ cp_fold_r (tree *stmt_p, int *walk_subtr > } > > code = TREE_CODE (stmt); > - if (code == OMP_FOR || code == OMP_SIMD || code == OMP_DISTRIBUTE > - || code == OMP_LOOP || code == OMP_TASKLOOP || code == OACC_LOOP) > + switch (code) > { > tree x; > int i, n; > - > + case OMP_FOR: > + case OMP_SIMD: > + case OMP_DISTRIBUTE: > + case OMP_LOOP: > + case OMP_TASKLOOP: > + case OACC_LOOP: > cp_walk_tree (&OMP_FOR_BODY (stmt), cp_fold_r, data, NULL); > cp_walk_tree (&OMP_FOR_CLAUSES (stmt), cp_fold_r, data, NULL); > cp_walk_tree (&OMP_FOR_INIT (stmt), cp_fold_r, data, NULL); > @@ -961,6 +996,22 @@ cp_fold_r (tree *stmt_p, int *walk_subtr > } > cp_walk_tree (&OMP_FOR_PRE_BODY (stmt), cp_fold_r, data, NULL); > *walk_subtrees = 0; > + return NULL; > + > + case IF_STMT: > + if (IF_STMT_CONSTEVAL_P (stmt)) > + { > + /* Don't walk THEN_CLAUSE (stmt) for consteval if. IF_COND is always > + boolean_false_node. */ > + cp_walk_tree (&ELSE_CLAUSE (stmt), cp_fold_r, data, NULL); > + cp_walk_tree (&IF_SCOPE (stmt), cp_fold_r, data, NULL); > + *walk_subtrees = 0; > + return NULL; > + } > + break; > + > + default: > + break; > } > > return NULL; > @@ -1476,14 +1527,6 @@ cp_genericize_r (tree *stmt_p, int *walk > break; > } > > - if (tree fndecl = cp_get_callee_fndecl_nofold (stmt)) > - if (DECL_IMMEDIATE_FUNCTION_P (fndecl)) > - { > - gcc_assert (source_location_current_p (fndecl)); > - *stmt_p = cxx_constant_value (stmt); > - break; > - } > - > if (!wtd->no_sanitize_p > && sanitize_flags_p ((SANITIZE_NULL > | SANITIZE_ALIGNMENT | SANITIZE_VPTR))) > @@ -2629,6 +2672,14 @@ cp_fold (tree x) > int sv = optimize, nw = sv; > tree callee = get_callee_fndecl (x); > > + if (tree fndecl = cp_get_callee_fndecl_nofold (x)) > + if (DECL_IMMEDIATE_FUNCTION_P (fndecl) > + && source_location_current_p (fndecl)) > + { > + x = cxx_constant_value (x); > + break; > + } > + > /* Some built-in function calls will be evaluated at compile-time in > fold (). Set optimize to 1 when folding __builtin_constant_p inside > a constexpr function so that fold_builtin_1 doesn't fold it to 0. */ > --- gcc/testsuite/g++.dg/cpp2a/consteval20.C.jj 2021-11-25 08:32:50.713487589 +0100 > +++ gcc/testsuite/g++.dg/cpp2a/consteval20.C 2021-11-25 14:25:33.420081603 +0100 > @@ -10,10 +10,14 @@ constexpr S s; > int > bar () > { > + auto c = &S::foo; // { dg-error "taking address of an immediate function" } > + constexpr auto d = &S::foo; // { dg-error "taking address of an immediate function" } > + static auto e = &S::foo; // { dg-error "taking address of an immediate function" } > return (s.*&S::foo) (); // { dg-error "taking address of an immediate function" } > } > > constexpr auto a = &S::foo; // { dg-error "taking address of an immediate function" } > +auto b = &S::foo; // { dg-error "taking address of an immediate function" } > > consteval int > baz () > --- gcc/testsuite/g++.dg/cpp2a/consteval23.C.jj 2021-11-25 08:32:50.767486819 +0100 > +++ gcc/testsuite/g++.dg/cpp2a/consteval23.C 2021-11-25 14:25:33.420081603 +0100 > @@ -2,6 +2,7 @@ > // { dg-do compile { target c++20 } } > > consteval int foo () { return 42; } > +constexpr auto baz (int (*fn) ()) { return fn; } > > consteval int > bar (int (*fn) () = foo) > @@ -11,3 +12,6 @@ bar (int (*fn) () = foo) > > static_assert (bar () == 42); > static_assert (bar (foo) == 42); > +static_assert (bar (&foo) == 42); > +static_assert (bar (baz (foo)) == 42); > +static_assert (bar (baz (&foo)) == 42); > --- gcc/testsuite/g++.dg/cpp2a/consteval25.C.jj 2021-11-25 14:25:33.420081603 +0100 > +++ gcc/testsuite/g++.dg/cpp2a/consteval25.C 2021-11-25 14:25:33.420081603 +0100 > @@ -0,0 +1,17 @@ > +// PR c++/102753 > +// { dg-do compile { target c++20 } } > +// { dg-options "" } > + > +consteval int foo () { return 42; } > + > +consteval int > +bar (int (*fn) ()) > +{ > + return fn (); > +} > + > +void > +baz () > +{ > + static_assert (bar (({ constexpr auto a = 1; foo; })) == 42); > +} > --- gcc/testsuite/g++.dg/cpp2a/srcloc20.C.jj 2021-11-25 14:25:33.420081603 +0100 > +++ gcc/testsuite/g++.dg/cpp2a/srcloc20.C 2021-11-25 14:25:33.420081603 +0100 > @@ -0,0 +1,44 @@ > +// { dg-do compile { target c++20 } } > + > +namespace std { > + struct source_location { > + struct __impl { > + const char *_M_file_name; > + const char *_M_function_name; > + unsigned int _M_line, _M_column; > + }; > + const __impl *__ptr; > + constexpr source_location () : __ptr (nullptr) {} > + static consteval source_location > + current (const void *__p = __builtin_source_location ()) { > + source_location __ret; > + __ret.__ptr = static_cast (__p); > + return __ret; > + } > + constexpr const char *file_name () const { > + return __ptr ? __ptr->_M_file_name : ""; > + } > + constexpr const char *function_name () const { > + return __ptr ? __ptr->_M_function_name : ""; > + } > + constexpr unsigned line () const { > + return __ptr ? __ptr->_M_line : 0; > + } > + constexpr unsigned column () const { > + return __ptr ? __ptr->_M_column : 0; > + } > + }; > +} > + > +using namespace std; > + > +auto a = source_location::current; // { dg-error "taking address of an immediate function" } > +constexpr auto b = &source_location::current; // { dg-error "taking address of an immediate function" } > + > +void > +foo () > +{ > + auto c = &source_location::current; // { dg-error "taking address of an immediate function" } > + constexpr auto d = source_location::current; // { dg-error "taking address of an immediate function" } > + static auto e = source_location::current; // { dg-error "taking address of an immediate function" } > +} > > > Jakub >