Fix FP initializerList with static member (#5864)
This commit is contained in:
parent
9fceba4fbc
commit
30397f0d53
|
@ -2677,6 +2677,10 @@ void CheckClass::initializerListOrder()
|
|||
if (const Variable* argVar = scope->getVariable(tok->str())) {
|
||||
if (scope != argVar->scope())
|
||||
continue;
|
||||
if (argVar->isStatic())
|
||||
continue;
|
||||
if (tok->variable() && tok->variable()->isArgument())
|
||||
continue;
|
||||
if (var->isPointer() && (argVar->isArray() || Token::simpleMatch(tok->astParent(), "&")))
|
||||
continue;
|
||||
if (var->isReference())
|
||||
|
|
|
@ -7632,6 +7632,20 @@ private:
|
|||
" int j;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkInitializerListOrder("struct S {\n"
|
||||
" S() : a(i) {}\n"
|
||||
" int a;\n"
|
||||
" static int i;\n"
|
||||
"};\n"
|
||||
"int S::i = 0;");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkInitializerListOrder("struct S {\n"
|
||||
" S(int b) : a(b) {}\n"
|
||||
" int a, b{};\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
#define checkInitializationListUsage(code) checkInitializationListUsage_(code, __FILE__, __LINE__)
|
||||
|
|
Loading…
Reference in New Issue