From 6e74fc64b9cc0dc162bc2bbd0c7457bcde37fe32 Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Thu, 24 Jun 2021 01:22:03 -0500 Subject: [PATCH] Fix 10317: Regression: internalAstError on valid C++ code (#3302) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2103644c1..bdb2c87fb 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1014,7 +1014,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state) compileUnaryOp(tok, state, compileExpression); else compileBinOp(tok, state, compileExpression); - if (Token::simpleMatch(tok, "}")) + while (Token::simpleMatch(tok, "}")) tok = tok->next(); } else break; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 07c0a5298..e15942197 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6014,11 +6014,14 @@ private: ASSERT_EQUALS("Abc({newreturn", testAst("return new A {b(c)};")); ASSERT_EQUALS("a{{return", testAst("return{{a}};")); ASSERT_EQUALS("a{b{,{return", testAst("return{{a},{b}};")); - ASSERT_EQUALS("stdvector::", testAst("std::vector>{{},{}}")); + ASSERT_EQUALS("stdvector::{{,{return", testAst("return std::vector >{{},{}};")); + ASSERT_EQUALS("stdvector::{2{,{return", testAst("return std::vector >{{}, {2}};")); + ASSERT_EQUALS("forbstdvector::{{,{:(", testAst("for (auto b : std::vector >{{},{}});")); + ASSERT_EQUALS("forbstdvector::{2{,{:(", testAst("for (auto b : std::vector >{{}, {2}});")); ASSERT_EQUALS("abR{{,P(,((", testAst("a(b(R{},{},P()));")); ASSERT_EQUALS("f1{2{,3{,{x,(", testAst("f({{1},{2},{3}},x);")); ASSERT_EQUALS("a1{ b2{", testAst("auto a{1}; auto b{2};")); - ASSERT_EQUALS("var1ab::23,{,{4ab::56,{,{,{", testAst("auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};")); + ASSERT_EQUALS("var1ab::23,{,4ab::56,{,{,{{", testAst("auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};")); ASSERT_EQUALS("var{{,{,{{", testAst("auto var{ {{},{}}, {} };")); // Initialization with decltype(expr) instead of a type