-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++][test] Make macro detection more friendly to MSVC #113633
Conversation
MSVC's test suite is a bit nervous about replacing non-macro-defined identifiers with `0` (see also https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4668?view=msvc-170). On MSVC (and MS-compatible mode of other compilers), `long double` has the same format (IEEE-754 binary64) as `double`, so it should be OK to define `TEST_LONG_DOUBLE_IS_DOUBLE` when `_MSC_VER` is defined. Such detection should be performed first.
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesMSVC STL's test suite is a bit nervous about replacing non-macro-defined identifiers with On MSVC (and MS-compatible mode of other compilers), Full diff: https://github.com/llvm/llvm-project/pull/113633.diff 1 Files Affected:
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 5ef14e54dae237..1b6473b623c53b 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -511,7 +511,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_CONSTEXPR_OPERATOR_NEW
#endif
-#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
+#if defined(_MSC_VER) || __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
# define TEST_LONG_DOUBLE_IS_DOUBLE
#endif
|
This looks good to me. Edit: EDG on Windows doesn't understand these macros, so
#include <print>
using namespace std;
int main() {
println("__SIZEOF_LONG_DOUBLE__: {}", __SIZEOF_LONG_DOUBLE__);
println("__SIZEOF_DOUBLE__: {}", __SIZEOF_DOUBLE__);
}
|
MSVC STL's test suite is a bit nervous about replacing non-macro-defined identifiers with `0` (see also https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4668?view=msvc-170). On MSVC (and MS-compatible mode of other compilers), `long double` has the same format (IEEE-754 binary64) as `double`, so it should be OK to define `TEST_LONG_DOUBLE_IS_DOUBLE` when `_MSC_VER` is defined. Such detection should be performed first.
MSVC STL's test suite is a bit nervous about replacing non-macro-defined identifiers with `0` (see also https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4668?view=msvc-170). On MSVC (and MS-compatible mode of other compilers), `long double` has the same format (IEEE-754 binary64) as `double`, so it should be OK to define `TEST_LONG_DOUBLE_IS_DOUBLE` when `_MSC_VER` is defined. Such detection should be performed first.
MSVC STL's test suite is a bit nervous about replacing non-macro-defined identifiers with
0
(see also https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4668?view=msvc-170).On MSVC (and MS-compatible mode of other compilers),
long double
has the same format (IEEE-754 binary64) asdouble
, so it should be OK to defineTEST_LONG_DOUBLE_IS_DOUBLE
when_MSC_VER
is defined. Such detection should be performed first.