Skip to content
Browse files

Fix overload resolution for pointer arguments

  • Loading branch information...
1 parent 670938f commit 820ab5996e759b6849b4b72015d7143d36d9558e @dkl dkl committed Apr 27, 2012
View
2 changelog.txt
@@ -131,6 +131,8 @@ Version 0.24.0:
- Unused bits (padding) in UDTs with bitfields could be left uninitialized by type initializers
- C backend #3421351: Wrong code for bitfield assignment when the target bitfield expression had nested field accesses
- #3509495: Delete[] on derived UDTs with destructors caused a compiler crash
+- Overload resolution treated pointer arguments as uintegers, allowing them to match integer parameters
+- Any Ptr arguments were seen as ambiguous even if there was a fully matching overload
Version 0.23.0:
View
49 compiler/symb-proc.bas
@@ -1560,37 +1560,27 @@ private function hCalcTypesDiff _
return FB_OVLPROC_HALFMATCH
end if
- '' param is an any ptr?
- if( param_dtype = typeAddrOf( FB_DATATYPE_VOID ) ) then
-
- '' we return a full match only if they're both any
- if( arg_dtype = typeAddrOf( FB_DATATYPE_VOID ) ) then
- return FB_OVLPROC_FULLMATCH
-
- '' other wise, it's a half match
- '' the arg indirection level shouldn't matter (as in g++)
- else
- return FB_OVLPROC_HALFMATCH
- end if
- end if
-
- '' arg is an any ptr?
- if( arg_dtype = typeAddrOf( FB_DATATYPE_VOID ) ) then
- '' not the same level of indirection?
- if( param_ptrcnt > 1 ) then
- return 0
- end if
-
- return FB_OVLPROC_FULLMATCH
+ '' Both are pointers (but they're different,
+ '' full match is already handled)
+ assert( arg_dtype <> param_dtype )
+
+ '' Any Ptr parameters can accept all pointer arguments, as in C++.
+ '' Additionally we also allow Any Ptr arguments to match all
+ '' pointer parameters, because we also allow such assignments,
+ '' unlike C++.
+ if( (param_dtype = typeAddrOf( FB_DATATYPE_VOID )) or _
+ (arg_dtype = typeAddrOf( FB_DATATYPE_VOID )) ) then
+ return FB_OVLPROC_HALFMATCH
end if
- '' no match
+ '' Different pointer types aren't compatible at all though,
+ '' that would be dangerous.
return 0
- '' param not a pointer, but is arg?
elseif( typeIsPtr( arg_dtype ) ) then
- '' use an UINT instead or LONGINT will match if any..
- arg_dtype = FB_DATATYPE_UINT
+ '' Param isn't a pointer, but arg is:
+ '' no match -- pointers don't match integers
+ return 0
end if
return FB_OVLPROC_HALFMATCH - abs( typeGet( param_dtype ) - typeGet( arg_dtype ) )
@@ -1753,9 +1743,7 @@ private function hCheckOvlParam _
'' same types?
if( typeGetDtAndPtrOnly( param_dtype ) = typeGetDtAndPtrOnly( arg_dtype ) ) then
-
if( typeGetConstMask( param_dtype ) = typeGetConstMask( arg_dtype ) ) then
-
'' same subtype? full match..
if( param_subtype = arg_subtype ) then
return FB_OVLPROC_FULLMATCH
@@ -1771,19 +1759,14 @@ private function hCheckOvlParam _
End Select
end if
end if
-
elseif( typeGetConstMask( param_dtype ) ) then
-
'' same subtype? ..
if( param_subtype = arg_subtype ) then
-
'' param is const but arg isn't?
if( symbCheckConstAssign( param_dtype, arg_dtype, param_subtype, arg_subtype ) ) then
return FB_OVLPROC_HALFMATCH
end if
-
end if
-
end if
'' if it's rtl, only if explicitly set
View
7 tests/overload/ambiguous-1.bas
@@ -0,0 +1,7 @@
+' TEST_MODE : COMPILE_ONLY_FAIL
+
+declare sub f overload( byval as byte ptr )
+declare sub f overload( byval as short ptr )
+
+dim as any ptr p
+f( p )
View
25 tests/overload/hex_oct_bin.bas
@@ -3,11 +3,16 @@
namespace fbc_tests.overloads.hex_oct_bin
sub test cdecl( )
+ type T
+ as integer a, b, c, d
+ end type
+
dim b as byte = -2 ^ 7
dim s as short = -2 ^ 15
dim i as integer = -2 ^ 31
dim l as longint = -2LL ^ 63
- dim p as any ptr = cptr(any ptr, i)
+ dim p as any ptr = cptr( any ptr, i )
+ dim pt as T ptr = cptr( T ptr, p )
CU_ASSERT( bin( b ) = "10000000" )
CU_ASSERT( bin( b, 1 ) = "0" )
@@ -21,6 +26,9 @@ sub test cdecl( )
CU_ASSERT( bin( p ) = "10000000000000000000000000000000" )
CU_ASSERT( bin( p, 1 ) = "0" )
CU_ASSERT( bin( p, 32 ) = "10000000000000000000000000000000" )
+ CU_ASSERT( bin( pt ) = "10000000000000000000000000000000" )
+ CU_ASSERT( bin( pt, 1 ) = "0" )
+ CU_ASSERT( bin( pt, 32 ) = "10000000000000000000000000000000" )
CU_ASSERT( bin( l ) = "1000000000000000000000000000000000000000000000000000000000000000" )
CU_ASSERT( bin( l, 1 ) = "0" )
CU_ASSERT( bin( l, 64 ) = "1000000000000000000000000000000000000000000000000000000000000000" )
@@ -37,6 +45,9 @@ sub test cdecl( )
CU_ASSERT( hex( p ) = "80000000" )
CU_ASSERT( hex( p, 1 ) = "0" )
CU_ASSERT( hex( p, 8 ) = "80000000" )
+ CU_ASSERT( hex( pt ) = "80000000" )
+ CU_ASSERT( hex( pt, 1 ) = "0" )
+ CU_ASSERT( hex( pt, 32 ) = "80000000" )
CU_ASSERT( hex( l ) = "8000000000000000" )
CU_ASSERT( hex( l, 1 ) = "0" )
CU_ASSERT( hex( l, 16 ) = "8000000000000000" )
@@ -53,6 +64,9 @@ sub test cdecl( )
CU_ASSERT( oct( p ) = "20000000000" )
CU_ASSERT( oct( p, 1 ) = "0" )
CU_ASSERT( oct( p, 11 ) = "20000000000" )
+ CU_ASSERT( oct( pt ) = "20000000000" )
+ CU_ASSERT( oct( pt, 1 ) = "0" )
+ CU_ASSERT( oct( pt, 32 ) = "20000000000" )
CU_ASSERT( oct( l ) = "1000000000000000000000" )
CU_ASSERT( oct( l, 1 ) = "0" )
CU_ASSERT( oct( l, 22 ) = "1000000000000000000000" )
@@ -73,6 +87,9 @@ sub test cdecl( )
CU_ASSERT( wbin( p ) = wstr( "10000000000000000000000000000000" ) )
CU_ASSERT( wbin( p, 1 ) = wstr( "0" ) )
CU_ASSERT( wbin( p, 32 ) = wstr( "10000000000000000000000000000000" ) )
+ CU_ASSERT( wbin( pt ) = wstr( "10000000000000000000000000000000" ) )
+ CU_ASSERT( wbin( pt, 1 ) = wstr( "0" ) )
+ CU_ASSERT( wbin( pt, 32 ) = wstr( "10000000000000000000000000000000" ) )
CU_ASSERT( wbin( l ) = wstr( "1000000000000000000000000000000000000000000000000000000000000000" ) )
CU_ASSERT( wbin( l, 1 ) = wstr( "0" ) )
CU_ASSERT( wbin( l, 64 ) = wstr( "1000000000000000000000000000000000000000000000000000000000000000" ) )
@@ -89,6 +106,9 @@ sub test cdecl( )
CU_ASSERT( whex( p ) = wstr( "80000000" ) )
CU_ASSERT( whex( p, 1 ) = wstr( "0" ) )
CU_ASSERT( whex( p, 8 ) = wstr( "80000000" ) )
+ CU_ASSERT( whex( pt ) = wstr( "80000000" ) )
+ CU_ASSERT( whex( pt, 1 ) = wstr( "0" ) )
+ CU_ASSERT( whex( pt, 32 ) = wstr( "80000000" ) )
CU_ASSERT( whex( l ) = wstr( "8000000000000000" ) )
CU_ASSERT( whex( l, 1 ) = wstr( "0" ) )
CU_ASSERT( whex( l, 16 ) = wstr( "8000000000000000" ) )
@@ -105,6 +125,9 @@ sub test cdecl( )
CU_ASSERT( woct( p ) = wstr( "20000000000" ) )
CU_ASSERT( woct( p, 1 ) = wstr( "0" ) )
CU_ASSERT( woct( p, 11 ) = wstr( "20000000000" ) )
+ CU_ASSERT( woct( pt ) = wstr( "20000000000" ) )
+ CU_ASSERT( woct( pt, 1 ) = wstr( "0" ) )
+ CU_ASSERT( woct( pt, 32 ) = wstr( "20000000000" ) )
CU_ASSERT( woct( l ) = wstr( "1000000000000000000000" ) )
CU_ASSERT( woct( l, 1 ) = wstr( "0" ) )
CU_ASSERT( woct( l, 22 ) = wstr( "1000000000000000000000" ) )
View
7 tests/overload/no-match-1.bas
@@ -0,0 +1,7 @@
+' TEST_MODE : COMPILE_ONLY_FAIL
+
+declare sub f overload( byval as byte ptr )
+declare sub f overload( byval as short ptr )
+
+dim as integer ptr p
+f( p )
View
7 tests/overload/no-match-2.bas
@@ -0,0 +1,7 @@
+' TEST_MODE : COMPILE_ONLY_FAIL
+
+declare sub f overload( byval as integer ptr ptr )
+declare sub f overload( byval as integer ptr ptr ptr )
+
+dim as integer ptr p
+f( p )
View
11 tests/overload/no-match-3.bas
@@ -0,0 +1,11 @@
+' TEST_MODE : COMPILE_ONLY_FAIL
+
+declare sub f overload( byval as integer )
+declare sub f overload( byval as uinteger )
+declare sub f overload( byval as long )
+declare sub f overload( byval as ulong )
+declare sub f overload( byval as longint )
+declare sub f overload( byval as ulongint )
+
+dim as integer ptr p
+f( p )
View
11 tests/overload/no-match-4.bas
@@ -0,0 +1,11 @@
+' TEST_MODE : COMPILE_ONLY_FAIL
+
+declare sub f overload( byval as integer )
+declare sub f overload( byval as uinteger )
+declare sub f overload( byval as long )
+declare sub f overload( byval as ulong )
+declare sub f overload( byval as longint )
+declare sub f overload( byval as ulongint )
+
+dim as any ptr p
+f( p )
View
261 tests/overload/pointers.bas
@@ -0,0 +1,261 @@
+# include "fbcu.bi"
+
+namespace fbc_tests.overload_.pointers
+
+type T
+ as integer a, b, c, d
+end type
+
+type Forward as MyUndefinedType
+
+dim shared pb as byte ptr, ppb as byte ptr ptr
+dim shared pub as ubyte ptr, ppub as ubyte ptr ptr
+dim shared ps as short ptr, pps as short ptr ptr
+dim shared pus as ushort ptr, ppus as ushort ptr ptr
+dim shared i as integer, pi as integer ptr, ppi as integer ptr ptr
+dim shared pui as uinteger ptr, ppui as uinteger ptr ptr
+dim shared pl as long ptr, ppl as long ptr ptr
+dim shared pul as ulong ptr, ppul as ulong ptr ptr
+dim shared pll as longint ptr, ppll as longint ptr ptr
+dim shared pull as ulongint ptr, ppull as ulongint ptr ptr
+dim shared pt as T ptr, ppt as T ptr ptr
+dim shared pany as any ptr, ppany as any ptr ptr
+dim shared pfwd as Forward ptr, ppfwd as Forward ptr ptr
+
+dim shared pds as string ptr, ppds as string ptr ptr
+dim shared pzs as zstring ptr, ppzs as zstring ptr ptr
+dim shared pws as wstring ptr, ppws as wstring ptr ptr
+
+#macro proc( T )
+ function f overload( byval p as T ) as string
+ function = #T
+ end function
+#endmacro
+
+namespace pointers
+ proc( byte ptr )
+ proc( byte ptr ptr )
+ proc( short ptr )
+ proc( short ptr ptr )
+ proc( integer ptr )
+ proc( integer ptr ptr )
+ proc( long ptr )
+ proc( long ptr ptr )
+ proc( longint ptr )
+ proc( longint ptr ptr )
+ proc( T ptr )
+ proc( T ptr ptr )
+ proc( any ptr )
+ proc( any ptr ptr )
+ proc( Forward ptr )
+ proc( Forward ptr ptr )
+ proc( string ptr )
+ proc( string ptr ptr )
+ proc( zstring ptr )
+ proc( zstring ptr ptr )
+ proc( wstring ptr )
+ proc( wstring ptr ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( pb ) = "byte ptr" )
+ CU_ASSERT( f( ps ) = "short ptr" )
+ CU_ASSERT( f( pi ) = "integer ptr" )
+ CU_ASSERT( f( pl ) = "long ptr" )
+ CU_ASSERT( f( pll ) = "longint ptr" )
+ CU_ASSERT( f( pt ) = "T ptr" )
+ CU_ASSERT( f( pany ) = "any ptr" )
+ CU_ASSERT( f( pfwd ) = "Forward ptr" )
+ CU_ASSERT( f( pds ) = "string ptr" )
+ CU_ASSERT( f( pzs ) = "zstring ptr" )
+ CU_ASSERT( f( pws ) = "wstring ptr" )
+
+ CU_ASSERT( f( ppb ) = "byte ptr ptr" )
+ CU_ASSERT( f( pps ) = "short ptr ptr" )
+ CU_ASSERT( f( ppi ) = "integer ptr ptr" )
+ CU_ASSERT( f( ppl ) = "long ptr ptr" )
+ CU_ASSERT( f( ppll ) = "longint ptr ptr" )
+ CU_ASSERT( f( ppt ) = "T ptr ptr" )
+ CU_ASSERT( f( ppany ) = "any ptr ptr" )
+ CU_ASSERT( f( ppfwd ) = "Forward ptr ptr" )
+ CU_ASSERT( f( ppds ) = "string ptr ptr" )
+ CU_ASSERT( f( ppzs ) = "zstring ptr ptr" )
+ CU_ASSERT( f( ppws ) = "wstring ptr ptr" )
+
+ CU_ASSERT( f( @ppb ) = "any ptr" )
+ CU_ASSERT( f( @pps ) = "any ptr" )
+ CU_ASSERT( f( @ppi ) = "any ptr" )
+ CU_ASSERT( f( @ppt ) = "any ptr" )
+ CU_ASSERT( f( @ppany ) = "any ptr" )
+ CU_ASSERT( f( @ppfwd ) = "any ptr" )
+ end sub
+end namespace
+
+namespace anyptrParam1
+ '' Any Ptr params accept all pointers
+ proc( any ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( pb ) = "any ptr" )
+ CU_ASSERT( f( ps ) = "any ptr" )
+ CU_ASSERT( f( pi ) = "any ptr" )
+ CU_ASSERT( f( pl ) = "any ptr" )
+ CU_ASSERT( f( pll ) = "any ptr" )
+ CU_ASSERT( f( pt ) = "any ptr" )
+ CU_ASSERT( f( pany ) = "any ptr" )
+ CU_ASSERT( f( pfwd ) = "any ptr" )
+ CU_ASSERT( f( pds ) = "any ptr" )
+ CU_ASSERT( f( pzs ) = "any ptr" )
+ CU_ASSERT( f( pws ) = "any ptr" )
+
+ CU_ASSERT( f( ppb ) = "any ptr" )
+ CU_ASSERT( f( pps ) = "any ptr" )
+ CU_ASSERT( f( ppi ) = "any ptr" )
+ CU_ASSERT( f( ppl ) = "any ptr" )
+ CU_ASSERT( f( ppll ) = "any ptr" )
+ CU_ASSERT( f( ppt ) = "any ptr" )
+ CU_ASSERT( f( ppany ) = "any ptr" )
+ CU_ASSERT( f( ppfwd ) = "any ptr" )
+ CU_ASSERT( f( ppds ) = "any ptr" )
+ CU_ASSERT( f( ppzs ) = "any ptr" )
+ CU_ASSERT( f( ppws ) = "any ptr" )
+ end sub
+end namespace
+
+namespace anyptrParam2
+ proc( integer ptr )
+ proc( any ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( pb ) = "any ptr" )
+ CU_ASSERT( f( ps ) = "any ptr" )
+ CU_ASSERT( f( pi ) = "integer ptr" ) '' Full match - not ambigious
+ CU_ASSERT( f( pl ) = "any ptr" )
+ CU_ASSERT( f( pll ) = "any ptr" )
+ CU_ASSERT( f( pt ) = "any ptr" )
+ CU_ASSERT( f( pany ) = "any ptr" ) '' Full match - not ambigious
+ CU_ASSERT( f( pfwd ) = "any ptr" )
+ CU_ASSERT( f( pds ) = "any ptr" )
+ CU_ASSERT( f( pzs ) = "any ptr" )
+ CU_ASSERT( f( pws ) = "any ptr" )
+
+ CU_ASSERT( f( ppb ) = "any ptr" )
+ CU_ASSERT( f( pps ) = "any ptr" )
+ CU_ASSERT( f( ppi ) = "any ptr" )
+ CU_ASSERT( f( ppl ) = "any ptr" )
+ CU_ASSERT( f( ppll ) = "any ptr" )
+ CU_ASSERT( f( ppt ) = "any ptr" )
+ CU_ASSERT( f( ppany ) = "any ptr" )
+ CU_ASSERT( f( ppfwd ) = "any ptr" )
+ CU_ASSERT( f( ppds ) = "any ptr" )
+ CU_ASSERT( f( ppzs ) = "any ptr" )
+ CU_ASSERT( f( ppws ) = "any ptr" )
+ end sub
+end namespace
+
+namespace anyptrParam3
+ proc( byte ptr )
+ proc( short ptr )
+ proc( integer ptr )
+ proc( any ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( pb ) = "byte ptr" )
+ CU_ASSERT( f( ps ) = "short ptr" )
+ CU_ASSERT( f( pi ) = "integer ptr" )
+ CU_ASSERT( f( pl ) = "any ptr" )
+ CU_ASSERT( f( pll ) = "any ptr" )
+ CU_ASSERT( f( pt ) = "any ptr" )
+ CU_ASSERT( f( pany ) = "any ptr" )
+ CU_ASSERT( f( pfwd ) = "any ptr" )
+ CU_ASSERT( f( pds ) = "any ptr" )
+ CU_ASSERT( f( pzs ) = "any ptr" )
+ CU_ASSERT( f( pws ) = "any ptr" )
+
+ '' With higher indirection level, these should all match the
+ '' Any Ptr, since there are no full matches
+ CU_ASSERT( f( ppb ) = "any ptr" )
+ CU_ASSERT( f( pps ) = "any ptr" )
+ CU_ASSERT( f( ppi ) = "any ptr" )
+ CU_ASSERT( f( ppl ) = "any ptr" )
+ CU_ASSERT( f( ppll ) = "any ptr" )
+ CU_ASSERT( f( ppt ) = "any ptr" )
+ CU_ASSERT( f( ppany ) = "any ptr" )
+ CU_ASSERT( f( ppfwd ) = "any ptr" )
+ CU_ASSERT( f( ppds ) = "any ptr" )
+ CU_ASSERT( f( ppzs ) = "any ptr" )
+ CU_ASSERT( f( ppws ) = "any ptr" )
+ end sub
+end namespace
+
+namespace anyptrArg1
+ '' Any Ptr args match all pointer params (unlike C++)
+ proc( integer )
+ proc( integer ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( i ) = "integer" )
+ CU_ASSERT( f( pi ) = "integer ptr" )
+ CU_ASSERT( f( pany ) = "integer ptr" )
+ end sub
+end namespace
+
+namespace anyptrArg2
+ proc( integer )
+ proc( T ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( i ) = "integer" )
+ CU_ASSERT( f( pt ) = "T ptr" )
+ CU_ASSERT( f( pany ) = "T ptr" )
+ end sub
+end namespace
+
+namespace anyptrArg3
+ proc( integer )
+ proc( T ptr ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( i ) = "integer" )
+ CU_ASSERT( f( ppt ) = "T ptr ptr" )
+ CU_ASSERT( f( pany ) = "T ptr ptr" )
+ end sub
+end namespace
+
+namespace anyptrArgRegressionTest1
+ '' Regression test (Any Ptr args were treated as Uintegers)
+ proc( uinteger )
+ proc( integer ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( i ) = "uinteger" )
+ CU_ASSERT( f( pi ) = "integer ptr" )
+ CU_ASSERT( f( pany ) = "integer ptr" )
+ end sub
+end namespace
+
+namespace anyptrArgRegressionTest2
+ proc( uinteger )
+ proc( any ptr )
+
+ sub test cdecl( )
+ CU_ASSERT( f( i ) = "uinteger" )
+ CU_ASSERT( f( pi ) = "any ptr" )
+ CU_ASSERT( f( pany ) = "any ptr" )
+ CU_ASSERT( f( pt ) = "any ptr" )
+ end sub
+end namespace
+
+private sub ctor( ) constructor
+ fbcu.add_suite( "tests/overload/pointers" )
+ fbcu.add_test( "pointers", @pointers.test )
+ fbcu.add_test( "Any Ptr param 1", @anyptrParam1.test )
+ fbcu.add_test( "Any Ptr param 2", @anyptrParam2.test )
+ fbcu.add_test( "Any Ptr param 3", @anyptrParam3.test )
+ fbcu.add_test( "Any Ptr arg 1", @anyptrArg1.test )
+ fbcu.add_test( "Any Ptr arg 2", @anyptrArg2.test )
+ fbcu.add_test( "Any Ptr arg 3", @anyptrArg3.test )
+ fbcu.add_test( "Any Ptr bug 1", @anyptrArgRegressionTest1.test )
+ fbcu.add_test( "Any Ptr bug 2", @anyptrArgRegressionTest2.test )
+end sub
+
+end namespace
View
29 tests/overload/simple.bas
@@ -1,11 +1,8 @@
# include "fbcu.bi"
+namespace fbc_tests.overload_.simple
-
-
-namespace fbc_tests.overloads.simple
-
-enum RESULT
+enum RESULT
RESULT_INT
RESULT_UINT
RESULT_SNG
@@ -32,9 +29,7 @@ end enum
# macro D_PROC(ArgT_, ReturnValue_)
function proc overload ( byval arg as ArgT_ ) as RESULT
-
function = ReturnValue_
-
end function
# endmacro
@@ -58,50 +53,46 @@ D_PROC(enum_b ptr, RESULT_ENUM_BPTR)
# undef D_PROC
-sub test_simple cdecl ()
-
+sub test cdecl( )
dim intvar as integer
dim uintvar as uinteger
dim fltvar as single
dim dblvar as double
dim lngvar as longint
dim barvar as ENUM_A
dim bazvar as ENUM_B
-
+
CU_ASSERT_EQUAL( proc( intvar ), RESULT_INT )
CU_ASSERT_EQUAL( proc( uintvar ), RESULT_UINT )
CU_ASSERT_EQUAL( proc( fltvar ), RESULT_SNG )
CU_ASSERT_EQUAL( proc( dblvar ), RESULT_DBL )
CU_ASSERT_EQUAL( proc( lngvar ), RESULT_LNG )
CU_ASSERT_EQUAL( proc( barvar ), RESULT_ENUM_A )
CU_ASSERT_EQUAL( proc( bazvar ), RESULT_ENUM_B )
-
+
dim intptrvar as integer ptr
dim uintptrvar as uinteger ptr
dim fltptrvar as single ptr
dim dblptrvar as double ptr
dim lngptrvar as longint ptr
dim barptrvar as ENUM_A ptr
dim bazptrvar as ENUM_B ptr
-
+
CU_ASSERT_EQUAL( proc( intptrvar ), RESULT_INTPTR )
CU_ASSERT_EQUAL( proc( uintptrvar ), RESULT_UINTPTR )
CU_ASSERT_EQUAL( proc( fltptrvar ), RESULT_SNGPTR )
CU_ASSERT_EQUAL( proc( dblptrvar ), RESULT_DBLPTR )
CU_ASSERT_EQUAL( proc( lngptrvar ), RESULT_LNGPTR )
CU_ASSERT_EQUAL( proc( barptrvar ), RESULT_ENUM_APTR )
CU_ASSERT_EQUAL( proc( bazptrvar ), RESULT_ENUM_BPTR )
-
+
CU_ASSERT_EQUAL( proc( cdbl( intvar ) ), RESULT_DBL )
CU_ASSERT_EQUAL( proc( intvar + dblvar ), RESULT_DBL )
-
end sub
-private sub ctor () constructor
-
- fbcu.add_suite("fb-tests-overload:simple")
- fbcu.add_test("test_simple", @test_simple)
-
+private sub ctor( ) constructor
+ fbcu.add_suite( "tests/overload/simple" )
+ fbcu.add_test( "simple", @test )
end sub
end namespace
View
26 tests/overload/void_resolution.bas
@@ -1,26 +0,0 @@
-' TEST_MODE : COMPILE_AND_RUN_OK
-
-#if 0 '' incomplete test
-
-type TrueType : __ as integer : end type
-type FalseType : __ as integer : end type
-
-function IsUDT overload ( byval p as byte ptr ) as FalseType : end function
-function IsUDT overload ( byval p as short ptr ) as FalseType : end function
-function IsUDT overload ( byval p as integer ptr ) as FalseType : end function
-function IsUDT overload ( byval p as any ptr ) as TrueType : end function
-
-dim a as byte
-dim b as short
-dim c as integer
-dim d as T
-
-'' Before r5156:
-
-' the following gives `error 88: Ambiguous call to overloaded function, ISUDT() in '# print typeof((IsUDT(@a)))'`
-assert(IsUDT(@a) = 0)
-assert(IsUDT(@b) = 0)
-assert(IsUDT(@c) = 0)
-assert(IsUDT(@d) = -1)
-
-#endif

0 comments on commit 820ab59

Please sign in to comment.
Something went wrong with that request. Please try again.