-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix and simplify the feature-test macro test #4103
Merged
StephanTLavavej
merged 11 commits into
microsoft:main
from
StephanTLavavej:feature-test-macro-test
Oct 20, 2023
Merged
Fix and simplify the feature-test macro test #4103
StephanTLavavej
merged 11 commits into
microsoft:main
from
StephanTLavavej:feature-test-macro-test
Oct 20, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This test originally covered both the compiler and library feature-test macros, and was therefore extremely paranoid about checking the behavior of the preprocessor. We gave the compiler test coverage to the compiler team a long time ago, so we can simplify the library test coverage now. This commit is a 100% regex search-and-replace, from: #ifndef (__cpp_lib_\w+) #error \1 is not defined #elif \1 != (\d{6}L) #error \1 is not \2 #else STATIC_ASSERT\(\1 == \2\); #endif to: #ifdef $1 STATIC_ASSERT($1 == $2); #else #error $1 is not defined #endif except with \n between each line of the "from" and "to" (presented here on separate lines for clarity).
These are always defined, but to varying values, so they use a slightly different pattern.
This was trying to be extra helpful with a message saying "is OLD_VALUE when it should be NEW_VALUE", but that made the code verbose and unsystematic. This test is passing, so we don't need elaborate error messages in case of failure.
This would never have detected `__cpp_lib_containers_ranges` being defined outside of the relevant mode.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
From: #ifdef (__cpp_lib_\w+) (STATIC_ASSERT\(\1 == \d{6}L\);) #else #error \1 is not defined #endif to: $2
…` again. This removes all occurrences of "is not defined".
From: #else #ifdef (__cpp_lib_\w+) #error \1 is defined #endif #endif to: #elif defined($1) #error $1 is defined #endif
Testing for non-`/clr:pure` mode allows this to follow the consistent pattern.
…r_interconvertible` tests. These tests weren't doing anything for C++14/17 mode. Now they'll detect the macros being present when they shouldn't be.
CaseyCarter
approved these changes
Oct 19, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much nicer - thanks!
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#error
messages.\n
between each line of the "from" and "to" (presented here on separate lines for clarity).__cpp_lib_chrono
and__cpp_lib_shared_ptr_arrays
.__cpp_lib_shift
.__cpp_lib_containers_ranges
test.__cpp_lib_containers_ranges
being defined outside of the relevant mode.__cpp_lib_chrono
and__cpp_lib_shared_ptr_arrays
again.__cpp_lib_shared_timed_mutex
./clr:pure
mode allows this to follow the consistent pattern.__cpp_lib_is_layout_compatible
and__cpp_lib_is_pointer_interconvertible
tests.