diff --git a/lib/platform.h b/lib/platform.h index 4673c4859e6..e3ee218d029 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -169,7 +169,11 @@ class CPPCHECKLIB Platform { bool isWindows() const { return type == Type::Win32A || type == Type::Win32W || - type == Type::Win64; + type == Type::Win64 +#ifdef _WIN32 + || type == Type::Native +#endif + ; } const char *toString() const { diff --git a/test/testplatform.cpp b/test/testplatform.cpp index c0f7bb2c017..ce3457e9dfc 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -37,6 +37,7 @@ class TestPlatform : public TestFixture { TEST_CASE(valid_config_win32w); TEST_CASE(valid_config_unix32); TEST_CASE(valid_config_win64); + TEST_CASE(valid_config_native); TEST_CASE(valid_config_file_1); TEST_CASE(valid_config_file_2); TEST_CASE(valid_config_file_3); @@ -205,6 +206,16 @@ class TestPlatform : public TestFixture { ASSERT_EQUALS(64, platform.long_double_bit); } + void valid_config_native() const { + Platform platform; + PLATFORM(platform, Platform::Type::Native); +#ifdef _WIN32 + ASSERT(platform.isWindows()); +#else + ASSERT(!platform.isWindows()); +#endif + } + void valid_config_file_1() const { // Valid platform configuration with all possible values specified. // Similar to the avr8 platform file. diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index f55b1e83fc7..5d5de26837c 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -42,6 +42,7 @@ class TestSimplifyTokens : public TestFixture { mNewTemplate = true; TEST_CASE(combine_strings); TEST_CASE(combine_wstrings); + TEST_CASE(combine_wstrings_Windows); TEST_CASE(combine_ustrings); TEST_CASE(combine_Ustrings); TEST_CASE(combine_u8strings); @@ -250,6 +251,15 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } + void combine_wstrings_Windows() { +#if defined(_WIN32) && defined(UNICODE) + const char code[] = "const auto* f() {\n" + " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" + "}"; + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, dinit(TokOptions, $.type = Platform::Type::Native))); +#endif + } + void combine_ustrings() { const char code[] = "abcd = u\"ab\" u\"cd\";";