CPP pragma ignored if top comments and Opt_KeepRawTokenStream
HaRe sets Opt_KeepRawTokenStream
to be able to round trip the source code.
If we have a module starting
{-
A normal comment, to check if we can still pick up the CPP directive after it.
-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE CPP #-}
-- Check that we can parse a file which requires CPP
module BCpp where
bob :: Int -> Int -> Int
#if __GLASGOW_HASKELL__ > 704
bob x y = x + y
#else
bob x y = x + y * 2
#endif
then the call to load LoadAllTargets
via the GHC API fails with
SourceError (lexical error at character 'i'
which is the normal error when #if
is hit and CPP is not enabled.
If Opt_KeepRawTokenStream
is not set it loads without problems.
Also, files using CPP but not having a top comment load properly too.