From 87ccd5e221b97a535a97b68e26f699a69b5a92c2 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sun, 12 Sep 2021 16:05:23 +0200 Subject: [PATCH] More autotest --- autotest/autotest.bat | 6 +++ autotest/qsorttest.c | 83 ++++++++++++++++++++++++++++++++++ include/stdio.c | 4 +- oscar64/InterCodeGenerator.cpp | 5 ++ oscar64/Parser.cpp | 4 +- 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 autotest/qsorttest.c diff --git a/autotest/autotest.bat b/autotest/autotest.bat index e1ae6b2..dee82e5 100644 --- a/autotest/autotest.bat +++ b/autotest/autotest.bat @@ -84,6 +84,12 @@ if %errorlevel% neq 0 goto :error ..\release\oscar64 -i=../include -rt=../include/crt.c -e -n floatstringtest.c if %errorlevel% neq 0 goto :error +..\release\oscar64 -i=../include -rt=../include/crt.c -e qsorttest.c +if %errorlevel% neq 0 goto :error + +..\release\oscar64 -i=../include -rt=../include/crt.c -e -n qsorttest.c +if %errorlevel% neq 0 goto :error + exit /b 0 :error echo Failed with error #%errorlevel%. diff --git a/autotest/qsorttest.c b/autotest/qsorttest.c new file mode 100644 index 0000000..f3ddeeb --- /dev/null +++ b/autotest/qsorttest.c @@ -0,0 +1,83 @@ +#include +#include +#include + +struct Node +{ + int a; + char s[10]; +}; + +void qsort(Node * n, int s) +{ + if (s > 1) + { + Node pn = n[0]; + int pi = 0; + for(int i=1; imLeft->mDecType, vr.mTemp, vr.mReference); } + else if (exp->mLeft->mDecType->mType != DT_TYPE_VOID && vr.mType->mType == DT_TYPE_VOID) + { + mErrors->Error(exp->mLocation, "Cannot cast void object to non void object"); + return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference); + } else { vr = Dereference(proc, block, vr); diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 5fac08e..c7eff3e 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -604,8 +604,8 @@ Expression* Parser::ParseInitExpression(Declaration* dtype) } else { - mErrors->Error(mScanner->mLocation, "Struct/Array constant expression expected"); - dec = new Declaration(mScanner->mLocation, DT_CONST_INTEGER); + exp = ParseRExpression(); + return exp; } exp = new Expression(mScanner->mLocation, EX_CONSTANT);