Fixed varId problem #5293 (and its duplicate #5577): Classes inside functions are non-executable scopes.
This commit is contained in:
parent
06618b31bb
commit
5f67bc1b0a
|
@ -2417,7 +2417,7 @@ void Tokenizer::setVarId()
|
|||
if (tok->strAt(-1) == ")" || Token::Match(tok->tokAt(-2), ") %type%")) {
|
||||
executableScope.push(true);
|
||||
} else {
|
||||
executableScope.push(executableScope.top());
|
||||
executableScope.push(tok->strAt(-1) == "else");
|
||||
scopeInfo.push(variableId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,6 +303,7 @@ private:
|
|||
TEST_CASE(varid_rvalueref);
|
||||
TEST_CASE(varid_arrayFuncPar); // #5294
|
||||
TEST_CASE(varid_sizeofPassed); // #5295
|
||||
TEST_CASE(varid_classInFunction); // #5293
|
||||
|
||||
TEST_CASE(varidclass1);
|
||||
TEST_CASE(varidclass2);
|
||||
|
@ -4719,6 +4720,22 @@ private:
|
|||
"}"));
|
||||
}
|
||||
|
||||
void varid_classInFunction() {
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: void AddSuppression ( ) {\n"
|
||||
"2: class QErrorLogger {\n"
|
||||
"3: void reportErr ( ErrorLogger :: ErrorMessage & msg@1 ) {\n"
|
||||
"4: }\n"
|
||||
"5: } ;\n"
|
||||
"6: }\n",
|
||||
tokenizeDebugListing("void AddSuppression() {\n"
|
||||
" class QErrorLogger {\n"
|
||||
" void reportErr(ErrorLogger::ErrorMessage &msg) {\n"
|
||||
" }\n"
|
||||
" }; \n"
|
||||
"}"));
|
||||
}
|
||||
|
||||
void varidclass1() {
|
||||
const std::string actual = tokenizeDebugListing(
|
||||
"class Fred\n"
|
||||
|
|
Loading…
Reference in New Issue