From 5c04da88731961636d08c0fd06f2aa291410d5b9 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 5 Dec 2019 20:06:46 +0000 Subject: [PATCH] PR c++/92271 - make __is_same alias for __is_same_as. Richard Smith proposed adding a synonym for __is_same_as, to accomodate the convention of exposing std::SOME_TRAIT::value as __SOME_TRAIT(A, B). So add that alias, and also adjust the C++ printer. I didn't bother changing the RID_ identifier. * c-common.c: Add __is_same, an alias for __is_same_as. * cxx-pretty-print.c (pp_cxx_trait_expression) : Print "__is_same". * g++.dg/ext/is_same.C: New test. From-SVN: r279018 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-common.c | 1 + gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cxx-pretty-print.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/is_same.C | 5 +++++ 6 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_same.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f85da5093d8..82a62b82749 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-12-05 Marek Polacek + + PR c++/92271 - make __is_same alias for __is_same_as. + * c-common.c: Add __is_same, an alias for __is_same_as. + 2019-12-03 Marek Polacek PR c++/91363 - P0960R3: Parenthesized initialization of aggregates. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2f389d2895a..8292d18621b 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -418,6 +418,7 @@ const struct c_common_resword c_common_reswords[] = { "__is_literal_type", RID_IS_LITERAL_TYPE, D_CXXONLY }, { "__is_pod", RID_IS_POD, D_CXXONLY }, { "__is_polymorphic", RID_IS_POLYMORPHIC, D_CXXONLY }, + { "__is_same", RID_IS_SAME_AS, D_CXXONLY }, { "__is_same_as", RID_IS_SAME_AS, D_CXXONLY }, { "__is_standard_layout", RID_IS_STD_LAYOUT, D_CXXONLY }, { "__is_trivial", RID_IS_TRIVIAL, D_CXXONLY }, diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b9b8949644a..4e88ed828f6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-12-05 Marek Polacek + + PR c++/92271 - make __is_same alias for __is_same_as. + * cxx-pretty-print.c (pp_cxx_trait_expression) : + Print "__is_same". + 2019-12-05 David Edelsohn * cp-gimplify.c: Include memmodel.h. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 909b2a4ef1d..62805446ba9 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -2661,7 +2661,7 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t) pp_cxx_ws_string (pp, "__is_polymorphic"); break; case CPTK_IS_SAME_AS: - pp_cxx_ws_string (pp, "__is_same_as"); + pp_cxx_ws_string (pp, "__is_same"); break; case CPTK_IS_STD_LAYOUT: pp_cxx_ws_string (pp, "__is_std_layout"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34e5783cedd..e1692fae10d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-05 Marek Polacek + + PR c++/92271 - make __is_same alias for __is_same_as. + * g++.dg/ext/is_same.C: New test. + 2019-12-05 Tobias Burnus * testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: Add diff --git a/gcc/testsuite/g++.dg/ext/is_same.C b/gcc/testsuite/g++.dg/ext/is_same.C new file mode 100644 index 00000000000..5e9079c5109 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_same.C @@ -0,0 +1,5 @@ +// PR c++/92271 - make __is_same alias for __is_same_as. +// { dg-do compile { target c++11 } } + +static_assert(__is_same(int, int) == __is_same_as(int, int), ""); +static_assert(__is_same(unsigned int, int) == __is_same_as(unsigned int, int), ""); -- 2.30.2