diff options
author | Brad King <brad.king@kitware.com> | 2018-08-06 17:40:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-08-06 17:50:49 (GMT) |
commit | ae9312119f768840cddfee22d0996266c7a06848 (patch) | |
tree | 4a26080ae2a25fc6f03f762aa5b86c2f3917f353 | |
parent | 6eb403d62df1a16d9d4b18775b747414f94a626d (diff) | |
download | CastXML-ae9312119f768840cddfee22d0996266c7a06848.zip CastXML-ae9312119f768840cddfee22d0996266c7a06848.tar.gz CastXML-ae9312119f768840cddfee22d0996266c7a06848.tar.bz2 |
Detect: Add __STDCPP_DEFAULT_NEW_ALIGNMENT__ predefined VS macro
This macro is missing from the main MSVC predefined macro list but is
documented by [1] and [2]. Also add `__STDCPP_STRICT_POINTER_SAFETY__`
as documented by [2] in case MSVC ever starts defining it.
[1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-alignednew
[2] https://en.cppreference.com/w/cpp/preprocessor/replace
Fixes: #125
-rw-r--r-- | share/castxml/detect_vs.cpp | 6 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/cc-msvc.c | 10 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt | 11 |
4 files changed, 27 insertions, 1 deletions
diff --git a/share/castxml/detect_vs.cpp b/share/castxml/detect_vs.cpp index 6ab88a0..2c81137 100644 --- a/share/castxml/detect_vs.cpp +++ b/share/castxml/detect_vs.cpp @@ -176,6 +176,12 @@ #ifdef __MSVC_RUNTIME_CHECKS # pragma message(TO_DEFINE(__MSVC_RUNTIME_CHECKS)) #endif +#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ +# pragma message(TO_DEFINE(__STDCPP_DEFAULT_NEW_ALIGNMENT__)) +#endif +#ifdef __STDCPP_STRICT_POINTER_SAFETY__ +# pragma message(TO_DEFINE(__STDCPP_STRICT_POINTER_SAFETY__)) +#endif #ifdef __STDCPP_THREADS__ # pragma message(TO_DEFINE(__STDCPP_THREADS__)) #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1ad5ff1..cc72d78 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -394,6 +394,7 @@ castxml_test_cmd(cc-msvc-std-c++98 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> castxml_test_cmd(cc-msvc-std-c++11 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1600 ")" ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-std-c++14 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 ")" ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-std-c++17 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 -msvc_lang=201703L ")" ${empty_cxx} "-###") +castxml_test_cmd(cc-msvc-std-c++17-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 -msvc_lang=201703L -stdcpp_default_new_alignment=16ll ")" ${empty_cxx} -E -dM) castxml_test_cmd(cc-msvc-std-explicit --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1500 ")" -std=gnu++14 ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-builtin-1800-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1800 ")" ${empty_cxx} -E -dM) castxml_test_cmd(cc-msvc-builtin-1900-E --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> -msc=1900 ")" ${empty_cxx} -E -dM) diff --git a/test/cc-msvc.c b/test/cc-msvc.c index 45feff8..b20121e 100644 --- a/test/cc-msvc.c +++ b/test/cc-msvc.c @@ -6,14 +6,17 @@ int main(int argc, const char* argv[]) int cpp = 0; const char* msc_ver = "1600"; const char* msvc_lang = 0; + const char* stdcpp_default_new_alignment = 0; int i; for (i = 1; i < argc; ++i) { if (strncmp(argv[i], "--cc-define=", 12) == 0) { fprintf(stdout, "\n#define %s 1", argv[i]+12); } else if (strncmp(argv[i], "-msc=", 5) == 0) { msc_ver = argv[i]+5; - } else if (strncmp(argv[i], "-msvc_lang=", 8) == 0) { + } else if (strncmp(argv[i], "-msvc_lang=", 11) == 0) { msvc_lang = argv[i]+11; + } else if (strncmp(argv[i], "-stdcpp_default_new_alignment=", 30) == 0) { + stdcpp_default_new_alignment = argv[i]+30; } else if (strstr(argv[i], ".cpp")) { cpp = 1; } @@ -34,6 +37,11 @@ int main(int argc, const char* argv[]) "#define _MSVC_LANG %s\n", msvc_lang ); } + if(stdcpp_default_new_alignment) { + fprintf(stdout, + "#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ %s\n", + stdcpp_default_new_alignment); + } fprintf(stdout, "#define __has_include(x) x\n" "#define __has_include_next(x) x\n" diff --git a/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt b/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt new file mode 100644 index 0000000..4015351 --- /dev/null +++ b/test/expect/cmd.cc-msvc-std-c++17-E.stdout.txt @@ -0,0 +1,11 @@ +^#define _MSC_VER 1900 +#define _MSVC_LANG 201703L +#define _WIN32 1 +#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16ll +#define __castxml__ [0-9]+ +#define __castxml_clang_major__ [0-9]+ +#define __castxml_clang_minor__ [0-9]+ +#define __castxml_clang_patchlevel__ [0-9]+ +#define __cplusplus 199711L +#define __is_assignable\(_To,_Fr\) \(sizeof\(__castxml__is_assignable_check<_To,_Fr>\(0\)\) == sizeof\(char\(&\)\[1\]\)\)( +#define __make_integer_seq __castxml__make_integer_seq)?$ |