Skip to content

Commit

Permalink
fbc: sf.net # 988: (regression) re-allow overloaded non-indexed array…
Browse files Browse the repository at this point in the history
… arguments

- Can't pass UDT member array to an overloaded sub
- commit #8ee7cd4e509 made internal handling on non-indexed arrays more strict but
  missed cases where they should in fact be allowed
- tests added
  • Loading branch information
jayrm committed Nov 4, 2023
1 parent f4dd65b commit 5e8d836
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -24,6 +24,7 @@ Version 1.20.0
- gas64: handle priority for constructors/destructors (SARG)
- gas64: optimization 16 modified retrieval of registers and improved to handle specific cases (SARG)
- gas64: NEW UBYTE/BYTE[count] not handled (SARG)
- sf.net #988: (regression) re-allow overloaded non-indexed array arguments - Can't pass UDT member array to an overloaded sub


Version 1.10.1
Expand Down
16 changes: 16 additions & 0 deletions src/compiler/parser-proccall-args.bas
Expand Up @@ -105,6 +105,14 @@ private function hProcArg _
lexSkipToken( )
amode = FB_PARAMMODE_BYDESC
end if
else
'' already a non-indexed array?
if( astIsNIDXARRAY( expr ) ) then
if( amode <> INVALID ) then
errReport( FB_ERRMSG_PARAMTYPEMISMATCH )
end if
amode = FB_PARAMMODE_BYDESC
end if
end if
end if
end if
Expand Down Expand Up @@ -192,6 +200,14 @@ private sub hOvlProcArg _
lexSkipToken( )
arg->mode = FB_PARAMMODE_BYDESC
end if
else
'' already a non-indexed array?
if( astIsNIDXARRAY( arg->expr ) ) then
if( arg->mode <> INVALID ) then
errReport( FB_ERRMSG_PARAMTYPEMISMATCH )
end if
arg->mode = FB_PARAMMODE_BYDESC
end if
end if
end if
end sub
Expand Down
22 changes: 22 additions & 0 deletions tests/overload/bydesc.bas
Expand Up @@ -62,6 +62,28 @@ SUITE( fbc_tests.overload_.bydesc )
CU_ASSERT( proc( scalar_single ) = RESULT_SCALAR_SINGLE )
CU_ASSERT( proc( scalar_intptr ) = RESULT_SCALAR_INTPTR )
END_TEST

type udt_with_arrays
dim as integer array_int(any), scalar_int
dim as uinteger array_uint(any), scalar_uint
dim as single array_single(any), scalar_single
dim as integer ptr array_intptr(any), scalar_intptr
end type


TEST( udt )
dim x as udt_with_arrays

CU_ASSERT( proc( x.array_int() ) = RESULT_ARRAY_INT )
CU_ASSERT( proc( x.array_uint() ) = RESULT_ARRAY_UINT )
CU_ASSERT( proc( x.array_single() ) = RESULT_ARRAY_SINGLE )
CU_ASSERT( proc( x.array_intptr() ) = RESULT_ARRAY_INTPTR )

CU_ASSERT( proc( x.scalar_int ) = RESULT_SCALAR_INT )
CU_ASSERT( proc( x.scalar_uint ) = RESULT_SCALAR_UINT )
CU_ASSERT( proc( x.scalar_single ) = RESULT_SCALAR_SINGLE )
CU_ASSERT( proc( x.scalar_intptr ) = RESULT_SCALAR_INTPTR )
END_TEST
END_TEST_GROUP

TEST_GROUP( dimensions1vs2 )
Expand Down

0 comments on commit 5e8d836

Please sign in to comment.