[commit: ghc] ghc-8.0: Use 0/1 instead of YES/NO as `__GLASGOW_HASKELL_TH__` macro value (39237c1)

git at git.haskell.org git at git.haskell.org
Thu Dec 31 21:56:56 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/39237c178f179a7e8d57e6e51e4dcd6881b97ca4/ghc

>---------------------------------------------------------------

commit 39237c178f179a7e8d57e6e51e4dcd6881b97ca4
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Thu Dec 31 21:02:50 2015 +0100

    Use 0/1 instead of YES/NO as `__GLASGOW_HASKELL_TH__` macro value
    
    Using `YES`/`NO` causes all sorts of problems as CPP doesn't work on
    symbolic tokens but rather on scalar values.
    
    A use like
    
       #if __GLASGOW_HASKELL_TH__==YES
       {-# LANGUAGE TemplateHaskell #-}
       #endif
    
    doesn't do what one may naively expect, and neither does
    
       #if __GLASGOW_HASKELL_TH__
       {-# LANGUAGE TemplateHaskell #-}
       #endif
    
    *unless* `YES` happens to evaluate to a non-zero scalar.
    
    `__GLASGOW_HASKELL_TH__ was originally introduced via D396 / #9734.
    
    Fixes #11322
    
    Reviewed By: austin
    
    Differential Revision: https://phabricator.haskell.org/D1723
    
    (cherry picked from commit eae40e16a0933fe3b6cb0ee4dc9cdbe3d21e44ce)


>---------------------------------------------------------------

39237c178f179a7e8d57e6e51e4dcd6881b97ca4
 compiler/main/DriverPipeline.hs  | 4 ++--
 docs/users_guide/8.0.1-notes.rst | 5 +++++
 docs/users_guide/phases.rst      | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 4936ace..23cc6de 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -2026,9 +2026,9 @@ doCpp dflags raw input_fn output_fn = do
     backend_defs <- getBackendDefs dflags
 
 #ifdef GHCI
-    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=YES" ]
+    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=1" ]
 #else
-    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=NO" ]
+    let th_defs = [ "-D__GLASGOW_HASKELL_TH__=0" ]
 #endif
     -- Default CPP defines in Haskell source
     ghcVersionH <- getGhcVersionPathName dflags
diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst
index 0aa221d..013b7b8 100644
--- a/docs/users_guide/8.0.1-notes.rst
+++ b/docs/users_guide/8.0.1-notes.rst
@@ -288,6 +288,11 @@ Template Haskell
    without interpreter support). Also, ``-XTemplateHaskellQuotes`` is
    considered safe under Safe Haskell.
 
+-  The ``__GLASGOW_HASKELL_TH__`` CPP constant denoting support for
+   ``-XTemplateHaskell`` introduced in GHC 7.10.1 has been changed to
+   use the values ``1``/``0`` instead of the previous ``YES``/``NO``
+   values.
+
 -  Partial type signatures can now be used in splices, see
    :ref:`pts-where`.
 
diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index 1c48cfc..cc4244e 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -328,8 +328,8 @@ defined by your local GHC installation, the following trick is useful:
     .. index::
        single: __GLASGOW_HASKELL_TH__
 
-    This is set to ``YES`` when the compiler supports Template Haskell,
-    and to ``NO`` when not. The latter is the case for a stage-1
+    This is set to ``1`` when the compiler supports Template Haskell,
+    and to ``0`` when not. The latter is the case for a stage-1
     compiler during bootstrapping, or on architectures where the
     interpreter is not available.
 



More information about the ghc-commits mailing list