Fixed #8390 (Syntax error from an MSVC internal header)

This commit is contained in:
Daniel Marjamäki 2018-03-22 09:07:58 +01:00
parent e38ec41ded
commit 3d4b773fd1
2 changed files with 19 additions and 7 deletions

View File

@ -3272,13 +3272,14 @@ void Tokenizer::createLinks2()
type.pop();
Token * const top2 = type.empty() ? nullptr : type.top();
type.push(top1);
if (token->str() == ">>" && (!top2 || top2->str() != "<"))
continue;
if (token->next() &&
!Token::Match(token->next(), "%name%|>|&|&&|*|::|,|(|)|{|}|;|[|:") &&
!Token::Match(token->next(), "&& %name% ="))
continue;
if (!top2 || top2->str() != "<") {
if (token->str() == ">>")
continue;
if (token->next() &&
!Token::Match(token->next(), "%name%|>|&|&&|*|::|,|(|)|{|}|;|[|:") &&
!Token::Match(token->next(), "&& %name% ="))
continue;
}
// if > is followed by [ .. "new a<b>[" is expected
if (token->strAt(1) == "[") {
Token *prev = type.top()->previous();
@ -8392,7 +8393,16 @@ void Tokenizer::findGarbageCode() const
}
// Operators without operands..
const Token *templateEndToken = nullptr;
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (!templateEndToken) {
if (tok->str() == "<" && isCPP())
templateEndToken = tok->findClosingBracket();
} else if (templateEndToken == tok) {
templateEndToken = nullptr;
} else if (Token::Match(tok, "> %cop%")) {
continue;
}
if (Token::Match(tok, "%cop%|=|,|[ %or%|%oror%|/|%"))
syntaxError(tok);
if (Token::Match(tok, ";|(|[ %comp%"))

View File

@ -1455,6 +1455,8 @@ private:
void garbageCode187() { // # 8152 - segfault in handling
const std::string inp("0|\0|0>;\n", 8);
ASSERT_THROW(checkCode(inp), InternalError);
checkCode("template<class T> struct S : A< B<T> || C<T> > {};"); // No syntax error: #8390
}
void garbageCode188() { // #8255