Add a C++ phase. Fixes bug #800
authorLemmih <lemmih@gmail.com>
Thu, 27 Jul 2006 08:00:23 +0000 (08:00 +0000)
committerLemmih <lemmih@gmail.com>
Thu, 27 Jul 2006 08:00:23 +0000 (08:00 +0000)
compiler/main/DriverPhases.hs
compiler/main/DriverPipeline.hs

index 6e94531..875c9f6 100644 (file)
@@ -71,6 +71,7 @@ data Phase
        | Cpp   HscSource
        | HsPp  HscSource
        | Hsc   HscSource
+        | Ccpp
        | Cc
        | HCc           -- Haskellised C (as opposed to vanilla C) compilation
        | Mangle        -- assembly mangling, now done by a separate script.
@@ -99,6 +100,7 @@ eqPhase (Unlit _)   (Unlit _)        = True
 eqPhase (Cpp   _)   (Cpp   _)  = True
 eqPhase (HsPp  _)   (HsPp  _)  = True
 eqPhase (Hsc   _)   (Hsc   _)  = True
+eqPhase Ccpp       Ccpp        = True
 eqPhase Cc         Cc          = True
 eqPhase HCc        HCc         = True
 eqPhase Mangle     Mangle      = True
@@ -129,6 +131,7 @@ nextPhase Mangle    = SplitMangle
 nextPhase SplitMangle  = As
 nextPhase As           = SplitAs
 nextPhase SplitAs      = StopLn
+nextPhase Ccpp         = As
 nextPhase Cc           = As
 nextPhase CmmCpp       = Cmm
 nextPhase Cmm          = HCc
@@ -145,10 +148,10 @@ startPhase "hspp"     = Hsc   HsSrcFile
 startPhase "hcr"      = Hsc   ExtCoreFile
 startPhase "hc"       = HCc
 startPhase "c"        = Cc
-startPhase "cpp"      = Cc
+startPhase "cpp"      = Ccpp
 startPhase "C"        = Cc
-startPhase "cc"       = Cc
-startPhase "cxx"      = Cc
+startPhase "cc"       = Ccpp
+startPhase "cxx"      = Ccpp
 startPhase "raw_s"    = Mangle
 startPhase "split_s"  = SplitMangle
 startPhase "s"        = As
@@ -171,6 +174,7 @@ phaseInputExt (Hsc   _)       = "hspp"      -- intermediate only
        --     because runPipeline uses the StopBefore phase to pick the
        --     output filename.  That could be fixed, but watch out.
 phaseInputExt HCc                = "hc"  
+phaseInputExt Ccpp               = "cpp"
 phaseInputExt Cc                 = "c"
 phaseInputExt Mangle             = "raw_s"
 phaseInputExt SplitMangle        = "split_s"   -- not really generated
index c0f5e7b..690328d 100644 (file)
@@ -789,7 +789,7 @@ runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc
 -- way too many hacks, and I can't say I've ever used it anyway.
 
 runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc
-   | cc_phase `eqPhase` Cc || cc_phase `eqPhase` HCc
+   | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc
    = do        let cc_opts = getOpts dflags opt_c
            hcc = cc_phase `eqPhase` HCc
 
@@ -851,7 +851,8 @@ runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc
                -- compiling .hc files, by adding the -x c option.
                -- Also useful for plain .c files, just in case GHC saw a 
                -- -x c option.
-                       [ SysTools.Option "-x", SysTools.Option "c"] ++
+                       [ SysTools.Option "-x", if cc_phase `eqPhase` Ccpp
+                                                then SysTools.Option "c++" else SysTools.Option "c"] ++
                        [ SysTools.FileOption "" input_fn
                        , SysTools.Option "-o"
                        , SysTools.FileOption "" output_fn