make --exceptions:quirky work with C++ (#21581)

* make --exceptions:quirky work with C++

* make tests green again
This commit is contained in:
Andreas Rumpf
2023-03-31 04:16:09 +02:00
committed by GitHub
parent 2e4ba4ad93
commit d5719c47dc
3 changed files with 7 additions and 5 deletions

View File

@@ -448,7 +448,7 @@ proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
else:
pushCurrentException(e)
{.emit: "throw `e`;".}
elif defined(nimQuirky) or gotoBasedExceptions:
elif quirkyExceptions or gotoBasedExceptions:
pushCurrentException(e)
when gotoBasedExceptions:
inc nimInErrorMode
@@ -560,7 +560,7 @@ proc nimFrame(s: PFrame) {.compilerRtl, inl, raises: [].} =
when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
not defined(js) and not defined(nimscript) and
hostOS != "standalone" and hostOS != "any" and not defined(noCppExceptions) and
not defined(nimQuirky):
not quirkyExceptions:
type
StdException {.importcpp: "std::exception", header: "<exception>".} = object

View File

@@ -9,7 +9,9 @@
{.push profiler: off.}
const gotoBasedExceptions = compileOption("exceptions", "goto")
const
gotoBasedExceptions = compileOption("exceptions", "goto")
quirkyExceptions = compileOption("exceptions", "quirky")
when hostOS == "standalone":
include "$projectpath/panicoverride"
@@ -21,7 +23,7 @@ when hostOS == "standalone":
rawoutput(message)
panic(arg)
elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
elif (quirkyExceptions or defined(nimPanics)) and not defined(nimscript):
import ansi_c
func name(t: typedesc): string {.magic: "TypeTrait".}

View File

@@ -3,7 +3,7 @@ discard """
exitcode: "1"
output: '''
t14444.nim(13) t14444
fatal.nim(51) sysFatal
fatal.nim(53) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
'''
"""