Skip to content

Commit

Permalink
fbc/clang: kludgy workaround to fix clang error when compiling with -e
Browse files Browse the repository at this point in the history
The error is "indirect goto in function with no address-of-label expressions"
See https://bugs.llvm.org/show_bug.cgi?id=18658
  • Loading branch information
rversteegen committed Jan 22, 2024
1 parent 26e2970 commit 13dfe66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -55,6 +55,7 @@ Version 1.20.0
- sf.net #659: Keep the stack 16-byte aligned on linux-x86, android-x86 and darwin-x86 to comply with ABI; fixes crashes when external libraries use SSE
- rtlib: win32/win64: MULTIKEY() on consoles track console focus, remove the 'FindWindow' logic for console windows and handle FOCUS_EVENT message to track focus (adeyblue)
- rtlib: win32/win64: MULTIKEY() always returns true; don't call GetAsyncKeyState(0), seem that in windows terminal, dragging a console tab out of the terminal window triggers key 0 and is never reset resulting in MULTIKEY() always returning true
- fbc: when compiling with "-e -gen clang", work around a "indirect goto in function with no address-of-label expressions" clang error


Version 1.10.2
Expand Down
10 changes: 10 additions & 0 deletions src/compiler/ir-hlc.bas
Expand Up @@ -4000,6 +4000,16 @@ private sub _emitProcBegin _
hWriteLine( "{" )
sectionIndent( )

if( (env.clopt.backend = FB_BACKEND_CLANG) and (env.clopt.errorcheck = TRUE) ) then
'' Compiling with -e
'' Work around an error clang unnecessarily throws if a function
'' contains a computed goto but no address-of-label operator.
'' See https://bugs.llvm.org/show_bug.cgi?id=18658
'' (TODO: We emit computed gotos for RESUME/ON ERROR GOTO
'' support (-ex) but also unnecessarily use them to terminate
'' the program after fb_ErrorThrowAt when compiled only with -e)
hWriteLine( "_unusedlabel: ; void *_llvmbug18658 = &&_unusedlabel;" )
end if
end sub

private sub _emitProcEnd _
Expand Down

0 comments on commit 13dfe66

Please sign in to comment.