aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorKen Matsui <kmatsui@gcc.gnu.org>2023-12-06 21:33:03 -0800
committerJason Merrill <jason@redhat.com>2023-12-10 13:11:22 -0500
commit8769777bf74a844b05521bf51bed4db4c9ca66d4 (patch)
tree5a9367a9ec29b9187ca31437f7ed8bcf7716ad55 /gcc/cp
parentea0a0e6bf1470e48cc5f337bc1be40c40ac8e5ed (diff)
downloadgcc-8769777bf74a844b05521bf51bed4db4c9ca66d4.zip
gcc-8769777bf74a844b05521bf51bed4db4c9ca66d4.tar.gz
gcc-8769777bf74a844b05521bf51bed4db4c9ca66d4.tar.bz2
c++: Implement __is_scoped_enum built-in trait
This patch implements built-in trait for std::is_scoped_enum. gcc/cp/ChangeLog: * cp-trait.def: Define __is_scoped_enum. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_SCOPED_ENUM. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_scoped_enum. * g++.dg/ext/is_scoped_enum.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/constraint.cc3
-rw-r--r--gcc/cp/cp-trait.def1
-rw-r--r--gcc/cp/semantics.cc4
3 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 2311bab..062dc40 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3783,6 +3783,9 @@ diagnose_trait_expr (tree expr, tree args)
case CPTK_IS_SAME:
inform (loc, " %qT is not the same as %qT", t1, t2);
break;
+ case CPTK_IS_SCOPED_ENUM:
+ inform (loc, " %qT is not a scoped enum", t1);
+ break;
case CPTK_IS_STD_LAYOUT:
inform (loc, " %qT is not an standard layout type", t1);
break;
diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def
index 0e93e2b..9d848f6 100644
--- a/gcc/cp/cp-trait.def
+++ b/gcc/cp/cp-trait.def
@@ -78,6 +78,7 @@ DEFTRAIT_EXPR (IS_POINTER_INTERCONVERTIBLE_BASE_OF, "__is_pointer_interconvertib
DEFTRAIT_EXPR (IS_POD, "__is_pod", 1)
DEFTRAIT_EXPR (IS_POLYMORPHIC, "__is_polymorphic", 1)
DEFTRAIT_EXPR (IS_SAME, "__is_same", 2)
+DEFTRAIT_EXPR (IS_SCOPED_ENUM, "__is_scoped_enum", 1)
DEFTRAIT_EXPR (IS_STD_LAYOUT, "__is_standard_layout", 1)
DEFTRAIT_EXPR (IS_TRIVIAL, "__is_trivial", 1)
DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2)
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index ecbd858..2bb5455 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -12446,6 +12446,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_SAME:
return same_type_p (type1, type2);
+ case CPTK_IS_SCOPED_ENUM:
+ return SCOPED_ENUM_P (type1);
+
case CPTK_IS_STD_LAYOUT:
return std_layout_type_p (type1);
@@ -12625,6 +12628,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_CLASS:
case CPTK_IS_ENUM:
case CPTK_IS_SAME:
+ case CPTK_IS_SCOPED_ENUM:
case CPTK_IS_UNION:
break;