From 13dfe663b3098fcf135241986ca7b8725cb521d6 Mon Sep 17 00:00:00 2001 From: Ralph Versteegen Date: Mon, 22 Jan 2024 11:46:43 +1300 Subject: [PATCH] fbc/clang: kludgy workaround to fix clang error when compiling with -e The error is "indirect goto in function with no address-of-label expressions" See https://bugs.llvm.org/show_bug.cgi?id=18658 --- changelog.txt | 1 + src/compiler/ir-hlc.bas | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/changelog.txt b/changelog.txt index 4d481cd72..804723f3e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/src/compiler/ir-hlc.bas b/src/compiler/ir-hlc.bas index 51709ff98..3b56cfabe 100644 --- a/src/compiler/ir-hlc.bas +++ b/src/compiler/ir-hlc.bas @@ -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 _