Fix syntaxError for struct initialization

This commit is contained in:
Daniel Marjamäki 2019-07-17 15:21:03 +02:00
parent a309095ec3
commit 64ef879ebf
2 changed files with 6 additions and 3 deletions

View File

@ -9272,11 +9272,12 @@ void Tokenizer::findGarbageCode() const
if (Token::simpleMatch(tok, ".") &&
!Token::simpleMatch(tok->previous(), ".") &&
!Token::simpleMatch(tok->next(), ".") &&
!Token::Match(tok->previous(), "{|, . %name% =")) {
!Token::Match(tok->previous(), "{|, . %name% =") &&
!Token::Match(tok->previous(), ", . %name%")) {
if (!Token::Match(tok->previous(), ")|]|>|}|%name%"))
syntaxError(tok);
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
if (!Token::Match(tok->next(), "template|operator|*|~|%name%"))
syntaxError(tok);
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
}
}

View File

@ -7694,6 +7694,8 @@ private:
// after (expr)
ASSERT_NO_THROW(tokenizeAndStringify("void f() { switch (a) int b; }"));
ASSERT_NO_THROW(tokenizeAndStringify("S s = { .x=2, .y[0]=3 };"));
}