From 95856ab8d3db88709c39c6809e81b8ea539b2e8b Mon Sep 17 00:00:00 2001 From: Andrii Riabushenko Date: Thu, 25 Jul 2019 23:07:43 +0100 Subject: [PATCH] add test --- compiler/pragmas.nim | 8 ++++++-- tests/pragmas/twarning_off.nim | 17 +++++++++++++++++ tests/pragmas/warn_module.nim | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/pragmas/twarning_off.nim create mode 100644 tests/pragmas/warn_module.nim diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 9e3976e73..93ac29027 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -321,8 +321,12 @@ proc processNote(c: PContext, n: PNode) = let x = c.semConstBoolExpr(c, n[1]) n.sons[1] = x - if x.kind == nkIntLit and x.intVal != 0: incl(c.config.notes, nk) - else: excl(c.config.notes, nk) + if x.kind == nkIntLit and x.intVal != 0: + incl(c.config.notes, nk) + incl(c.optionStack[^1].notes, nk) + else: + excl(c.config.notes, nk) + excl(c.optionStack[^1].notes, nk) else: invalidPragma(c, n) diff --git a/tests/pragmas/twarning_off.nim b/tests/pragmas/twarning_off.nim new file mode 100644 index 000000000..1b86c6299 --- /dev/null +++ b/tests/pragmas/twarning_off.nim @@ -0,0 +1,17 @@ +discard """ + nimout: ''' +compile start +Hint: warn_module [Processing] +Hint: hashes [Processing] +warn_module.nim(4, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed] +compile end +''' +""" + +static: + echo "compile start" + +import warn_module + +static: + echo "compile end" diff --git a/tests/pragmas/warn_module.nim b/tests/pragmas/warn_module.nim new file mode 100644 index 000000000..0d1e5f419 --- /dev/null +++ b/tests/pragmas/warn_module.nim @@ -0,0 +1,7 @@ + +{.warning[UnusedImport]: off.} + +import hashes + +proc test(a: float): float = + a