diff --git a/libcxx/include/numbers b/libcxx/include/numbers --- a/libcxx/include/numbers +++ b/libcxx/include/numbers @@ -73,42 +73,42 @@ namespace numbers { -template +template inline constexpr bool __false = false; -template +template struct __illformed { - static_assert(__false, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); + static_assert(__false<_Tp>, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); }; -template inline constexpr T e_v = __illformed{}; -template inline constexpr T log2e_v = __illformed{}; -template inline constexpr T log10e_v = __illformed{}; -template inline constexpr T pi_v = __illformed{}; -template inline constexpr T inv_pi_v = __illformed{}; -template inline constexpr T inv_sqrtpi_v = __illformed{}; -template inline constexpr T ln2_v = __illformed{}; -template inline constexpr T ln10_v = __illformed{}; -template inline constexpr T sqrt2_v = __illformed{}; -template inline constexpr T sqrt3_v = __illformed{}; -template inline constexpr T inv_sqrt3_v = __illformed{}; -template inline constexpr T egamma_v = __illformed{}; -template inline constexpr T phi_v = __illformed{}; - -template inline constexpr T e_v = 2.718281828459045235360287471352662; -template inline constexpr T log2e_v = 1.442695040888963407359924681001892; -template inline constexpr T log10e_v = 0.434294481903251827651128918916605; -template inline constexpr T pi_v = 3.141592653589793238462643383279502; -template inline constexpr T inv_pi_v = 0.318309886183790671537767526745028; -template inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772; -template inline constexpr T ln2_v = 0.693147180559945309417232121458176; -template inline constexpr T ln10_v = 2.302585092994045684017991454684364; -template inline constexpr T sqrt2_v = 1.414213562373095048801688724209698; -template inline constexpr T sqrt3_v = 1.732050807568877293527446341505872; -template inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957; -template inline constexpr T egamma_v = 0.577215664901532860606512090082402; -template inline constexpr T phi_v = 1.618033988749894848204586834365638; +template inline constexpr _Tp e_v = __illformed<_Tp>{}; +template inline constexpr _Tp log2e_v = __illformed<_Tp>{}; +template inline constexpr _Tp log10e_v = __illformed<_Tp>{}; +template inline constexpr _Tp pi_v = __illformed<_Tp>{}; +template inline constexpr _Tp inv_pi_v = __illformed<_Tp>{}; +template inline constexpr _Tp inv_sqrtpi_v = __illformed<_Tp>{}; +template inline constexpr _Tp ln2_v = __illformed<_Tp>{}; +template inline constexpr _Tp ln10_v = __illformed<_Tp>{}; +template inline constexpr _Tp sqrt2_v = __illformed<_Tp>{}; +template inline constexpr _Tp sqrt3_v = __illformed<_Tp>{}; +template inline constexpr _Tp inv_sqrt3_v = __illformed<_Tp>{}; +template inline constexpr _Tp egamma_v = __illformed<_Tp>{}; +template inline constexpr _Tp phi_v = __illformed<_Tp>{}; + +template inline constexpr _Tp e_v<_Tp> = 2.718281828459045235360287471352662; +template inline constexpr _Tp log2e_v<_Tp> = 1.442695040888963407359924681001892; +template inline constexpr _Tp log10e_v<_Tp> = 0.434294481903251827651128918916605; +template inline constexpr _Tp pi_v<_Tp> = 3.141592653589793238462643383279502; +template inline constexpr _Tp inv_pi_v<_Tp> = 0.318309886183790671537767526745028; +template inline constexpr _Tp inv_sqrtpi_v<_Tp> = 0.564189583547756286948079451560772; +template inline constexpr _Tp ln2_v<_Tp> = 0.693147180559945309417232121458176; +template inline constexpr _Tp ln10_v<_Tp> = 2.302585092994045684017991454684364; +template inline constexpr _Tp sqrt2_v<_Tp> = 1.414213562373095048801688724209698; +template inline constexpr _Tp sqrt3_v<_Tp> = 1.732050807568877293527446341505872; +template inline constexpr _Tp inv_sqrt3_v<_Tp> = 0.577350269189625764509148780501957; +template inline constexpr _Tp egamma_v<_Tp> = 0.577215664901532860606512090082402; +template inline constexpr _Tp phi_v<_Tp> = 1.618033988749894848204586834365638; inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -1167,8 +1167,8 @@ }; #if _LIBCPP_STD_VER >= 17 -template - optional(T) -> optional; +template + optional(_Tp) -> optional<_Tp>; #endif // Comparisons between optionals diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -2318,7 +2318,7 @@ // Clang provides variadic templates in C++03 as an extension. #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ -template +template struct __common_types; template struct _LIBCPP_TEMPLATE_VIS common_type; diff --git a/libcxx/test/libcxx/alphabetic_macros.compile.pass.cpp b/libcxx/test/libcxx/alphabetic_macros.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/alphabetic_macros.compile.pass.cpp @@ -0,0 +1,410 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Test that headers are not tripped up by the surrounding code defining various +// alphabetic macros. + +// Prevent from generating deprecated warnings for this test. +#if defined(__DEPRECATED) +# undef __DEPRECATED +#endif + +// Support static_assert in C++03 mode. +#include "test_macros.h" + +#define A 42 +#define Arg 42 +#define Args 42 +#define As 42 +#define B 42 +#define Bs 42 +#define C 42 +#define Cs 42 +#define R 42 +#define Rp 42 +#define T 42 +#define Tp 42 +#define Ts 42 +#define Type 42 +#define Types 42 +#define U 42 +#define Up 42 +#define Us 42 +#define V 42 +#define Vs 42 +#define X 42 +#define Xs 42 + +#define TM(X) static_assert(X == 42, ""); +#define TEST_MACROS() \ + TM(A) TM(Arg) TM(Args) TM(As) TM(B) TM(Bs) TM(C) TM(Cs) + TM(R) TM(Rp) TM(T) TM(Tp) TM(Ts) TM(Type) TM(Types) + TM(U) TM(Up) TM(Us) TM(V) TM(Vs) TM(X) TM(Xs) + +//////////////////////////////////////////////////////////////////////////////// +// BEGIN-GENERATED-HEADERS +//////////////////////////////////////////////////////////////////////////////// + +// clang-format off + +// WARNING: This test was generated by generate_header_tests.py +// and should not be edited manually. + +// Top level headers +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +TEST_MACROS(); +#endif +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_THREADS +# include +TEST_MACROS(); +#endif +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#include +TEST_MACROS(); +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +TEST_MACROS(); +#endif +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# include +TEST_MACROS(); +#endif + +// experimental headers +#if __cplusplus >= 201103L +# include +TEST_MACROS(); +# ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES +# include +TEST_MACROS(); +# endif +# include +TEST_MACROS(); +# ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY +# include +TEST_MACROS(); +# endif +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# ifndef _LIBCPP_HAS_NO_LOCALIZATION +# include +TEST_MACROS(); +# endif +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +# include +TEST_MACROS(); +#endif // __cplusplus >= 201103L + +// extended headers +#include +TEST_MACROS(); +#include +TEST_MACROS(); + +// clang-format on + +//////////////////////////////////////////////////////////////////////////////// +// END-GENERATED-HEADERS +//////////////////////////////////////////////////////////////////////////////// diff --git a/libcxx/utils/generate_header_tests.py b/libcxx/utils/generate_header_tests.py --- a/libcxx/utils/generate_header_tests.py +++ b/libcxx/utils/generate_header_tests.py @@ -207,6 +207,8 @@ post_include='TEST_MACROS();') produce_test('no_assert_include.compile.pass.cpp', exclusions=['cassert']) + produce_test('alphabetic_macros.compile.pass.cpp', + post_include='TEST_MACROS();') if __name__ == '__main__':