Skip to content

Commit d7bcdb5

Browse files
Fix #14809 FP syntaxError for typedef involving std::size_t (#8618)
`size_t` is a platform type and will be simplified anyway, this is tested here: https://github.com/cppcheck-opensource/cppcheck/blob/e1053dba3b0988dc828d7a9c4b2a8f6c9866035b/test/testtokenize.cpp#L9012 --------- Co-authored-by: chrchr-github <noreply@github.com>
1 parent 49f7cd2 commit d7bcdb5

4 files changed

Lines changed: 3 additions & 19 deletions

File tree

lib/token.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ static const std::unordered_set<std::string> stdTypes = { "bool"
204204
, "int"
205205
, "long"
206206
, "short"
207-
, "size_t"
208207
, "void"
209208
, "wchar_t"
210209
, "signed"

test/testtoken.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ class TestToken : public TestFixture {
10591059
standard_types.emplace_back("long");
10601060
standard_types.emplace_back("float");
10611061
standard_types.emplace_back("double");
1062-
standard_types.emplace_back("size_t");
10631062

10641063
for (auto test_op = standard_types.cbegin(); test_op != standard_types.cend(); ++test_op) {
10651064
auto tokensFrontBack = std::make_shared<TokensFrontBack>();
@@ -1484,13 +1483,6 @@ class TestToken : public TestFixture {
14841483
tok.str("char"); // not treated as keyword in TokenList::isKeyword()
14851484
assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true);
14861485
}
1487-
{
1488-
TokenList list_c{settingsDefault, Standards::Language::C};
1489-
auto tokensFrontBack = std::make_shared<TokensFrontBack>();
1490-
Token tok(list_c, std::move(tokensFrontBack));
1491-
tok.str("size_t"); // not treated as keyword in TokenList::isKeyword()
1492-
assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true);
1493-
}
14941486
}
14951487

14961488
void update_property_info_etype_cpp() const
@@ -1502,21 +1494,12 @@ class TestToken : public TestFixture {
15021494
tok.str("bool"); // not treated as keyword in TokenList::isKeyword()
15031495
assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true);
15041496
}
1505-
{
1506-
TokenList list_cpp{settingsDefault, Standards::Language::CPP};
1507-
auto tokensFrontBack = std::make_shared<TokensFrontBack>();
1508-
Token tok(list_cpp, std::move(tokensFrontBack));
1509-
tok.str("size_t");
1510-
assert_tok(&tok, Token::Type::eType, /*l=*/ false, /*std=*/ true);
1511-
}
15121497
}
15131498

15141499
void update_property_info_replace() const // #13743
15151500
{
15161501
auto tokensFrontBack = std::make_shared<TokensFrontBack>();
15171502
Token tok(list, std::move(tokensFrontBack));
1518-
tok.str("size_t");
1519-
assert_tok(&tok, Token::Type::eType, false, true);
15201503
tok.str("long");
15211504
assert_tok(&tok, Token::Type::eType, false, true);
15221505
}

test/testtokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7893,6 +7893,8 @@ class TestTokenizer : public TestFixture {
78937893
"}\n"));
78947894

78957895
ignore_errout();
7896+
7897+
ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809
78967898
}
78977899

78987900

test/testvarid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ class TestVarID : public TestFixture {
28412841
void varid_using() {
28422842
// #3648
28432843
const char code[] = "using std::size_t;";
2844-
const char expected[] = "1: using unsigned long ;\n";
2844+
const char expected[] = "1: ;\n";
28452845
ASSERT_EQUALS(expected, tokenize(code));
28462846
}
28472847

0 commit comments

Comments
 (0)