@@ -2736,7 +2736,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
27362736 bool TrappingMathPresent = false ; // Is trapping-math in args, and not
27372737 // overriden by ffp-exception-behavior?
27382738 bool RoundingFPMath = false ;
2739- bool RoundingMathPresent = false ; // Is rounding-math in args?
27402739 // -ffp-model values: strict, fast, precise
27412740 StringRef FPModel = " " ;
27422741 // -ffp-exception-behavior options: strict, maytrap, ignore
@@ -2799,11 +2798,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
27992798 }
28002799
28012800 for (const Arg *A : Args) {
2802- auto optID = A->getOption ().getID ();
2803- bool PreciseFPModel = false ;
2804- switch (optID) {
2805- default :
2806- break ;
2801+ switch (A->getOption ().getID ()) {
2802+ // If this isn't an FP option skip the claim below
2803+ default : continue ;
2804+
28072805 case options::OPT_fcx_limited_range:
28082806 if (GccRangeComplexOption.empty ()) {
28092807 if (Range != LangOptions::ComplexRangeKind::CX_Basic)
@@ -2895,7 +2893,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
28952893 AssociativeMath = false ;
28962894 ReciprocalMath = false ;
28972895 SignedZeros = true ;
2898- // -fno_fast_math restores default denormal and fpcontract handling
28992896 FPContract = " on" ;
29002897
29012898 StringRef Val = A->getValue ();
@@ -2906,10 +2903,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29062903 break ;
29072904 }
29082905 StrictFPModel = false ;
2909- PreciseFPModel = true ;
2910- // ffp-model= is a Driver option, it is entirely rewritten into more
2911- // granular options before being passed into cc1.
2912- // Use the gcc option in the switch below.
29132906 if (!FPModel.empty () && !FPModel.equals (Val))
29142907 D.Diag (clang::diag::warn_drv_overriding_option)
29152908 << Args.MakeArgString (" -ffp-model=" + FPModel)
@@ -2918,27 +2911,20 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29182911 FPModel = Val;
29192912 applyFastMath ();
29202913 } else if (Val.equals (" precise" )) {
2921- optID = options::OPT_ffp_contract;
29222914 FPModel = Val;
29232915 FPContract = " on" ;
2924- PreciseFPModel = true ;
29252916 } else if (Val.equals (" strict" )) {
29262917 StrictFPModel = true ;
2927- optID = options::OPT_frounding_math;
29282918 FPExceptionBehavior = " strict" ;
29292919 FPModel = Val;
29302920 FPContract = " off" ;
29312921 TrappingMath = true ;
2922+ RoundingFPMath = true ;
29322923 } else
29332924 D.Diag (diag::err_drv_unsupported_option_argument)
29342925 << A->getSpelling () << Val;
29352926 break ;
29362927 }
2937- }
2938-
2939- switch (optID) {
2940- // If this isn't an FP option skip the claim below
2941- default : continue ;
29422928
29432929 // Options controlling individual features
29442930 case options::OPT_fhonor_infinities: HonorINFs = true ; break ;
@@ -2982,12 +2968,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29822968
29832969 case options::OPT_frounding_math:
29842970 RoundingFPMath = true ;
2985- RoundingMathPresent = true ;
29862971 break ;
29872972
29882973 case options::OPT_fno_rounding_math:
29892974 RoundingFPMath = false ;
2990- RoundingMathPresent = false ;
29912975 break ;
29922976
29932977 case options::OPT_fdenormal_fp_math_EQ:
@@ -3010,13 +2994,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30102994 // Validate and pass through -ffp-contract option.
30112995 case options::OPT_ffp_contract: {
30122996 StringRef Val = A->getValue ();
3013- if (PreciseFPModel) {
3014- // -ffp-model=precise enables ffp-contract=on.
3015- // -ffp-model=precise sets PreciseFPModel to on and Val to
3016- // "precise". FPContract is set.
3017- ;
3018- } else if (Val.equals (" fast" ) || Val.equals (" on" ) || Val.equals (" off" ) ||
3019- Val.equals (" fast-honor-pragmas" )) {
2997+ if (Val.equals (" fast" ) || Val.equals (" on" ) || Val.equals (" off" ) ||
2998+ Val.equals (" fast-honor-pragmas" )) {
30202999 FPContract = Val;
30213000 LastSeenFfpContractOption = Val;
30223001 } else
@@ -3025,13 +3004,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30253004 break ;
30263005 }
30273006
3028- // Validate and pass through -ffp-model option.
3029- case options::OPT_ffp_model_EQ:
3030- // This should only occur in the error case
3031- // since the optID has been replaced by a more granular
3032- // floating point option.
3033- break ;
3034-
30353007 // Validate and pass through -ffp-exception-behavior option.
30363008 case options::OPT_ffp_exception_behavior_EQ: {
30373009 StringRef Val = A->getValue ();
@@ -3152,6 +3124,12 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31523124 }
31533125 break ;
31543126 }
3127+ // The StrictFPModel local variable is needed to report warnings
3128+ // in the way we intend. If -ffp-model=strict has been used, we
3129+ // want to report a warning for the next option encountered that
3130+ // takes us out of the settings described by fp-model=strict, but
3131+ // we don't want to continue issuing warnings for other conflicting
3132+ // options after that.
31553133 if (StrictFPModel) {
31563134 // If -ffp-model=strict has been specified on command line but
31573135 // subsequent options conflict then emit warning diagnostic.
@@ -3225,11 +3203,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
32253203 if (!FPContract.empty ())
32263204 CmdArgs.push_back (Args.MakeArgString (" -ffp-contract=" + FPContract));
32273205
3228- if (!RoundingFPMath)
3229- CmdArgs.push_back (Args.MakeArgString (" -fno-rounding-math" ));
3230-
3231- if (RoundingFPMath && RoundingMathPresent)
3206+ if (RoundingFPMath)
32323207 CmdArgs.push_back (Args.MakeArgString (" -frounding-math" ));
3208+ else
3209+ CmdArgs.push_back (Args.MakeArgString (" -fno-rounding-math" ));
32333210
32343211 if (!FPExceptionBehavior.empty ())
32353212 CmdArgs.push_back (Args.MakeArgString (" -ffp-exception-behavior=" +
0 commit comments