fixes #22101; std/pegs with nim cpp --mm:orc --exceptions:goto creates invalid C++ (#24531)

fixes #22101

The old implementation generates

`auto T = value;` for the cpp backend which causes problems for goto
exceptions. This PR puts the declaration of `T` to the cpsLocals parts
and makes it compatible with goto exceptions.

(cherry picked from commit f7a461a30c)
This commit is contained in:
ringabout
2024-12-13 05:56:41 +08:00
committed by narimiran
parent 428b64251f
commit e2b6021630
2 changed files with 2 additions and 2 deletions

View File

@@ -135,7 +135,7 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
d.snippet = pl
excl d.flags, lfSingleUse
else:
if d.k == locNone and p.splitDecls == 0:
if d.k == locNone and p.splitDecls == 0 and p.config.exc != excGoto:
d = getTempCpp(p, typ.returnType, pl)
else:
if d.k == locNone: d = getTemp(p, typ.returnType)

View File

@@ -1,5 +1,5 @@
discard """
matrix: "--mm:refc; --mm:orc"
matrix: "--mm:refc; --mm:orc; --exceptions:goto"
targets: "c cpp js"
output: '''
PEG AST traversal output