summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
authorSimon Jakobi <simon.jakobi@gmail.com>2018-11-22 11:52:53 -0500
committerBen Gamari <ben@smart-cactus.org>2018-11-22 13:14:02 -0500
commit699e507237ccda65fe9f37651d2358129390e2de (patch)
tree0515530b121307e5421a72d1055474a287bf954e /compiler/parser
parentf2d9fb0c288788abeb796a13d600295a526290cd (diff)
downloadhaskell-699e507237ccda65fe9f37651d2358129390e2de.tar.gz
Remove warnings-silencing flags for code generated by Alex
Current versions of Alex don't seem to produce as many warnings any more. In order to silence a warning and to avoid overlong lines, I've taken the liberty of refactoring 'tok_num'. Test Plan: ./validate Reviewers: bgamari, simonmar Reviewed By: simonmar Subscribers: erikd, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5319
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/Lexer.x54
1 files changed, 9 insertions, 45 deletions
diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x
index f99a344d31..9597f10b0a 100644
--- a/compiler/parser/Lexer.x
+++ b/compiler/parser/Lexer.x
@@ -42,13 +42,7 @@
{
{-# LANGUAGE BangPatterns #-}
-
--- See Note [Warnings in code generated by Alex] in compiler/parser/Lexer.x
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-{-# OPTIONS_GHC -fno-warn-unused-binds #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-{-# OPTIONS_GHC -fno-warn-tabs #-}
-{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
+{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
@@ -1388,13 +1382,15 @@ tok_integral itint transint transbuf translen (radix,char_to_int) span buf len =
(offsetBytes transbuf buf) (subtract translen len) radix char_to_int
tok_num :: (Integer -> Integer)
- -> Int -> Int
- -> (Integer, (Char->Int)) -> Action
-tok_num = tok_integral itint
+ -> Int -> Int
+ -> (Integer, (Char->Int)) -> Action
+tok_num = tok_integral $ \case
+ st@(SourceText ('-':_)) -> itint st (const True)
+ st@(SourceText _) -> itint st (const False)
+ st@NoSourceText -> itint st (< 0)
where
- itint st@(SourceText ('-':str)) val = ITinteger (((IL $! st) $! True) $! val)
- itint st@(SourceText str ) val = ITinteger (((IL $! st) $! False) $! val)
- itint st@(NoSourceText ) val = ITinteger (((IL $! st) $! (val < 0)) $! val)
+ itint :: SourceText -> (Integer -> Bool) -> Integer -> Token
+ itint !st is_negative !val = ITinteger ((IL st $! is_negative val) val)
tok_primint :: (Integer -> Integer)
-> Int -> Int
@@ -3114,36 +3110,4 @@ isDocComment (ITdocCommentNamed _) = True
isDocComment (ITdocSection _ _) = True
isDocComment (ITdocOptions _) = True
isDocComment _ = False
-
-{- Note [Warnings in code generated by Alex]
-
-We add the following warning suppression flags to all code generated by Alex:
-
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-{-# OPTIONS_GHC -fno-warn-unused-binds #-}
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-{-# OPTIONS_GHC -fno-warn-tabs #-}
-{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-
-Without these flags, current versions of Alex will generate code that is not
-warning free. Note that this is the result of Alex' internals, not of the way
-we have written our (Lexer).x files.
-
-As always, we need code to be warning free when validating with -Werror.
-
-The list of flags is as short as possible (at the time of writing), to try to
-avoid suppressing warnings for bugs in our own code.
-
-TODO. Reevaluate this situation once Alex >3.1.4 is released. Hopefully you
-can remove these flags from all (Lexer).x files in the repository, and also
-delete this Note. Don't forget to update aclocal.m4, and send a HEADS UP
-message to ghc-devs.
-
-The first release of Alex after 3.1.4 will either suppress all warnings itself
-[1] (bad), or most warnings will be fixed and only a few select ones will be
-suppressed by default [2] (better).
-
-[1] https://github.com/simonmar/alex/commit/1eefcde22ba1bb9b51d523814415714e20f0761e
-[2] https://github.com/simonmar/alex/pull/69
--}
}