Fix struct volatile cast
This commit is contained in:
parent
4ea3633b5a
commit
a6b3533e61
|
@ -979,7 +979,7 @@ Declaration::Declaration(const Location& loc, DecType type)
|
||||||
: mLocation(loc), mEndLocation(loc), mType(type), mScope(nullptr), mData(nullptr), mIdent(nullptr), mQualIdent(nullptr), mMangleIdent(nullptr),
|
: mLocation(loc), mEndLocation(loc), mType(type), mScope(nullptr), mData(nullptr), mIdent(nullptr), mQualIdent(nullptr), mMangleIdent(nullptr),
|
||||||
mSize(0), mOffset(0), mFlags(0), mComplexity(0), mLocalSize(0), mNumVars(0),
|
mSize(0), mOffset(0), mFlags(0), mComplexity(0), mLocalSize(0), mNumVars(0),
|
||||||
mBase(nullptr), mParams(nullptr), mParamPack(nullptr), mValue(nullptr), mReturn(nullptr), mNext(nullptr), mPrev(nullptr),
|
mBase(nullptr), mParams(nullptr), mParamPack(nullptr), mValue(nullptr), mReturn(nullptr), mNext(nullptr), mPrev(nullptr),
|
||||||
mConst(nullptr), mMutable(nullptr),
|
mConst(nullptr), mMutable(nullptr), mVolatile(nullptr),
|
||||||
mDefaultConstructor(nullptr), mDestructor(nullptr), mCopyConstructor(nullptr), mCopyAssignment(nullptr), mMoveConstructor(nullptr), mMoveAssignment(nullptr),
|
mDefaultConstructor(nullptr), mDestructor(nullptr), mCopyConstructor(nullptr), mCopyAssignment(nullptr), mMoveConstructor(nullptr), mMoveAssignment(nullptr),
|
||||||
mVectorConstructor(nullptr), mVectorDestructor(nullptr), mVectorCopyConstructor(nullptr), mVectorCopyAssignment(nullptr),
|
mVectorConstructor(nullptr), mVectorDestructor(nullptr), mVectorCopyConstructor(nullptr), mVectorCopyAssignment(nullptr),
|
||||||
mVTable(nullptr), mTemplate(nullptr), mForwardParam(nullptr), mForwardCall(nullptr),
|
mVTable(nullptr), mTemplate(nullptr), mForwardParam(nullptr), mForwardCall(nullptr),
|
||||||
|
@ -1859,6 +1859,59 @@ Declaration* Declaration::ToStriped(int stripe)
|
||||||
return ndec;
|
return ndec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Declaration* Declaration::ToVolatileType(void)
|
||||||
|
{
|
||||||
|
if (mFlags & DTF_VOLATILE)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (!mVolatile)
|
||||||
|
{
|
||||||
|
Declaration* ndec = new Declaration(mLocation, mType);
|
||||||
|
ndec->mSize = mSize;
|
||||||
|
ndec->mStride = mStride;
|
||||||
|
ndec->mBase = mBase;
|
||||||
|
ndec->mFlags = mFlags | DTF_VOLATILE;
|
||||||
|
ndec->mScope = mScope;
|
||||||
|
ndec->mParams = mParams;
|
||||||
|
ndec->mIdent = mIdent;
|
||||||
|
ndec->mQualIdent = mQualIdent;
|
||||||
|
ndec->mTemplate = mTemplate;
|
||||||
|
|
||||||
|
if (mType == DT_TYPE_STRUCT)
|
||||||
|
{
|
||||||
|
ndec->mScope = new DeclarationScope(nullptr, mScope->mLevel);
|
||||||
|
Declaration* p = mParams;
|
||||||
|
Declaration* prev = nullptr;
|
||||||
|
while (p)
|
||||||
|
{
|
||||||
|
Declaration* pnec = p->Clone();
|
||||||
|
pnec->mBase = pnec->mBase->ToVolatileType();
|
||||||
|
|
||||||
|
ndec->mScope->Insert(pnec->mIdent, pnec);
|
||||||
|
|
||||||
|
if (prev)
|
||||||
|
prev->mNext = pnec;
|
||||||
|
else
|
||||||
|
ndec->mParams = pnec;
|
||||||
|
prev = pnec;
|
||||||
|
p = p->mNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ndec->mDestructor = mDestructor;
|
||||||
|
ndec->mDefaultConstructor = mDefaultConstructor;
|
||||||
|
ndec->mCopyConstructor = mCopyConstructor;
|
||||||
|
ndec->mMoveConstructor = mMoveConstructor;
|
||||||
|
ndec->mVectorConstructor = mVectorConstructor;
|
||||||
|
ndec->mVectorCopyConstructor = mVectorCopyConstructor;
|
||||||
|
ndec->mVTable = mVTable;
|
||||||
|
|
||||||
|
mVolatile = ndec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mVolatile;
|
||||||
|
}
|
||||||
|
|
||||||
Declaration* Declaration::ToConstType(void)
|
Declaration* Declaration::ToConstType(void)
|
||||||
{
|
{
|
||||||
if (mFlags & DTF_CONST)
|
if (mFlags & DTF_CONST)
|
||||||
|
|
|
@ -267,7 +267,7 @@ public:
|
||||||
Location mLocation, mEndLocation;
|
Location mLocation, mEndLocation;
|
||||||
DecType mType;
|
DecType mType;
|
||||||
Token mToken;
|
Token mToken;
|
||||||
Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable;
|
Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable, * mVolatile;
|
||||||
Declaration * mDefaultConstructor, * mDestructor, * mCopyConstructor, * mCopyAssignment, * mMoveConstructor, * mMoveAssignment;
|
Declaration * mDefaultConstructor, * mDestructor, * mCopyConstructor, * mCopyAssignment, * mMoveConstructor, * mMoveAssignment;
|
||||||
Declaration * mVectorConstructor, * mVectorDestructor, * mVectorCopyConstructor, * mVectorCopyAssignment;
|
Declaration * mVectorConstructor, * mVectorDestructor, * mVectorCopyConstructor, * mVectorCopyAssignment;
|
||||||
Declaration * mVTable, * mClass, * mTemplate;
|
Declaration * mVTable, * mClass, * mTemplate;
|
||||||
|
@ -315,6 +315,7 @@ public:
|
||||||
|
|
||||||
Declaration* ToConstType(void);
|
Declaration* ToConstType(void);
|
||||||
Declaration* ToMutableType(void);
|
Declaration* ToMutableType(void);
|
||||||
|
Declaration* ToVolatileType(void);
|
||||||
|
|
||||||
Declaration* ToStriped(int stripe);
|
Declaration* ToStriped(int stripe);
|
||||||
Declaration* ToStriped(Errors* errors);
|
Declaration* ToStriped(Errors* errors);
|
||||||
|
|
|
@ -648,6 +648,13 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio
|
||||||
|
|
||||||
mScope = oscope;
|
mScope = oscope;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((flags & ~dec->mFlags) == DTF_CONST)
|
||||||
|
dec = dec->ToConstType();
|
||||||
|
else if ((flags & ~dec->mFlags) == DTF_VOLATILE)
|
||||||
|
dec = dec->ToVolatileType();
|
||||||
|
}
|
||||||
|
|
||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
|
@ -820,6 +827,8 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl
|
||||||
{
|
{
|
||||||
if ((flags & ~dec->mFlags) == DTF_CONST)
|
if ((flags & ~dec->mFlags) == DTF_CONST)
|
||||||
dec = dec->ToConstType();
|
dec = dec->ToConstType();
|
||||||
|
else if ((flags & ~dec->mFlags) == DTF_VOLATILE)
|
||||||
|
dec = dec->ToVolatileType();
|
||||||
else if (dec->IsSimpleType() && (flags & ~dec->mFlags))
|
else if (dec->IsSimpleType() && (flags & ~dec->mFlags))
|
||||||
{
|
{
|
||||||
Declaration* ndec = new Declaration(dec->mLocation, dec->mType);
|
Declaration* ndec = new Declaration(dec->mLocation, dec->mType);
|
||||||
|
@ -832,6 +841,8 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl
|
||||||
{
|
{
|
||||||
if ((flags & ~dec->mFlags) == DTF_CONST)
|
if ((flags & ~dec->mFlags) == DTF_CONST)
|
||||||
dec = dec->ToConstType();
|
dec = dec->ToConstType();
|
||||||
|
else if ((flags & ~dec->mFlags) == DTF_VOLATILE)
|
||||||
|
dec = dec->ToVolatileType();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Declaration* ndec = new Declaration(dec->mLocation, dec->mType);
|
Declaration* ndec = new Declaration(dec->mLocation, dec->mType);
|
||||||
|
|
Loading…
Reference in New Issue