c++: implement __remove_cv, __remove_reference and __remove_cvref
commit9ca147154074a0de548138b4e73477e94903a855
authorPatrick Palka <ppalka@redhat.com>
Thu, 29 Sep 2022 13:18:40 +0000 (29 09:18 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 29 Sep 2022 13:18:40 +0000 (29 09:18 -0400)
tree689d3428db5ceea4aa86f800a8d59a1c8e9d300c
parent817e878a31671fcb68492bce35aa1ac87e08efdb
c++: implement __remove_cv, __remove_reference and __remove_cvref

This implements builtins for std::remove_cv, std::remove_reference and
std::remove_cvref using TRAIT_TYPE from the previous patch.

gcc/c-family/ChangeLog:

* c-common.cc (c_common_reswords): Add __remove_cv,
__remove_reference and __remove_cvref.
* c-common.h (enum rid): Add RID_REMOVE_CV, RID_REMOVE_REFERENCE
and RID_REMOVE_CVREF.

gcc/cp/ChangeLog:

* constraint.cc (diagnose_trait_expr): Handle CPTK_REMOVE_CV,
CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
* cp-objcp-common.cc (names_builtin_p): Likewise.
* cp-tree.h (enum cp_trait_kind): Add CPTK_REMOVE_CV,
CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
* cxx-pretty-print.cc (pp_cxx_trait): Handle CPTK_REMOVE_CV,
CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF.
* parser.cc (cp_keyword_starts_decl_specifier_p): Return true
for RID_REMOVE_CV, RID_REMOVE_REFERENCE and RID_REMOVE_CVREF.
(cp_parser_trait): Handle RID_REMOVE_CV, RID_REMOVE_REFERENCE
and RID_REMOVE_CVREF.
(cp_parser_simple_type_specifier): Likewise.
* semantics.cc (finish_trait_type): Likewise.

libstdc++-v3/ChangeLog:

* include/bits/unique_ptr.h (unique_ptr<_Tp[], _Dp>): Remove
__remove_cv and use __remove_cv_t instead.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __remove_cv,
__remove_reference and __remove_cvref.
* g++.dg/ext/remove_cv.C: New test.
* g++.dg/ext/remove_reference.C: New test.
* g++.dg/ext/remove_cvref.C: New test.
13 files changed:
gcc/c-family/c-common.cc
gcc/c-family/c-common.h
gcc/cp/constraint.cc
gcc/cp/cp-objcp-common.cc
gcc/cp/cp-tree.h
gcc/cp/cxx-pretty-print.cc
gcc/cp/parser.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/ext/has-builtin-1.C
gcc/testsuite/g++.dg/ext/remove_cv.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/remove_cvref.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/remove_reference.C [new file with mode: 0644]
libstdc++-v3/include/bits/unique_ptr.h