Fixed #9261 (Inconsistent violation report between using global enum and namespaced enum.)
This commit is contained in:
parent
4943771e41
commit
00fae7fb42
|
@ -443,6 +443,8 @@ void CheckOther::checkRedundantAssignment()
|
||||||
return ChildrenToVisit::none;
|
return ChildrenToVisit::none;
|
||||||
if (Token::Match(rhs, "%str%|%num%|%name%") && !rhs->varId())
|
if (Token::Match(rhs, "%str%|%num%|%name%") && !rhs->varId())
|
||||||
return ChildrenToVisit::none;
|
return ChildrenToVisit::none;
|
||||||
|
if (Token::Match(rhs, ":: %name%") && rhs->hasKnownIntValue())
|
||||||
|
return ChildrenToVisit::none;
|
||||||
if (rhs->isCast())
|
if (rhs->isCast())
|
||||||
return ChildrenToVisit::op2;
|
return ChildrenToVisit::op2;
|
||||||
trivial = false;
|
trivial = false;
|
||||||
|
|
|
@ -6679,11 +6679,19 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// "trivial" initialization => do not warn
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" struct S s = {0};\n"
|
" struct S s = {0};\n"
|
||||||
" s = dostuff();\n"
|
" s = dostuff();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("namespace N { enum E {e0,e1}; }\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" N::E e = N::e0;\n" // #9261
|
||||||
|
" e = dostuff();\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void redundantMemWrite() {
|
void redundantMemWrite() {
|
||||||
|
|
Loading…
Reference in New Issue