fixes #21995: align C++ with C backend behavior for empty raise state… (#21998)

* fixes #21995: align C with C++ backend behavior for empty raise statements

* make runtime behavior match across both C and C++ backend and all exception modes
This commit is contained in:
heterodoxic
2023-06-07 15:15:08 +02:00
committed by GitHub
parent 47fa7506ab
commit 7fad6e5c70
2 changed files with 10 additions and 5 deletions

View File

@@ -779,11 +779,7 @@ proc genRaiseStmt(p: BProc, t: PNode) =
else:
finallyActions(p)
genLineDir(p, t)
# reraise the last exception:
if p.config.exc == excCpp:
line(p, cpsStmts, "throw;\n")
else:
linefmt(p, cpsStmts, "#reraiseException();$n", [])
linefmt(p, cpsStmts, "#reraiseException();$n", [])
raiseInstr(p, p.s(cpsStmts))
template genCaseGenericBranch(p: BProc, b: PNode, e: TLoc,

9
tests/ccgbugs/t21995.nim Normal file
View File

@@ -0,0 +1,9 @@
discard """
targets: "c cpp"
output: "Hi!"
"""
try:
raise
except:
echo "Hi!"