Fix 9245: Synax error on valid C++14 code: AST broken, binary operator '=' doesn't have two operands. (#3400)

This commit is contained in:
Paul Fultz II 2021-08-14 15:50:58 -05:00 committed by GitHub
parent c92dab1329
commit 6d65f86871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 9 deletions

View File

@ -4525,9 +4525,7 @@ void Tokenizer::createLinks2()
if (!top2 || top2->str() != "<") {
if (token->str() == ">>")
continue;
if (token->next() &&
!Token::Match(token->next(), "%name%|%comp%|&|&&|*|::|,|(|)|{|}|;|[|:|.|=") &&
!Token::simpleMatch(token->next(), "...") &&
if (!Token::Match(token->next(), "%name%|%cop%|::|,|(|)|{|}|;|[|:|.|=|...") &&
!Token::Match(token->next(), "&& %name% ="))
continue;
}

View File

@ -1738,12 +1738,13 @@ private:
void cliCode() {
// #8913
ASSERT_THROW(checkCode("public ref class LibCecSharp : public CecCallbackMethods {\n"
ASSERT_NO_THROW(checkCode(
"public ref class LibCecSharp : public CecCallbackMethods {\n"
"array<CecAdapter ^> ^ FindAdapters(String ^ path) {}\n"
"bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs) {\n"
"bool bReturn(false);\n"
"}\n"
"};"), InternalError);
"};"));
}
void enumTrailingComma() {

View File

@ -6586,6 +6586,15 @@ private:
"template <class> struct F;\n"
"int main() { using T = void (*)(a<j<F, char[]>>); }\n"));
// #9245
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"
" typedef int b;\n"
" operator b();\n"
"};\n"
"template <int> using c = a;\n"
"template <int d> c<d> e;\n"
"auto f = ((e<4> | 0));\n"));
// #9340
ASSERT_NO_THROW(tokenizeAndStringify(
"struct a {\n"
@ -6608,6 +6617,13 @@ private:
" ;\n"
"}\n"));
// #10015
ASSERT_NO_THROW(tokenizeAndStringify(
"void func() {\n"
" if (std::is_same_v<int, int> || 1)\n"
" ;\n"
"}\n"));
// #10309
ASSERT_NO_THROW(tokenizeAndStringify(
"using a = void *;\n"