Print which flag controls emitted SafeHaskell warnings
authorHerbert Valerio Riedel <hvr@gnu.org>
Sat, 27 Feb 2016 17:48:04 +0000 (18:48 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Sat, 27 Feb 2016 17:48:04 +0000 (18:48 +0100)
This is extends bb5afd3c274011c5ea302210b4c290ec1f83209c to cover
SafeHaskell warnings.

This implements yet another part of #10752

20 files changed:
compiler/main/HscMain.hs
testsuite/tests/safeHaskell/flags/SafeFlags22.stderr
testsuite/tests/safeHaskell/flags/SafeFlags23.stderr
testsuite/tests/safeHaskell/flags/SafeFlags25.stderr
testsuite/tests/safeHaskell/flags/SafeFlags26.stderr
testsuite/tests/safeHaskell/overlapping/SH_Overlap11.stderr
testsuite/tests/safeHaskell/overlapping/SH_Overlap7.stderr
testsuite/tests/safeHaskell/safeInfered/SafeInfered05.stderr
testsuite/tests/safeHaskell/safeInfered/SafeWarn01.stderr
testsuite/tests/safeHaskell/safeInfered/TrustworthySafe02.stderr
testsuite/tests/safeHaskell/safeInfered/TrustworthySafe03.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered11.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeInfered12.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn01.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn02.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn03.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn04.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn05.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn06.stderr
testsuite/tests/safeHaskell/safeInfered/UnsafeWarn07.stderr

index d9aae24..aaf9a9b 100644 (file)
@@ -450,12 +450,16 @@ tcRnModule' hsc_env sum save_rn_syntax mod = do
             safe <- liftIO $ fst <$> readIORef (tcg_safeInfer tcg_res')
             when safe $ do
               case wopt Opt_WarnSafe dflags of
-                True -> (logWarnings $ unitBag $ mkPlainWarnMsg dflags
-                       (warnSafeOnLoc dflags) $ errSafe tcg_res')
+                True -> (logWarnings $ unitBag $
+                         makeIntoWarning (Reason Opt_WarnSafe) $
+                         mkPlainWarnMsg dflags (warnSafeOnLoc dflags) $
+                         errSafe tcg_res')
                 False | safeHaskell dflags == Sf_Trustworthy &&
                         wopt Opt_WarnTrustworthySafe dflags ->
-                  (logWarnings $ unitBag $ mkPlainWarnMsg dflags
-                    (trustworthyOnLoc dflags) $ errTwthySafe tcg_res')
+                        (logWarnings $ unitBag $
+                         makeIntoWarning (Reason Opt_WarnTrustworthySafe) $
+                         mkPlainWarnMsg dflags (trustworthyOnLoc dflags) $
+                         errTwthySafe tcg_res')
                 False -> return ()
             return tcg_res'
   where
@@ -1095,7 +1099,7 @@ markUnsafeInfer tcg_env whyUnsafe = do
     dflags <- getDynFlags
 
     when (wopt Opt_WarnUnsafe dflags)
-         (logWarnings $ unitBag $
+         (logWarnings $ unitBag $ makeIntoWarning (Reason Opt_WarnUnsafe) $
              mkPlainWarnMsg dflags (warnUnsafeOnLoc dflags) (whyUnsafe' dflags))
 
     liftIO $ writeIORef (tcg_safeInfer tcg_env) (False, whyUnsafe)
index 5e1801c..42d10b3 100644 (file)
@@ -1,7 +1,7 @@
 
-SafeFlags22.hs:1:16: Warning:
+SafeFlags22.hs:1:16: warning: [-Wunsafe]
     ‘SafeFlags22’ has been inferred as unsafe!
     Reason:
-        SafeFlags22.hs:7:1:
+        SafeFlags22.hs:7:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
index b2a5709..f4e46c2 100644 (file)
@@ -1,10 +1,10 @@
 
-SafeFlags23.hs:1:16: Warning:
+SafeFlags23.hs:1:16: warning: [-Wunsafe]
     ‘SafeFlags22’ has been inferred as unsafe!
     Reason:
-        SafeFlags23.hs:7:1:
+        SafeFlags23.hs:7:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
 
-<no location info>: 
+<no location info>: error: 
 Failing due to -Werror.
index 434ea2b..bf82025 100644 (file)
@@ -1,3 +1,3 @@
 
-SafeFlags25.hs:1:16: Warning:
+SafeFlags25.hs:1:16: warning: [-Wsafe]
     ‘SafeFlags25’ has been inferred as safe!
index 47dd882..bc27ac2 100644 (file)
@@ -1,6 +1,6 @@
 
-SafeFlags26.hs:1:16: Warning:
+SafeFlags26.hs:1:16: warning: [-Wsafe]
     ‘SafeFlags26’ has been inferred as safe!
 
-<no location info>: 
+<no location info>: error: 
 Failing due to -Werror.
index 76d7779..aca02ef 100644 (file)
@@ -2,17 +2,18 @@
 [2 of 3] Compiling SH_Overlap11_A   ( SH_Overlap11_A.hs, SH_Overlap11_A.o )
 [3 of 3] Compiling SH_Overlap11     ( SH_Overlap11.hs, SH_Overlap11.o )
 
-SH_Overlap11.hs:1:16: warning:
+SH_Overlap11.hs:1:16: warning: [-Wunsafe]
     ‘SH_Overlap11’ has been inferred as unsafe!
     Reason:
         SH_Overlap11.hs:17:8: warning:
-            Unsafe overlapping instances for C [Int] arising from a use of ‘f’
-            The matching instance is:
-              instance [overlap ok] [safe] C [Int]
-                -- Defined at SH_Overlap11_A.hs:11:3
-            It is compiled in a Safe module and as such can only
-            overlap instances from the same module, however it
-            overlaps the following instances from different modules:
-              instance C [a] -- Defined at SH_Overlap11.hs:13:3
-            In the expression: f ([1, 2, 3, 4] :: [Int])
-            In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int])
+            • Unsafe overlapping instances for C [Int]
+                arising from a use of ‘f’
+              The matching instance is:
+                instance [overlap ok] [safe] C [Int]
+                  -- Defined at SH_Overlap11_A.hs:11:3
+              It is compiled in a Safe module and as such can only
+              overlap instances from the same module, however it
+              overlaps the following instances from different modules:
+                instance C [a] -- Defined at SH_Overlap11.hs:13:3
+            • In the expression: f ([1, 2, 3, 4] :: [Int])
+              In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int])
index 088d0f0..8010407 100644 (file)
@@ -2,20 +2,21 @@
 [2 of 3] Compiling SH_Overlap7_A    ( SH_Overlap7_A.hs, SH_Overlap7_A.o )
 [3 of 3] Compiling SH_Overlap7      ( SH_Overlap7.hs, SH_Overlap7.o )
 
-SH_Overlap7.hs:1:16: warning:
+SH_Overlap7.hs:1:16: warning: [-Wunsafe]
     ‘SH_Overlap7’ has been inferred as unsafe!
     Reason:
         SH_Overlap7.hs:14:8: warning:
-            Unsafe overlapping instances for C [Int] arising from a use of ‘f’
-            The matching instance is:
-              instance [overlap ok] [safe] C [Int]
-                -- Defined at SH_Overlap7_A.hs:12:3
-            It is compiled in a Safe module and as such can only
-            overlap instances from the same module, however it
-            overlaps the following instances from different modules:
-              instance C [a] -- Defined at SH_Overlap7.hs:10:10
-            In the expression: f ([1, 2, 3, 4] :: [Int])
-            In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int])
+            • Unsafe overlapping instances for C [Int]
+                arising from a use of ‘f’
+              The matching instance is:
+                instance [overlap ok] [safe] C [Int]
+                  -- Defined at SH_Overlap7_A.hs:12:3
+              It is compiled in a Safe module and as such can only
+              overlap instances from the same module, however it
+              overlaps the following instances from different modules:
+                instance C [a] -- Defined at SH_Overlap7.hs:10:10
+            • In the expression: f ([1, 2, 3, 4] :: [Int])
+              In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int])
 
 <no location info>: error: 
 Failing due to -Werror.
index 0690054..5d19406 100644 (file)
@@ -3,6 +3,6 @@ SafeInfered05.hs:2:14: warning:
     -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
 [1 of 2] Compiling SafeInfered05_A  ( SafeInfered05_A.hs, SafeInfered05_A.o )
 
-SafeInfered05_A.hs:2:16: warning:
+SafeInfered05_A.hs:2:16: warning: [-Wsafe]
     ‘SafeInfered05_A’ has been inferred as safe!
 [2 of 2] Compiling SafeInfered05    ( SafeInfered05.hs, SafeInfered05.o )
index e9849d9..5e824de 100644 (file)
@@ -1,3 +1,3 @@
 
-SafeWarn01.hs:2:16: Warning:
+SafeWarn01.hs:2:16: warning: [-Wsafe]
     ‘SafeWarn01’ has been inferred as safe!
index 68bf4e9..7d42cb0 100644 (file)
@@ -1,3 +1,3 @@
 
-TrustworthySafe02.hs:1:14: Warning:
+TrustworthySafe02.hs:1:14: warning: [-Wtrustworthy-safe (in -Wall)]
     ‘TrustworthySafe02’ is marked as Trustworthy but has been inferred as safe!
index 9505d06..9938109 100644 (file)
@@ -1,3 +1,3 @@
 
-TrustworthySafe03.hs:1:14: Warning:
+TrustworthySafe03.hs:1:14: warning: [-Wtrustworthy-safe (in -Wall)]
     ‘TrustworthySafe03’ is marked as Trustworthy but has been inferred as safe!
index d1cfe99..18a6a45 100644 (file)
@@ -1,13 +1,13 @@
 [1 of 2] Compiling UnsafeInfered11_A ( UnsafeInfered11_A.hs, UnsafeInfered11_A.o )
 
-UnsafeInfered11_A.hs:1:16: Warning:
+UnsafeInfered11_A.hs:1:16: warning: [-Wunsafe]
     ‘UnsafeInfered11_A’ has been inferred as unsafe!
     Reason:
-        UnsafeInfered11_A.hs:17:11: Warning:
+        UnsafeInfered11_A.hs:17:11: warning:
             Rule "lookupx/T" ignored
             User defined rules are disabled under Safe Haskell
 [2 of 2] Compiling UnsafeInfered11  ( UnsafeInfered11.hs, UnsafeInfered11.o )
 
-UnsafeInfered11.hs:5:1:
+UnsafeInfered11.hs:5:1: error:
     UnsafeInfered11_A: Can't be safely imported!
     The module itself isn't safe.
index 470e1b7..74cf60d 100644 (file)
@@ -1,9 +1,9 @@
 
-UnsafeInfered12.hs:2:16: Warning:
+UnsafeInfered12.hs:2:16: warning: [-Wunsafe]
     ‘UnsafeInfered12’ has been inferred as unsafe!
     Reason:
         UnsafeInfered12.hs:1:14:
             -XTemplateHaskell is not allowed in Safe Haskell
 
-<no location info>: 
+<no location info>: error: 
 Failing due to -Werror.
index 1ef043a..6d2afb2 100644 (file)
@@ -1,7 +1,7 @@
 
-UnsafeWarn01.hs:2:16: Warning:
+UnsafeWarn01.hs:2:16: warning: [-Wunsafe]
     ‘UnsafeWarn01’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn01.hs:7:1:
+        UnsafeWarn01.hs:7:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
index 7421ad0..2ee83ac 100644 (file)
@@ -1,5 +1,5 @@
 
-UnsafeWarn02.hs:2:16: Warning:
+UnsafeWarn02.hs:2:16: warning: [-Wunsafe]
     ‘UnsafeWarn02’ has been inferred as unsafe!
     Reason:
         UnsafeWarn02.hs:4:14:
index a3d44ba..6ddea45 100644 (file)
@@ -1,7 +1,7 @@
 
-UnsafeWarn03.hs:3:16: Warning:
+UnsafeWarn03.hs:3:16: warning: [-Wunsafe]
     ‘UnsafeWarn03’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn03.hs:8:1:
+        UnsafeWarn03.hs:8:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
index 66deff4..c91f421 100644 (file)
@@ -1,7 +1,7 @@
 
-UnsafeWarn04.hs:3:16: Warning:
+UnsafeWarn04.hs:3:16: warning: [-Wunsafe]
     ‘UnsafeWarn04’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn04.hs:8:1:
+        UnsafeWarn04.hs:8:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
index 229ce3d..dfd4193 100644 (file)
@@ -1,14 +1,14 @@
 
-UnsafeWarn05.hs:4:16: Warning:
+UnsafeWarn05.hs:4:16: warning: [-Wunsafe]
     ‘UnsafeWarn05’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn05.hs:10:1:
+        UnsafeWarn05.hs:10:1: error:
             System.IO.Unsafe: Can't be safely imported!
             The module itself isn't safe.
 
-UnsafeWarn05.hs:4:16: Warning:
+UnsafeWarn05.hs:4:16: warning: [-Wunsafe]
     ‘UnsafeWarn05’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn05.hs:15:11: Warning:
+        UnsafeWarn05.hs:15:11: warning:
             Rule "g" ignored
             User defined rules are disabled under Safe Haskell
index 8fde73e..323bb19 100644 (file)
@@ -1,7 +1,7 @@
 
-UnsafeWarn06.hs:3:16: Warning:
+UnsafeWarn06.hs:3:16: warning: [-Wunsafe]
     ‘UnsafeWarn06’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn06.hs:8:11: Warning:
+        UnsafeWarn06.hs:8:11: warning:
             Rule "f" ignored
             User defined rules are disabled under Safe Haskell
index c5c5e63..11116b6 100644 (file)
@@ -1,7 +1,7 @@
 
-UnsafeWarn07.hs:4:16: Warning:
+UnsafeWarn07.hs:4:16: warning: [-Wunsafe]
     ‘UnsafeWarn07’ has been inferred as unsafe!
     Reason:
-        UnsafeWarn07.hs:9:11: Warning:
+        UnsafeWarn07.hs:9:11: warning:
             Rule "f" ignored
             User defined rules are disabled under Safe Haskell