Added the -fwarn-type-defaults compiler option (for when integer literals are given a default type) and fixed the few warnings that arose from doing so

This commit is contained in:
Neil Brown 2007-09-27 13:29:16 +00:00
parent 38c409d378
commit 15ecb2b178
6 changed files with 14 additions and 13 deletions

View File

@ -15,6 +15,7 @@ ghc_opts = \
-fallow-undecidable-instances \
-fwarn-unused-binds \
-fwarn-unused-imports \
-fwarn-type-defaults \
-icommon -itransformations -ifrontends -ibackends \
$(profile_opts)

View File

@ -307,7 +307,7 @@ cgenOverArray ops m var func
tell ["_sizes[", show v, "]; "]
call genVariable ops i
tell ["++) {\n"]
| (v, i) <- zip [0..] indices]
| (v :: Integer, i) <- zip [0..] indices]
p
sequence_ [tell ["}\n"] | _ <- indices]
Nothing -> return ()
@ -1043,6 +1043,7 @@ cgenArrayAbbrev :: GenOps -> A.Variable -> (CGen (), A.Name -> CGen ())
cgenArrayAbbrev ops v
= (tell ["&"] >> call genVariable ops v, genAASize v 0)
where
genAASize :: A.Variable -> Integer -> A.Name -> CGen ()
genAASize (A.SubscriptedVariable _ (A.Subscript _ _) v) arg
= genAASize v (arg + 1)
genAASize (A.Variable _ on) arg

View File

@ -1196,7 +1196,7 @@ cppgenOverArray ops m var func
tell [".extent(", show v, "); "]
call genVariable ops i
tell ["++) {\n"]
| (v, i) <- zip [0..] indices]
| (v :: Integer, i) <- zip [0..] indices]
p
sequence_ [tell ["}\n"] | _ <- indices]
Nothing -> return ()

View File

@ -93,12 +93,6 @@ debugAST p
veryDebug $ pshow ps
veryDebug $ "}}}"
-- | Number lines in a piece of text.
numberLines :: String -> String
numberLines s
= concat $ intersperse "\n" $ [show n ++ ": " ++ s
| (n, s) <- zip [1..] (lines s)]
-- | Make a generic rule for a pass.
makeGeneric :: (Data t) => (forall s. Data s => s -> PassM s) -> t -> PassM t
makeGeneric top

View File

@ -128,7 +128,7 @@ checkMatch m@(Match con items) b
else (gmapQi index (checkMatch f) d)
--Possibly a better way?
where
numIndexes = length (gmapQ (const 0) d)
numIndexes = length (gmapQ (const undefined) d)
{-

View File

@ -70,20 +70,24 @@ constantFoldPass = everywhereASTM doExpression
annnotateIntLiteralTypes :: Data t => t -> PassM t
annnotateIntLiteralTypes = everywhereASTM doExpression
where
--Function is separated out to easily provide the type description of Integer
powOf2 :: Integer -> Integer
powOf2 x = 2 ^ x
doExpression :: A.Expression -> PassM A.Expression
doExpression (A.Literal m t (A.IntLiteral m' s))
= do t' <-
if (t == A.Int64) then --it's a signed literal
(if (n >= 2^63 || n < (-(2^63)))
(if (n >= powOf2 63 || n < (-(powOf2 63)))
then dieP m $ "Signed integer literal too large to fit into 64 bits: " ++ s
else
if (n < (-(2^31)) || n >= 2^31)
if (n < (-(powOf2 31)) || n >= powOf2 31)
then return A.Int64
else
if (n < (-(2^15)) || n >= 2^15)
if (n < (-(powOf2 15)) || n >= powOf2 15)
then return A.Int32
else
if (n < (-(2^7)) || n >= 2^7)
if (n < (-(powOf2 7)) || n >= powOf2 7)
then return A.Int16
else return A.Int8
)
@ -91,6 +95,7 @@ annnotateIntLiteralTypes = everywhereASTM doExpression
dieP m $ "Unsigned literals currently unsupported"
return $ A.Literal m t' (A.IntLiteral m' s)
where
n :: Integer
n = read s
doExpression e = return e