Fix unnamed structs

This commit is contained in:
drmortalwombat 2023-12-18 07:40:31 +01:00
parent 5055635d3d
commit ef6598e94b
3 changed files with 17 additions and 9 deletions

View File

@ -125,7 +125,7 @@ float exp(float f)
int fi = (int)ff;
union xx {
union {
float f;
int i[2];
} x;
@ -155,7 +155,7 @@ float log(float f)
if (f == 0.0)
return 1.0;
union xx {
union {
float f;
int i[2];
} x;
@ -193,7 +193,7 @@ float sqrt(float f)
{
if (f >= 0)
{
union xx {
union {
float f;
int i[2];
} x;
@ -216,7 +216,7 @@ float sqrt(float f)
bool isinf(float f)
{
union xx {
union {
float f;
unsigned i[2];
} x;
@ -228,7 +228,7 @@ bool isinf(float f)
bool isfinite(float f)
{
union xx {
union {
float f;
unsigned i[2];
} x;

View File

@ -1301,11 +1301,17 @@ const Ident* Declaration::MangleIdent(void)
}
else if (mType == DT_TYPE_STRUCT)
{
mMangleIdent = mQualIdent->PreMangle("struct ");
if (mQualIdent)
mMangleIdent = mQualIdent->PreMangle("struct ");
else
mMangleIdent = Ident::Unique("struct");
}
else if (mType == DT_TYPE_ENUM)
{
mMangleIdent = mQualIdent->PreMangle("enum ");
if (mQualIdent)
mMangleIdent = mQualIdent->PreMangle("enum ");
else
mMangleIdent = Ident::Unique("enum");
}
else if (mType == DT_TYPE_VOID)
{

View File

@ -174,8 +174,10 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio
}
}
}
else
mErrors->Error(mScanner->mLocation, EERR_UNIMPLEMENTED, "Unnamed structs are not implemented");
else if ((mCompilerOptions & COPT_CPLUSPLUS) && mScope->mLevel < SLEVEL_CLASS)
{
mErrors->Error(mScanner->mLocation, EERR_INVALID_IDENTIFIER, "Invalid unnamed struct on global level");
}
if (!dec->mIdent || !dec->mScope)
{