Fixed #9286 (FP: syntax error: { .abc.a = 1)

This commit is contained in:
Daniel Marjamäki 2019-08-20 13:56:38 +02:00
parent 26dfee58f8
commit ef47d3d304
2 changed files with 4 additions and 3 deletions

View File

@ -9358,11 +9358,11 @@ 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%"))
if (!Token::Match(tok->previous(), "%name%|)|]|>|}"))
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
if (!Token::Match(tok->next(), "template|operator|*|~|%name%"))
if (!Token::Match(tok->next(), "%name%|*|~"))
syntaxError(tok, tok->strAt(-1) + " " + tok->str() + " " + tok->strAt(1));
}
}

View File

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