Skip to content

Commit 188b0c0

Browse files
Merge branch 'main' into chr_14395
2 parents df9c4de + d329ee9 commit 188b0c0

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

cfg/std.cfg

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
<!-- stdint.h -->
44
<define name="INT8_MIN" value="-128"/>
55
<define name="INT16_MIN" value="-32768"/>
6-
<define name="INT32_MIN" value="-2147483648"/>
7-
<define name="INT64_MIN" value="-9223372036854775808"/>
6+
<define name="INT32_MIN" value="(-2147483647-1)"/>
7+
<define name="INT64_MIN" value="(-9223372036854775807-1)"/>
88
<define name="INT_FAST8_MIN" value="-128"/>
9-
<define name="INT_FAST16_MIN" value="-9223372036854775808"/>
10-
<define name="INT_FAST32_MIN" value="-9223372036854775808"/>
11-
<define name="INT_FAST64_MIN" value="-9223372036854775808"/>
9+
<define name="INT_FAST16_MIN" value="(-9223372036854775807-1)"/>
10+
<define name="INT_FAST32_MIN" value="(-9223372036854775807-1)"/>
11+
<define name="INT_FAST64_MIN" value="(-9223372036854775807-1)"/>
1212
<define name="INT_LEAST8_MIN" value="-128"/>
1313
<define name="INT_LEAST16_MIN" value="-32768"/>
14-
<define name="INT_LEAST32_MIN" value="-2147483648"/>
15-
<define name="INT_LEAST64_MIN" value="-9223372036854775808"/>
14+
<define name="INT_LEAST32_MIN" value="(-2147483647-1)"/>
15+
<define name="INT_LEAST64_MIN" value="(-9223372036854775807-1)"/>
1616
<define name="INT8_MAX" value="127"/>
1717
<define name="INT16_MAX" value="32767"/>
1818
<define name="INT32_MAX" value="2147483647"/>

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static bool isClassStructUnionEnumStart(const Token * tok)
110110
const Token * tok2 = tok->previous();
111111
while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;|>|>>"))
112112
tok2 = tok2->previous();
113-
return Token::Match(tok2, "class|struct|union|enum");
113+
return Token::Match(tok2, "class|struct|union|enum") && !Token::simpleMatch(tok2->tokAt(-1), "->");
114114
}
115115

116116
//---------------------------------------------------------------------------

test/cfg/std.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
#include <math.h>
3939
#include <stddef.h>
4040

41+
void test_int32_min() {
42+
// cppcheck-suppress shiftNegativeLHS
43+
// cppcheck-suppress shiftTooManyBits ; tests that INT32_MIN is a 32-bit expression (not 64-bit expression)
44+
(void)(INT32_MIN >> 40);
45+
}
46+
47+
void test_int64_min() {
48+
// cppcheck-suppress compareValueOutOfTypeRangeError ; tests that INT64_MIN is a signed expression
49+
if (INT64_MIN < 0) {}
50+
}
51+
4152
size_t invalidFunctionArgStr_wcslen(void)
4253
{
4354
const wchar_t terminated0[] = L"ABCDEF49620910";

test/testtokenize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7683,6 +7683,12 @@ class TestTokenizer : public TestFixture {
76837683

76847684
ASSERT_NO_THROW(tokenizeAndStringify("struct S { unsigned u:2, :30; };")); // #14393
76857685

7686+
ASSERT_NO_THROW(tokenizeAndStringify("struct S {};\n" // #14400
7687+
"auto f(bool b) -> struct S {\n"
7688+
" if (b) {}\n"
7689+
" return {};\n"
7690+
"};\n"));
7691+
76867692
ASSERT_NO_THROW(tokenizeAndStringify("void f() {\n" // #14395
76877693
" for (int i : [](int a, int b) { ++a; ++b; return std::vector<int>{a, b}; }(1, 2)) {}\n"
76887694
"}\n"));

0 commit comments

Comments
 (0)