Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2650,6 +2650,10 @@ namespace {
return false;
}

if (Token::simpleMatch(tok1->tokAt(-2), "> ::")) {
return false;
}

if (Token::Match(tok1, "%name% (") && TokenList::isFunctionHead(tok1->next(), "{;:")) {
if (Token::Match(tok1->previous(), "%name%") && !tok1->previous()->isControlFlowKeyword())
return false;
Expand Down
10 changes: 10 additions & 0 deletions test/testnullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class TestNullPointer : public TestFixture {
TEST_CASE(nullpointer101); // #11382
TEST_CASE(nullpointer102);
TEST_CASE(nullpointer103);
TEST_CASE(nullpointer104); // #13881
TEST_CASE(nullpointer_addressOf); // address of
TEST_CASE(nullpointerSwitch); // #2626
TEST_CASE(nullpointer_cast); // #4692
Expand Down Expand Up @@ -2919,6 +2920,15 @@ class TestNullPointer : public TestFixture {
TODO_ASSERT_EQUALS("", "[test.cpp:3:10]: (warning) Possible null pointer dereference: p [nullPointer]\n", errout_str());
}

void nullpointer104() // #13881
{
check("using std::max;\n"
"void f(int i) {\n"
" const size_t maxlen = i == 1 ? 8 : (std::numeric_limits<std::size_t>::max());\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void nullpointer_addressOf() { // address of
check("void f() {\n"
" struct X *x = 0;\n"
Expand Down
9 changes: 9 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing33);
TEST_CASE(simplifyUsing34);
TEST_CASE(simplifyUsing35);
TEST_CASE(simplifyUsing36);

TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
Expand Down Expand Up @@ -873,6 +874,14 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing36() {
const char code[] = "using A::a;\n"
"int c = B<int>::a;\n";
const char expected[] = "int c ; c = B < int > :: a ;";
ASSERT_EQUALS(expected, tok(code));
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"
Expand Down
Loading