1
0
Эх сурвалжийг харах

Merge topic 'cxx11-features'

60c0d2dd Features: Add cxx_defaulted_move_initializers.
c4e67235 Features: Add cxx_long_long_type.
dcaafada Features: Add cxx_func_identifier.
251a1f02 Features: Add cxx_local_type_template_args.
53fe7773 Features: Add cxx_extended_friend_declarations.
16603f7c Features: Add cxx_enum_forward_declarations.
adf22f61 Features: Add cxx_default_function_template_args.
7b3e8a05 Features: Add cxx_right_angle_brackets.
9a49fd21 Features: Add cxx_decltype_incomplete_return_types.
1889045c Features: Add cxx_sizeof_member.
ab455eba Features: Add cxx_thread_local.
300ce248 Features: Add cxx_inline_namespaces.
f9d04a96 Features: Add cxx_variadic_macros.
3d76656f Features: Add cxx_uniform_initialization.
e74b216c Features: Add cxx_generalized_initializers.
ff80c3b4 Features: Add cxx_attributes.
...
Brad King 11 жил өмнө
parent
commit
8472ef243f
47 өөрчлөгдсөн 796 нэмэгдсэн , 1 устгасан
  1. 220 0
      Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst
  2. 69 0
      Modules/Compiler/GNU-CXX-FeatureTests.cmake
  3. 45 1
      Source/cmMakefile.cxx
  4. 11 0
      Tests/CompileFeatures/cxx_alias_templates.cpp
  5. 4 0
      Tests/CompileFeatures/cxx_alignas.cpp
  6. 5 0
      Tests/CompileFeatures/cxx_alignof.cpp
  7. 2 0
      Tests/CompileFeatures/cxx_attributes.cpp
  8. 5 0
      Tests/CompileFeatures/cxx_constexpr.cpp
  9. 7 0
      Tests/CompileFeatures/cxx_decltype.cpp
  10. 14 0
      Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
  11. 12 0
      Tests/CompileFeatures/cxx_default_function_template_args.cpp
  12. 9 0
      Tests/CompileFeatures/cxx_defaulted_functions.cpp
  13. 7 0
      Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp
  14. 15 0
      Tests/CompileFeatures/cxx_delegating_constructors.cpp
  15. 6 0
      Tests/CompileFeatures/cxx_deleted_functions.cpp
  16. 8 0
      Tests/CompileFeatures/cxx_enum_forward_declarations.cpp
  17. 10 0
      Tests/CompileFeatures/cxx_explicit_conversions.cpp
  18. 25 0
      Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
  19. 12 0
      Tests/CompileFeatures/cxx_extern_templates.cpp
  20. 2 0
      Tests/CompileFeatures/cxx_final.cpp
  21. 6 0
      Tests/CompileFeatures/cxx_func_identifier.cpp
  22. 23 0
      Tests/CompileFeatures/cxx_generalized_initializers.cpp
  23. 18 0
      Tests/CompileFeatures/cxx_inheriting_constructors.cpp
  24. 26 0
      Tests/CompileFeatures/cxx_inline_namespaces.cpp
  25. 5 0
      Tests/CompileFeatures/cxx_lambdas.cpp
  26. 21 0
      Tests/CompileFeatures/cxx_local_type_template_args.cpp
  27. 5 0
      Tests/CompileFeatures/cxx_long_long_type.cpp
  28. 5 0
      Tests/CompileFeatures/cxx_noexcept.cpp
  29. 4 0
      Tests/CompileFeatures/cxx_nonstatic_member_init.cpp
  30. 10 0
      Tests/CompileFeatures/cxx_nullptr.cpp
  31. 7 0
      Tests/CompileFeatures/cxx_override.cpp
  32. 10 0
      Tests/CompileFeatures/cxx_range_for.cpp
  33. 7 0
      Tests/CompileFeatures/cxx_raw_string_literals.cpp
  34. 11 0
      Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
  35. 12 0
      Tests/CompileFeatures/cxx_right_angle_brackets.cpp
  36. 5 0
      Tests/CompileFeatures/cxx_rvalue_references.cpp
  37. 10 0
      Tests/CompileFeatures/cxx_sizeof_member.cpp
  38. 2 0
      Tests/CompileFeatures/cxx_static_assert.cpp
  39. 7 0
      Tests/CompileFeatures/cxx_strong_enums.cpp
  40. 2 0
      Tests/CompileFeatures/cxx_thread_local.cpp
  41. 5 0
      Tests/CompileFeatures/cxx_trailing_return_types.cpp
  42. 3 0
      Tests/CompileFeatures/cxx_unicode_literals.cpp
  43. 9 0
      Tests/CompileFeatures/cxx_uniform_initialization.cpp
  44. 11 0
      Tests/CompileFeatures/cxx_unrestricted_unions.cpp
  45. 7 0
      Tests/CompileFeatures/cxx_user_literals.cpp
  46. 12 0
      Tests/CompileFeatures/cxx_variadic_macros.cpp
  47. 65 0
      Tests/CompileFeatures/cxx_variadic_templates.cpp

