parent
29001b651b
commit
10654386db
|
@ -764,7 +764,14 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
||||||
if (initList) {
|
if (initList) {
|
||||||
if (level == 0 && Token::Match(ftok, "%name% {|(") && Token::Match(ftok->linkAt(1), "}|) ,|{")) {
|
if (level == 0 && Token::Match(ftok, "%name% {|(") && Token::Match(ftok->linkAt(1), "}|) ,|{")) {
|
||||||
if (ftok->str() != func.name()) {
|
if (ftok->str() != func.name()) {
|
||||||
|
if (ftok->varId())
|
||||||
initVar(usage, ftok->varId());
|
initVar(usage, ftok->varId());
|
||||||
|
else { // base class constructor
|
||||||
|
for (Usage& u : usage) {
|
||||||
|
if (u.var->scope() != scope) // assume that all variables are initialized in base class
|
||||||
|
u.init = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else { // c++11 delegate constructor
|
} else { // c++11 delegate constructor
|
||||||
const Function *member = ftok->function();
|
const Function *member = ftok->function();
|
||||||
// member function not found => assume it initializes all members
|
// member function not found => assume it initializes all members
|
||||||
|
|
|
@ -1467,6 +1467,22 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("template <class T>\n" // #12128
|
||||||
|
"struct B {\n"
|
||||||
|
" T x;\n"
|
||||||
|
"};\n"
|
||||||
|
"struct D : B<double> {\n"
|
||||||
|
" D(double x) : B{ x } {}\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("struct B {\n"
|
||||||
|
" int x;\n"
|
||||||
|
"};\n"
|
||||||
|
"struct D : B {\n"
|
||||||
|
" D(int i) : B{ i } {}\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void initvar_derived_pod_struct_with_union() {
|
void initvar_derived_pod_struct_with_union() {
|
||||||
|
|
Loading…
Reference in New Issue