[clang] eb535d2 - Accept __is_same_as as a GCC-compatibility synonym for the proper trait name __is_same.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 14:45:17 PDT 2019


Author: Richard Smith
Date: 2019-10-29T14:44:38-07:00
New Revision: eb535d23418c7259cac85bdb13197263b2cee056

URL: https://github.com/llvm/llvm-project/commit/eb535d23418c7259cac85bdb13197263b2cee056
DIFF: https://github.com/llvm/llvm-project/commit/eb535d23418c7259cac85bdb13197263b2cee056.diff

LOG: Accept __is_same_as as a GCC-compatibility synonym for the proper trait name __is_same.

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/include/clang/Basic/TokenKinds.def
    clang/test/Preprocessor/feature_tests.cpp
    clang/test/SemaCXX/type-traits.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 51e6a4460336..a9fb85fa0d8d 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1157,6 +1157,7 @@ The following type trait primitives are supported by Clang. Those traits marked
 * ``__is_reference`` (C++, Embarcadero)
 * ``__is_rvalue_reference`` (C++, Embarcadero)
 * ``__is_same`` (C++, Embarcadero)
+* ``__is_same_as`` (GCC): Synonym for ``__is_same``.
 * ``__is_scalar`` (C++, Embarcadero)
 * ``__is_sealed`` (Microsoft):
   Synonym for ``__is_final``.

diff  --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 94fe1ba63a9f..ae908bbdf3a8 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -524,6 +524,8 @@ TYPE_TRAIT_2(__is_same, IsSame, KEYCXX)
 TYPE_TRAIT_2(__is_convertible, IsConvertible, KEYCXX)
 KEYWORD(__array_rank                , KEYCXX)
 KEYWORD(__array_extent              , KEYCXX)
+// Name for GCC 6 compatibility.
+ALIAS("__is_same_as", __is_same, KEYCXX)
 
 // Apple Extension.
 KEYWORD(__private_extern__          , KEYALL)

diff  --git a/clang/test/Preprocessor/feature_tests.cpp b/clang/test/Preprocessor/feature_tests.cpp
index 50da228a4efe..b501cb7a6e59 100644
--- a/clang/test/Preprocessor/feature_tests.cpp
+++ b/clang/test/Preprocessor/feature_tests.cpp
@@ -29,6 +29,7 @@
     !__has_builtin(__array_rank) || \
     !__has_builtin(__underlying_type) || \
     !__has_builtin(__is_trivial) || \
+    !__has_builtin(__is_same_as) || \
     !__has_builtin(__has_unique_object_representations)
 #error Clang should have these
 #endif

diff  --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index 99270f19e68b..c2f233b5d0c9 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -1960,6 +1960,10 @@ void is_same()
   int t10[F(__is_same(Base, const Base))];
   int t11[F(__is_same(Base, Base&))];
   int t12[F(__is_same(Base, Derived))];
+
+  // __is_same_as is a GCC compatibility synonym for __is_same.
+  int t20[T(__is_same_as(int, int))];
+  int t21[F(__is_same_as(int, float))];
 }
 
 struct IntWrapper


        


More information about the cfe-commits mailing list