Fix call of function pointers in array

This commit is contained in:
drmortalwombat 2022-04-13 16:29:36 +02:00
parent 417574b4bb
commit 8f32b87b18
7 changed files with 44 additions and 9 deletions

View File

@ -108,6 +108,9 @@ rem @echo off
@call :test funcvartest.c
@if %errorlevel% neq 0 goto :error
@call :test funcarraycall.c
@if %errorlevel% neq 0 goto :error
@call :test structassigntest.c
@if %errorlevel% neq 0 goto :error

30
autotest/funcarraycall.c Normal file
View File

@ -0,0 +1,30 @@
int (*funcs[10])(int);
#assign x 0
#repeat
int f##x(int i)
{
return i + x;
}
#assign x x + 1
#until x == 10
int test(int k)
{
for(char i=0; i<10; i++)
k = funcs[i](k);
return k;
}
int main(void)
{
#assign x 0
#repeat
funcs[x] = f##x;
#assign x x + 1
#until x == 10
int k = test(-45);
return k;
}

View File

@ -361,6 +361,8 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec)
return Analyze(exp->mLeft, procDec);
case EX_INDEX:
ldec = Analyze(exp->mLeft, procDec);
if (ldec->mType == DT_VARIABLE || ldec->mType == DT_ARGUMENT)
ldec = ldec->mBase;
rdec = Analyze(exp->mRight, procDec);
return ldec->mBase;
case EX_QUALIFY:

View File

@ -2336,7 +2336,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
atotal = 2;
}
if (exp->mLeft->mDecValue->mType == DT_CONST_FUNCTION)
if (exp->mLeft->mDecValue && exp->mLeft->mDecValue->mType == DT_CONST_FUNCTION)
proc->AddCalledFunction(proc->mModule->mProcedures[exp->mLeft->mDecValue->mVarIndex]);
else
proc->CallsFunctionPointer();

View File

@ -73,7 +73,7 @@ int main2(int argc, const char** argv)
#else
strcpy(strProductName, "oscar64");
strcpy(strProductVersion, "1.5.115");
strcpy(strProductVersion, "1.5.116");
#ifdef __APPLE__
uint32_t length = sizeof(basePath);

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,5,115,0
PRODUCTVERSION 1,5,115,0
FILEVERSION 1,5,116,0
PRODUCTVERSION 1,5,116,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -43,12 +43,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "oscar64"
VALUE "FileDescription", "oscar64 compiler"
VALUE "FileVersion", "1.5.115.0"
VALUE "FileVersion", "1.5.116.0"
VALUE "InternalName", "oscar64.exe"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "oscar64.exe"
VALUE "ProductName", "oscar64"
VALUE "ProductVersion", "1.5.115.0"
VALUE "ProductVersion", "1.5.116.0"
END
END
BLOCK "VarFileInfo"

View File

@ -4023,15 +4023,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:oscar64"
"ProductCode" = "8:{FA319FAF-1EB3-4F52-9FEA-2BC0B4CB5CAC}"
"PackageCode" = "8:{ACF87401-D180-424C-B9D4-E855CBF66BB1}"
"ProductCode" = "8:{0ED76161-EB93-44B9-8ED5-B52DAE35B818}"
"PackageCode" = "8:{B9A27BFE-6C41-4995-B0B1-AA37F7D48E99}"
"UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.5.115"
"ProductVersion" = "8:1.5.116"
"Manufacturer" = "8:oscar64"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"