@@ -2723,42 +2723,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
2723
2723
}
2724
2724
}
2725
2725
2726
- static void EmitComplexRangeDiag (const Driver &D, StringRef LastOpt,
2727
- LangOptions::ComplexRangeKind Range,
2728
- StringRef NewOpt,
2729
- LangOptions::ComplexRangeKind NewRange) {
2730
- // Do not emit a warning if NewOpt overrides LastOpt in the following cases.
2731
- //
2732
- // | LastOpt | NewOpt |
2733
- // |-----------------------|-----------------------|
2734
- // | -fcx-limited-range | -fno-cx-limited-range |
2735
- // | -fno-cx-limited-range | -fcx-limited-range |
2736
- // | -fcx-fortran-rules | -fno-cx-fortran-rules |
2737
- // | -fno-cx-fortran-rules | -fcx-fortran-rules |
2738
- // | -ffast-math | -fno-fast-math |
2739
- // | -ffp-model= | -ffast-math |
2740
- // | -ffp-model= | -fno-fast-math |
2741
- // | -ffp-model= | -ffp-model= |
2742
- // | -fcomplex-arithmetic= | -fcomplex-arithmetic= |
2743
- if (LastOpt == NewOpt || NewOpt.empty () || LastOpt.empty () ||
2744
- (LastOpt == " -fcx-limited-range" && NewOpt == " -fno-cx-limited-range" ) ||
2745
- (LastOpt == " -fno-cx-limited-range" && NewOpt == " -fcx-limited-range" ) ||
2746
- (LastOpt == " -fcx-fortran-rules" && NewOpt == " -fno-cx-fortran-rules" ) ||
2747
- (LastOpt == " -fno-cx-fortran-rules" && NewOpt == " -fcx-fortran-rules" ) ||
2748
- (LastOpt == " -ffast-math" && NewOpt == " -fno-fast-math" ) ||
2749
- (LastOpt.starts_with (" -ffp-model=" ) && NewOpt == " -ffast-math" ) ||
2750
- (LastOpt.starts_with (" -ffp-model=" ) && NewOpt == " -fno-fast-math" ) ||
2751
- (LastOpt.starts_with (" -ffp-model=" ) &&
2752
- NewOpt.starts_with (" -ffp-model=" )) ||
2753
- (LastOpt.starts_with (" -fcomplex-arithmetic=" ) &&
2754
- NewOpt.starts_with (" -fcomplex-arithmetic=" )))
2755
- return ;
2756
-
2757
- D.Diag (clang::diag::warn_drv_overriding_complex_range)
2758
- << LastOpt << NewOpt << complexRangeKindToStr (Range)
2759
- << complexRangeKindToStr (NewRange);
2760
- }
2761
-
2762
2726
static void RenderFloatingPointOptions (const ToolChain &TC, const Driver &D,
2763
2727
bool OFastEnabled, const ArgList &Args,
2764
2728
ArgStringList &CmdArgs,
@@ -2815,27 +2779,19 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2815
2779
std::string ComplexRangeStr;
2816
2780
StringRef LastComplexRangeOption;
2817
2781
2818
- auto setComplexRange = [&](StringRef NewOption,
2819
- LangOptions::ComplexRangeKind NewRange) {
2820
- // Warn if user overrides the previously set complex number
2821
- // multiplication/division option.
2822
- if (Range != LangOptions::ComplexRangeKind::CX_None && Range != NewRange)
2823
- EmitComplexRangeDiag (D, LastComplexRangeOption, Range, NewOption,
2824
- NewRange);
2825
- LastComplexRangeOption = NewOption;
2826
- Range = NewRange;
2827
- };
2828
-
2829
2782
// Lambda to set fast-math options. This is also used by -ffp-model=fast
2830
2783
auto applyFastMath = [&](bool Aggressive, StringRef CallerOption) {
2831
2784
if (Aggressive) {
2832
2785
HonorINFs = false ;
2833
2786
HonorNaNs = false ;
2834
- setComplexRange (CallerOption, LangOptions::ComplexRangeKind::CX_Basic);
2787
+ setComplexRange (D, CallerOption, LangOptions::ComplexRangeKind::CX_Basic,
2788
+ LastComplexRangeOption, Range);
2835
2789
} else {
2836
2790
HonorINFs = true ;
2837
2791
HonorNaNs = true ;
2838
- setComplexRange (CallerOption, LangOptions::ComplexRangeKind::CX_Promoted);
2792
+ setComplexRange (D, CallerOption,
2793
+ LangOptions::ComplexRangeKind::CX_Promoted,
2794
+ LastComplexRangeOption, Range);
2839
2795
}
2840
2796
MathErrno = false ;
2841
2797
AssociativeMath = true ;
@@ -2887,18 +2843,24 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2887
2843
default : continue ;
2888
2844
2889
2845
case options::OPT_fcx_limited_range:
2890
- setComplexRange (A->getSpelling (),
2891
- LangOptions::ComplexRangeKind::CX_Basic);
2846
+ setComplexRange (D, A->getSpelling (),
2847
+ LangOptions::ComplexRangeKind::CX_Basic,
2848
+ LastComplexRangeOption, Range);
2892
2849
break ;
2893
2850
case options::OPT_fno_cx_limited_range:
2894
- setComplexRange (A->getSpelling (), LangOptions::ComplexRangeKind::CX_Full);
2851
+ setComplexRange (D, A->getSpelling (),
2852
+ LangOptions::ComplexRangeKind::CX_Full,
2853
+ LastComplexRangeOption, Range);
2895
2854
break ;
2896
2855
case options::OPT_fcx_fortran_rules:
2897
- setComplexRange (A->getSpelling (),
2898
- LangOptions::ComplexRangeKind::CX_Improved);
2856
+ setComplexRange (D, A->getSpelling (),
2857
+ LangOptions::ComplexRangeKind::CX_Improved,
2858
+ LastComplexRangeOption, Range);
2899
2859
break ;
2900
2860
case options::OPT_fno_cx_fortran_rules:
2901
- setComplexRange (A->getSpelling (), LangOptions::ComplexRangeKind::CX_Full);
2861
+ setComplexRange (D, A->getSpelling (),
2862
+ LangOptions::ComplexRangeKind::CX_Full,
2863
+ LastComplexRangeOption, Range);
2902
2864
break ;
2903
2865
case options::OPT_fcomplex_arithmetic_EQ: {
2904
2866
LangOptions::ComplexRangeKind RangeVal;
@@ -2916,7 +2878,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2916
2878
<< A->getSpelling () << Val;
2917
2879
break ;
2918
2880
}
2919
- setComplexRange (Args.MakeArgString (A->getSpelling () + Val), RangeVal);
2881
+ setComplexRange (D, Args.MakeArgString (A->getSpelling () + Val), RangeVal,
2882
+ LastComplexRangeOption, Range);
2920
2883
break ;
2921
2884
}
2922
2885
case options::OPT_ffp_model_EQ: {
@@ -2956,8 +2919,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2956
2919
FPModel = Val;
2957
2920
FPContract = " on" ;
2958
2921
LastFpContractOverrideOption = " -ffp-model=precise" ;
2959
- setComplexRange (Args.MakeArgString (A->getSpelling () + Val),
2960
- LangOptions::ComplexRangeKind::CX_Full);
2922
+ setComplexRange (D, Args.MakeArgString (A->getSpelling () + Val),
2923
+ LangOptions::ComplexRangeKind::CX_Full,
2924
+ LastComplexRangeOption, Range);
2961
2925
} else if (Val == " strict" ) {
2962
2926
StrictFPModel = true ;
2963
2927
FPExceptionBehavior = " strict" ;
@@ -2966,8 +2930,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
2966
2930
LastFpContractOverrideOption = " -ffp-model=strict" ;
2967
2931
TrappingMath = true ;
2968
2932
RoundingFPMath = true ;
2969
- setComplexRange (Args.MakeArgString (A->getSpelling () + Val),
2970
- LangOptions::ComplexRangeKind::CX_Full);
2933
+ setComplexRange (D, Args.MakeArgString (A->getSpelling () + Val),
2934
+ LangOptions::ComplexRangeKind::CX_Full,
2935
+ LastComplexRangeOption, Range);
2971
2936
} else
2972
2937
D.Diag (diag::err_drv_unsupported_option_argument)
2973
2938
<< A->getSpelling () << Val;
@@ -3174,8 +3139,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
3174
3139
SignedZeros = true ;
3175
3140
restoreFPContractState ();
3176
3141
if (Range != LangOptions::ComplexRangeKind::CX_Full)
3177
- setComplexRange (A->getSpelling (),
3178
- LangOptions::ComplexRangeKind::CX_None);
3142
+ setComplexRange (D, A->getSpelling (),
3143
+ LangOptions::ComplexRangeKind::CX_None,
3144
+ LastComplexRangeOption, Range);
3179
3145
else
3180
3146
Range = LangOptions::ComplexRangeKind::CX_None;
3181
3147
LastComplexRangeOption = " " ;
0 commit comments