+ 220 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -12,7 +12,227 @@ command.
 
 The features known to this version of CMake are:
 
+``cxx_alias_templates``
+  Template aliases, as defined in N2258_.
+
+  .. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
+
+``cxx_alignas``
+  Alignment control ``alignas``, as defined in N2341_.
+
+  .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_alignof``
+  Alignment control ``alignof``, as defined in N2341_.
+
+  .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_attributes``
+  Generic attributes, as defined in N2761_.
+
+  .. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
+
 ``cxx_auto_type``
   Automatic type deduction, as defined in N1984_.
 
   .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
+
+``cxx_constexpr``
+  Constant expressions, as defined in N2235_.
+
+  .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf
+
+``cxx_decltype_incomplete_return_types``
+  Decltype on incomplete return types, as defined in N3276_.
+
+  .. _N3276 : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf
+
+``cxx_decltype``
+  Decltype, as defined in N2343_.
+
+  .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
+
+``cxx_default_function_template_args``
+  Default template arguments for function templates, as defined in DR226_
+
+  .. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
+
+``cxx_defaulted_functions``
+  Defaulted functions, as defined in N2346_.
+
+  .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_defaulted_move_initializers``
+  Defaulted move initializers, as defined in N3053_.
+
+  .. _N3053: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html
+
+``cxx_delegating_constructors``
+  Delegating constructors, as defined in N1986_.
+
+  .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
+
+``cxx_deleted_functions``
+  Deleted functions, as defined in  N2346_.
+
+  .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_enum_forward_declarations``
+  Enum forward declarations, as defined in N2764_.
+
+  .. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
+
+``cxx_explicit_conversions``
+  Explicit conversion operators, as defined in N2437_.
+
+  .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
+
+``cxx_extended_friend_declarations``
+  Extended friend declarations, as defined in N1791_.
+
+  .. _N1791: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
+
+``cxx_extern_templates``
+  Extern templates, as defined in N1987_.
+
+  .. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
+
+``cxx_final``
+  Override control ``final`` keyword, as defined in N2928_.
+
+  .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_func_identifier``
+  Predefined ``__func__`` identifier, as defined in N2340_.
+
+  .. _N2340: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm
+
+``cxx_generalized_initializers``
+  Initializer lists, as defined in N2672_.
+
+  .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
+
+``cxx_inheriting_constructors``
+  Inheriting constructors, as defined in N2540_.
+
+  .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm
+
+``cxx_inline_namespaces``
+  Inline namespaces, as defined in N2535_.
+
+  .. _N2535: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm
+
+``cxx_lambdas``
+  Lambda functions, as defined in N2927_.
+
+  .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
+
+``cxx_local_type_template_args``
+  Local and unnamed types as template arguments, as defined in N2657_.
+
+  .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
+
+``cxx_long_long_type``
+  ``long long`` type, as defined in N1811_.
+
+  .. _N1811: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf
+
+``cxx_noexcept``
+  Exception specifications, as defined in N3050_.
+
+  .. _N3050: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
+
+``cxx_nonstatic_member_init``
+  Non-static data member initialization, as defined in N2756.
+
+  .. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm
+
+``cxx_nullptr``
+  Null pointer, as defined in N2431_.
+
+  .. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
+
+``cxx_override``
+  Override control ``override`` keyword, as defined in N2928_.
+
+  .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_range_for``
+  Range-based for, as defined in N2930_.
+
+  .. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
+
+``cxx_raw_string_literals``
+  Raw string literals, as defined in N2442_.
+
+  .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_reference_qualified_functions``
+  Reference qualified functions, as defined in N2439_.
+
+  .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
+
+``cxx_right_angle_brackets``
+  Right angle bracket parsing, as defined in N1757_.
+
+  .. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
+
+``cxx_rvalue_references``
+  R-value references, as defined in N2118_.
+
+  .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
+
+``cxx_sizeof_member``
+  Size of non-static data members, as defined in N2253_.
+
+  .. _N2253: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
+
+``cxx_static_assert``
+  Static assert, as defined in N1720_.
+
+  .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
+
+``cxx_strong_enums``
+  Strongly typed enums, as defined in N2347_.
+
+  .. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
+
+``cxx_thread_local``
+  Thread-local variables, as defined in N2659_.
+
+  .. _N2659: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm
+
+``cxx_trailing_return_types``
+  Automatic function return type, as defined in N2541_.
+
+  .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
+
+``cxx_unicode_literals``
+  Unicode string literals, as defined in N2442_.
+
+  .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_uniform_initialization``
+  Uniform intialization, as defined in N2640_.
+
+  .. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf
+
+``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_.
+
+  .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
+
+``cxx_variadic_macros``
+  Variadic macros, as defined in N1653_.
+
+  .. _N1653: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm
+
+``cxx_variadic_templates``
+  Variadic templates, as defined in N2242_.
+
+  .. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf

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

