diff options
author | heterodoxic <122719743+heterodoxic@users.noreply.github.com> | 2024-02-19 20:59:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 20:59:14 +0100 |
commit | 9a4623033547ffa0d6746c91b9817b8353ed8361 (patch) | |
tree | 593f3c3d5c5f6cc38cb2e26ac77254e5dac3f416 | |
parent | 92c8c6d5f4e5a96b71bf4eca5f6a136410f97d6e (diff) | |
download | Nim-9a4623033547ffa0d6746c91b9817b8353ed8361.tar.gz |
assume a module's usage if it contains a passC/passL/compile pragma w… (#23323)
…hich conveys effects beyond its module scope for C/C++ codegen(suppresses current UnusedImport warning) Just a minor inconvenience working in the area of C/C++ integration I guess, but here we go: I noticed receiving ```UnusedImport``` warnings for modules having only ```passC```/```passL```/```compile``` pragmas around. I gather the compiler cannot actually infer those modules being unused as they *may* have consequences for the whole build process (as they did in my simple case). Thus, I hereby suggest adding the `sfUsed` flag to the respective module in order to suppress the compiler's warning. I reckon other pragmas should be put into consideration as well: I will keep up the investigation with PR followups.
-rw-r--r-- | compiler/pragmas.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index a4c539799..d85c52a93 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -1129,13 +1129,20 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, of wFatal: fatal(c.config, it.info, expectStrLit(c, it)) of wDefine: processDefine(c, it, sym) of wUndef: processUndef(c, it) - of wCompile: processCompile(c, it) + of wCompile: + let m = sym.getModule() + incl(m.flags, sfUsed) + processCompile(c, it) of wLink: processLink(c, it) of wPassl: + let m = sym.getModule() + incl(m.flags, sfUsed) let s = expectStrLit(c, it) extccomp.addLinkOption(c.config, s) recordPragma(c, it, "passl", s) of wPassc: + let m = sym.getModule() + incl(m.flags, sfUsed) let s = expectStrLit(c, it) extccomp.addCompileOption(c.config, s) recordPragma(c, it, "passc", s) |