diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index e488412af7..a6c1917792 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -1318,8 +1318,12 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, pragmaProposition(c, it) of wEnsures: pragmaEnsures(c, it) - of wEnforceNoRaises, wQuirky: + of wEnforceNoRaises: sym.flags.incl sfNeverRaises + of wQuirky: + sym.flags.incl sfNeverRaises + if sym.kind in {skProc, skMethod, skConverter, skFunc, skIterator}: + sym.options.incl optQuirky of wSystemRaisesDefect: sym.flags.incl sfSystemRaisesDefect of wVirtual: diff --git a/lib/system/arc.nim b/lib/system/arc.nim index 7537fd2125..d67af9817a 100644 --- a/lib/system/arc.nim +++ b/lib/system/arc.nim @@ -87,6 +87,9 @@ else: template count(x: Cell): untyped = x.rc shr rcShift +when not defined(nimHasQuirky): + {.pragma: quirky.} + proc nimNewObj(size, alignment: int): pointer {.compilerRtl.} = let hdrSize = align(sizeof(RefHeader), alignment) let s = size + hdrSize @@ -190,7 +193,7 @@ proc nimRawDispose(p: pointer, alignment: int) {.compilerRtl.} = template `=dispose`*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x), T.alignOf) #proc dispose*(x: pointer) = nimRawDispose(x) -proc nimDestroyAndDispose(p: pointer) {.compilerRtl, raises: [].} = +proc nimDestroyAndDispose(p: pointer) {.compilerRtl, quirky, raises: [].} = let rti = cast[ptr PNimTypeV2](p) if rti.destructor != nil: cast[DestructorProc](rti.destructor)(p) diff --git a/tests/arc/tvalgrind.nim b/tests/arc/tvalgrind.nim new file mode 100644 index 0000000000..27d089d153 --- /dev/null +++ b/tests/arc/tvalgrind.nim @@ -0,0 +1,16 @@ +discard """ + cmd: "nim c --mm:orc -d:useMalloc $file" + valgrind: "true" +""" + +import std/streams + + +proc foo() = + var name = newStringStream("2r2") + raise newException(ValueError, "sh") + +try: + foo() +except: + discard \ No newline at end of file