Skip to content

Commit 370196a

Browse files
RobkeBaeramai2012
authored andcommitted
Fix extern c typedef syntax error (#2438)
* Fix extern c typedef syntax error * Fix extraWhiteSpaceError * Move test from testgarbage to testtokenize
1 parent 965784d commit 370196a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9346,7 +9346,8 @@ void Tokenizer::findGarbageCode() const
93469346
while (prev && prev->isName())
93479347
prev = prev->previous();
93489348
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
9349-
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
9349+
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if") &&
9350+
!Token::simpleMatch(tok->tokAt(-2), "extern \"C\"") )
93509351
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
93519352
}
93529353
}

test/testtokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7959,6 +7959,8 @@ class TestTokenizer : public TestFixture {
79597959

79607960
ASSERT_NO_THROW(tokenizeAndStringify("S s = { .x=2, .y[0]=3 };"));
79617961
ASSERT_NO_THROW(tokenizeAndStringify("S s = { .ab.a=2, .ab.b=3 };"));
7962+
7963+
ASSERT_NO_THROW(tokenizeAndStringify("extern \"C\" typedef void FUNC();"));
79627964
}
79637965

79647966

0 commit comments

Comments
 (0)