Fix extern c typedef syntax error (#2438)

* Fix extern c typedef syntax error

* Fix extraWhiteSpaceError

* Move test from testgarbage to testtokenize
This commit is contained in:
RobkeBaer 2019-12-12 13:51:14 +01:00 committed by amai2012
parent 965784dd19
commit 370196a14c
2 changed files with 4 additions and 1 deletions

View File

@ -9346,7 +9346,8 @@ void Tokenizer::findGarbageCode() const
while (prev && prev->isName())
prev = prev->previous();
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if") &&
!Token::simpleMatch(tok->tokAt(-2), "extern \"C\"") )
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
}
}

View File

@ -7959,6 +7959,8 @@ private:
ASSERT_NO_THROW(tokenizeAndStringify("S s = { .x=2, .y[0]=3 };"));
ASSERT_NO_THROW(tokenizeAndStringify("S s = { .ab.a=2, .ab.b=3 };"));
ASSERT_NO_THROW(tokenizeAndStringify("extern \"C\" typedef void FUNC();"));
}