Skip to content

Commit 943d487

Browse files
Compile clash-ghc warning free on GHC 9.12
1 parent 7ceb967 commit 943d487

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

clash-ghc/src-ghc/Clash/GHC/GHC2Core.hs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,11 @@ coreToTerm primMap unlocs = term
692692
LitFloat r -> C.FloatLiteral . floatToWord $ fromRational r
693693
LitDouble r -> C.DoubleLiteral . doubleToWord $ fromRational r
694694
LitNullAddr -> C.StringLiteral []
695+
#if MIN_VERSION_ghc(9,12,0)
696+
LitLabel fs _ -> C.StringLiteral (unpackFS fs)
697+
#else
695698
LitLabel fs _ _ -> C.StringLiteral (unpackFS fs)
699+
#endif
696700

697701
addUsefull :: SrcSpan
698702
-> C2C a
@@ -746,6 +750,7 @@ hasPrimCo (ForAllCo {fco_body = co}) = hasPrimCo co
746750
hasPrimCo (ForAllCo _ _ co) = hasPrimCo co
747751
#endif
748752

753+
#if !MIN_VERSION_ghc(9,12,0)
749754
hasPrimCo co@(AxiomInstCo _ _ coers) = do
750755
let (Pair ty1 _) = coercionKind co
751756
ty1PM <- isPrimTc ty1
@@ -764,6 +769,7 @@ hasPrimCo co@(AxiomInstCo _ _ coers) = do
764769
,"Clash.Sized.Internal.Unsigned.Unsigned"
765770
])
766771
isPrimTc _ = return False
772+
#endif
767773

768774
hasPrimCo (SymCo co) = hasPrimCo co
769775

@@ -773,7 +779,11 @@ hasPrimCo (TransCo co1 co2) = do
773779
Just _ -> return tc1M
774780
_ -> hasPrimCo co2
775781

782+
#if MIN_VERSION_ghc(9,12,0)
783+
hasPrimCo (AxiomCo _ coers) = do
784+
#else
776785
hasPrimCo (AxiomRuleCo _ coers) = do
786+
#endif
777787
tcs <- catMaybes <$> mapM hasPrimCo coers
778788
return (listToMaybe tcs)
779789

@@ -786,7 +796,13 @@ hasPrimCo (LRCo _ co) = hasPrimCo co
786796
hasPrimCo (InstCo co _) = hasPrimCo co
787797
hasPrimCo (SubCo co) = hasPrimCo co
788798

789-
hasPrimCo _ = return Nothing
799+
hasPrimCo (Refl {}) = return Nothing
800+
hasPrimCo (GRefl {}) = return Nothing
801+
hasPrimCo (FunCo {}) = return Nothing
802+
hasPrimCo (CoVarCo {}) = return Nothing
803+
hasPrimCo (UnivCo {}) = return Nothing
804+
hasPrimCo (KindCo {}) = return Nothing
805+
hasPrimCo (HoleCo {}) = return Nothing
790806

791807
coreToDataCon :: DataCon
792808
-> C2C C.DataCon

clash-ghc/src-ghc/Clash/GHC/Util.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ import GhcPlugins (DynFlags, SourceError, ($$), blankLine, empty, isGood
5757
#endif
5858
import GHC (GhcMonad(..), printException)
5959

60-
import Control.Exception (Exception(..), ErrorCall(..))
60+
#if !MIN_VERSION_ghc(9,12,0)
61+
import Control.Exception (ErrorCall(..))
62+
#endif
63+
import Control.Exception (Exception(..))
6164
import GHC.Exception (SomeException)
6265
import System.Exit (ExitCode(ExitFailure), exitWith)
6366

@@ -100,6 +103,7 @@ handleClashException df opts e = case fromException e of
100103
#endif
101104
(blankLine $$ textLines s $$ blankLine $$ srcInfo' $$ showExtra (opt_errorExtra opts) eM))
102105
_ -> case fromException e of
106+
#if !MIN_VERSION_ghc(9,12,0)
103107
Just (ErrorCallWithLocation _ _) ->
104108
throwOneError
105109
#if MIN_VERSION_ghc(9,8,0)
@@ -115,6 +119,7 @@ handleClashException df opts e = case fromException e of
115119
#endif
116120
(text "Clash error call:" $$ textLines (show e)))
117121
_ -> case fromException e of
122+
#endif
118123
Just (e' :: SourceError) -> do
119124
GHC.printException e'
120125
liftIO $ exitWith (ExitFailure 1)

0 commit comments

Comments
 (0)