Ticket #8361: Fix false positive in Tokenizer::findGarbageCode. (#1061)

This commit is contained in:
Simon Martin 2018-01-26 22:06:07 +01:00 committed by amai2012
parent 3ebedcd7f5
commit 71ba513bdb
2 changed files with 7 additions and 1 deletions

View File

@ -8413,7 +8413,7 @@ const Token * Tokenizer::findGarbageCode() const
tok = tok->next()->findClosingBracket();
if (!tok)
return tok1;
if (!Token::Match(tok, ">|>> %name%"))
if (!Token::Match(tok, ">|>> ::| %name%"))
return tok->next() ? tok->next() : tok1;
}
}

View File

@ -73,6 +73,7 @@ private:
TEST_CASE(tokenize32); // #5884 (fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp:852:46)
TEST_CASE(tokenize33); // #5780 Various crashes on valid template code
TEST_CASE(tokenize34); // #8031
TEST_CASE(tokenize35); // #8361
TEST_CASE(validate);
@ -841,6 +842,11 @@ private:
}
}
void tokenize35() { // #8361
tokenizeAndStringify("typedef int CRCWord; "
"template<typename T> ::CRCWord const Compute(T const t) { return 0; }");
}
void validate() {
// C++ code in C file
ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);