From e89aa11e862db268f3e53fe5097eabe6fe3b3998 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:31:03 +0200 Subject: [PATCH] Implement parse of octal numbers --- oscar64/Declaration.h | 1 + oscar64/GlobalAnalyzer.cpp | 7 +++++++ oscar64/Parser.cpp | 4 ++-- oscar64/Scanner.cpp | 10 ++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/oscar64/Declaration.h b/oscar64/Declaration.h index 763d5c1..7234b0a 100644 --- a/oscar64/Declaration.h +++ b/oscar64/Declaration.h @@ -123,6 +123,7 @@ static const uint64 DTF_FUNC_THIS = (1ULL << 47); static const uint64 DTF_VAR_ALIASING = (1ULL << 48); static const uint64 DTF_FPARAM_UNUSED = (1ULL << 49); +static const uint64 DTF_DEPRECATED = (1ULL << 50); class Declaration; diff --git a/oscar64/GlobalAnalyzer.cpp b/oscar64/GlobalAnalyzer.cpp index c02b22f..9455186 100644 --- a/oscar64/GlobalAnalyzer.cpp +++ b/oscar64/GlobalAnalyzer.cpp @@ -600,6 +600,13 @@ void GlobalAnalyzer::AnalyzeProcedure(Expression* cexp, Expression* exp, Declara { dec->mFlags |= DTF_FUNC_ANALYZING; + if (dec->mFlags & DTF_DEPRECATED) + { + mErrors->Error(dec->mLocation, EWARN_DEFAULT_COPY_DEPRECATED, "Using deprecated function", dec->mQualIdent->mString); + if (cexp) + mErrors->Error(cexp->mLocation, EINFO_CALLED_FROM, "Called from here"); + } + mFunctions.Push(dec); Declaration* pdec = dec->mBase->mParams; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index e879e02..d6bdccc 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -2605,7 +2605,7 @@ void Parser::AddDefaultConstructors(Declaration* pthis) cdec->mVarIndex = -1; if (explicitDestructor) - mErrors->Error(pthis->mBase->mLocation, EWARN_DEFAULT_COPY_DEPRECATED, "Default copy constructor deprecated due to explicit destructor"); + cdec->mFlags |= DTF_DEPRECATED; cdec->mValue = new Expression(mScanner->mLocation, EX_VOID); @@ -2777,7 +2777,7 @@ void Parser::AddDefaultConstructors(Declaration* pthis) cdec->mVarIndex = -1; if (explicitDestructor) - mErrors->Error(pthis->mBase->mLocation, EWARN_DEFAULT_COPY_DEPRECATED, "Default copy constructor deprecated due to explicit destructor"); + cdec->mFlags |= DTF_DEPRECATED; Expression* pthisexp = new Expression(pthis->mLocation, EX_VARIABLE); pthisexp->mDecType = pthis; diff --git a/oscar64/Scanner.cpp b/oscar64/Scanner.cpp index a7fe446..ae60eb4 100644 --- a/oscar64/Scanner.cpp +++ b/oscar64/Scanner.cpp @@ -2362,14 +2362,21 @@ void Scanner::ParseNumberToken(void) } else { + int64 moctal = 0; + bool zerostart = mant == 0; + int n = 0; if (mTokenChar >= '0' && mTokenChar <= '9') { mant = mant * 10 + (int)mTokenChar - (int)'0'; + moctal = moctal * 8 + (int)mTokenChar - (int)'0'; while (NextChar()) { if (mTokenChar >= '0' && mTokenChar <= '9') + { mant = mant * 10 + (int)mTokenChar - (int)'0'; + moctal = moctal * 8 + (int)mTokenChar - (int)'0'; + } else break; n++; @@ -2378,6 +2385,9 @@ void Scanner::ParseNumberToken(void) if (mTokenChar != '.') { + if (zerostart) + mant = moctal; + if (mTokenChar == 'U' || mTokenChar == 'u') { NextChar();