Skip to content

Commit 8291324

Browse files
committed
fbc: g++ ABI - prepare for addition of deleting destructor
- internal changes - rename FB_PROCATTRIB_DESTRUCTOR to FB_PROCATTRIB_DESTRUCTOR1 for the complete destructor - add FB_PROCATTRIB_DESTRUCTOR0 for the deleting destructor - add mangling for complete dtor (D1) and deleting dtor (D0)
1 parent 180516f commit 8291324

File tree

10 files changed

+36
-24
lines changed

10 files changed

+36
-24
lines changed

src/compiler/ast-node-proc.bas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ sub astProcBegin( byval sym as FBSYMBOL ptr, byval ismain as integer )
500500
astNewVAR( symbGetParamVar( argv ) ) )
501501

502502
'' Destructor?
503-
elseif( symbIsDestructor( sym ) and enable_implicit_code ) then
503+
elseif( symbIsDestructor1( sym ) and enable_implicit_code ) then
504504
''
505505
'' If the UDT has a vptr, reset it at the top of destructors,
506506
'' such that the vptr always matches the type of object that
@@ -673,7 +673,7 @@ function astProcEnd( byval callrtexit as integer ) as integer
673673

674674
if( res ) then
675675
'' Destructor?
676-
if( symbIsDestructor( sym ) and enable_implicit_code ) then
676+
if( symbIsDestructor1( sym ) and enable_implicit_code ) then
677677
'' Call destructors, behind the exit label, so they'll
678678
'' always be called, even with early returns.
679679
hCallDtors( sym )

src/compiler/error.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ private function hMakeParamDesc _
878878
pname = strptr( s )
879879
'' method?
880880
elseif( (proc->pattrib and (FB_PROCATTRIB_CONSTRUCTOR or _
881-
FB_PROCATTRIB_DESTRUCTOR or _
881+
FB_PROCATTRIB_DESTRUCTOR1 or FB_PROCATTRIB_DESTRUCTOR0 or _
882882
FB_PROCATTRIB_OPERATOR)) <> 0 ) then
883883
s = symbMethodToStr( proc )
884884
pname = strptr( s )

src/compiler/parser-compound.bas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ sub cExitStatement( )
317317
if( symbGetType( parser.currproc ) = FB_DATATYPE_VOID ) then
318318
if( (parser.currproc->pattrib and _
319319
(FB_PROCATTRIB_PROPERTY or FB_PROCATTRIB_OPERATOR or _
320-
FB_PROCATTRIB_CONSTRUCTOR or FB_PROCATTRIB_DESTRUCTOR)) <> 0 ) then
320+
FB_PROCATTRIB_CONSTRUCTOR or FB_PROCATTRIB_DESTRUCTOR1 or FB_PROCATTRIB_DESTRUCTOR0)) <> 0 ) then
321321
errnum = FB_ERRMSG_ILLEGALOUTSIDEASUB
322322
end if
323323
else
@@ -328,7 +328,7 @@ sub cExitStatement( )
328328
if( symbGetType( parser.currproc ) <> FB_DATATYPE_VOID ) then
329329
if( (parser.currproc->pattrib and _
330330
(FB_PROCATTRIB_PROPERTY or FB_PROCATTRIB_OPERATOR or _
331-
FB_PROCATTRIB_CONSTRUCTOR or FB_PROCATTRIB_DESTRUCTOR)) <> 0 ) then
331+
FB_PROCATTRIB_CONSTRUCTOR or FB_PROCATTRIB_DESTRUCTOR1 or FB_PROCATTRIB_DESTRUCTOR0)) <> 0 ) then
332332
errnum = FB_ERRMSG_ILLEGALOUTSIDEAFUNCTION
333333
else
334334
errnum = hCheckForCtorResult( )
@@ -357,7 +357,7 @@ sub cExitStatement( )
357357
end if
358358

359359
case FB_TK_DESTRUCTOR
360-
if( symbIsDestructor( parser.currproc ) = FALSE ) then
360+
if( symbIsDestructor1( parser.currproc ) = FALSE ) then
361361
errnum = FB_ERRMSG_ILLEGALOUTSIDEADTOR
362362
end if
363363

src/compiler/parser-proc.bas

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,9 @@ function cProcHeader _
10561056
if( tk = FB_TK_CONSTRUCTOR ) then
10571057
pattrib or= FB_PROCATTRIB_CONSTRUCTOR or FB_PROCATTRIB_OVERLOADED
10581058
else
1059-
pattrib or= FB_PROCATTRIB_DESTRUCTOR
1059+
'' destructor defined by user source is always the complete dtor
1060+
'' the deleting dtor is implicitly defined later
1061+
pattrib or= FB_PROCATTRIB_DESTRUCTOR1
10601062
end if
10611063

