Fix 10139: AST broken; std::enable_if_t<> (#3424)

This commit is contained in:
Paul Fultz II 2021-08-28 02:28:56 -05:00 committed by GitHub
parent 4566e0e439
commit c0765c451d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -2900,12 +2900,11 @@ void Tokenizer::combineOperators()
// combine +-*/ and =
if (c2 == '=' && (std::strchr("+-*/%|^=!<>", c1))) {
// skip templates
if (cpp && tok->str() == ">") {
const Token *opening = tok->findOpeningBracket();
if (opening) {
if (Token::Match(opening->previous(), "%name%"))
continue;
}
if (cpp && (tok->str() == ">" || Token::simpleMatch(tok->previous(), "> *"))) {
const Token* opening =
tok->str() == ">" ? tok->findOpeningBracket() : tok->previous()->findOpeningBracket();
if (opening && Token::Match(opening->previous(), "%name%"))
continue;
}
tok->str(tok->str() + c2);
tok->deleteNext();
@ -4561,7 +4560,7 @@ void Tokenizer::createLinks2()
if (!top2 || top2->str() != "<") {
if (token->str() == ">>")
continue;
if (!Token::Match(token->next(), "%name%|%cop%|::|,|(|)|{|}|;|[|:|.|=|...") &&
if (!Token::Match(token->next(), "%name%|%cop%|%assign%|::|,|(|)|{|}|;|[|:|.|=|...") &&
!Token::Match(token->next(), "&& %name% ="))
continue;
}

View File

@ -6479,6 +6479,9 @@ private:
" int x = a < b ? b : a;"
"};\n"));
// #10139
ASSERT_NO_THROW(tokenizeAndStringify("template<typename F>\n"
"void foo(std::enable_if_t<value<F>>* = 0) {}\n"));
}
void checkTemplates() {