From dd6833297f2d477258541b44203e61782af64c69 Mon Sep 17 00:00:00 2001 From: xflywind <43030857+xflywind@users.noreply.github.com> Date: Wed, 29 Jun 2022 15:54:45 +0800 Subject: [PATCH] add warnings if noinit is ignored --- compiler/cgen.nim | 2 ++ compiler/lineinfos.nim | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 4878c3f322..a9e1f65e3e 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1067,6 +1067,8 @@ proc genProcAux(m: BModule, prc: PSym) = if sfNoInit in prc.flags and p.config.selectedGC notin {gcArc, gcOrc}: discard elif allPathsAsgnResult(procBody) == InitSkippable: discard else: + if sfNoInit in prc.flags and p.config.selectedGC in {gcArc, gcOrc}: + message(m.config, resNode.info, warnNoInitIgnored, "") resetLoc(p, res.loc) if skipTypes(res.typ, abstractInst).kind == tyArray: #incl(res.loc.flags, lfIndirect) diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index 105de1636f..5991f1c31a 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -78,6 +78,7 @@ type warnAnyEnumConv = "AnyEnumConv", warnHoleEnumConv = "HoleEnumConv", warnCstringConv = "CStringConv", + warnNoInitIgnored = "NoInitIgnored" warnEffect = "Effect", warnUser = "User", # hints @@ -170,6 +171,7 @@ const warnAnyEnumConv: "$1", warnHoleEnumConv: "$1", warnCstringConv: "$1", + warnNoInitIgnored: "noInit is ignored", warnEffect: "$1", warnUser: "$1", hintSuccess: "operation successful: $#",