10621064
case FB_TK_OPERATOR
@@ -1762,7 +1764,9 @@ sub cProcStmtBegin( byval attrib as FB_SYMBATTRIB, byval pattrib as FB_PROCATTRI
17621764
if( fbLangOptIsSet( FB_LANG_OPT_CLASS ) = FALSE ) then
17631765
errReportNotAllowed( FB_LANG_OPT_CLASS )
17641766
else
1765-
pattrib or= FB_PROCATTRIB_DESTRUCTOR
1767+
'' destructor defined by user source is always the complete dtor
1768+
'' the deleting dtor is implicitly defined later
1769+
pattrib or= FB_PROCATTRIB_DESTRUCTOR1
17661770
end if
17671771

17681772
hDisallowStaticAttrib( attrib, pattrib )

src/compiler/rtl-array.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private sub hCheckDtor _
331331

332332
if( dtor = NULL ) then exit sub
333333

334-
assert( symbIsDestructor( dtor ) )
334+
assert( symbIsDestructor1( dtor ) )
335335

336336
if( check_access ) then
337337
if( symbCheckAccess( dtor ) = FALSE ) then

src/compiler/symb-comp.bas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ sub symbUdtDeclareDefaultMembers _
619619

620620
'' no default dtor explicitly defined?
621621
if( udt->udt.ext->dtor = NULL ) then
622-
'' Dtor
623-
default.dtor = hDeclareProc( udt, INVALID, FB_DATATYPE_INVALID, FB_SYMBATTRIB_NONE, FB_PROCATTRIB_DESTRUCTOR )
622+
'' Complete Dtor
623+
default.dtor = hDeclareProc( udt, INVALID, FB_DATATYPE_INVALID, FB_SYMBATTRIB_NONE, FB_PROCATTRIB_DESTRUCTOR1 )
624624

625625
'' Don't allow the implicit dtor to override a FINAL dtor from the base
626626
symbProcCheckOverridden( default.dtor, TRUE )
@@ -785,7 +785,7 @@ end sub
785785

786786
sub symbSetCompDtor( byval sym as FBSYMBOL ptr, byval proc as FBSYMBOL ptr )
787787
if( symbIsStruct( sym ) ) then
788-
assert( symbIsDestructor( proc ) )
788+
assert( symbIsDestructor1( proc ) )
789789
symbUdtAllocExt( sym )
790790
if( sym->udt.ext->dtor = NULL ) then
791791
'' Add dtor

src/compiler/symb-mangling.bas

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,9 @@ private sub hMangleProc( byval sym as FBSYMBOL ptr )
12781278
end if
12791279
elseif( symbIsConstructor( sym ) ) then
12801280
mangled += "C1"
1281-
elseif( symbIsDestructor( sym ) ) then
1281+
elseif( symbIsDestructor0( sym ) ) then
1282+
mangled += "D0"
1283+
elseif( symbIsDestructor1( sym ) ) then
12821284
mangled += "D1"
12831285
else
12841286
if( symbGetMangling( sym ) = FB_MANGLING_BASIC ) then

src/compiler/symb-proc.bas

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ private function hSetupProc _
716716

717717
'' ctor/dtor?
718718
if( (pattrib and (FB_PROCATTRIB_CONSTRUCTOR or _
719-
FB_PROCATTRIB_DESTRUCTOR)) <> 0 ) then
719+
FB_PROCATTRIB_DESTRUCTOR1 or FB_PROCATTRIB_DESTRUCTOR0)) <> 0 ) then
720720

721721
assert( pattrib and FB_PROCATTRIB_METHOD )
722722

@@ -748,7 +748,7 @@ private function hSetupProc _
748748
'' otherwise, try to overload
749749
else
750750
'' dtor?
751-
if( (pattrib and FB_PROCATTRIB_DESTRUCTOR) <> 0 ) then
751+
if( (pattrib and (FB_PROCATTRIB_DESTRUCTOR1 or FB_PROCATTRIB_DESTRUCTOR0)) <> 0 ) then
752752
'' can't overload
753753
return NULL
754754
end if
@@ -920,8 +920,8 @@ add_proc:
920920
overridden = NULL
921921
if( parent->udt.base ) then
922922
'' Destructor?
923-
if( symbIsDestructor( proc ) ) then
924-
'' There can always only be one, so there is no
923+
if( symbIsDestructor1( proc ) ) then
924+
'' There can always only be one complete dtor, so there is no
925925
'' need to do a lookup and/or overload checks.
926926
overridden = symbGetCompDtor( parent->udt.base->subtype )
927927
elseif( symbIsOperator( proc ) ) then
@@ -1601,7 +1601,7 @@ function symbFindCtorProc _
16011601
) as FBSYMBOL ptr
16021602

