Browse Source

Features: Add cxx_unrestricted_unions.

Stephen Kelly 11 years ago
parent
commit
9064f78b0c

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -127,6 +127,11 @@ The features known to this version of CMake are:
 
   .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
 
+``cxx_unrestricted_unions``
+  Unrestricted unions, as defined in N2544_.
+
+  .. _N2544: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
+
 ``cxx_user_literals``
   User-defined literals, as defined in N2765_.
 

+ 1 - 0
Modules/Compiler/GNU-CXX-FeatureTests.cmake

@@ -26,6 +26,7 @@ set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
 set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}")
 set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
 # TODO: Should be supported by GNU 4.5
 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")

+ 1 - 0
Source/cmMakefile.cxx

@@ -65,6 +65,7 @@
   F(cxx_strong_enums) \
   F(cxx_trailing_return_types) \
   F(cxx_unicode_literals) \
+  F(cxx_unrestricted_unions) \
   F(cxx_user_literals) \
   F(cxx_variadic_templates)
 

+ 11 - 0
Tests/CompileFeatures/cxx_unrestricted_unions.cpp

@@ -0,0 +1,11 @@
+
+struct point {
+  point() {}
+  point(int x, int y) : x_(x), y_(y) {}
+  int x_, y_;
+};
+union u {
+  point p_;
+  int i_;
+  const char* s_;
+};