Skip to content

Commit

Permalink
fixes #22101; std/pegs with nim cpp --mm:orc --exceptions:goto create…
Browse files Browse the repository at this point in the history
…s 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.
  • Loading branch information
ringabout authored Dec 12, 2024
1 parent f796c01 commit f7a461a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/ccgcalls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc,
d.snippet = extract(result)
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, extract(result))
else:
if d.k == locNone: d = getTemp(p, typ.returnType)
Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/tpegs.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f7a461a

Please sign in to comment.