* Partial fix for #11378 internalAstError regressions (iscpp11init) * Use %cop% * Add test for #11229 * Format * Format
This commit is contained in:
parent
9c55b933c1
commit
4c8aa56d8b
|
@ -691,7 +691,7 @@ static bool iscpp11init_impl(const Token * const tok)
|
|||
if (!Token::simpleMatch(endtok, "} ;"))
|
||||
return true;
|
||||
const Token *prev = nameToken;
|
||||
while (Token::Match(prev, "%name%|::|:|<|>|,|%num%")) {
|
||||
while (Token::Match(prev, "%name%|::|:|<|>|,|%num%|%cop%")) {
|
||||
if (Token::Match(prev, "class|struct|union|enum"))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ private:
|
|||
TEST_CASE(nullpointer94); // #11040
|
||||
TEST_CASE(nullpointer95); // #11142
|
||||
TEST_CASE(nullpointer96); // #11416
|
||||
TEST_CASE(nullpointer97); // #11229
|
||||
TEST_CASE(nullpointer_addressOf); // address of
|
||||
TEST_CASE(nullpointerSwitch); // #2626
|
||||
TEST_CASE(nullpointer_cast); // #4692
|
||||
|
@ -2783,6 +2784,20 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer97() // #11229
|
||||
{
|
||||
check("struct B { virtual int f() = 0; };\n"
|
||||
"struct D : public B { int f() override; };\n"
|
||||
"int g(B* p) {\n"
|
||||
" if (p) {\n"
|
||||
" auto d = dynamic_cast<B*>(p);\n"
|
||||
" return d ? d->f() : 0;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer_addressOf() { // address of
|
||||
check("void f() {\n"
|
||||
" struct X *x = 0;\n"
|
||||
|
|
|
@ -7535,6 +7535,13 @@ private:
|
|||
"}\n",
|
||||
"{ } }",
|
||||
TokenImpl::Cpp11init::NOINIT);
|
||||
|
||||
testIsCpp11init("template <std::size_t N>\n"
|
||||
"struct C : public C<N - 1>, public B {\n"
|
||||
" ~C() {}\n"
|
||||
"};\n",
|
||||
"{ } }",
|
||||
TokenImpl::Cpp11init::NOINIT);
|
||||
#undef testIsCpp11init
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue