@@ -227,22 +227,31 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
227227
228228 // -{E,EP,P,M,MM} only run the preprocessor.
229229 if (CCCIsCPP () || (PhaseArg = DAL.getLastArg (options::OPT_E)) ||
230+ (PhaseArg = DAL.getLastArg (options::OPT_fsyntax_only)) ||
230231 (PhaseArg = DAL.getLastArg (options::OPT__SLASH_EP)) ||
231232 (PhaseArg = DAL.getLastArg (options::OPT_M, options::OPT_MM)) ||
232233 (PhaseArg = DAL.getLastArg (options::OPT__SLASH_P))) {
233- FinalPhase = phases::Preprocess;
234234
235- // -fsyntax-only stops Fortran compilation after FortranFrontend
236- } else if (IsFortranMode () && (PhaseArg = DAL.getLastArg (options::OPT_fsyntax_only))) {
237- FinalPhase = phases::FortranFrontend;
235+ // -fsyntax-only or -E stops Fortran compilation after FortranFrontend
236+ if (IsFortranMode () && (DAL.getLastArg (options::OPT_E) ||
237+ DAL.getLastArg (options::OPT_fsyntax_only))) {
238+ FinalPhase = phases::FortranFrontend;
239+
240+ // if not Fortran, fsyntax_only implies 'Compile' is the FinalPhase
241+ } else if (DAL.getLastArg (options::OPT_fsyntax_only)) {
242+ FinalPhase = phases::Compile;
243+
244+ // everything else has 'Preprocess' as its FinalPhase
245+ } else {
246+ FinalPhase = phases::Preprocess;
247+ }
238248
239249 // --precompile only runs up to precompilation.
240250 } else if ((PhaseArg = DAL.getLastArg (options::OPT__precompile))) {
241251 FinalPhase = phases::Precompile;
242252
243- // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
244- } else if ((PhaseArg = DAL.getLastArg (options::OPT_fsyntax_only)) ||
245- (PhaseArg = DAL.getLastArg (options::OPT_module_file_info)) ||
253+ // -{analyze,emit-ast} only run up to the compiler.
254+ } else if ((PhaseArg = DAL.getLastArg (options::OPT_module_file_info)) ||
246255 (PhaseArg = DAL.getLastArg (options::OPT_verify_pch)) ||
247256 (PhaseArg = DAL.getLastArg (options::OPT_rewrite_objc)) ||
248257 (PhaseArg = DAL.getLastArg (options::OPT_rewrite_legacy_objc)) ||
0 commit comments