diff options
author | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-02-14 23:21:35 -0800 |
---|---|---|
committer | Ken Matsui <kmatsui@gcc.gnu.org> | 2024-05-10 18:17:09 -0700 |
commit | c08d1afbf539a672f28100640d964565ac575ff5 (patch) | |
tree | 3330da5efbd56bb86ae49251361d68cbebf9ba7c /gcc/cp/semantics.cc | |
parent | 86812be98a129ac9923df5dfb6b457bfe28e9e8c (diff) | |
download | gcc-c08d1afbf539a672f28100640d964565ac575ff5.zip gcc-c08d1afbf539a672f28100640d964565ac575ff5.tar.gz gcc-c08d1afbf539a672f28100640d964565ac575ff5.tar.bz2 |
c++: Implement __add_lvalue_reference built-in trait
This patch implements built-in trait for std::add_lvalue_reference.
gcc/cp/ChangeLog:
* cp-trait.def: Define __add_lvalue_reference.
* semantics.cc (finish_trait_type): Handle
CPTK_ADD_LVALUE_REFERENCE.
gcc/testsuite/ChangeLog:
* g++.dg/ext/has-builtin-1.C: Test existence of
__add_lvalue_reference.
* g++.dg/ext/add_lvalue_reference.C: New test.
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/semantics.cc')
-rw-r--r-- | gcc/cp/semantics.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index c2ab08c..a6f795d 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12924,6 +12924,12 @@ finish_trait_type (cp_trait_kind kind, tree type1, tree type2, switch (kind) { + case CPTK_ADD_LVALUE_REFERENCE: + /* [meta.trans.ref]. */ + if (referenceable_type_p (type1)) + return cp_build_reference_type (type1, /*rval=*/false); + return type1; + case CPTK_ADD_POINTER: /* [meta.trans.ptr]. */ if (VOID_TYPE_P (type1) || referenceable_type_p (type1)) |