@@ -2736,7 +2736,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2736
2736
bool TrappingMathPresent = false ; // Is trapping-math in args, and not
2737
2737
// overriden by ffp-exception-behavior?
2738
2738
bool RoundingFPMath = false ;
2739
- bool RoundingMathPresent = false ; // Is rounding-math in args?
2740
2739
// -ffp-model values: strict, fast, precise
2741
2740
StringRef FPModel = " " ;
2742
2741
// -ffp-exception-behavior options: strict, maytrap, ignore
@@ -2799,11 +2798,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2799
2798
}
2800
2799
2801
2800
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
+
2807
2805
case options::OPT_fcx_limited_range:
2808
2806
if (GccRangeComplexOption.empty ()) {
2809
2807
if (Range != LangOptions::ComplexRangeKind::CX_Basic)
@@ -2895,7 +2893,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2895
2893
AssociativeMath = false ;
2896
2894
ReciprocalMath = false ;
2897
2895
SignedZeros = true ;
2898
- // -fno_fast_math restores default denormal and fpcontract handling
2899
2896
FPContract = " on" ;
2900
2897
2901
2898
StringRef Val = A->getValue ();
@@ -2906,10 +2903,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2906
2903
break ;
2907
2904
}
2908
2905
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.
2913
2906
if (!FPModel.empty () && !FPModel.equals (Val))
2914
2907
D.Diag (clang::diag::warn_drv_overriding_option)
2915
2908
<< Args.MakeArgString (" -ffp-model=" + FPModel)
@@ -2918,27 +2911,20 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2918
2911
FPModel = Val;
2919
2912
applyFastMath ();
2920
2913
} else if (Val.equals (" precise" )) {
2921
- optID = options::OPT_ffp_contract;
2922
2914
FPModel = Val;
2923
2915
FPContract = " on" ;
2924
- PreciseFPModel = true ;
2925
2916
} else if (Val.equals (" strict" )) {
2926
2917
StrictFPModel = true ;
2927
- optID = options::OPT_frounding_math;
2928
2918
FPExceptionBehavior = " strict" ;
2929
2919
FPModel = Val;
2930
2920
FPContract = " off" ;
2931
2921
TrappingMath = true ;
2922
+ RoundingFPMath = true ;
2932
2923
} else
2933
2924
D.Diag (diag::err_drv_unsupported_option_argument)
2934
2925
<< A->getSpelling () << Val;
2935
2926
break ;
2936
2927
}
2937
- }
2938
-
2939
- switch (optID) {
2940
- // If this isn't an FP option skip the claim below
2941
- default : continue ;
2942
2928
2943
2929
// Options controlling individual features
2944
2930
case options::OPT_fhonor_infinities: HonorINFs = true ; break ;
@@ -2982,12 +2968,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2982
2968
2983
2969
case options::OPT_frounding_math:
2984
2970
RoundingFPMath = true ;
2985
- RoundingMathPresent = true ;
2986
2971
break ;
2987
2972
2988
2973
case options::OPT_fno_rounding_math:
2989
2974
RoundingFPMath = false ;
2990
- RoundingMathPresent = false ;
2991
2975
break ;
2992
2976
2993
2977
case options::OPT_fdenormal_fp_math_EQ:
@@ -3010,13 +2994,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
3010
2994
// Validate and pass through -ffp-contract option.
3011
2995
case options::OPT_ffp_contract: {
3012
2996
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" )) {
3020
2999
FPContract = Val;
3021
3000
LastSeenFfpContractOption = Val;
3022
3001
} else
@@ -3025,13 +3004,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
3025
3004
break ;
3026
3005
}
3027
3006
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
-
3035
3007
// Validate and pass through -ffp-exception-behavior option.
3036
3008
case options::OPT_ffp_exception_behavior_EQ: {
3037
3009
StringRef Val = A->getValue ();
@@ -3152,6 +3124,12 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
3152
3124
}
3153
3125
break ;
3154
3126
}
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.
3155
3133
if (StrictFPModel) {
3156
3134
// If -ffp-model=strict has been specified on command line but
3157
3135
// subsequent options conflict then emit warning diagnostic.
@@ -3225,11 +3203,10 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
3225
3203
if (!FPContract.empty ())
3226
3204
CmdArgs.push_back (Args.MakeArgString (" -ffp-contract=" + FPContract));
3227
3205
3228
- if (!RoundingFPMath)
3229
- CmdArgs.push_back (Args.MakeArgString (" -fno-rounding-math" ));
3230
-
3231
- if (RoundingFPMath && RoundingMathPresent)
3206
+ if (RoundingFPMath)
3232
3207
CmdArgs.push_back (Args.MakeArgString (" -frounding-math" ));
3208
+ else
3209
+ CmdArgs.push_back (Args.MakeArgString (" -fno-rounding-math" ));
3233
3210
3234
3211
if (!FPExceptionBehavior.empty ())
3235
3212
CmdArgs.push_back (Args.MakeArgString (" -ffp-exception-behavior=" +
0 commit comments