From 68e980c18eeb5fdbc293a8af7dbe9881c1591ff7 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Tue, 2 Jun 2026 19:19:51 +0200 Subject: [PATCH 1/2] Fix #14809 FP syntaxError for typedef involving std::size_t --- lib/token.cpp | 1 - test/testtoken.cpp | 7 ------- test/testtokenize.cpp | 3 +++ test/testvarid.cpp | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index b11e12bf0a7..c659d76c664 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -204,7 +204,6 @@ static const std::unordered_set stdTypes = { "bool" , "int" , "long" , "short" - , "size_t" , "void" , "wchar_t" , "signed" diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 83a514eb963..cd5afe716f8 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -1059,7 +1059,6 @@ class TestToken : public TestFixture { standard_types.emplace_back("long"); standard_types.emplace_back("float"); standard_types.emplace_back("double"); - standard_types.emplace_back("size_t"); for (auto test_op = standard_types.cbegin(); test_op != standard_types.cend(); ++test_op) { auto tokensFrontBack = std::make_shared(); @@ -1488,8 +1487,6 @@ class TestToken : public TestFixture { TokenList list_c{settingsDefault, Standards::Language::C}; auto tokensFrontBack = std::make_shared(); Token tok(list_c, std::move(tokensFrontBack)); - tok.str("size_t"); // not treated as keyword in TokenList::isKeyword() - assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true); } } @@ -1506,8 +1503,6 @@ class TestToken : public TestFixture { TokenList list_cpp{settingsDefault, Standards::Language::CPP}; auto tokensFrontBack = std::make_shared(); Token tok(list_cpp, std::move(tokensFrontBack)); - tok.str("size_t"); - assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true); } } @@ -1515,8 +1510,6 @@ class TestToken : public TestFixture { { auto tokensFrontBack = std::make_shared(); Token tok(list, std::move(tokensFrontBack)); - tok.str("size_t"); - assert_tok(&tok, Token::Type::eType, false, true); tok.str("long"); assert_tok(&tok, Token::Type::eType, false, true); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7b2bee0d80e..b8b105793bf 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7845,6 +7845,9 @@ class TestTokenizer : public TestFixture { "}\n")); ignore_errout(); + + ASSERT_EQUALS("unsigned long s ;", tokenizeAndStringify("typedef std::size_t size_t;\n" // #14809 + "size_t s;\n")); } diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 64b7b6664be..72b9ca0d09c 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -2840,7 +2840,7 @@ class TestVarID : public TestFixture { void varid_using() { // #3648 const char code[] = "using std::size_t;"; - const char expected[] = "1: using unsigned long ;\n"; + const char expected[] = "1: ;\n"; ASSERT_EQUALS(expected, tokenize(code)); } From 58f5ea800cf20a847171f65e3d04f37bfaa7bdc4 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Tue, 2 Jun 2026 19:31:15 +0200 Subject: [PATCH 2/2] Fix --- test/testtokenize.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b8b105793bf..edffe2aee39 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7846,8 +7846,7 @@ class TestTokenizer : public TestFixture { ignore_errout(); - ASSERT_EQUALS("unsigned long s ;", tokenizeAndStringify("typedef std::size_t size_t;\n" // #14809 - "size_t s;\n")); + ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809 }