@@ -2,7 +2,76 @@
 # Reference: http://gcc.gnu.org/projects/cxx0x.html
 
 set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408")
+# Introduced in GCC 4.8.1
+set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
+set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
+set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
+# TODO: Should be supported by GNU 4.7
+set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_final "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_override "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}")
+# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor
+# release following that (March 2012), and the first minor release to
+# support -std=c++11. Prior to that, support for C++11 features is technically
+# experiemental and possibly incomplete (see for example the note below about
+# cxx_variadic_template_template_parameters)
+# TODO: Should be supported by GNU 4.6
+set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_enum_forward_declarations "${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}")
+set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
 # TODO: Should be supported by GNU 4.4
 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}")
+# TODO: If features are ever recorded for GNU 4.3, there should possibly
+# be a new feature added like cxx_variadic_template_template_parameters,
+# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is
+# actually implemented by GNU 4.3, but variadic template template parameters
+# 'completes' it, so that is the version we record as having the variadic
+# templates capability in CMake. See
+# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
+# TODO: Should be supported by GNU 4.3
+set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}")
+# TODO: Should be supported since GNU 3.4?
+set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus >= 201103L")
+# TODO: Should be supported forever?
+set(_cmake_feature_test_cxx_func_identifier "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L")
 set(_oldestSupported)

+ 45 - 1
Source/cmMakefile.cxx

@@ -42,7 +42,51 @@
 #include <assert.h>
 
 #define FOR_EACH_CXX_FEATURE(F) \
