Files
CMake/Tests/CompileFeatures/msvc_permissive.cxx
Brad King 914571a042 Place language standard flags just after CMAKE_<LANG>_FLAGS
Previously we added the language standard flag near the end of all
options, even after those added by `add_compile_options` and friends.
However, on some compilers such as MSVC, the `-std` flag may reset
defaults for flags that precede it on the command line.  Move the
language standard flag to before all other flags that CMake adds for
other abstractions, and before those added by `add_compile_options`.

`CMAKE_<LANG>_FLAGS` should still precede the language flags though,
because they are meant to be treated as language-wide modifications to
the compiler defaults, similar to `$CC $CFLAGS`.

Fixes: #23860
Fixes: #24170
2022-11-18 11:44:52 -05:00

10 lines
240 B
C++

#if !defined(_MSVC_LANG) || _MSVC_LANG < 202002L
# error "This source must be compiled with MSVC as C++20 or later."
#endif
// Test a construct that is allowed by MSVC only with 'cl -permissive'.
enum class X
{
Y = 1
};
int array[X::Y];