parent
c8554ebc0c
commit
8df20276c9
2 changed files with 7 additions and 4 deletions
|
|
@ -975,6 +975,9 @@ proc genProcBody(p: BProc; procBody: PNode) =
|
||||||
p.blocks[0].sections[cpsLocals].add(ropecg(p.module, "NIM_BOOL* nimErr_;$n", []))
|
p.blocks[0].sections[cpsLocals].add(ropecg(p.module, "NIM_BOOL* nimErr_;$n", []))
|
||||||
p.blocks[0].sections[cpsInit].add(ropecg(p.module, "nimErr_ = #nimErrorFlag();$n", []))
|
p.blocks[0].sections[cpsInit].add(ropecg(p.module, "nimErr_ = #nimErrorFlag();$n", []))
|
||||||
|
|
||||||
|
proc isNoReturn(m: BModule; s: PSym): bool {.inline.} =
|
||||||
|
sfNoReturn in s.flags and m.config.exc != excGoto
|
||||||
|
|
||||||
proc genProcAux(m: BModule, prc: PSym) =
|
proc genProcAux(m: BModule, prc: PSym) =
|
||||||
var p = newProc(prc, m)
|
var p = newProc(prc, m)
|
||||||
var header = genProcHeader(m, prc)
|
var header = genProcHeader(m, prc)
|
||||||
|
|
@ -1029,7 +1032,7 @@ proc genProcAux(m: BModule, prc: PSym) =
|
||||||
|
|
||||||
var generatedProc: Rope
|
var generatedProc: Rope
|
||||||
generatedProc.genCLineDir prc.info, m.config
|
generatedProc.genCLineDir prc.info, m.config
|
||||||
if sfNoReturn in prc.flags:
|
if isNoReturn(p.module, prc):
|
||||||
if hasDeclspec in extccomp.CC[p.config.cCompiler].props:
|
if hasDeclspec in extccomp.CC[p.config.cCompiler].props:
|
||||||
header = "__declspec(noreturn) " & header
|
header = "__declspec(noreturn) " & header
|
||||||
if sfPure in prc.flags:
|
if sfPure in prc.flags:
|
||||||
|
|
@ -1092,13 +1095,13 @@ proc genProcPrototype(m: BModule, sym: PSym) =
|
||||||
let asPtr = isReloadable(m, sym)
|
let asPtr = isReloadable(m, sym)
|
||||||
var header = genProcHeader(m, sym, asPtr)
|
var header = genProcHeader(m, sym, asPtr)
|
||||||
if not asPtr:
|
if not asPtr:
|
||||||
if sfNoReturn in sym.flags and hasDeclspec in extccomp.CC[m.config.cCompiler].props:
|
if isNoReturn(m, sym) and hasDeclspec in extccomp.CC[m.config.cCompiler].props:
|
||||||
header = "__declspec(noreturn) " & header
|
header = "__declspec(noreturn) " & header
|
||||||
if sym.typ.callConv != ccInline and requiresExternC(m, sym):
|
if sym.typ.callConv != ccInline and requiresExternC(m, sym):
|
||||||
header = "extern \"C\" " & header
|
header = "extern \"C\" " & header
|
||||||
if sfPure in sym.flags and hasAttribute in CC[m.config.cCompiler].props:
|
if sfPure in sym.flags and hasAttribute in CC[m.config.cCompiler].props:
|
||||||
header.add(" __attribute__((naked))")
|
header.add(" __attribute__((naked))")
|
||||||
if sfNoReturn in sym.flags and hasAttribute in CC[m.config.cCompiler].props:
|
if isNoReturn(m, sym) and hasAttribute in CC[m.config.cCompiler].props:
|
||||||
header.add(" __attribute__((noreturn))")
|
header.add(" __attribute__((noreturn))")
|
||||||
m.s[cfsProcHeaders].add(ropecg(m, "$1;$N", [header]))
|
m.s[cfsProcHeaders].add(ropecg(m, "$1;$N", [header]))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -904,7 +904,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
of wNoreturn:
|
of wNoreturn:
|
||||||
noVal(c, it)
|
noVal(c, it)
|
||||||
# Disable the 'noreturn' annotation when in the "Quirky Exceptions" mode!
|
# Disable the 'noreturn' annotation when in the "Quirky Exceptions" mode!
|
||||||
if c.config.exc notin {excQuirky, excGoto}:
|
if c.config.exc != excQuirky:
|
||||||
incl(sym.flags, sfNoReturn)
|
incl(sym.flags, sfNoReturn)
|
||||||
if sym.typ[0] != nil:
|
if sym.typ[0] != nil:
|
||||||
localError(c.config, sym.ast[paramsPos][0].info,
|
localError(c.config, sym.ast[paramsPos][0].info,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue