Add support for has_feature(cxx_alignof) and has_feature(c_alignof).

r142020 added support for has_feature(cxx_alignas). This does the same for
alignof.

llvm-svn: 223186
This commit is contained in:
Nico Weber 2014-12-03 01:25:49 +00:00
parent aad4af6d50
commit 736a993828
5 changed files with 35 additions and 4 deletions

View File

@ -543,6 +543,9 @@ C++11 alignment specifiers
Use ``__has_feature(cxx_alignas)`` or ``__has_extension(cxx_alignas)`` to
determine if support for alignment specifiers using ``alignas`` is enabled.
Use ``__has_feature(cxx_alignof)`` or ``__has_extension(cxx_alignof)`` to
determine if support for the ``alignof`` keyword is enabled.
C++11 attributes
^^^^^^^^^^^^^^^^
@ -857,6 +860,9 @@ C11 alignment specifiers
Use ``__has_feature(c_alignas)`` or ``__has_extension(c_alignas)`` to determine
if support for alignment specifiers using ``_Alignas`` is enabled.
Use ``__has_feature(c_alignof)`` or ``__has_extension(c_alignof)`` to determine
if support for the ``_Alignof`` keyword is enabled.
C11 atomic operations
^^^^^^^^^^^^^^^^^^^^^

View File

@ -913,6 +913,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("arc_cf_code_audited", true)
// C11 features
.Case("c_alignas", LangOpts.C11)
.Case("c_alignof", LangOpts.C11)
.Case("c_atomic", LangOpts.C11)
.Case("c_generic_selections", LangOpts.C11)
.Case("c_static_assert", LangOpts.C11)
@ -922,6 +923,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("cxx_access_control_sfinae", LangOpts.CPlusPlus11)
.Case("cxx_alias_templates", LangOpts.CPlusPlus11)
.Case("cxx_alignas", LangOpts.CPlusPlus11)
.Case("cxx_alignof", LangOpts.CPlusPlus11)
.Case("cxx_atomic", LangOpts.CPlusPlus11)
.Case("cxx_attributes", LangOpts.CPlusPlus11)
.Case("cxx_auto_type", LangOpts.CPlusPlus11)
@ -1030,6 +1032,7 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) {
return llvm::StringSwitch<bool>(Extension)
// C11 features supported by other languages as extensions.
.Case("c_alignas", true)
.Case("c_alignof", true)
.Case("c_atomic", true)
.Case("c_generic_selections", true)
.Case("c_static_assert", true)

View File

@ -36,6 +36,14 @@ int has_c_alignas();
int no_c_alignas();
#endif
// CHECK-PED-NONE: has_c_alignof
// CHECK-PED-ERR: no_c_alignof
#if __has_extension(c_alignof)
int has_c_alignof();
#else
int no_c_alignof();
#endif
// Arbitrary feature to test that the extension name can be surrounded with
// double underscores.
// CHECK-PED-NONE: has_double_underscores

View File

@ -12,7 +12,6 @@ int has_atomic();
#else
int no_atomic();
#endif
// CHECK-1X: has_atomic
// CHECK-NO-1X: no_atomic
@ -21,7 +20,6 @@ int has_static_assert();
#else
int no_static_assert();
#endif
// CHECK-1X: has_static_assert
// CHECK-NO-1X: no_static_assert
@ -30,7 +28,6 @@ int has_generic_selections();
#else
int no_generic_selections();
#endif
// CHECK-1X: has_generic_selections
// CHECK-NO-1X: no_generic_selections
@ -39,10 +36,17 @@ int has_alignas();
#else
int no_alignas();
#endif
// CHECK-1X: has_alignas
// CHECK-NO-1X: no_alignas
#if __has_feature(c_alignof)
int has_alignof();
#else
int no_alignof();
#endif
// CHECK-1X: has_alignof
// CHECK-NO-1X: no_alignof
#if __has_feature(c_thread_local)
int has_thread_local();
#else

View File

@ -234,6 +234,16 @@ int no_alignas();
// CHECK-11: has_alignas
// CHECK-NO-11: no_alignas
#if __has_feature(cxx_alignof)
int has_alignof();
#else
int no_alignof();
#endif
// CHECK-1Y: has_alignof
// CHECK-11: has_alignof
// CHECK-NO-11: no_alignof
#if __has_feature(cxx_raw_string_literals)
int has_raw_string_literals();
#else