[clang] 2d4f289 - [clang] Add `__has_extension ()` for C++11 features
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 3 07:16:18 PDT 2023
Author: Mariya Podchishchaeva
Date: 2023-07-03T10:15:40-04:00
New Revision: 2d4f2890823fa3edc6ae563edec4dacad1989564
URL: https://github.com/llvm/llvm-project/commit/2d4f2890823fa3edc6ae563edec4dacad1989564
DIFF: https://github.com/llvm/llvm-project/commit/2d4f2890823fa3edc6ae563edec4dacad1989564.diff
LOG: [clang] Add `__has_extension ()` for C++11 features
Add `__has_extension (cxx_defaulted_functions)` and
`__has_extension (cxx_default_function_template_args)` since they are
accepted in C++98 mode as extensions.
Fixes https://github.com/llvm/llvm-project/issues/61758
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D154334
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Features.def
clang/test/Lexer/has_extension_cxx.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 94eddd5e3b89c7..022d51b525c04c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -565,6 +565,9 @@ Bug Fixes in This Version
(`#63629 <https://github.com/llvm/llvm-project/issues/63629>`_)
- Fixed parsing of elaborated type specifier inside of a new expression.
(`#34341 <https://github.com/llvm/llvm-project/issues/34341>`_)
+- Clang now correctly evaluates ``__has_extension (cxx_defaulted_functions)``
+ and ``__has_extension (cxx_default_function_template_args)`` to 1.
+ (`#61758 <https://github.com/llvm/llvm-project/issues/61758>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def
index 4113b4d868dda6..1eb4573a8f7fef 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -247,6 +247,8 @@ EXTENSION(c_static_assert, true)
EXTENSION(c_thread_local, PP.getTargetInfo().isTLSSupported())
// C++11 features supported by other languages as extensions.
EXTENSION(cxx_atomic, LangOpts.CPlusPlus)
+EXTENSION(cxx_default_function_template_args, LangOpts.CPlusPlus)
+EXTENSION(cxx_defaulted_functions, LangOpts.CPlusPlus)
EXTENSION(cxx_deleted_functions, LangOpts.CPlusPlus)
EXTENSION(cxx_explicit_conversions, LangOpts.CPlusPlus)
EXTENSION(cxx_inline_namespaces, LangOpts.CPlusPlus)
diff --git a/clang/test/Lexer/has_extension_cxx.cpp b/clang/test/Lexer/has_extension_cxx.cpp
index d1267eaf85d84b..1ae6a446b300a7 100644
--- a/clang/test/Lexer/has_extension_cxx.cpp
+++ b/clang/test/Lexer/has_extension_cxx.cpp
@@ -11,6 +11,16 @@ int c_static_assert();
int c_generic_selections();
#endif
+// CHECK: has_default_function_template_args
+#if __has_extension(cxx_default_function_template_args)
+int has_default_function_template_args();
+#endif
+
+// CHECK: has_defaulted_functions
+#if __has_extension(cxx_defaulted_functions)
+int has_defaulted_functions();
+#endif
+
// CHECK: has_deleted_functions
#if __has_extension(cxx_deleted_functions)
int has_deleted_functions();
More information about the cfe-commits
mailing list