From c89cb9d70ed3f303b80c78ae8e9a59bf4978ac63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 2 Dec 2026 12:55:31 +0100 Subject: [PATCH 1/2] test --- test/testtokenize.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7a8d2512b4f..f7a2df42664 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -547,6 +547,8 @@ class TestTokenizer : public TestFixture { TEST_CASE(simplifyEnum1); TEST_CASE(simplifyEnum2); + + TEST_CASE(nonStandardCharLiteral); } class TokenizerTest final : public Tokenizer @@ -9547,6 +9549,12 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(tok->column(), 24); ASSERT_EQUALS(tok->next()->column(), 16); } + + void nonStandardCharLiteral() { + const Settings s = settingsBuilder(settings2).severity(Severity::portability).build(); + (void)tokenizeAndStringify("int a = '\\s';\n", s, false); + ASSERT_EQUALS("[test.c:1:9]: (portability) Non-standard character literal '\\s'. invalid escape sequence [nonStandardCharLiteral]\n", errout_str()); + } }; REGISTER_TEST(TestTokenizer) From 700b926ebf349d8e4bd3a8f330ec6d01699b4e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 2 Dec 2026 12:56:07 +0100 Subject: [PATCH 2/2] fix --- lib/vf_common.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index a96c0ea9ad4..a057c36ea85 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -19,6 +19,7 @@ #include "vf_common.h" #include "astutils.h" +#include "errortypes.h" #include "library.h" #include "mathlib.h" #include "path.h" @@ -137,6 +138,8 @@ namespace ValueFlow setTokenValue(tok, std::move(value), settings); } catch (const std::exception & /*e*/) { // Bad character literal + } catch (const InternalError & /*e*/) { + // Bad character literal } } else if (tok->isNumber() && MathLib::isFloat(tok->str())) { // A long double literal out of the range of double (1e400L) has no