Fix uninitialized vars in EnumDeclaration

'protection' and 'parent' are used in ScopeDSymbol::search
detected by Valgrind). The assignment in semantic0 is enough to
fix the bug, but I also added an initialization to the constructor.

This is a backport of DMD commit 4dfaf02d4d by Don Clugston.
This commit is contained in:
David Nadlinger
2013-05-09 22:33:08 +02:00
parent e5d6cf4dd8
commit 10f5d74737

View File

@@ -38,6 +38,8 @@ EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype)
#if IN_DMD
objFileDone = 0;
#endif
protection = PROTundefined;
parent = NULL;
}
Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s)
@@ -79,6 +81,10 @@ void EnumDeclaration::semantic0(Scope *sc)
if (isdone || !scope)
return;
parent = scope->parent;
protection = scope->protection;
if (!isAnonymous() || memtype)
return;
for (size_t i = 0; i < members->dim; i++)