diff --git a/.travis_suppressions b/.travis_suppressions index 9c9fd948c..b616b1480 100644 --- a/.travis_suppressions +++ b/.travis_suppressions @@ -9,7 +9,6 @@ bitwiseOnBoolean unusedPrivateFunction:test/test*.cpp useStlAlgorithm simplifyUsing:lib/valueptr.h -simplifyUsingUnmatchedBodyEnd # debug suppressions valueFlowBailout diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 31a2eb7fe..5cac88e1a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1915,10 +1915,11 @@ namespace { ScopeInfo3 *parent = (*scopeInfo)->parent; while (parent && parent->bodyEnd != tok) parent = parent->parent; - if (parent) + if (parent) { *scopeInfo = parent; - if (debug) - throw std::runtime_error("Internal error: unmatched }"); + if (debug) + throw std::runtime_error("Internal error: unmatched }"); + } } return; } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index b3152aae0..e0c1a917b 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -92,6 +92,7 @@ private: TEST_CASE(simplifyUsing10335); TEST_CASE(scopeInfo1); + TEST_CASE(scopeInfo2); } std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) { @@ -1324,6 +1325,18 @@ private: tok(code, true); ASSERT_EQUALS("", errout.str()); } + + void scopeInfo2() { + const char code[] = "struct A {\n" + " using Map = std::map;\n" + " Map values;\n" + "};\n" + "\n" + "static void getInitialProgramState(const A::Map& vars = A::Map {})\n" + "{}\n"; + tok(code, true); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestSimplifyUsing)