From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa33.google.com (mail-vk1-xa33.google.com [IPv6:2607:f8b0:4864:20::a33]) by sourceware.org (Postfix) with ESMTPS id EF7173858C60 for ; Fri, 15 Mar 2024 06:35:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF7173858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF7173858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::a33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710484526; cv=none; b=aOjglV+eYrYkz+3eN2585jAucs17s8XtzR2KGWAr8h0eDkhC6f96AGpwT1KWR2ShbdBEDbzcfP9bz0VjKojqQNnVMz2yk+19cnwF1lie6gat7mHg/xO6W+mTos10q3aZn3mxr48Dw+XixCLLHqvUGovCRV16nkKBAUd58Jdvn0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710484526; c=relaxed/simple; bh=BYyIKGyyWZZRzsigvY+3mK2zrJLg2qnUCVpNQk1B0Xw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=q5r2zwcUBlKQNk9FPoMZcrAdG5LlLyut6Wqkuk3gQoL6Ph2uBv7TnR8MxCO+d5KKNskNhmrsGiJ5cRUvZBCJpAuaIj9FwIxFe5Jfv6u3uAP31UBVBWoDZr3KO81HdvEuTSyqfhtLc3NtE6txogQqzLsLFkmLbAQk4IeCptGFhQU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-4d436ab8a36so168539e0c.0 for ; Thu, 14 Mar 2024 23:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1710484520; x=1711089320; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XvXE6StQtD3Rp+dAainaRRgB65j60Szs6ysQzN2YrNw=; b=FF/oBkjE6seKw7wKV3EDx0hDPIJZxYEoRD0rMQF3gFyC2qopRvWbpicVjJiadn5wuV PFSKzrKg0Las8cGk9xnRbpbMoCQaXwEAlcFtwastLNzLH3DrugXAQcDJlodH0XSn+xa9 kMGNcavtn43jNUNOyLzq2LvZ8NcObNE7xZKfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710484520; x=1711089320; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XvXE6StQtD3Rp+dAainaRRgB65j60Szs6ysQzN2YrNw=; b=SuM96MZ7aFG7ebCYoX18eKS4KRCV8UUOEv6sqeHyCJBt5XJuvWERDkKzLtTXoSBGDh mxUiBgmWCxqzGTC2aD6Dn90otKFhfZyyXR/EuuKMkzYBeTjoh1LcRnkBIfYSoqZx7s4t 8f7Os3dNf2yyKacsu0yCv8Nz5EBYC+zfpaE92s+3Ne6JyYJIdkmNvZ7cCi6iuvC0tcO8 poyg4/uMcl/TSeZwKjeIJkEXmJClftlCPc8/qelkri2ss6a6/z+9+gs+vKyCaix7QnDU 5P9nm5hAVRKBB8RNFdc26Dsdva78F0JvDquyh22QfZuHRb59PAxTQI4aipfvIALGaQy5 aZmw== X-Forwarded-Encrypted: i=1; AJvYcCUlezYPY9zyg74Ec+LpW26rvEzsoCzK+ECOKLODPdx/gfuq8qJTMojI7CLnHSkAZRdwAdZcRacD+7OilcTvBA/2eeIr94w= X-Gm-Message-State: AOJu0Yyy1WBI3f0vl+HiTn6irrlJ/EVNFgdQBG/BcZnzPGddZ8VmIqvD zBfXPQsWkPRNUtkM4w+1TxTG5Ga/MznlYCkN8lrM6tt6QLFULaxHDbaYC21K8QXahjJCyOQYuhu er9sO/6ywWcPvEyn/+r/FQgPUXjiueQUaPs/x X-Google-Smtp-Source: AGHT+IElkifQXct2QBC1tEpQAgLeFoKcSMRrMWkMgtL4HkF4+5J+sgfq9GSx1SqSYAl0M4jAioJMLUmosq8boxb+esU= X-Received: by 2002:a1f:dd81:0:b0:4d4:15d2:8b3b with SMTP id u123-20020a1fdd81000000b004d415d28b3bmr4457859vkg.9.1710484519845; Thu, 14 Mar 2024 23:35:19 -0700 (PDT) MIME-Version: 1.0 References: <20240221093616.4001742-1-kmatsui@gcc.gnu.org> <20240228192843.188979-1-kmatsui@gcc.gnu.org> <20240228192843.188979-24-kmatsui@gcc.gnu.org> <6d95f98c-9aab-c3c4-fe91-142082e5acd7@idea> In-Reply-To: From: Ken Matsui Date: Thu, 14 Mar 2024 23:34:43 -0700 Message-ID: Subject: Re: [PATCH v14 23/26] c++: Implement __is_invocable built-in trait To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Mar 14, 2024 at 6:53=E2=80=AFPM Ken Matsui wrote: > > On Fri, Mar 8, 2024 at 9:17=E2=80=AFAM Patrick Palka = wrote: > > > > On Wed, 28 Feb 2024, Ken Matsui wrote: > > > > > This patch implements built-in trait for std::is_invocable. > > > > > > gcc/cp/ChangeLog: > > > > > > * cp-trait.def: Define __is_invocable. > > > * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_INVOCABLE= . > > > * semantics.cc (trait_expr_value): Likewise. > > > (finish_trait_expr): Likewise. > > > * cp-tree.h (build_invoke): New function. > > > * method.cc (build_invoke): New function. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * g++.dg/ext/has-builtin-1.C: Test existence of __is_invocable. > > > * g++.dg/ext/is_invocable1.C: New test. > > > * g++.dg/ext/is_invocable2.C: New test. > > > * g++.dg/ext/is_invocable3.C: New test. > > > * g++.dg/ext/is_invocable4.C: New test. > > > > Thanks, this looks great! This generic build_invoke function could be > > used for invoke_result etc as well, and it could also cache the built-u= p > > call across __is_invocable and __is_nothrow_invocable checks on the sam= e > > arguments (which is a common pattern in the standard library). LGTM > > > > > > > > Signed-off-by: Ken Matsui > > > --- > > > gcc/cp/constraint.cc | 6 + > > > gcc/cp/cp-trait.def | 1 + > > > gcc/cp/cp-tree.h | 2 + > > > gcc/cp/method.cc | 132 +++++++++ > > > gcc/cp/semantics.cc | 4 + > > > gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 + > > > gcc/testsuite/g++.dg/ext/is_invocable1.C | 349 +++++++++++++++++++++= ++ > > > gcc/testsuite/g++.dg/ext/is_invocable2.C | 139 +++++++++ > > > gcc/testsuite/g++.dg/ext/is_invocable3.C | 51 ++++ > > > gcc/testsuite/g++.dg/ext/is_invocable4.C | 33 +++ > > > 10 files changed, 720 insertions(+) > > > create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable1.C > > > create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable2.C > > > create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable3.C > > > create mode 100644 gcc/testsuite/g++.dg/ext/is_invocable4.C > > > > > > diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc > > > index 23ea66d9c12..c87b126fdb1 100644 > > > --- a/gcc/cp/constraint.cc > > > +++ b/gcc/cp/constraint.cc > > > @@ -3791,6 +3791,12 @@ diagnose_trait_expr (tree expr, tree args) > > > case CPTK_IS_FUNCTION: > > > inform (loc, " %qT is not a function", t1); > > > break; > > > + case CPTK_IS_INVOCABLE: > > > + if (!t2) > > > + inform (loc, " %qT is not invocable", t1); > > > + else > > > + inform (loc, " %qT is not invocable by %qE", t1, t2); > > > + break; > > > case CPTK_IS_LAYOUT_COMPATIBLE: > > > inform (loc, " %qT is not layout compatible with %qT", t1, t2= ); > > > break; > > > diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def > > > index 85056c8140b..6cb2b55f4ea 100644 > > > --- a/gcc/cp/cp-trait.def > > > +++ b/gcc/cp/cp-trait.def > > > @@ -75,6 +75,7 @@ DEFTRAIT_EXPR (IS_EMPTY, "__is_empty", 1) > > > DEFTRAIT_EXPR (IS_ENUM, "__is_enum", 1) > > > DEFTRAIT_EXPR (IS_FINAL, "__is_final", 1) > > > DEFTRAIT_EXPR (IS_FUNCTION, "__is_function", 1) > > > +DEFTRAIT_EXPR (IS_INVOCABLE, "__is_invocable", -1) > > > DEFTRAIT_EXPR (IS_LAYOUT_COMPATIBLE, "__is_layout_compatible", 2) > > > DEFTRAIT_EXPR (IS_LITERAL_TYPE, "__is_literal_type", 1) > > > DEFTRAIT_EXPR (IS_MEMBER_FUNCTION_POINTER, "__is_member_function_poi= nter", 1) > > > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > > > index 334c11396c2..261d3a71faa 100644 > > > --- a/gcc/cp/cp-tree.h > > > +++ b/gcc/cp/cp-tree.h > > > @@ -7334,6 +7334,8 @@ extern tree get_copy_assign = (tree); > > > extern tree get_default_ctor (tree); > > > extern tree get_dtor (tree, tsubst_flags_t); > > > extern tree build_stub_object (tree); > > > +extern tree build_invoke (tree, const_tree, > > > + tsubst_flags_t); > > > extern tree strip_inheriting_ctors (tree); > > > extern tree inherited_ctor_binfo (tree); > > > extern bool base_ctor_omit_inherited_parms (tree); > > > diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc > > > index 98c10e6a8b5..953f1bed6fc 100644 > > > --- a/gcc/cp/method.cc > > > +++ b/gcc/cp/method.cc > > > @@ -1928,6 +1928,138 @@ build_trait_object (tree type) > > > return build_stub_object (type); > > > } > > > > > > +/* [func.require] Build an expression of INVOKE(FN_TYPE, ARG_TYPES..= .). If the > > > + given is not invocable, returns error_mark_node. */ > > > + > > > +tree > > > +build_invoke (tree fn_type, const_tree arg_types, tsubst_flags_t com= plain) > > > +{ > > > + if (fn_type =3D=3D error_mark_node || arg_types =3D=3D error_mark_= node) > > > + return error_mark_node; > > > + > > > + gcc_assert (TYPE_P (fn_type)); > > > + gcc_assert (TREE_CODE (arg_types) =3D=3D TREE_VEC); > > > + > > > + /* Access check is required to determine if the given is invocable= . */ > > > + deferring_access_check_sentinel acs (dk_no_deferred); > > > + > > > + /* INVOKE is an unevaluated context. */ > > > + cp_unevaluated cp_uneval_guard; > > > + > > > + bool is_ptrdatamem; > > > + bool is_ptrmemfunc; > > > + if (TREE_CODE (fn_type) =3D=3D REFERENCE_TYPE) > > > + { > > > + tree deref_fn_type =3D TREE_TYPE (fn_type); > > > + is_ptrdatamem =3D TYPE_PTRDATAMEM_P (deref_fn_type); > > > + is_ptrmemfunc =3D TYPE_PTRMEMFUNC_P (deref_fn_type); > > > + > > > + /* Dereference fn_type if it is a pointer to member. */ > > > + if (is_ptrdatamem || is_ptrmemfunc) > > > + fn_type =3D deref_fn_type; > > > + } > > > + else > > > + { > > > + is_ptrdatamem =3D TYPE_PTRDATAMEM_P (fn_type); > > > + is_ptrmemfunc =3D TYPE_PTRMEMFUNC_P (fn_type); > > > + } > > > + > > > + if (is_ptrdatamem && TREE_VEC_LENGTH (arg_types) !=3D 1) > > > + /* Only a pointer to data member with one argument is invocable.= */ > > > > Just one note, if/when build_invoke gets a caller that passes tf_error > > (for e.g. elaborating why is_invocable is false, or why invoke_result > > is ill-formed) these error_mark_node code paths will need to issue > > diagnostics b. > > Which function should we use for diagnostics - error, error_at, or > something else? If we opt for error_at, which location information do > we want to use? > Never mind, I can follow your finish_type_pack_element implementation :) > > > > > + return error_mark_node; > > > + > > > + if (is_ptrmemfunc && TREE_VEC_LENGTH (arg_types) =3D=3D 0) > > > + /* A pointer to member function with no arguments is not invocab= le. */ > > > + return error_mark_node; > > > + > > > + /* Construct an expression of a pointer to member. */ > > > + tree ptrmem_expr; > > > + if (is_ptrdatamem || is_ptrmemfunc) > > > + { > > > + tree datum_type =3D TREE_VEC_ELT (arg_types, 0); > > > + > > > + /* datum must be a class type or a reference/pointer to a clas= s type. */ > > > + if (TYPE_REF_P (datum_type) || POINTER_TYPE_P (datum_type)) > > > + { > > > + if (!CLASS_TYPE_P (TREE_TYPE (datum_type))) > > > + return error_mark_node; > > > + } > > > + else if (!CLASS_TYPE_P (datum_type)) > > > + return error_mark_node; > > > + > > > + bool is_refwrap =3D false; > > > + if (CLASS_TYPE_P (datum_type)) > > > + { > > > + /* 1.2 & 1.5: Handle std::reference_wrapper. */ > > > + tree datum_decl =3D TYPE_NAME (TYPE_MAIN_VARIANT (datum_type)= ); > > > + if (decl_in_std_namespace_p (datum_decl)) > > > + { > > > + const_tree name =3D DECL_NAME (datum_decl); > > > + if (name && (id_equal (name, "reference_wrapper"))) > > > + { > > > + /* Retrieve T from std::reference_wrapper, > > > + i.e., decltype(datum.get()). */ > > > + datum_type =3D TREE_VEC_ELT (TYPE_TI_ARGS (datum_type= ), 0); > > > + is_refwrap =3D true; > > > + } > > > + } > > > + } > > > + > > > + tree datum_expr =3D build_trait_object (datum_type); > > > + tree fn_expr =3D build_trait_object (fn_type); > > > + ptrmem_expr =3D build_m_component_ref (datum_expr, fn_expr, co= mplain); > > > + > > > + if (error_operand_p (ptrmem_expr) && !is_refwrap) > > > + { > > > + tree ptrmem_class_type =3D TYPE_PTRMEM_CLASS_TYPE (fn_type); > > > + const bool ptrmem_is_base_of_datum =3D > > > + (NON_UNION_CLASS_TYPE_P (ptrmem_class_type) > > > + && NON_UNION_CLASS_TYPE_P (datum_type) > > > + && (same_type_ignoring_top_level_qualifiers_p (ptrmem_clas= s_type, > > > + datum_type) > > > + || DERIVED_FROM_P (ptrmem_class_type, datum_type))); > > > + > > > + if (!ptrmem_is_base_of_datum) > > > + { > > > + /* 1.3 & 1.6: Try to dereference datum_expr. */ > > > + datum_expr =3D build_x_indirect_ref (UNKNOWN_LOCATION, da= tum_expr, > > > + RO_UNARY_STAR, NULL_TR= EE, > > > + complain); > > > + /* Rebuild ptrmem_expr. */ > > > + ptrmem_expr =3D build_m_component_ref (datum_expr, fn_exp= r, > > > + complain); > > > + } > > > + } > > > + /* 1.1 & 1.4: Otherwise. */ > > > + > > > + if (error_operand_p (ptrmem_expr)) > > > + return error_mark_node; > > > + > > > + if (is_ptrdatamem) > > > + return ptrmem_expr; > > > + } > > > + > > > + /* Construct expressions for arguments to INVOKE. For a pointer t= o member > > > + function, the first argument, which is the object, is not argum= ents to > > > + the function. */ > > > + releasing_vec args; > > > + for (int i =3D is_ptrmemfunc ? 1 : 0; i < TREE_VEC_LENGTH (arg_typ= es); ++i) > > > + { > > > + tree arg_type =3D TREE_VEC_ELT (arg_types, i); > > > + tree arg =3D build_trait_object (arg_type); > > > + vec_safe_push (args, arg); > > > + } > > > + > > > + tree invoke_expr; > > > + if (is_ptrmemfunc) > > > + invoke_expr =3D build_offset_ref_call_from_tree (ptrmem_expr, &a= rgs, > > > + complain); > > > + else /* 1.7. */ > > > + invoke_expr =3D finish_call_expr (build_trait_object (fn_type), = &args, false, > > > + false, complain); > > > + return invoke_expr; > > > +} > > > + > > > /* Determine which function will be called when looking up NAME in T= YPE, > > > called with a single ARGTYPE argument, or no argument if ARGTYPE = is > > > null. FLAGS and COMPLAIN are as for build_new_method_call. > > > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > > > index 7242db75248..149c0631d62 100644 > > > --- a/gcc/cp/semantics.cc > > > +++ b/gcc/cp/semantics.cc > > > @@ -12467,6 +12467,9 @@ trait_expr_value (cp_trait_kind kind, tree ty= pe1, tree type2) > > > case CPTK_IS_FUNCTION: > > > return type_code1 =3D=3D FUNCTION_TYPE; > > > > > > + case CPTK_IS_INVOCABLE: > > > + return !error_operand_p (build_invoke (type1, type2, tf_none))= ; > > > + > > > case CPTK_IS_LAYOUT_COMPATIBLE: > > > return layout_compatible_type_p (type1, type2); > > > > > > @@ -12682,6 +12685,7 @@ finish_trait_expr (location_t loc, cp_trait_k= ind kind, tree type1, tree type2) > > > break; > > > > > > case CPTK_IS_CONVERTIBLE: > > > + case CPTK_IS_INVOCABLE: > > > case CPTK_IS_NOTHROW_ASSIGNABLE: > > > case CPTK_IS_NOTHROW_CONSTRUCTIBLE: > > > case CPTK_IS_NOTHROW_CONVERTIBLE: > > > diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite= /g++.dg/ext/has-builtin-1.C > > > index 7f7b27f7aa7..d2a7ebdf25c 100644 > > > --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C > > > +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C > > > @@ -104,6 +104,9 @@ > > > #if !__has_builtin (__is_function) > > > # error "__has_builtin (__is_function) failed" > > > #endif > > > +#if !__has_builtin (__is_invocable) > > > +# error "__has_builtin (__is_invocable) failed" > > > +#endif > > > #if !__has_builtin (__is_layout_compatible) > > > # error "__has_builtin (__is_layout_compatible) failed" > > > #endif > > > diff --git a/gcc/testsuite/g++.dg/ext/is_invocable1.C b/gcc/testsuite= /g++.dg/ext/is_invocable1.C > > > new file mode 100644 > > > index 00000000000..d21ae1d1958 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/ext/is_invocable1.C > > > @@ -0,0 +1,349 @@ > > > +// { dg-do compile { target c++11 } } > > > + > > > +#define SA(X) static_assert((X),#X) > > > + > > > +using func_type_v0 =3D void(*)(); > > > + > > > +SA( __is_invocable( func_type_v0 ) ); > > > +SA( ! __is_invocable( func_type_v0, int ) ); > > > + > > > +using func_type_i0 =3D int(*)(); > > > + > > > +SA( __is_invocable( func_type_i0 ) ); > > > +SA( ! __is_invocable( func_type_i0, int ) ); > > > + > > > +using func_type_l0 =3D int&(*)(); > > > + > > > +SA( __is_invocable( func_type_l0 ) ); > > > +SA( ! __is_invocable( func_type_l0(int) ) ); > > > + > > > +using func_type_ii =3D int(*)(int); > > > + > > > +SA( ! __is_invocable( func_type_ii ) ); > > > +SA( __is_invocable( func_type_ii, int ) ); > > > + > > > +using func_type_il =3D int(*)(int&); > > > + > > > +SA( ! __is_invocable( func_type_il ) ); > > > +SA( ! __is_invocable( func_type_il, int ) ); > > > +SA( __is_invocable( func_type_il, int& ) ); > > > + > > > +using func_type_ir =3D int(*)(int&&); > > > + > > > +SA( ! __is_invocable( func_type_ir ) ); > > > +SA( ! __is_invocable( func_type_ir, int& ) ); > > > +SA( __is_invocable( func_type_ir, int ) ); > > > +SA( __is_invocable( func_type_ir, int&& ) ); > > > + > > > +struct A { }; > > > + > > > +using mem_type_i =3D int A::*; > > > + > > > +SA( ! __is_invocable( mem_type_i ) ); > > > +SA( ! __is_invocable( mem_type_i, int ) ); > > > +SA( ! __is_invocable( mem_type_i, int* ) ); > > > +SA( ! __is_invocable( mem_type_i, int& ) ); > > > +SA( ! __is_invocable( mem_type_i, int&& ) ); > > > +SA( __is_invocable( mem_type_i, A ) ); > > > +SA( __is_invocable( mem_type_i, A* ) ); > > > +SA( __is_invocable( mem_type_i, A& ) ); > > > +SA( __is_invocable( mem_type_i, A&& ) ); > > > +SA( __is_invocable( mem_type_i, const A& ) ); > > > +SA( ! __is_invocable( mem_type_i, A&, int ) ); > > > + > > > +using memfun_type_i =3D int (A::*)(); > > > + > > > +SA( ! __is_invocable( memfun_type_i ) ); > > > +SA( ! __is_invocable( memfun_type_i, int ) ); > > > +SA( ! __is_invocable( memfun_type_i, int* ) ); > > > +SA( ! __is_invocable( memfun_type_i, int& ) ); > > > +SA( ! __is_invocable( memfun_type_i, int&& ) ); > > > +SA( __is_invocable( memfun_type_i, A ) ); > > > +SA( __is_invocable( memfun_type_i, A* ) ); > > > +SA( __is_invocable( memfun_type_i, A& ) ); > > > +SA( __is_invocable( memfun_type_i, A&& ) ); > > > +SA( ! __is_invocable( memfun_type_i, const A& ) ); > > > +SA( ! __is_invocable( memfun_type_i, A&, int ) ); > > > + > > > +using memfun_type_ic =3D int (A::*)() const; > > > + > > > +SA( ! __is_invocable( memfun_type_ic ) ); > > > +SA( ! __is_invocable( memfun_type_ic, int ) ); > > > +SA( ! __is_invocable( memfun_type_ic, int& ) ); > > > +SA( __is_invocable( memfun_type_ic, A& ) ); > > > +SA( __is_invocable( memfun_type_ic, A* ) ); > > > +SA( ! __is_invocable( memfun_type_ic, A&, int ) ); > > > +SA( ! __is_invocable( memfun_type_ic, A*, int& ) ); > > > +SA( __is_invocable( memfun_type_ic, const A& ) ); > > > +SA( __is_invocable( memfun_type_ic, const A* ) ); > > > +SA( ! __is_invocable( memfun_type_ic, const A&, int& ) ); > > > +SA( ! __is_invocable( memfun_type_ic, const A*, int ) ); > > > + > > > +using memfun_type_iic =3D int& (A::*)(int&) const; > > > + > > > +SA( ! __is_invocable( memfun_type_iic ) ); > > > +SA( ! __is_invocable( memfun_type_iic, int ) ); > > > +SA( ! __is_invocable( memfun_type_iic, int& ) ); > > > +SA( ! __is_invocable( memfun_type_iic, A&, int ) ); > > > +SA( __is_invocable( memfun_type_iic, A&, int& ) ); > > > +SA( ! __is_invocable( memfun_type_iic, A*, int ) ); > > > +SA( __is_invocable( memfun_type_iic, A*, int& ) ); > > > +SA( ! __is_invocable( memfun_type_iic, const A&, int ) ); > > > +SA( ! __is_invocable( memfun_type_iic, const A&, int&, int ) ); > > > +SA( __is_invocable( memfun_type_iic, const A&, int& ) ); > > > +SA( __is_invocable( memfun_type_iic, const A*, int& ) ); > > > + > > > +struct B { > > > + int& operator()(); > > > + long& operator()() const; > > > + bool& operator()(int); > > > +private: > > > + void operator()(int, int); > > > +}; > > > +using CB =3D const B; > > > + > > > +SA( __is_invocable( B ) ); > > > +SA( __is_invocable( B& ) ); > > > +SA( __is_invocable( B&& ) ); > > > +SA( ! __is_invocable( B* ) ); > > > +SA( __is_invocable( CB ) ); > > > +SA( __is_invocable( CB& ) ); > > > +SA( ! __is_invocable( CB* ) ); > > > + > > > +SA( __is_invocable( B, int ) ); > > > +SA( __is_invocable( B&, int ) ); > > > +SA( __is_invocable( B&&, int ) ); > > > +SA( ! __is_invocable( B*, int ) ); > > > +SA( ! __is_invocable( CB, int ) ); > > > +SA( ! __is_invocable( CB&, int ) ); > > > +SA( ! __is_invocable( CB*, int ) ); > > > + > > > +SA( ! __is_invocable( B, int, int ) ); > > > +SA( ! __is_invocable( B&, int, int ) ); > > > +SA( ! __is_invocable( B&&, int, int ) ); > > > +SA( ! __is_invocable( B*, int, int ) ); > > > +SA( ! __is_invocable( CB, int, int ) ); > > > +SA( ! __is_invocable( CB&, int, int ) ); > > > +SA( ! __is_invocable( CB*, int, int ) ); > > > + > > > +struct C : B { int& operator()() =3D delete; }; > > > +using CC =3D const C; > > > + > > > +SA( ! __is_invocable( C ) ); > > > +SA( ! __is_invocable( C& ) ); > > > +SA( ! __is_invocable( C&& ) ); > > > +SA( ! __is_invocable( C* ) ); > > > +SA( ! __is_invocable( CC ) ); > > > +SA( ! __is_invocable( CC& ) ); > > > +SA( ! __is_invocable( CC* ) ); > > > + > > > +struct D { B operator*(); }; > > > +using CD =3D const D; > > > + > > > +SA( ! __is_invocable( D ) ); > > > + > > > +struct E { void v(); }; > > > +using CE =3D const E; > > > + > > > +SA( ! __is_invocable( E ) ); > > > +SA( ! __is_invocable( void (E::*)() ) ); > > > +SA( __is_invocable( void (E::*)(), E ) ); > > > +SA( __is_invocable( void (E::*)(), E* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CE ) ); > > > + > > > +struct F : E {}; > > > +using CF =3D const F; > > > + > > > +SA( ! __is_invocable( F ) ); > > > +SA( __is_invocable( void (E::*)(), F ) ); > > > +SA( __is_invocable( void (E::*)(), F* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CF ) ); > > > + > > > +struct G { E operator*(); }; > > > +using CG =3D const G; > > > + > > > +SA( ! __is_invocable( G ) ); > > > +SA( __is_invocable( void (E::*)(), G ) ); > > > +SA( ! __is_invocable( void (E::*)(), G* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CG ) ); > > > + > > > +struct H { E& operator*(); }; > > > +using CH =3D const H; > > > + > > > +SA( ! __is_invocable( H ) ); > > > +SA( __is_invocable( void (E::*)(), H ) ); > > > +SA( ! __is_invocable( void (E::*)(), H* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CH ) ); > > > + > > > +struct I { E&& operator*(); }; > > > +using CI =3D const I; > > > + > > > +SA( ! __is_invocable( I ) ); > > > +SA( __is_invocable( void (E::*)(), I ) ); > > > +SA( ! __is_invocable( void (E::*)(), I* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CI ) ); > > > + > > > +struct K { E* operator*(); }; > > > +using CK =3D const K; > > > + > > > +SA( ! __is_invocable( K ) ); > > > +SA( ! __is_invocable( void (E::*)(), K ) ); > > > +SA( ! __is_invocable( void (E::*)(), K* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CK ) ); > > > + > > > +struct L { CE operator*(); }; > > > +using CL =3D const L; > > > + > > > +SA( ! __is_invocable( L ) ); > > > +SA( ! __is_invocable( void (E::*)(), L ) ); > > > +SA( ! __is_invocable( void (E::*)(), L* ) ); > > > +SA( ! __is_invocable( void (E::*)(), CL ) ); > > > + > > > +struct M { > > > + int i; > > > +private: > > > + long l; > > > +}; > > > +using CM =3D const M; > > > + > > > +SA( ! __is_invocable( M ) ); > > > +SA( ! __is_invocable( M& ) ); > > > +SA( ! __is_invocable( M&& ) ); > > > +SA( ! __is_invocable( M* ) ); > > > +SA( ! __is_invocable( CM ) ); > > > +SA( ! __is_invocable( CM& ) ); > > > +SA( ! __is_invocable( CM* ) ); > > > + > > > +SA( ! __is_invocable( int M::* ) ); > > > +SA( __is_invocable( int M::*, M ) ); > > > +SA( __is_invocable( int M::*, M& ) ); > > > +SA( __is_invocable( int M::*, M&& ) ); > > > +SA( __is_invocable( int M::*, M* ) ); > > > +SA( __is_invocable( int M::*, CM ) ); > > > +SA( __is_invocable( int M::*, CM& ) ); > > > +SA( __is_invocable( int M::*, CM* ) ); > > > +SA( ! __is_invocable( int M::*, int ) ); > > > + > > > +SA( ! __is_invocable( int CM::* ) ); > > > +SA( __is_invocable( int CM::*, M ) ); > > > +SA( __is_invocable( int CM::*, M& ) ); > > > +SA( __is_invocable( int CM::*, M&& ) ); > > > +SA( __is_invocable( int CM::*, M* ) ); > > > +SA( __is_invocable( int CM::*, CM ) ); > > > +SA( __is_invocable( int CM::*, CM& ) ); > > > +SA( __is_invocable( int CM::*, CM* ) ); > > > +SA( ! __is_invocable( int CM::*, int ) ); > > > + > > > +SA( ! __is_invocable( long M::* ) ); > > > +SA( __is_invocable( long M::*, M ) ); > > > +SA( __is_invocable( long M::*, M& ) ); > > > +SA( __is_invocable( long M::*, M&& ) ); > > > +SA( __is_invocable( long M::*, M* ) ); > > > +SA( __is_invocable( long M::*, CM ) ); > > > +SA( __is_invocable( long M::*, CM& ) ); > > > +SA( __is_invocable( long M::*, CM* ) ); > > > +SA( ! __is_invocable( long M::*, long ) ); > > > + > > > +SA( ! __is_invocable( long CM::* ) ); > > > +SA( __is_invocable( long CM::*, M ) ); > > > +SA( __is_invocable( long CM::*, M& ) ); > > > +SA( __is_invocable( long CM::*, M&& ) ); > > > +SA( __is_invocable( long CM::*, M* ) ); > > > +SA( __is_invocable( long CM::*, CM ) ); > > > +SA( __is_invocable( long CM::*, CM& ) ); > > > +SA( __is_invocable( long CM::*, CM* ) ); > > > +SA( ! __is_invocable( long CM::*, long ) ); > > > + > > > +SA( ! __is_invocable( short M::* ) ); > > > +SA( __is_invocable( short M::*, M ) ); > > > +SA( __is_invocable( short M::*, M& ) ); > > > +SA( __is_invocable( short M::*, M&& ) ); > > > +SA( __is_invocable( short M::*, M* ) ); > > > +SA( __is_invocable( short M::*, CM ) ); > > > +SA( __is_invocable( short M::*, CM& ) ); > > > +SA( __is_invocable( short M::*, CM* ) ); > > > +SA( ! __is_invocable( short M::*, short ) ); > > > + > > > +SA( ! __is_invocable( short CM::* ) ); > > > +SA( __is_invocable( short CM::*, M ) ); > > > +SA( __is_invocable( short CM::*, M& ) ); > > > +SA( __is_invocable( short CM::*, M&& ) ); > > > +SA( __is_invocable( short CM::*, M* ) ); > > > +SA( __is_invocable( short CM::*, CM ) ); > > > +SA( __is_invocable( short CM::*, CM& ) ); > > > +SA( __is_invocable( short CM::*, CM* ) ); > > > +SA( ! __is_invocable( short CM::*, short ) ); > > > + > > > +struct N { M operator*(); }; > > > +SA( __is_invocable( int M::*, N ) ); > > > +SA( ! __is_invocable( int M::*, N* ) ); > > > + > > > +struct O { M& operator*(); }; > > > +SA( __is_invocable( int M::*, O ) ); > > > +SA( ! __is_invocable( int M::*, O* ) ); > > > + > > > +struct P { M&& operator*(); }; > > > +SA( __is_invocable( int M::*, P ) ); > > > +SA( ! __is_invocable( int M::*, P* ) ); > > > + > > > +struct Q { M* operator*(); }; > > > +SA( ! __is_invocable( int M::*, Q ) ); > > > +SA( ! __is_invocable( int M::*, Q* ) ); > > > + > > > +struct R { void operator()(int =3D 0); }; > > > + > > > +SA( __is_invocable( R ) ); > > > +SA( __is_invocable( R, int ) ); > > > +SA( ! __is_invocable( R, int, int ) ); > > > + > > > +struct S { void operator()(int, ...); }; > > > + > > > +SA( ! __is_invocable( S ) ); > > > +SA( __is_invocable( S, int ) ); > > > +SA( __is_invocable( S, int, int ) ); > > > +SA( __is_invocable( S, int, int, int ) ); > > > + > > > +void fn1() {} > > > + > > > +SA( __is_invocable( decltype(fn1) ) ); > > > + > > > +void fn2(int arr[10]); > > > + > > > +SA( __is_invocable( decltype(fn2), int[10] ) ); > > > +SA( __is_invocable( decltype(fn2), int(&)[10] ) ); > > > +SA( __is_invocable( decltype(fn2), int(&&)[10] ) ); > > > +SA( ! __is_invocable( decltype(fn2), int(*)[10] ) ); > > > +SA( ! __is_invocable( decltype(fn2), int(*&)[10] ) ); > > > +SA( ! __is_invocable( decltype(fn2), int(*&&)[10] ) ); > > > +SA( __is_invocable( decltype(fn2), int[] ) ); > > > + > > > +auto lambda =3D []() {}; > > > + > > > +SA( __is_invocable( decltype(lambda) ) ); > > > + > > > +template > > > +struct can_invoke { > > > + static constexpr bool value =3D __is_invocable( Func, Args... ); > > > +}; > > > + > > > +SA( can_invoke::value ); > > > + > > > +struct T { > > > + void func() const {} > > > + int data; > > > +}; > > > + > > > +SA( __is_invocable( decltype(&T::func)&, T& ) ); > > > +SA( __is_invocable( decltype(&T::data)&, T& ) ); > > > + > > > +struct U { }; > > > +struct V : U { U& operator*() =3D delete; }; > > > +SA( __is_invocable( int U::*, V ) ); > > > + > > > +struct W : private U { U& operator*(); }; > > > +SA( ! __is_invocable( int U::*, W ) ); > > > + > > > +struct X { int m; }; > > > +struct Y { X& operator*(); }; > > > +struct Z : Y { }; > > > +SA( __is_invocable(int X::*, Z) ); > > > diff --git a/gcc/testsuite/g++.dg/ext/is_invocable2.C b/gcc/testsuite= /g++.dg/ext/is_invocable2.C > > > new file mode 100644 > > > index 00000000000..a68aefd3e13 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/ext/is_invocable2.C > > > @@ -0,0 +1,139 @@ > > > +// { dg-do compile { target c++11 } } > > > +// __is_invocable should handle std::reference_wrapper correctly. > > > + > > > +#include > > > + > > > +#define SA(X) static_assert((X),#X) > > > + > > > +using std::reference_wrapper; > > > + > > > +using func_type_v0 =3D void(*)(); > > > + > > > +SA( __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > + > > > +using func_type_i0 =3D int(*)(); > > > + > > > +SA( __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > + > > > +using func_type_l0 =3D int&(*)(); > > > + > > > +SA( __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > + > > > +using func_type_ii =3D int(*)(int); > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( __is_invocable( reference_wrapper, int ) ); > > > + > > > +using func_type_il =3D int(*)(int&); > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > +SA( __is_invocable( reference_wrapper, int& ) ); > > > + > > > +using func_type_ir =3D int(*)(int&&); > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int& ) ); > > > +SA( __is_invocable( reference_wrapper, int ) ); > > > +SA( __is_invocable( reference_wrapper, int&& ) ); > > > + > > > +struct A { }; > > > + > > > +using mem_type_i =3D int A::*; > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > +SA( ! __is_invocable( reference_wrapper, int* ) ); > > > +SA( ! __is_invocable( reference_wrapper, int& ) ); > > > +SA( ! __is_invocable( reference_wrapper, int&& ) ); > > > +SA( __is_invocable( reference_wrapper, A ) ); > > > +SA( __is_invocable( reference_wrapper, A* ) ); > > > +SA( __is_invocable( reference_wrapper, A& ) ); > > > +SA( __is_invocable( reference_wrapper, A&& ) ); > > > + > > > +using memfun_type_i =3D int (A::*)(); > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > +SA( ! __is_invocable( reference_wrapper, int* ) ); > > > +SA( ! __is_invocable( reference_wrapper, int& ) ); > > > +SA( ! __is_invocable( reference_wrapper, int&& ) ); > > > +SA( __is_invocable( reference_wrapper, A ) ); > > > +SA( __is_invocable( reference_wrapper, A* ) ); > > > +SA( __is_invocable( reference_wrapper, A& ) ); > > > +SA( __is_invocable( reference_wrapper, A&& ) ); > > > +SA( ! __is_invocable( reference_wrapper, const A& ) )= ; > > > +SA( ! __is_invocable( reference_wrapper, A&, int ) ); > > > + > > > +using memfun_type_ic =3D int (A::*)() const; > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > +SA( ! __is_invocable( reference_wrapper, int& ) ); > > > +SA( __is_invocable( reference_wrapper, A& ) ); > > > +SA( __is_invocable( reference_wrapper, A* ) ); > > > +SA( ! __is_invocable( reference_wrapper, A&, int ) )= ; > > > +SA( ! __is_invocable( reference_wrapper, A*, int& ) = ); > > > +SA( __is_invocable( reference_wrapper, const A& ) = ); > > > +SA( __is_invocable( reference_wrapper, const A* ) = ); > > > +SA( ! __is_invocable( reference_wrapper, const A&, i= nt& ) ); > > > +SA( ! __is_invocable( reference_wrapper, const A*, i= nt ) ); > > > + > > > +using memfun_type_iic =3D int& (A::*)(int&) const; > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper, int ) ); > > > +SA( ! __is_invocable( reference_wrapper, int& ) ); > > > +SA( ! __is_invocable( reference_wrapper, A&, int ) = ); > > > +SA( __is_invocable( reference_wrapper, A&, int& )= ); > > > +SA( ! __is_invocable( reference_wrapper, A*, int ) = ); > > > +SA( __is_invocable( reference_wrapper, A*, int& )= ); > > > +SA( ! __is_invocable( reference_wrapper, const A&, = int ) ); > > > +SA( ! __is_invocable( reference_wrapper, const A&, = int&, int ) ); > > > +SA( __is_invocable( reference_wrapper, const A&, = int& ) ); > > > +SA( __is_invocable( reference_wrapper, const A*, = int& ) ); > > > + > > > +struct B { > > > + int& operator()(); > > > + long& operator()() const; > > > + bool& operator()(int); > > > +private: > > > + void operator()(int, int); > > > +}; > > > +using CB =3D const B; > > > + > > > +SA( __is_invocable( reference_wrapper ) ); > > > +SA( __is_invocable( reference_wrapper& ) ); > > > +SA( __is_invocable( reference_wrapper&& ) ); > > > +SA( __is_invocable( reference_wrapper ) ); > > > +SA( __is_invocable( reference_wrapper& ) ); > > > +SA( __is_invocable( reference_wrapper, int ) ); > > > +SA( ! __is_invocable( reference_wrapper&, int, int ) ); > > > + > > > +struct C : B { int& operator()() =3D delete; }; > > > +using CC =3D const C; > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper& ) ); > > > +SA( ! __is_invocable( reference_wrapper&& ) ); > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper& ) ); > > > + > > > +struct D { B operator*(); }; > > > +using CD =3D const D; > > > + > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper& ) ); > > > +SA( ! __is_invocable( reference_wrapper&& ) ); > > > +SA( ! __is_invocable( reference_wrapper* ) ); > > > +SA( ! __is_invocable( reference_wrapper ) ); > > > +SA( ! __is_invocable( reference_wrapper* ) ); > > > + > > > +std::function fn =3D []() {}; > > > +auto refwrap =3D std::ref(fn); > > > + > > > +SA( __is_invocable( decltype(fn) ) ); > > > +SA( __is_invocable( decltype(refwrap) ) ); > > > diff --git a/gcc/testsuite/g++.dg/ext/is_invocable3.C b/gcc/testsuite= /g++.dg/ext/is_invocable3.C > > > new file mode 100644 > > > index 00000000000..8699b0a53ca > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/ext/is_invocable3.C > > > @@ -0,0 +1,51 @@ > > > +// { dg-do compile { target c++11 } } > > > +// __is_invocable should handle incomplete class correctly. > > > + > > > +#define SA(X) static_assert((X),#X) > > > + > > > +struct Incomplete; > > > + > > > +SA( ! __is_invocable( Incomplete ) ); // { dg-error "incomplete type= " } > > > +SA( ! __is_invocable( Incomplete, int ) ); // { dg-error "incomplete= type" } > > > + > > > +SA( ! __is_invocable( int, Incomplete, int ) ); // { dg-error "incom= plete type" } > > > +SA( ! __is_invocable( int, Incomplete ) ); // { dg-error "incomplete= type" } > > > + > > > +SA( ! __is_invocable( Incomplete, Incomplete() ) ); // { dg-error "i= ncomplete type" } > > > +SA( ! __is_invocable( Incomplete, Incomplete(int), int ) ); // { dg-= error "incomplete type" } > > > +SA( ! __is_invocable( Incomplete, Incomplete(int, int), int, int ) )= ; // { dg-error "incomplete type" } > > > + > > > +SA( ! __is_invocable( Incomplete, Incomplete(), int, int ) ); // { d= g-error "incomplete type" } > > > + > > > +SA( ! __is_invocable( int(Incomplete), Incomplete ) ); // { dg-error= "incomplete type" } > > > +SA( ! __is_invocable( int(int, Incomplete), int, Incomplete ) ); // = { dg-error "incomplete type" } > > > +SA( ! __is_invocable( int(int, Incomplete), Incomplete, int ) ); // = { dg-error "incomplete type" } > > > + > > > +SA( __is_invocable( int(Incomplete&), Incomplete& ) ); // { dg-bog= us "incomplete type" } > > > +SA( __is_invocable( int(int, Incomplete&), int, Incomplete& ) ); /= / { dg-bogus "incomplete type" } > > > + > > > +SA( __is_invocable( int(Incomplete&&), Incomplete&& ) ); // { dg-b= ogus "incomplete type" } > > > +SA( __is_invocable( int(int, Incomplete&&), int, Incomplete&& ) );= // { dg-bogus "incomplete type" } > > > + > > > +SA( __is_invocable( int(const Incomplete&&), const Incomplete&& ) = ); // { dg-bogus "incomplete type" } > > > +SA( __is_invocable( int(int, const Incomplete&&), int, const Incom= plete&& ) ); // { dg-bogus "incomplete type" } > > > + > > > +SA( __is_invocable( int(const Incomplete&), const Incomplete& ) );= // { dg-bogus "incomplete type" } > > > +SA( __is_invocable( int(int, const Incomplete&), int, const Incomp= lete& ) ); // { dg-bogus "incomplete type" } > > > + > > > +SA( __is_invocable( int(const Incomplete&), Incomplete& ) ); // { = dg-bogus "incomplete type" } > > > +SA( __is_invocable( int(int, const Incomplete&), int, Incomplete& = ) ); // { dg-bogus "incomplete type" } > > > + > > > +SA( __is_invocable( int Incomplete::*, const Incomplete& ) ); // {= dg-bogus "incomplete type" } > > > +SA( ! __is_invocable( void (Incomplete::*)(long&), const Incomplete*= , long& ) ); // { dg-bogus "incomplete type" } > > > +SA( __is_invocable( void (Incomplete::*)(long&) const, Incomplete*= , long& ) ); // { dg-bogus "incomplete type" } > > > + > > > +template > > > +struct Holder { T t; }; > > > + > > > +SA( __is_invocable( int(Holder&), Holder& = ) ); // { dg-bogus "incomplete type" } > > > + > > > +// Define Incomplete, which is now not incomplete. > > > +struct Incomplete { void operator()(); }; > > > + > > > +SA( __is_invocable( Incomplete ) ); // { dg-bogus "incomplete type= " } > > > diff --git a/gcc/testsuite/g++.dg/ext/is_invocable4.C b/gcc/testsuite= /g++.dg/ext/is_invocable4.C > > > new file mode 100644 > > > index 00000000000..d1efccf08f8 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/ext/is_invocable4.C > > > @@ -0,0 +1,33 @@ > > > +// { dg-do compile { target c++11 } } > > > +// Failed access check should be a substitution failure, not an erro= r. > > > + > > > +#define SA(X) static_assert((X),#X) > > > + > > > +template > > > +struct bool_constant { static constexpr bool value =3D B; }; > > > + > > > +template > > > +struct is_invocable > > > +: public bool_constant<__is_invocable(_Fn, _ArgTypes...)> > > > +{ }; > > > + > > > +#if __cpp_variable_templates > > > +template > > > +constexpr bool is_invocable_v =3D __is_invocable(_Fn, _ArgTypes...); > > > +#endif > > > + > > > +class Private > > > +{ > > > + void operator()() const > > > + { > > > + SA( ! is_invocable::value ); > > > +#if __cpp_variable_templates > > > + SA( ! is_invocable_v ); > > > +#endif > > > + } > > > +}; > > > + > > > +SA( ! is_invocable::value ); > > > +#if __cpp_variable_templates > > > +SA( ! is_invocable_v ); > > > +#endif > > > -- > > > 2.44.0 > > > > > > > >