From 12e832ebd355123220387a46433002bef327c721 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Fri, 2 May 2025 16:44:24 +0200 Subject: [PATCH] Fix static constexpr in class context --- oscar64/Parser.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 4a4488e..94e20f4 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -359,6 +359,29 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio mdec->mVarIndex = -1; mdec->mQualIdent = mScope->Mangle(mdec->mIdent); + if (mdec->mValue && (mdec->mBase->mFlags & DTF_CONST)) + { + if (mdec->mBase->IsNumericType()) + { + if (mdec->mValue->mType == EX_CONSTANT) + { + mdec->mType = mdec->mValue->mDecValue->mType; + mdec->mInteger = mdec->mValue->mDecValue->mInteger; + } + } + else if (dec->mBase->mType == DT_TYPE_POINTER) + { + if (dec->mValue->mType == EX_CONSTANT) + { + if (dec->mValue->mDecValue->mType == DT_CONST_ADDRESS || dec->mValue->mDecValue->mType == DT_CONST_POINTER) + { + mdec->mType = mdec->mValue->mDecValue->mType; + mdec->mInteger = mdec->mValue->mDecValue->mInteger; + } + } + } + } + Declaration * pdec = mCompilationUnits->mScope->Insert(mdec->mQualIdent, mdec); if (pdec) @@ -5479,6 +5502,11 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex else if (pthis) { ndec->mFlags |= storageFlags & (DTF_STATIC | DTF_PREVENT_INLINE | DTF_FORCE_INLINE); + if (storageFlags & DTF_CONSTEXPR) + { + ndec->mFlags |= DTF_CONSTEXPR; + ndec->mBase = ndec->mBase->ToConstType(); + } } ndec->mOffset = 0;