diff --git a/oscar64/GlobalOptimizer.cpp b/oscar64/GlobalOptimizer.cpp index e23e8a8..3df1ce0 100644 --- a/oscar64/GlobalOptimizer.cpp +++ b/oscar64/GlobalOptimizer.cpp @@ -275,14 +275,22 @@ bool GlobalOptimizer::ReplaceGlobalConst(Expression* exp) { if (exp->mType == EX_VARIABLE && (exp->mDecValue->mFlags & (DTF_GLOBAL | DTF_STATIC)) && !(exp->mDecValue->mOptFlags & (OPTF_VAR_MODIFIED | OPTF_VAR_ADDRESS)) && exp->mDecValue->mValue) { + Expression* cexp = exp->mDecValue->mValue; - if (cexp->mType == EX_CONSTANT && - (cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER || - cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT)) + if (cexp->mType == EX_CONSTANT) { - exp->mType = EX_CONSTANT; - exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType); - changed = true; + + if (cexp->mDecValue->mType == DT_CONST_ADDRESS || cexp->mDecValue->mType == DT_CONST_INTEGER || + cexp->mDecValue->mType == DT_CONST_POINTER || cexp->mDecValue->mType == DT_CONST_FLOAT) + { + exp->mType = EX_CONSTANT; + exp->mDecValue = cexp->mDecValue->ConstCast(exp->mDecType); + changed = true; + } + else if (exp->mDecValue->mBase->mType == DT_TYPE_STRUCT) + { + exp->mDecValue->mBase = exp->mDecValue->mBase->ToConstType(); + } } }