-  F(cxx_auto_type)
+  F(cxx_alias_templates) \
+  F(cxx_alignas) \
+  F(cxx_alignof) \
+  F(cxx_attributes) \
+  F(cxx_auto_type) \
+  F(cxx_constexpr) \
+  F(cxx_decltype) \
+  F(cxx_decltype_incomplete_return_types) \
+  F(cxx_default_function_template_args) \
+  F(cxx_defaulted_functions) \
+  F(cxx_defaulted_move_initializers) \
+  F(cxx_delegating_constructors) \
+  F(cxx_deleted_functions) \
+  F(cxx_enum_forward_declarations) \
+  F(cxx_explicit_conversions) \
+  F(cxx_extended_friend_declarations) \
+  F(cxx_extern_templates) \
+  F(cxx_final) \
+  F(cxx_func_identifier) \
+  F(cxx_generalized_initializers) \
+  F(cxx_inheriting_constructors) \
+  F(cxx_inline_namespaces) \
+  F(cxx_lambdas) \
+  F(cxx_local_type_template_args) \
+  F(cxx_long_long_type) \
+  F(cxx_noexcept) \
+  F(cxx_nonstatic_member_init) \
+  F(cxx_nullptr) \
+  F(cxx_override) \
+  F(cxx_range_for) \
+  F(cxx_raw_string_literals) \
+  F(cxx_reference_qualified_functions) \
+  F(cxx_right_angle_brackets) \
+  F(cxx_rvalue_references) \
+  F(cxx_sizeof_member) \
+  F(cxx_static_assert) \
+  F(cxx_strong_enums) \
+  F(cxx_thread_local) \
+  F(cxx_trailing_return_types) \
+  F(cxx_unicode_literals) \
+  F(cxx_uniform_initialization) \
+  F(cxx_unrestricted_unions) \
+  F(cxx_user_literals) \
+  F(cxx_variadic_macros) \
+  F(cxx_variadic_templates)
 
 class cmMakefile::Internals
 {

+ 11 - 0
Tests/CompileFeatures/cxx_alias_templates.cpp

@@ -0,0 +1,11 @@
+
+template <typename T1, typename T2>
+struct A
+{
+  typedef T1 MyT1;
+  using MyT2 = T2;
+};
+
+using B = A<int, char>;
+template<typename T>
+using C = A<int, T>;

+ 4 - 0
Tests/CompileFeatures/cxx_alignas.cpp

@@ -0,0 +1,4 @@
+
+struct S1 {
+  alignas(8) int n;
+};

+ 5 - 0
Tests/CompileFeatures/cxx_alignof.cpp

@@ -0,0 +1,5 @@
+
+int someFunc()
+{
+  return alignof(int);
+}

+ 2 - 0
Tests/CompileFeatures/cxx_attributes.cpp

@@ -0,0 +1,2 @@
+
+void unusedFunc [[noreturn]] () { throw 1; }

+ 5 - 0
Tests/CompileFeatures/cxx_constexpr.cpp

@@ -0,0 +1,5 @@
+
+constexpr int getNum()
+{
+  return 42;
+}

+ 7 - 0
Tests/CompileFeatures/cxx_decltype.cpp

@@ -0,0 +1,7 @@
+
+int someFunc()
+{
+  int i = 0;
+  decltype(i) other = 0;
+  return other;
+}

+ 14 - 0
Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp

@@ -0,0 +1,14 @@
+
+template<class T>
+struct A
+{
+  ~A() = delete;
+};
+
+template<class T> auto h() -> A<T>;
+template<class T> auto i(T) -> T;
+template<class T> auto f(T) -> decltype(i(h<T>()));
+template<class T> auto f(T) -> void;
+auto g() -> void {
+  f(42);
+}

+ 12 - 0
Tests/CompileFeatures/cxx_default_function_template_args.cpp

@@ -0,0 +1,12 @@
+
+template<typename T = int>
+int someFunc()
+{
+  T t = 0;
+  return t;
+}
+
+void otherFunc()
+{
+  someFunc();
+}

+ 9 - 0
Tests/CompileFeatures/cxx_defaulted_functions.cpp

@@ -0,0 +1,9 @@
+
+struct A {
+  A() = default;
+};
+
+void someFunc()
+{
+  A a;
+}

+ 7 - 0
Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp

@@ -0,0 +1,7 @@
+
+struct A
+{
+  A() = default;
+  A& operator=(A&&) = default;
+  A(A&&) = default;
+};

+ 15 - 0
Tests/CompileFeatures/cxx_delegating_constructors.cpp

@@ -0,0 +1,15 @@
+
+class Foo
+{
+public:
+  Foo(int i);
+
+  Foo(double d)
+    : Foo(static_cast<int>(d))
+  {
+
+  }
+
+private:
+  int m_i;
+};

+ 6 - 0
Tests/CompileFeatures/cxx_deleted_functions.cpp

@@ -0,0 +1,6 @@
+
+struct A
+{
+  A(const A&) = delete;
+  A& operator=(const A&) = delete;
+};

+ 8 - 0
Tests/CompileFeatures/cxx_enum_forward_declarations.cpp

@@ -0,0 +1,8 @@
+
+enum SomeEnum : short;
+
+void someFunc()
+{
+  SomeEnum value;
+  int i = value;
+}

+ 10 - 0
Tests/CompileFeatures/cxx_explicit_conversions.cpp

@@ -0,0 +1,10 @@
+
+class A
+{
+  int m_i;
+public:
+  explicit operator bool()
+  {
+    return m_i != 0;
+  }
+};

+ 25 - 0
Tests/CompileFeatures/cxx_extended_friend_declarations.cpp

@@ -0,0 +1,25 @@
+
+template <typename T>
+struct B
+{
+  B() : m_i(42) {}
+private:
+  int m_i;
+  friend T;
+};
+
+struct A
+{
+  template<typename T>
+  int getBValue(B<T> b)
+  {
+    return b.m_i;
+  }
+};
+
+void someFunc()
+{
+  A a;
+  B<A> b;
+  a.getBValue(b);
+}

+ 12 - 0
Tests/CompileFeatures/cxx_extern_templates.cpp

@@ -0,0 +1,12 @@
+
+template<typename T>
+void someFunc()
+{
+}
+
+extern template void someFunc<int>();
+
+void otherFunc()
+{
+  someFunc<int>();
+}

+ 2 - 0
Tests/CompileFeatures/cxx_final.cpp

@@ -0,0 +1,2 @@
+
+struct A final {};

+ 6 - 0
Tests/CompileFeatures/cxx_func_identifier.cpp

@@ -0,0 +1,6 @@
+
+void someFunc()
+{
+  bool b = sizeof(__func__);
+  (void)b;
+}

+ 23 - 0
Tests/CompileFeatures/cxx_generalized_initializers.cpp

@@ -0,0 +1,23 @@
+
+// Dummy implementation. Test only the compiler feature.
+namespace std {
+  typedef decltype(sizeof(int)) size_t;
+  template <class _E>
+  class initializer_list
+  {
+    const _E* __begin_;
+    size_t    __size_;
+
+  };
+}
+
+template <typename T>
+struct A
+{
+  A(std::initializer_list<T>) {}
+};
+
+void someFunc()
+{
+  A<int> as = { 1, 2, 3, 4 };
+}

+ 18 - 0
Tests/CompileFeatures/cxx_inheriting_constructors.cpp

@@ -0,0 +1,18 @@
+
+struct A
+{
+  int m_i;
+
+  A(int i) : m_i(i) {}
+};
+
+struct B : public A
+{
+  using A::A;
+};
+
+void someFunc()
+{
+  int i;
+  B b(i);
+}

+ 26 - 0
Tests/CompileFeatures/cxx_inline_namespaces.cpp

@@ -0,0 +1,26 @@
+namespace Lib
+{
+inline namespace Lib_1
+{
+  template <typename T> class A;
+}
+
+template <typename T> void g(T);
+}
+
+struct MyClass {
+
+};
+namespace Lib
+{
+template<>
+class A<MyClass> {
+
+};
+}
+
+void someFunc()
+{
+  Lib::A<MyClass> a;
+  g(a);  // ok, Lib is an associated namespace of A
+}

+ 5 - 0
Tests/CompileFeatures/cxx_lambdas.cpp

@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+  [](){}();
+}

