Fix bitfield delcaration in function local struct
This commit is contained in:
parent
8d18969940
commit
aae7d81cc6
|
@ -288,7 +288,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio
|
||||||
else if (ConsumeTokenIf(TK_FRIEND))
|
else if (ConsumeTokenIf(TK_FRIEND))
|
||||||
{
|
{
|
||||||
mScope = oscope;
|
mScope = oscope;
|
||||||
Declaration* fdec = ParseDeclaration(nullptr, true, false);
|
Declaration* fdec = ParseDeclaration(nullptr, true, false, false);
|
||||||
if (fdec->mType == DT_ANON)
|
if (fdec->mType == DT_ANON)
|
||||||
fdec = fdec->mBase;
|
fdec = fdec->mBase;
|
||||||
dec->mFriends.Push(fdec);
|
dec->mFriends.Push(fdec);
|
||||||
|
@ -304,7 +304,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Declaration* mdec = ParseDeclaration(nullptr, false, false, pthis);
|
Declaration* mdec = ParseDeclaration(nullptr, false, false, true, pthis);
|
||||||
if (mdec)
|
if (mdec)
|
||||||
{
|
{
|
||||||
mdec->mQualIdent = dec->mScope->Mangle(mdec->mIdent);
|
mdec->mQualIdent = dec->mScope->Mangle(mdec->mIdent);
|
||||||
|
@ -713,15 +713,22 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl
|
||||||
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
||||||
dec->mFlags = flags | DTF_DEFINED;
|
dec->mFlags = flags | DTF_DEFINED;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
if (mScanner->mToken == TK_INT || mScanner->mToken == TK_SHORT)
|
if (mScanner->mToken == TK_INT)
|
||||||
{
|
{
|
||||||
dec->mSize = 2;
|
dec->mSize = 2;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
}
|
}
|
||||||
|
else if (mScanner->mToken == TK_SHORT)
|
||||||
|
{
|
||||||
|
dec->mSize = 2;
|
||||||
|
mScanner->NextToken();
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
|
}
|
||||||
else if (mScanner->mToken == TK_LONG)
|
else if (mScanner->mToken == TK_LONG)
|
||||||
{
|
{
|
||||||
dec->mSize = 4;
|
dec->mSize = 4;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
}
|
}
|
||||||
else if (mScanner->mToken == TK_CHAR)
|
else if (mScanner->mToken == TK_CHAR)
|
||||||
{
|
{
|
||||||
|
@ -737,15 +744,22 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl
|
||||||
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
||||||
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
if (mScanner->mToken == TK_INT || mScanner->mToken == TK_SHORT)
|
if (mScanner->mToken == TK_INT)
|
||||||
{
|
{
|
||||||
dec->mSize = 2;
|
dec->mSize = 2;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
}
|
}
|
||||||
|
else if (mScanner->mToken == TK_SHORT)
|
||||||
|
{
|
||||||
|
dec->mSize = 2;
|
||||||
|
mScanner->NextToken();
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
|
}
|
||||||
else if (mScanner->mToken == TK_LONG)
|
else if (mScanner->mToken == TK_LONG)
|
||||||
{
|
{
|
||||||
dec->mSize = 4;
|
dec->mSize = 4;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
}
|
}
|
||||||
else if (mScanner->mToken == TK_CHAR)
|
else if (mScanner->mToken == TK_CHAR)
|
||||||
{
|
{
|
||||||
|
@ -774,9 +788,22 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl
|
||||||
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
||||||
else
|
else
|
||||||
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TK_SHORT:
|
case TK_SHORT:
|
||||||
|
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
||||||
|
dec->mSize = 2;
|
||||||
|
mScanner->NextToken();
|
||||||
|
if (ConsumeTokenIf(TK_UNSIGNED))
|
||||||
|
dec->mFlags = flags | DTF_DEFINED;
|
||||||
|
else if (ConsumeTokenIf(TK_SIGNED))
|
||||||
|
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
||||||
|
else
|
||||||
|
dec->mFlags = flags | DTF_DEFINED | DTF_SIGNED;
|
||||||
|
ConsumeTokenIf(TK_INT);
|
||||||
|
break;
|
||||||
|
|
||||||
case TK_INT:
|
case TK_INT:
|
||||||
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
dec = new Declaration(mScanner->mLocation, DT_TYPE_INTEGER);
|
||||||
dec->mSize = 2;
|
dec->mSize = 2;
|
||||||
|
@ -4017,7 +4044,7 @@ void Parser::ParseVariableInit(Declaration* ndec, Expression* pexp)
|
||||||
mErrors->Error(mScanner->mLocation, EERR_INCOMPATIBLE_TYPES, "Can not initialize variable with expression", ndec->mIdent);
|
mErrors->Error(mScanner->mLocation, EERR_INCOMPATIBLE_TYPES, "Can not initialize variable with expression", ndec->mIdent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool expression, Declaration* pthis, Declaration* ptempl)
|
Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool expression, bool member, Declaration* pthis, Declaration* ptempl)
|
||||||
{
|
{
|
||||||
bool definingType = false, destructor = false;
|
bool definingType = false, destructor = false;
|
||||||
uint64 storageFlags = 0, typeFlags = 0;
|
uint64 storageFlags = 0, typeFlags = 0;
|
||||||
|
@ -4882,7 +4909,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
|
||||||
ldec = ndec;
|
ldec = ndec;
|
||||||
// ndec->mNext = nullptr;
|
// ndec->mNext = nullptr;
|
||||||
|
|
||||||
if (!mFunctionType && ConsumeTokenIf(TK_COLON))
|
if (member && ConsumeTokenIf(TK_COLON))
|
||||||
{
|
{
|
||||||
Expression* exp = ParseRExpression();
|
Expression* exp = ParseRExpression();
|
||||||
if (!ndec->mBase->IsIntegerType())
|
if (!ndec->mBase->IsIntegerType())
|
||||||
|
@ -5238,7 +5265,7 @@ Expression* Parser::ParseDeclarationExpression(Declaration * pdec)
|
||||||
Declaration* dec;
|
Declaration* dec;
|
||||||
Expression* exp = nullptr, * rexp = nullptr;
|
Expression* exp = nullptr, * rexp = nullptr;
|
||||||
|
|
||||||
dec = ParseDeclaration(pdec, true, true);
|
dec = ParseDeclaration(pdec, true, true, false);
|
||||||
if (dec->mType == DT_ANON && dec->mNext == 0)
|
if (dec->mType == DT_ANON && dec->mNext == 0)
|
||||||
{
|
{
|
||||||
exp = new Expression(dec->mLocation, EX_TYPE);
|
exp = new Expression(dec->mLocation, EX_TYPE);
|
||||||
|
@ -5806,7 +5833,7 @@ Expression* Parser::ParseSimpleExpression(bool lhs, bool tid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TK_USING:
|
case TK_USING:
|
||||||
ParseDeclaration(nullptr, true, true);
|
ParseDeclaration(nullptr, true, true, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TK_CHARACTER:
|
case TK_CHARACTER:
|
||||||
|
@ -10415,7 +10442,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
tdec->mBase = p->ParseDeclaration(nullptr, true, false, tpthis, tdec);
|
tdec->mBase = p->ParseDeclaration(nullptr, true, false, false, tpthis, tdec);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->mTemplateScope = nullptr;
|
p->mTemplateScope = nullptr;
|
||||||
|
@ -12745,7 +12772,7 @@ void Parser::ParseNamespace(void)
|
||||||
ParseNamespace();
|
ParseNamespace();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ParseDeclaration(nullptr, true, false);
|
ParseDeclaration(nullptr, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsumeToken(TK_CLOSE_BRACE);
|
ConsumeToken(TK_CLOSE_BRACE);
|
||||||
|
@ -12831,6 +12858,6 @@ void Parser::Parse(void)
|
||||||
ParseNamespace();
|
ParseNamespace();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ParseDeclaration(nullptr, true, false);
|
ParseDeclaration(nullptr, true, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ protected:
|
||||||
|
|
||||||
Declaration* ParseBaseTypeQualify(bool qualified, Declaration* dec, const Ident *& pident);
|
Declaration* ParseBaseTypeQualify(bool qualified, Declaration* dec, const Ident *& pident);
|
||||||
Declaration* ParseBaseTypeDeclaration(uint64 flags, bool qualified, Declaration* ptempl = nullptr);
|
Declaration* ParseBaseTypeDeclaration(uint64 flags, bool qualified, Declaration* ptempl = nullptr);
|
||||||
Declaration* ParseDeclaration(Declaration* pdec, bool variable, bool expression, Declaration * pthis = nullptr, Declaration * ptempl = nullptr);
|
Declaration* ParseDeclaration(Declaration* pdec, bool variable, bool expression, bool member, Declaration * pthis = nullptr, Declaration * ptempl = nullptr);
|
||||||
Declaration* ParseStructDeclaration(uint64 flags, DecType dt, Declaration* ptempl = nullptr);
|
Declaration* ParseStructDeclaration(uint64 flags, DecType dt, Declaration* ptempl = nullptr);
|
||||||
|
|
||||||
Declaration* CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp);
|
Declaration* CopyConstantInitializer(int offset, Declaration* dtype, Expression* exp);
|
||||||
|
|
Loading…
Reference in New Issue