Skip to content

Commit d26bd80

Browse files
committed
Fix #255: suppress additional warnings: tabs, unused-imports
Closes #255.
1 parent 24d786c commit d26bd80

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/Main.hs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,25 @@ injectCode (Just (AlexPn _ ln _,code)) filename hdl = do
364364
hPutStrLn hdl code
365365

366366
optsToInject :: Target -> [CLIFlags] -> [String]
367-
optsToInject target _ = optNoWarnings : "{-# LANGUAGE CPP #-}" : case target of
368-
GhcTarget -> ["{-# LANGUAGE MagicHash #-}"]
369-
_ -> []
367+
optsToInject target _ = concat
368+
[ optNoWarnings
369+
, [ "{-# LANGUAGE CPP #-}" ]
370+
, [ "{-# LANGUAGE MagicHash #-}" | target == GhcTarget ]
371+
]
370372

371-
optNoWarnings :: String
372-
optNoWarnings = "{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}"
373+
-- List here all harmless warnings caused by Alex-generated code.
374+
--
375+
-- These will be suppressed so that they are not printed
376+
-- when users turn on @-Wall@ in their lexer project.
377+
--
378+
optNoWarnings :: [String]
379+
optNoWarnings =
380+
map (("{-# OPTIONS_GHC -fno-warn-" ++) . (++ " #-}"))
381+
[ "missing-signatures"
382+
, "tabs"
383+
, "unused-binds"
384+
, "unused-imports"
385+
]
373386

374387
importsToInject :: Target -> [CLIFlags] -> String
375388
importsToInject _ cli = always_imports ++ debug_imports ++ glaexts_import

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GHC_SHIPS_WITH_TEXT:=$(shell if [ $(GHC_MAJOR_VERSION) -gt 8 -o $(GHC_MAJOR_VERS
3939
# Turn off x-partial warning (new in GHC 9.8)
4040
WARNS_DEP_GHC_GTEQ_9_8:=$(shell if [ $(GHC_MAJOR_VERSION) -gt 9 -o $(GHC_MAJOR_VERSION) -ge 9 -a $(GHC_MINOR_VERSION) -ge 8 ]; then echo "-Wno-x-partial"; fi)
4141

42-
HC_OPTS=-Wall $(WARNS_DEP_GHC_GTEQ_9_8) -fwarn-incomplete-uni-patterns -fno-warn-missing-signatures -fno-warn-unused-imports -fno-warn-tabs -Werror
42+
HC_OPTS=-Wall $(WARNS_DEP_GHC_GTEQ_9_8) -fwarn-incomplete-uni-patterns -Werror
4343

4444
.PRECIOUS: %.n.hs %.g.hs %.o %.exe %.bin
4545

0 commit comments

Comments
 (0)