AST: non-standard handling of ; in argument list for unknown macro
This commit is contained in:
parent
bdd41151ed
commit
35d04cd2d3
|
@ -440,7 +440,8 @@ struct AST_state {
|
|||
bool cpp;
|
||||
int assign;
|
||||
bool inCase; // true from case to :
|
||||
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false) {}
|
||||
const Token *functionCallEndPar;
|
||||
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false), functionCallEndPar(nullptr) {}
|
||||
};
|
||||
|
||||
static Token * skipDecl(Token *tok)
|
||||
|
@ -1119,6 +1120,8 @@ static void compileComma(Token *&tok, AST_state& state)
|
|||
tok = tok->next();
|
||||
else
|
||||
compileBinOp(tok, state, compileAssignTernary);
|
||||
} else if (tok->str() == ";" && state.functionCallEndPar && tok->index() < state.functionCallEndPar->index()) {
|
||||
compileBinOp(tok, state, compileAssignTernary);
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
|
@ -1356,6 +1359,8 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
|
||||
Token * const tok1 = tok;
|
||||
AST_state state(cpp);
|
||||
if (Token::Match(tok, "%name% ("))
|
||||
state.functionCallEndPar = tok->linkAt(1);
|
||||
compileExpression(tok, state);
|
||||
const Token * const endToken = tok;
|
||||
if (endToken == tok1 || !endToken)
|
||||
|
|
|
@ -316,7 +316,7 @@ private:
|
|||
void wrong_syntax1() {
|
||||
{
|
||||
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
|
||||
ASSERT_EQUALS("TR ( kvmpio , PROTO ( int rw ) , ARGS ( rw ) , TP_ ( aa . rw ; ) )", checkCode(code));
|
||||
ASSERT_THROW(checkCode(code), InternalError);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -7122,6 +7122,7 @@ private:
|
|||
tokenList.combineOperators();
|
||||
tokenList.createLinks();
|
||||
tokenList.createLinks2();
|
||||
tokenList.list.front()->assignIndexes();
|
||||
|
||||
// set varid..
|
||||
for (Token *tok = tokenList.list.front(); tok; tok = tok->next()) {
|
||||
|
@ -7423,7 +7424,7 @@ private:
|
|||
"y=(int)(d({e(f);}));"));
|
||||
ASSERT_EQUALS("A{,( x0= Bx1={{,( x2=", // TODO: This is not perfect!!
|
||||
testAst("A({},{x=0;});" // don't hang
|
||||
"B({x=1;},{x=2;});"));
|
||||
"B({x=1},{x=2});"));
|
||||
ASSERT_EQUALS("xMACROtype.T=value.1=,{({=",
|
||||
testAst("x = { MACRO( { .type=T, .value=1 } ) }")); // don't hang: MACRO({..})
|
||||
ASSERT_EQUALS("fori10=i{;;( i--", testAst("for (i=10;i;({i--;}) ) {}"));
|
||||
|
@ -7520,6 +7521,7 @@ private:
|
|||
ASSERT_EQUALS("for_each_commit_graftint((void,(", testAst("extern int for_each_commit_graft(int (*)(int*), void *);"));
|
||||
ASSERT_EQUALS("for;;(", testAst("for (;;) {}"));
|
||||
ASSERT_EQUALS("xsizeofvoid(=", testAst("x=sizeof(void*)"));
|
||||
ASSERT_EQUALS("abc;(", testAst("a(b;c)"));
|
||||
}
|
||||
|
||||
void asttemplate() { // uninstantiated templates will have <,>,etc..
|
||||
|
|
Loading…
Reference in New Issue