From caacea2e4f123d0c480a986ec840a199ccb2ed20 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 7 May 2026 15:25:14 +0200 Subject: [PATCH 1/2] Update tokenize.cpp --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1acf1b1f6c4..70a38a30eb9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4970,7 +4970,7 @@ void Tokenizer::setVarIdPass1() decl = false; } else if (cpp && Token::Match(prev2, "%type% {") && Token::simpleMatch(tok2->link(), "} ;")) { // C++11 initialization style if (tok2->link() != tok2->next() && // add value-initialized variable T x{}; - (Token::Match(prev2, "do|try|else") || Token::Match(prev2->tokAt(-2), "struct|class|:"))) + (Token::Match(prev2, "do|try|else") || Token::simpleMatch(prev2->tokAt(-2), ":"))) continue; } else decl = false; From 0142994a26dd4e12df9007e9990c21b488976b68 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 7 May 2026 15:26:18 +0200 Subject: [PATCH 2/2] Update testvarid.cpp --- test/testvarid.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 64b7b6664be..73eaa3f97eb 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -3066,6 +3066,11 @@ class TestVarID : public TestFixture { " int j{i};\n" " }\n" "};")); + + ASSERT_EQUALS("1: struct Sx { int i@1 ; } ;\n" // #14733 + "2: struct Sx sx@2 { 0 } ;\n", + tokenize("struct Sx { int i; };\n" + "struct Sx sx{ 0 }; \n")); } void varid_inheritedMembers() {