Add c_alignas and cxx_alignas features

llvm-svn: 142020
This commit is contained in:
Peter Collingbourne 2011-10-14 23:44:46 +00:00
parent 3d711633a3
commit 60188eb8bf
5 changed files with 43 additions and 0 deletions

View File

@ -40,6 +40,7 @@
<ul>
<li><a href="#cxx_access_control_sfinae">C++0x SFINAE includes access control</a></li>
<li><a href="#cxx_alias_templates">C++0x alias templates</a></li>
<li><a href="#cxx_alignas">C++0x alignment specifiers</a></li>
<li><a href="#cxx_attributes">C++0x attributes</a></li>
<li><a href="#cxx_constexpr">C++0x generalized constant expressions</a></li>
<li><a href="#cxx_decltype">C++0x <tt>decltype()</tt></a></li>
@ -71,6 +72,7 @@
</ul></li>
<li><a href="#c1x">C1X</a>
<ul>
<li><a href="#c_alignas">C1X alignment specifiers</a></li>
<li><a href="#c_generic_selections">C1X generic selections</a></li>
<li><a href="#c_static_assert">C1X <tt>_Static_assert()</tt></a></li>
</ul></li>
@ -476,6 +478,12 @@ with the <tt>-std=c++0x</tt> option when compiling C++ code.</p>
<tt>__has_extension(cxx_alias_templates)</tt> to determine if support for
C++0x's alias declarations and alias templates is enabled.</p>
<h4 id="cxx_alignas">C++0x alignment specifiers</h4>
<p>Use <tt>__has_feature(cxx_alignas)</tt> or
<tt>__has_extension(cxx_alignas)</tt> to determine if support for alignment
specifiers using <tt>alignas</tt> is enabled.</p>
<h4 id="cxx_attributes">C++0x attributes</h4>
<p>Use <tt>__has_feature(cxx_attributes)</tt> or
@ -635,6 +643,12 @@ for variadic templates is enabled.</p>
C1X standard. As a result, all these features are enabled
with the <tt>-std=c1x</tt> option when compiling C code.</p>
<h4 id="c_alignas">C1X alignment specifiers</h4>
<p>Use <tt>__has_feature(c_alignas)</tt> or <tt>__has_extension(c_alignas)</tt>
to determine if support for alignment specifiers using <tt>_Alignas</tt>
is enabled.</p>
<h4 id="c_generic_selections">C1X generic selections</h4>
<p>Use <tt>__has_feature(c_generic_selections)</tt> or

View File

@ -609,11 +609,13 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
.Case("ownership_returns", true)
.Case("ownership_takes", true)
// C1X features
.Case("c_alignas", LangOpts.C1X)
.Case("c_generic_selections", LangOpts.C1X)
.Case("c_static_assert", LangOpts.C1X)
// C++0x features
.Case("cxx_access_control_sfinae", LangOpts.CPlusPlus0x)
.Case("cxx_alias_templates", LangOpts.CPlusPlus0x)
.Case("cxx_alignas", LangOpts.CPlusPlus0x)
.Case("cxx_attributes", LangOpts.CPlusPlus0x)
.Case("cxx_auto_type", LangOpts.CPlusPlus0x)
//.Case("cxx_constexpr", false);
@ -702,6 +704,7 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) {
// must be less restrictive than HasFeature's.
return llvm::StringSwitch<bool>(II->getName())
// C1X features supported by other languages as extensions.
.Case("c_alignas", true)
.Case("c_generic_selections", true)
.Case("c_static_assert", true)
// C++0x features supported by other languages as extensions.

View File

@ -28,3 +28,11 @@ int has_c_generic_selections();
int no_c_generic_selections();
#endif
// CHECK-PED-NONE: has_c_alignas
// CHECK-PED-ERR: no_c_alignas
#if __has_extension(c_alignas)
int has_c_alignas();
#else
int no_c_alignas();
#endif

View File

@ -18,3 +18,12 @@ int no_generic_selections();
// CHECK-1X: has_generic_selections
// CHECK-NO-1X: no_generic_selections
#if __has_feature(c_alignas)
int has_alignas();
#else
int no_alignas();
#endif
// CHECK-1X: has_alignas
// CHECK-NO-1X: no_alignas

View File

@ -173,3 +173,12 @@ int no_implicit_moves();
// CHECK-0X: has_implicit_moves
// CHECK-NO-0X: no_implicit_moves
#if __has_feature(cxx_alignas)
int has_alignas();
#else
int no_alignas();
#endif
// CHECK-0X: has_alignas
// CHECK-NO-0X: no_alignas