Skip to content

Commit

Permalink
[clang] Add __has_extension () for C++11 features
Browse files Browse the repository at this point in the history
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 #61758

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D154334
  • Loading branch information
Fznamznon committed Jul 3, 2023
1 parent 23ed601 commit 2d4f289
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Lexer/has_extension_cxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2d4f289

Please sign in to comment.