Fix and simplify the feature-test macro test#4103
Merged
StephanTLavavej merged 11 commits intomicrosoft:mainfrom Oct 20, 2023
Merged
Fix and simplify the feature-test macro test#4103StephanTLavavej merged 11 commits intomicrosoft:mainfrom
StephanTLavavej merged 11 commits intomicrosoft:mainfrom
Conversation
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
Contributor
CaseyCarter
left a comment
There was a problem hiding this comment.
This is so much nicer - thanks!
Member
Author
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
This file contains hidden or 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
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.
#errormessages.\nbetween each line of the "from" and "to" (presented here on separate lines for clarity).__cpp_lib_chronoand__cpp_lib_shared_ptr_arrays.__cpp_lib_shift.__cpp_lib_containers_rangestest.__cpp_lib_containers_rangesbeing defined outside of the relevant mode.__cpp_lib_chronoand__cpp_lib_shared_ptr_arraysagain.__cpp_lib_shared_timed_mutex./clr:puremode allows this to follow the consistent pattern.__cpp_lib_is_layout_compatibleand__cpp_lib_is_pointer_interconvertibletests.