Fix in Tokenizer::simplifyUsing for non-scopes
This commit is contained in:
parent
96196875b4
commit
ca50dea97d
|
@ -9,7 +9,6 @@ bitwiseOnBoolean
|
|||
unusedPrivateFunction:test/test*.cpp
|
||||
useStlAlgorithm
|
||||
simplifyUsing:lib/valueptr.h
|
||||
simplifyUsingUnmatchedBodyEnd
|
||||
|
||||
# debug suppressions
|
||||
valueFlowBailout
|
||||
|
|
|
@ -1915,11 +1915,12 @@ 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 }");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!Token::Match(tok, "namespace|class|struct|union %name% {|:|::|<")) {
|
||||
|
|
|
@ -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<int, int>;\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)
|
||||
|
|
Loading…
Reference in New Issue