+ 21 - 0
Tests/CompileFeatures/cxx_local_type_template_args.cpp

@@ -0,0 +1,21 @@
+
+template <typename T>
+class X { };
+template <typename T>
+void f(T t) { }
+struct {} unnamed_obj;
+void f() {
+  struct A { };
+  enum { e1 };
+  typedef struct {} B;
+  B b;
+  X<A> x1;
+  X<A*> x2;
+  X<B> x3;
+  f(e1);
+  f(unnamed_obj);
+  f(b);
+  (void)x1;
+  (void)x2;
+  (void)x3;
+}

+ 5 - 0
Tests/CompileFeatures/cxx_long_long_type.cpp

@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+  long long ll = 9223372036854775807LL;
+}

+ 5 - 0
Tests/CompileFeatures/cxx_noexcept.cpp

@@ -0,0 +1,5 @@
+
+void someFunc() noexcept
+{
+
+}

+ 4 - 0
Tests/CompileFeatures/cxx_nonstatic_member_init.cpp

@@ -0,0 +1,4 @@
+class A
+{
+  int m_i = 42;
+};

+ 10 - 0
Tests/CompileFeatures/cxx_nullptr.cpp

@@ -0,0 +1,10 @@
+
+void someFunc(int*)
+{
+
+}
+
+void otherFunc()
+{
+  someFunc(nullptr);
+}

+ 7 - 0
Tests/CompileFeatures/cxx_override.cpp

@@ -0,0 +1,7 @@
+
+struct A {
+  virtual void doNothing() {}
+};
+struct B : A {
+  void doNothing() override {}
+};

+ 10 - 0
Tests/CompileFeatures/cxx_range_for.cpp

@@ -0,0 +1,10 @@
+
+void someFunc()
+{
+  int accumulated = 0;
+  int numbers[] = { 1, 2, 5 };
+  for (int i : numbers)
+    {
+    accumulated += i;
+    }
+}

+ 7 - 0
Tests/CompileFeatures/cxx_raw_string_literals.cpp

@@ -0,0 +1,7 @@
+
+void someFunc()
+{
+const char p[] = R"(a\
+b
+c)";
+}

+ 11 - 0
Tests/CompileFeatures/cxx_reference_qualified_functions.cpp

