Skip to content

Commit cc8d5df

Browse files
Don't warn about 'prepositive-qualified-module' in Paths_pkgs
Enabling '-Wprepositive-qualified-module' in a project leads to warnings when used in combination with Cabal's Paths_* feature. Given that this is code outside of a user's control, this warning should be disabled locally.
1 parent a5106be commit cc8d5df

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed

Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ render z_root = execWriter $ do
4141
return ()
4242
else do
4343
return ()
44+
if (zSupportsCpp z_root)
45+
then do
46+
tell "#if __GLASGOW_HASKELL__ >= 810\n"
47+
tell "{-# OPTIONS_GHC -Wno-prepositive-qualified-module #-}\n"
48+
tell "#endif\n"
49+
return ()
50+
else do
51+
return ()
4452
tell "{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}\n"
4553
tell "{-# OPTIONS_GHC -w #-}\n"
4654
tell "module Paths_"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = return ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: PathsModule
2+
version: 0.1
3+
license: BSD3
4+
author: Martijn Bastiaan
5+
category: PackageTests
6+
build-type: Simple
7+
Cabal-version: >= 1.2
8+
9+
description:
10+
Check that the generated paths module compiles.
11+
12+
Executable TestPathsModule
13+
main-is: Main.hs
14+
if impl(ghc >= 8.10.0)
15+
ghc-options: -Werror -fwarn-prepositive-qualified-module
16+
other-modules: Paths_PathsModule
17+
build-depends: base
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Setup configure
2+
Configuring PathsModule-0.1...
3+
# Setup build
4+
Preprocessing executable 'TestPathsModule' for PathsModule-0.1..
5+
Building executable 'TestPathsModule' for PathsModule-0.1..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Setup configure
2+
Configuring PathsModule-0.1...
3+
# Setup build
4+
Preprocessing executable 'TestPathsModule' for PathsModule-0.1..
5+
Building executable 'TestPathsModule' for PathsModule-0.1..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Test.Cabal.Prelude
2+
-- Test that Paths module is generated and available for executables.
3+
main = setupAndCabalTest $ setup_build []
4+

templates/Paths_pkg.template.hs

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
{% if not absolute %}
88
{-# LANGUAGE ForeignFunctionInterface #-}
99
{% endif %}
10+
{% if supportsCpp %}
11+
#if __GLASGOW_HASKELL__ >= 810
12+
{-# OPTIONS_GHC -Wno-prepositive-qualified-module #-}
13+
#endif
14+
{% endif %}
1015
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
1116
{-# OPTIONS_GHC -w #-}
1217
module Paths_{{ manglePkgName packageName }} (

0 commit comments

Comments
 (0)