Fix regression: wrong varid with using namespace (#3866)
* Fix #10059 missing varId with using namespace * Undo * Fix test * Limit namespace candidates, duplicateBranch * rvalue ref * Undo * Undo * Undo * Format * Fix condition * Fix regression: wrong varid with using namespace
This commit is contained in:
parent
0b310b9d07
commit
43fb3dd047
|
@ -4377,7 +4377,8 @@ void Tokenizer::setVarIdPass2()
|
||||||
Token *tok2 = matchMemberVarName(var, scopeInfo);
|
Token *tok2 = matchMemberVarName(var, scopeInfo);
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
continue;
|
continue;
|
||||||
tok2->varId(thisClassVars[tok2->str()]);
|
if (tok2->varId() == 0)
|
||||||
|
tok2->varId(thisClassVars[tok2->str()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isC() || tok->str() == "namespace")
|
if (isC() || tok->str() == "namespace")
|
||||||
|
|
|
@ -6876,28 +6876,55 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyKnownVariablesNamespace() { // #10059
|
void simplifyKnownVariablesNamespace() { // #10059
|
||||||
const char code[] = "namespace N {\n"
|
{
|
||||||
" const int n = 0;\n"
|
const char code[] = "namespace N {\n"
|
||||||
" namespace M { const int m = 0; }\n"
|
" const int n = 0;\n"
|
||||||
"}\n"
|
" namespace M { const int m = 0; }\n"
|
||||||
"using namespace N;\n"
|
"}\n"
|
||||||
"int i(n);\n"
|
"using namespace N;\n"
|
||||||
"int j(M::m);\n"
|
"int i(n);\n"
|
||||||
"using namespace N::M;\n"
|
"int j(M::m);\n"
|
||||||
"int k(m);\n"
|
"using namespace N::M;\n"
|
||||||
"int l(N::M::m);\n";
|
"int k(m);\n"
|
||||||
const char exp[] = "\n\n##file 0\n"
|
"int l(N::M::m);\n";
|
||||||
"1: namespace N {\n"
|
const char exp[] = "\n\n##file 0\n"
|
||||||
"2: const int n@1 = 0 ;\n"
|
"1: namespace N {\n"
|
||||||
"3: namespace M { const int m@2 = 0 ; }\n"
|
"2: const int n@1 = 0 ;\n"
|
||||||
"4: }\n"
|
"3: namespace M { const int m@2 = 0 ; }\n"
|
||||||
"5: using namespace N ;\n"
|
"4: }\n"
|
||||||
"6: int i ; i = n@1 ;\n"
|
"5: using namespace N ;\n"
|
||||||
"7: int j ( M :: m@2 ) ;\n"
|
"6: int i ; i = n@1 ;\n"
|
||||||
"8: using namespace N :: M ;\n"
|
"7: int j ( M :: m@2 ) ;\n"
|
||||||
"9: int k ; k = m@2 ;\n"
|
"8: using namespace N :: M ;\n"
|
||||||
"10: int l ( N :: M :: m@2 ) ;\n";
|
"9: int k ; k = m@2 ;\n"
|
||||||
ASSERT_EQUALS(exp, tokenizeDebugListing(code));
|
"10: int l ( N :: M :: m@2 ) ;\n";
|
||||||
|
ASSERT_EQUALS(exp, tokenizeDebugListing(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "struct S {\n"
|
||||||
|
" S() { f(); }\n"
|
||||||
|
" void f();\n"
|
||||||
|
" int i;\n"
|
||||||
|
"};\n"
|
||||||
|
"namespace N { int j; }\n"
|
||||||
|
"using namespace N;\n"
|
||||||
|
"void S::f() {\n"
|
||||||
|
" i = 0;\n"
|
||||||
|
"}\n";
|
||||||
|
const char exp[] = "\n\n##file 0\n"
|
||||||
|
"1: struct S {\n"
|
||||||
|
"2: S ( ) { f ( ) ; }\n"
|
||||||
|
"3: void f ( ) ;\n"
|
||||||
|
"4: int i@1 ;\n"
|
||||||
|
"5: } ;\n"
|
||||||
|
"6: namespace N { int j@2 ; }\n"
|
||||||
|
"7: using namespace N ;\n"
|
||||||
|
"8: void S :: f ( ) {\n"
|
||||||
|
"9: i@1 = 0 ;\n"
|
||||||
|
"10: }\n";
|
||||||
|
ASSERT_EQUALS(exp, tokenizeDebugListing(code));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyKnownVariablesClassMember() {
|
void simplifyKnownVariablesClassMember() {
|
||||||
|
|
Loading…
Reference in New Issue