16031603
'' dtor? can't overload..
1604-
if( symbIsDestructor( ovl_head_proc ) ) then
1604+
if( symbIsDestructor1( ovl_head_proc ) ) then
16051605
return ovl_head_proc
16061606
else
16071607
return symbFindOverloadProc( ovl_head_proc, proc )
@@ -2845,7 +2845,7 @@ sub symbProcCheckOverridden _
28452845
'' implicit dtors and LET overloads. Since they
28462846
'' are not visible in the original code,
28472847
'' the error message must have more info.
2848-
if( symbIsDestructor( proc ) ) then
2848+
if( symbIsDestructor1( proc ) ) then
28492849
errmsg = FB_ERRMSG_IMPLICITDTOROVERRIDECALLCONVDIFFERS
28502850
else
28512851
errmsg = FB_ERRMSG_IMPLICITLETOVERRIDECALLCONVDIFFERS
@@ -2916,7 +2916,7 @@ end sub
29162916
'' Append calling convention, if it differs from the default
29172917
private sub hProcModeToStr( byref s as string, byval proc as FBSYMBOL ptr )
29182918
'' Ctors/Dtors currently always default to CDECL, see cProcHeader()
2919-
if( symbIsConstructor( proc ) or symbIsDestructor( proc ) ) then
2919+
if( symbIsConstructor( proc ) or symbIsDestructor1( proc ) or symbIsDestructor0( proc ) ) then
29202920
select case( symbGetProcMode( proc ) )
29212921
case FB_FUNCMODE_STDCALL, FB_FUNCMODE_STDCALL_MS
29222922
s += " stdcall"
@@ -3045,7 +3045,9 @@ function symbGetFullProcName( byval proc as FBSYMBOL ptr ) as zstring ptr
30453045

30463046
if( symbIsConstructor( proc ) ) then
30473047
res += "constructor"
3048-
elseif( symbIsDestructor( proc ) ) then
3048+
elseif( symbIsDestructor1( proc ) ) then
3049+
res += "destructor"
3050+
elseif( symbIsDestructor0( proc ) ) then
30493051
res += "destructor"
30503052
elseif( symbIsOperator( proc ) ) then
30513053
res += "operator."

src/compiler/symb.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,8 @@ function symbDumpToStr _
25062506
checkPAttrib( OVERLOADED )
25072507
checkPAttrib( METHOD )
25082508
checkPAttrib( CONSTRUCTOR )
2509-
checkPAttrib( DESTRUCTOR )
2509+
checkPAttrib( DESTRUCTOR1 )
2510+
checkPAttrib( DESTRUCTOR0 )
25102511
checkPAttrib( OPERATOR )
25112512
checkPAttrib( PROPERTY )
25122513
checkPAttrib( RETURNBYREF )

src/compiler/symb.bi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ enum FB_PROCATTRIB
191191
FB_PROCATTRIB_OVERLOADED = &h00000001 '' PROCs / METHODs only
192192
FB_PROCATTRIB_METHOD = &h00000002 '' Non-STATIC UDT member procs, i.e. procs with implicit THIS ptr
193193
FB_PROCATTRIB_CONSTRUCTOR = &h00000004 '' methods only
194-
FB_PROCATTRIB_DESTRUCTOR = &h00000008 '' methods only
194+
FB_PROCATTRIB_DESTRUCTOR1 = &h00000008 '' methods only
195195
FB_PROCATTRIB_OPERATOR = &h00000010 '' methods only
196196
FB_PROCATTRIB_PROPERTY = &h00000020 '' methods only
197197
FB_PROCATTRIB_STATICLOCALS = &h00000040 '' PROCs only
@@ -200,6 +200,7 @@ enum FB_PROCATTRIB
200200
FB_PROCATTRIB_ABSTRACT = &h00000200 '' methods only: pure virtuals (only)
201201
FB_PROCATTRIB_NOTHISCONSTNESS = &h00000400 '' PROCs only
202202
FB_PROCATTRIB_RETURNBYREF = &h00000800 '' PROCs (functions/function pointers returning BYREF)
203+
FB_PROCATTRIB_DESTRUCTOR0 = &h00001000 '' methods only - deleting destructor
203204
end enum
204205

205206
'' parameter modes
@@ -2498,7 +2499,9 @@ declare sub symbProcRecalcRealType( byval proc as FBSYMBOL ptr )
24982499

24992500
#define symbIsConstructor(s) ((s->pattrib and FB_PROCATTRIB_CONSTRUCTOR) <> 0)
25002501

2501-
#define symbIsDestructor(s) ((s->pattrib and FB_PROCATTRIB_DESTRUCTOR) <> 0)
2502+
#define symbIsDestructor0(s) ((s->pattrib and FB_PROCATTRIB_DESTRUCTOR0) <> 0)
2503+
2504+
#define symbIsDestructor1(s) ((s->pattrib and FB_PROCATTRIB_DESTRUCTOR1) <> 0)
25022505

25032506
#define symbIsOperator(s) ((s->pattrib and FB_PROCATTRIB_OPERATOR) <> 0)
25042507

0 commit comments

Comments
 (0)