Skip to content

Commit

Permalink
Fix #255: suppress additional warnings: tabs, unused-imports
Browse files Browse the repository at this point in the history
Closes #255.
  • Loading branch information
andreasabel committed Jan 27, 2024
1 parent 24d786c commit d26bd80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,25 @@ injectCode (Just (AlexPn _ ln _,code)) filename hdl = do
hPutStrLn hdl code

optsToInject :: Target -> [CLIFlags] -> [String]
optsToInject target _ = optNoWarnings : "{-# LANGUAGE CPP #-}" : case target of
GhcTarget -> ["{-# LANGUAGE MagicHash #-}"]
_ -> []
optsToInject target _ = concat
[ optNoWarnings
, [ "{-# LANGUAGE CPP #-}" ]
, [ "{-# LANGUAGE MagicHash #-}" | target == GhcTarget ]
]

optNoWarnings :: String
optNoWarnings = "{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}"
-- List here all harmless warnings caused by Alex-generated code.
--
-- These will be suppressed so that they are not printed
-- when users turn on @-Wall@ in their lexer project.
--
optNoWarnings :: [String]
optNoWarnings =
map (("{-# OPTIONS_GHC -fno-warn-" ++) . (++ " #-}"))
[ "missing-signatures"
, "tabs"
, "unused-binds"
, "unused-imports"
]

importsToInject :: Target -> [CLIFlags] -> String
importsToInject _ cli = always_imports ++ debug_imports ++ glaexts_import
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GHC_SHIPS_WITH_TEXT:=$(shell if [ $(GHC_MAJOR_VERSION) -gt 8 -o $(GHC_MAJOR_VERS
# Turn off x-partial warning (new in GHC 9.8)
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)

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
HC_OPTS=-Wall $(WARNS_DEP_GHC_GTEQ_9_8) -fwarn-incomplete-uni-patterns -Werror

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

Expand Down

0 comments on commit d26bd80

Please sign in to comment.