Fixed #8907 (unknown macro not detected)
This commit is contained in:
parent
115be7dfc8
commit
19514331fb
|
@ -8463,6 +8463,12 @@ void Tokenizer::findGarbageCode() const
|
|||
}
|
||||
}
|
||||
|
||||
// UNKNOWN_MACRO(return)
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "throw|return )") && Token::Match(tok->linkAt(1)->previous(), "%name% ("))
|
||||
unknownMacroError(tok->linkAt(1)->previous());
|
||||
}
|
||||
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... }
|
||||
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,"))
|
||||
|
|
|
@ -232,6 +232,7 @@ private:
|
|||
TEST_CASE(garbageCode199); // #8752
|
||||
TEST_CASE(garbageCode200); // #8757
|
||||
TEST_CASE(garbageCode201); // #8873
|
||||
TEST_CASE(garbageCode202); // #8907
|
||||
|
||||
TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
|
||||
|
||||
|
@ -1557,6 +1558,12 @@ private:
|
|||
ASSERT_THROW(checkCode("void f() { std::string s=\"abc\"; return s + }"), InternalError);
|
||||
}
|
||||
|
||||
// #8907
|
||||
void garbageCode202() {
|
||||
ASSERT_THROW(checkCode("void f() { UNKNOWN_MACRO(return); }"), InternalError);
|
||||
ASSERT_THROW(checkCode("void f() { UNKNOWN_MACRO(throw); }"), InternalError);
|
||||
}
|
||||
|
||||
void syntaxErrorFirstToken() {
|
||||
ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818
|
||||
ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858
|
||||
|
|
|
@ -2683,12 +2683,6 @@ private:
|
|||
"}", nullptr, false, false, false);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Label 'label' is not used.\n", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" wxCHECK2(state < 3 && state >= 0, return);\n"
|
||||
" _checkboxState = state;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct A {\n"
|
||||
" virtual void foo (P & Val) throw ();\n"
|
||||
" virtual void foo1 (P & Val) throw ();\n"
|
||||
|
|
Loading…
Reference in New Issue