Skip to content

Commit 2c6f957

Browse files
committed
C backend: Fix emitting of Static references with dtype with dtor
1 parent 50c1128 commit 2c6f957

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/compiler/ir-hlc.bas

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,10 @@ end sub
14001400
private sub _scopeEnd( byval s as FBSYMBOL ptr )
14011401
end sub
14021402

1403+
private function hIsStaticWithDtor( byval sym as FBSYMBOL ptr ) as integer
1404+
function = symbIsStatic( sym ) and (not symbIsRef( sym )) and symbHasDtor( sym )
1405+
end function
1406+
14031407
private sub _procAllocStaticVars( byval sym as FBSYMBOL ptr )
14041408
dim as FBSYMBOL ptr desc = any
14051409
dim as integer section = any
@@ -1425,7 +1429,7 @@ private sub _procAllocStaticVars( byval sym as FBSYMBOL ptr )
14251429
'' variable?
14261430
case FB_SYMBCLASS_VAR
14271431
'' static with dtor?
1428-
if( symbIsStatic( sym ) and symbHasDtor( sym ) ) then
1432+
if( hIsStaticWithDtor( sym ) ) then
14291433
hMaybeEmitLocalVar( sym )
14301434

14311435
''
@@ -3115,7 +3119,7 @@ private sub _emitDECL( byval sym as FBSYMBOL ptr )
31153119
'' Emit locals/statics locally, except statics with dtor - those are
31163120
'' handled in _procAllocStaticVars(), including their dynamic array
31173121
'' descriptors (if any).
3118-
if( symbIsStatic( sym ) and symbHasDtor( sym ) ) then
3122+
if( hIsStaticWithDtor( sym ) ) then
31193123
exit sub
31203124
end if
31213125

@@ -3125,7 +3129,7 @@ private sub _emitDECL( byval sym as FBSYMBOL ptr )
31253129
assert( symbIsVar( sym ) )
31263130
array = sym->var_.desc.array
31273131
if( array ) then
3128-
if( symbIsStatic( array ) and symbHasDtor( array ) ) then
3132+
if( hIsStaticWithDtor( array ) ) then
31293133
exit sub
31303134
end if
31313135
end if

0 commit comments

Comments
 (0)