Fixed daca@home crash by stopping for unknown macro 'MACRO(a();b();)'
This commit is contained in:
parent
3b2e1cb367
commit
1173186876
|
@ -9308,6 +9308,21 @@ void Tokenizer::reportUnknownMacros()
|
|||
}
|
||||
}
|
||||
|
||||
// Report unknown macros that contain several statements "MACRO(a;b;c)"
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (!Token::Match(tok, "%name% ("))
|
||||
continue;
|
||||
if (!tok->isUpperCaseName())
|
||||
continue;
|
||||
const Token *endTok = tok->linkAt(1);
|
||||
for (const Token *inner = tok->tokAt(2); inner != endTok; inner = inner->next()) {
|
||||
if (Token::Match(inner, "[[({]"))
|
||||
inner = inner->link();
|
||||
else if (inner->str() == ";")
|
||||
unknownMacroError(inner);
|
||||
}
|
||||
}
|
||||
|
||||
// Report unknown macros in non-executable scopes..
|
||||
std::set<std::string> possible;
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -1153,12 +1153,6 @@ private:
|
|||
"}", "test.cpp", &settings2);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #7979 - code is not well configured
|
||||
check("void foo() {\n"
|
||||
" DEBUG(x(); mystrcmp(a,b););\n"
|
||||
"}", "test.cpp", &settings2);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo() {\n" // don't crash
|
||||
" DEBUG(123)(mystrcmp(a,b))(fd);\n"
|
||||
"}", "test.c", &settings2);
|
||||
|
|
|
@ -3550,9 +3550,7 @@ private:
|
|||
ASSERT_EQUALS("void f ( int i ) { goto label ; { label : ; exit ( 0 ) ; } }", tokWithStdLib("void f (int i) { goto label; switch(i) { label: exit(0); } }"));
|
||||
//ticket #3148
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( exit ( 0 ) ) }", tokWithStdLib("void f() { MACRO(exit(0)) }"));
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( exit ( 0 ) ; , NULL ) }", tokWithStdLib("void f() { MACRO(exit(0);, NULL) }"));
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( bar1 , exit ( 0 ) ) }", tokWithStdLib("void f() { MACRO(bar1, exit(0)) }"));
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( exit ( 0 ) ; bar2 , foo ) }", tokWithStdLib("void f() { MACRO(exit(0); bar2, foo) }"));
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -2735,7 +2735,7 @@ private:
|
|||
" BENCH1(q = _mhz_M(n); n = 1;)\n"
|
||||
" use_pointer(q);\n"
|
||||
"}";
|
||||
tokenizeAndStringify(code, true); // don't hang
|
||||
ASSERT_THROW(tokenizeAndStringify(code, true), InternalError);
|
||||
}
|
||||
|
||||
void simplifyKnownVariables52() { // #4728 "= x %op%"
|
||||
|
@ -5338,7 +5338,7 @@ private:
|
|||
ASSERT_EQUALS("void f ( ) { ab : ; { & b = 0 ; } }", tokenizeAndStringify("void f() { ab: { &b=0;} }"));
|
||||
ASSERT_EQUALS("void f ( ) { ab : ; { & ( * b . x ) = 0 ; } }", tokenizeAndStringify("void f() { ab: {&(*b.x)=0;} }"));
|
||||
//with unhandled MACRO() code
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( ab : b = 0 ; , foo ) }", tokenizeAndStringify("void f() { MACRO(ab: b=0;, foo)}"));
|
||||
ASSERT_THROW(tokenizeAndStringify("void f() { MACRO(ab: b=0;, foo)}"), InternalError);
|
||||
ASSERT_EQUALS("void f ( ) { MACRO ( bar , ab : { & ( * b . x ) = 0 ; } ) }", tokenizeAndStringify("void f() { MACRO(bar, ab: {&(*b.x)=0;})}"));
|
||||
}
|
||||
|
||||
|
@ -7994,6 +7994,11 @@ private:
|
|||
" virtual MACRO(int) f2() {}\n"
|
||||
"};";
|
||||
ASSERT_THROW(tokenizeAndStringify(code4), InternalError);
|
||||
|
||||
const char code5[] = "void foo() {\n"
|
||||
" EVALUATE(123, int x=a; int y=b+c;);\n"
|
||||
"}";
|
||||
ASSERT_THROW(tokenizeAndStringify(code5), InternalError);
|
||||
}
|
||||
|
||||
void findGarbageCode() { // Test Tokenizer::findGarbageCode()
|
||||
|
@ -8344,8 +8349,8 @@ private:
|
|||
}
|
||||
|
||||
void checkConfiguration() {
|
||||
checkConfig("void f() { DEBUG(x();y()); }");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (information) Ensure that 'DEBUG' is defined either using -I, --include or -D.\n", errout.str());
|
||||
ASSERT_THROW(checkConfig("void f() { DEBUG(x();y()); }"), InternalError);
|
||||
//ASSERT_EQUALS("[test.cpp:1]: (information) Ensure that 'DEBUG' is defined either using -I, --include or -D.\n", errout.str());
|
||||
}
|
||||
|
||||
void unknownType() { // #8952
|
||||
|
|
Loading…
Reference in New Issue