diff options
author | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-02-19 18:10:16 -0800 |
---|---|---|
committer | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-05-10 18:17:52 -0700 |
commit | 7bd33955970202095738e85c4ddf161432ece099 (patch) | |
tree | 4dbc1c370f9f4b1d59ca1bae4219c56f7f77d5f0 /gcc/cp/semantics.cc | |
parent | 37fad797adea340307fb33c3d7a0a17652063a33 (diff) | |
download | gcc-7bd33955970202095738e85c4ddf161432ece099.zip gcc-7bd33955970202095738e85c4ddf161432ece099.tar.gz gcc-7bd33955970202095738e85c4ddf161432ece099.tar.bz2 |
c++: Implement __is_invocable built-in trait
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.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/semantics.cc')
-rw-r--r-- | gcc/cp/semantics.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index bde26e4..311e4f4 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12565,6 +12565,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_FUNCTION: return type_code1 == 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); @@ -12723,6 +12726,7 @@ same_type_ref_bind_p (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CONSTRUCTIBLE: case CPTK_IS_NOTHROW_CONSTRUCTIBLE: case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: + case CPTK_IS_INVOCABLE: case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: case CPTK_REF_CONVERTS_FROM_TEMPORARY: to = type1; @@ -12825,6 +12829,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CONSTRUCTIBLE: case CPTK_IS_CONVERTIBLE: + case CPTK_IS_INVOCABLE: case CPTK_IS_NOTHROW_CONSTRUCTIBLE: case CPTK_IS_NOTHROW_CONVERTIBLE: case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: |