@@ -0,0 +1,11 @@
+
+struct test{
+  void f() & { }
+  void f() && { }
+};
+
+void someFunc(){
+  test t;
+  t.f(); // lvalue
+  test().f(); // rvalue
+}

+ 12 - 0
Tests/CompileFeatures/cxx_right_angle_brackets.cpp

@@ -0,0 +1,12 @@
+
+template<typename T>
+struct A
+{
+  typedef T Result;
+};
+
+void someFunc()
+{
+  A<A<int>> object;
+  (void)object;
+}

+ 5 - 0
Tests/CompileFeatures/cxx_rvalue_references.cpp

@@ -0,0 +1,5 @@
+
+void someFunc(int&&)
+{
+
+}

+ 10 - 0
Tests/CompileFeatures/cxx_sizeof_member.cpp

@@ -0,0 +1,10 @@
+
+struct A
+{
+  int m_i;
+};
+
+int someFunc()
+{
+  return sizeof(A::m_i) > 0 ? 1 : 2;
+}

+ 2 - 0
Tests/CompileFeatures/cxx_static_assert.cpp

@@ -0,0 +1,2 @@
+
+static_assert(true, "static_assert test");

+ 7 - 0
Tests/CompileFeatures/cxx_strong_enums.cpp

@@ -0,0 +1,7 @@
+
+enum class Colors
+{
+  RedColor,
+  GreenColor,
+  BlueColor
+};

+ 2 - 0
Tests/CompileFeatures/cxx_thread_local.cpp

@@ -0,0 +1,2 @@
+
+thread_local unsigned int rage = 1;

+ 5 - 0
Tests/CompileFeatures/cxx_trailing_return_types.cpp

@@ -0,0 +1,5 @@
+
+auto someFunc() -> int
+{
+  return 42;
+}

+ 3 - 0
Tests/CompileFeatures/cxx_unicode_literals.cpp

@@ -0,0 +1,3 @@
+
+const char16_t lit_16[] = u"\u00DA";
+const char32_t lit_32[] = U"\u00DA";

+ 9 - 0
Tests/CompileFeatures/cxx_uniform_initialization.cpp

@@ -0,0 +1,9 @@
+struct A {};
+struct B {
+  B(A) {}
+};
+
+void Func()
+{
+  B b{A{}};
+}

+ 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_;
+};

+ 7 - 0
Tests/CompileFeatures/cxx_user_literals.cpp

@@ -0,0 +1,7 @@
+
+long double operator "" _meters(long double);
+
+void someFunc()
+{
+  long double i = 1.2_meters;
+}

+ 12 - 0
Tests/CompileFeatures/cxx_variadic_macros.cpp

@@ -0,0 +1,12 @@
+
+int someFunc(int, char, int)
+{
+  return 0;
+}
+
+#define FUNC_WRAPPER(...) someFunc(__VA_ARGS__)
+
+void otherFunc()
+{
+  FUNC_WRAPPER(42, 'a', 7);
+}

+ 65 - 0
Tests/CompileFeatures/cxx_variadic_templates.cpp

@@ -0,0 +1,65 @@
+template<int I, int... Is>
+struct Interface;
+
+template<int I>
+struct Interface<I>
+{
+  static int accumulate()
+  {
+    return I;
+  }
+};
+
+template<int I, int... Is>
+struct Interface
+{
+  static int accumulate()
+  {
+    return I + Interface<Is...>::accumulate();
+  }
+};
+
+// Note: split this into a separate test if a
+// cxx_variadic_template_template_parameters feature is added.
+
+template<typename T>
+struct eval {
+  enum {
+    Matched = 0
+  };
+};
+
+template<template<typename...> class T, typename... U>
+struct eval<T<U...> > {
+  enum {
+    Matched = 1
+  };
+};
+
+template<typename...>
+struct A {
+
+};
+template<typename T>
+struct B {
+
+};
+template<typename T, typename U>
+struct C {
+
+};
+template<typename T, typename U, typename...>
+struct D {
+
+};
+
+// Note: This test assumes that a compiler supporting this feature
+// supports static_assert. Add a workaround if that does not hold.
+static_assert(eval<A<> >::Matched, "A Matches");
+static_assert(eval<A<int> >::Matched, "A Matches");
+static_assert(eval<A<int, char> >::Matched, "A Matches");
+static_assert(eval<B<int> >::Matched, "B Matches");
+static_assert(eval<C<int, char> >::Matched, "C Matches");
+static_assert(eval<D<int, char> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches");