Commit 699e5072 authored by Simon Jakobi's avatar Simon Jakobi Committed by Ben Gamari

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
parent f2d9fb0c
......@@ -958,16 +958,10 @@ else
fi;
changequote([, ])dnl
])
FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-ge],[3.0],
[Alex3=YES],[Alex3=NO])
if test ! -f compiler/cmm/CmmLex.hs || test ! -f compiler/parser/Lexer.hs
then
FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.0],
[AC_MSG_ERROR([Alex version 3.1.0 or later is required to compile GHC.])])[]
fi
FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.7],
[AC_MSG_ERROR([Alex version 3.1.7 or later is required to compile GHC.])])[]
AlexVersion=$fptools_cv_alex_version;
AC_SUBST(AlexVersion)
AC_SUBST(Alex3)
])
......
......@@ -11,13 +11,6 @@
-----------------------------------------------------------------------------
{
-- 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 #-}
module CmmLex (
CmmToken(..), cmmlex,
) where
......
......@@ -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
-}
}
......@@ -859,16 +859,13 @@ SRC_HAPPY_OPTS = -agc --strict
#
ALEX = @AlexCmd@
ALEX_VERSION = @AlexVersion@
Alex3 = @Alex3@
#
# Options to pass to Alex when we're going to compile the output with GHC
#
SRC_ALEX_OPTS = -g
ifeq "$(Alex3)" "YES"
# The compiler isn't using the Unicode support in Alex 3.0 yet, in fact we do our own
# Unicode handling, so diable Alex's.
compiler_ALEX_OPTS = --latin1
endif
# Should we build haddock docs?
HADDOCK_DOCS = YES
......
{
-- 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-tabs #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Lexer (lex_tok) where
import ParserM (ParserM (..), mkT, mkTv, Token(..), start_code,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment