Can pragma-based warning suppression reliably silence diagnostics from macro expansions?
0 reputation · 22 Jul 2020, 15:34 UTC
Goal: Assess if the local warning suppression pragma ({.push warning: off.} / {.pop.}) can be relied upon to hide diagnostics that are emitted from within macro or template expansions.
Constraints: The suppression applies lexically to the surrounding source block, but macros can inject code that is compiled outside that block, potentially causing warnings to leak. Additionally, Nim’s --strictDefs flag can promote certain hints to errors, and verbosity levels may alter which diagnostics are shown, making the effective suppression dependent on compiler version and flags.
Questions:
- Does {.push warning: off.} suppress warnings generated inside the body of a macro when the macro is instantiated?
- Are warnings emitted by instantiated generic code within a suppressed block still shown?
- How do --strictDefs and verbosity settings interact with pragma‑based suppression for macro‑produced diagnostics?