Fix const array dereference
This commit is contained in:
parent
55ddce2211
commit
c3c0583f19
|
@ -452,9 +452,11 @@ Expression* Expression::LogicInvertExpression(void)
|
|||
}
|
||||
}
|
||||
|
||||
Expression* Expression::ConstantDereference(void)
|
||||
Expression* Expression::ConstantDereference(Errors* errors, LinkerSection* dataSection)
|
||||
{
|
||||
if (mType == EX_VARIABLE)
|
||||
{
|
||||
if (mDecType->IsSimpleType())
|
||||
{
|
||||
if (mDecValue->mType == DT_VARIABLE && (mDecValue->mFlags & DTF_CONST) && mDecValue->mValue)
|
||||
return mDecValue->mValue;
|
||||
|
@ -486,6 +488,21 @@ Expression* Expression::ConstantDereference(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mType == EX_BINARY)
|
||||
{
|
||||
Expression* lexp = mLeft->ConstantDereference(errors, dataSection);
|
||||
Expression* rexp = mRight->ConstantDereference(errors, dataSection);
|
||||
if (lexp != mLeft || rexp != mRight)
|
||||
{
|
||||
Expression* nexp = new Expression(mLocation, EX_BINARY);
|
||||
nexp->mToken = mToken;
|
||||
nexp->mDecType = mDecType;
|
||||
nexp->mLeft = lexp;
|
||||
nexp->mRight = rexp;
|
||||
return nexp->ConstantFold(errors, dataSection)->ConstantDereference(errors, dataSection);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ public:
|
|||
|
||||
Expression* LogicInvertExpression(void);
|
||||
Expression* ConstantFold(Errors * errors, LinkerSection* dataSection, Linker * linker = nullptr);
|
||||
Expression* ConstantDereference(void);
|
||||
Expression* ConstantDereference(Errors* errors, LinkerSection* dataSection);
|
||||
bool HasSideEffects(void) const;
|
||||
|
||||
bool IsSame(const Expression* exp) const;
|
||||
|
|
|
@ -1405,7 +1405,7 @@ Declaration* Parser::ReverseDeclaration(Declaration* odec, Declaration* bdec)
|
|||
|
||||
Declaration * Parser::CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp)
|
||||
{
|
||||
exp = exp->ConstantDereference();
|
||||
exp = exp->ConstantDereference(mErrors, mDataSection);
|
||||
|
||||
Declaration* dec = exp->mDecValue;
|
||||
|
||||
|
|
|
@ -6154,15 +6154,15 @@
|
|||
{
|
||||
"Name" = "8:Microsoft Visual Studio"
|
||||
"ProductName" = "8:oscar64"
|
||||
"ProductCode" = "8:{D12BF264-6CF6-4631-A5F7-D73B85702BEA}"
|
||||
"PackageCode" = "8:{1A998B16-D7AB-43C3-8240-BA87403D6169}"
|
||||
"ProductCode" = "8:{7E6F8BA9-C000-403E-A935-50863009AD03}"
|
||||
"PackageCode" = "8:{EAE2B6EE-7460-4439-9EA5-71D17A7290BA}"
|
||||
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
|
||||
"AspNetVersion" = "8:2.0.50727.0"
|
||||
"RestartWWWService" = "11:FALSE"
|
||||
"RemovePreviousVersions" = "11:TRUE"
|
||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||
"InstallAllUsers" = "11:FALSE"
|
||||
"ProductVersion" = "8:1.27.241"
|
||||
"ProductVersion" = "8:1.27.242"
|
||||
"Manufacturer" = "8:oscar64"
|
||||
"ARPHELPTELEPHONE" = "8:"
|
||||
"ARPHELPLINK" = "8:"
|
||||
|
|
Loading…
Reference in New Issue