From d26bd802c6e5b16575741f36b9d6c95261fc8049 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sat, 27 Jan 2024 16:30:54 +0100 Subject: [PATCH] Fix #255: suppress additional warnings: tabs, unused-imports Closes #255. --- src/Main.hs | 23 ++++++++++++++++++----- tests/Makefile | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index fdcb7a6..29837a5 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -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 diff --git a/tests/Makefile b/tests/Makefile index 1e0b8aa..9d3466f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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