* Fix #10059 missing varId with using namespace * Undo * Fix test * Limit namespace candidates, duplicateBranch * rvalue ref * Undo * Undo * Undo * Format * Fix condition
This commit is contained in:
parent
d79d6e60db
commit
ddb0a8bb0b
|
@ -4243,7 +4243,8 @@ void Tokenizer::setVarIdPass2()
|
|||
tok = tok->next();
|
||||
else if (Token::Match(tok->previous(), "!!:: %name% <") && Token::Match(tok->next()->findClosingBracket(),"> :: ~| %name%"))
|
||||
tok = tok->next()->findClosingBracket()->next();
|
||||
else
|
||||
else if (usingnamespaces.empty() || tok->varId() || !tok->isName() || tok->isStandardType() || tok->tokType() == Token::eKeyword || tok->tokType() == Token::eBoolean ||
|
||||
Token::Match(tok->previous(), ".|namespace|class|struct|&|&&|*|> %name%") || Token::Match(tok->previous(), "%type%| %name% ( %type%|)") || Token::Match(tok, "public:|private:|protected:"))
|
||||
continue;
|
||||
|
||||
while (Token::Match(tok, ":: ~| %name%")) {
|
||||
|
|
|
@ -3589,7 +3589,7 @@ private:
|
|||
" stringstream out;\n"
|
||||
" out << ((ip >> 0) & 0xFF);\n"
|
||||
" return out.str();\n"
|
||||
"}n", true);
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
// avoid regression from first fix attempt for #5811...
|
||||
check("void deserialize(const std::string &data) {\n"
|
||||
|
|
|
@ -344,6 +344,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariablesGlobalVars);
|
||||
TEST_CASE(simplifyKnownVariablesReturn); // 3500 - return
|
||||
TEST_CASE(simplifyKnownVariablesPointerAliasFunctionCall); // #7440
|
||||
TEST_CASE(simplifyKnownVariablesNamespace); // #10059
|
||||
|
||||
TEST_CASE(simplifyCasts1);
|
||||
TEST_CASE(simplifyCasts2);
|
||||
|
@ -6874,6 +6875,31 @@ private:
|
|||
ASSERT_EQUALS(exp, tokenizeAndStringify(code, /*simplify=*/ true));
|
||||
}
|
||||
|
||||
void simplifyKnownVariablesNamespace() { // #10059
|
||||
const char code[] = "namespace N {\n"
|
||||
" const int n = 0;\n"
|
||||
" namespace M { const int m = 0; }\n"
|
||||
"}\n"
|
||||
"using namespace N;\n"
|
||||
"int i(n);\n"
|
||||
"int j(M::m);\n"
|
||||
"using namespace N::M;\n"
|
||||
"int k(m);\n"
|
||||
"int l(N::M::m);\n";
|
||||
const char exp[] = "\n\n##file 0\n"
|
||||
"1: namespace N {\n"
|
||||
"2: const int n@1 = 0 ;\n"
|
||||
"3: namespace M { const int m@2 = 0 ; }\n"
|
||||
"4: }\n"
|
||||
"5: using namespace N ;\n"
|
||||
"6: int i ; i = n@1 ;\n"
|
||||
"7: int j ( M :: m@2 ) ;\n"
|
||||
"8: using namespace N :: M ;\n"
|
||||
"9: int k ; k = m@2 ;\n"
|
||||
"10: int l ( N :: M :: m@2 ) ;\n";
|
||||
ASSERT_EQUALS(exp, tokenizeDebugListing(code));
|
||||
}
|
||||
|
||||
void simplifyKnownVariablesClassMember() {
|
||||
// Ticket #2815
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue