@@ -2723,42 +2723,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
27232723 }
27242724}
27252725
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-
27622726static void RenderFloatingPointOptions (const ToolChain &TC, const Driver &D,
27632727 bool OFastEnabled, const ArgList &Args,
27642728 ArgStringList &CmdArgs,
@@ -2815,27 +2779,19 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
28152779 std::string ComplexRangeStr;
28162780 StringRef LastComplexRangeOption;
28172781
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-
28292782 // Lambda to set fast-math options. This is also used by -ffp-model=fast
28302783 auto applyFastMath = [&](bool Aggressive, StringRef CallerOption) {
28312784 if (Aggressive) {
28322785 HonorINFs = false ;
28332786 HonorNaNs = false ;
2834- setComplexRange (CallerOption, LangOptions::ComplexRangeKind::CX_Basic);
2787+ setComplexRange (D, CallerOption, LangOptions::ComplexRangeKind::CX_Basic,
2788+ LastComplexRangeOption, Range);
28352789 } else {
28362790 HonorINFs = true ;
28372791 HonorNaNs = true ;
2838- setComplexRange (CallerOption, LangOptions::ComplexRangeKind::CX_Promoted);
2792+ setComplexRange (D, CallerOption,
2793+ LangOptions::ComplexRangeKind::CX_Promoted,
2794+ LastComplexRangeOption, Range);
28392795 }
28402796 MathErrno = false ;
28412797 AssociativeMath = true ;
@@ -2887,18 +2843,24 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
28872843 default : continue ;
28882844
28892845 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);
28922849 break ;
28932850 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);
28952854 break ;
28962855 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);
28992859 break ;
29002860 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);
29022864 break ;
29032865 case options::OPT_fcomplex_arithmetic_EQ: {
29042866 LangOptions::ComplexRangeKind RangeVal;
@@ -2916,7 +2878,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29162878 << A->getSpelling () << Val;
29172879 break ;
29182880 }
2919- setComplexRange (Args.MakeArgString (A->getSpelling () + Val), RangeVal);
2881+ setComplexRange (D, Args.MakeArgString (A->getSpelling () + Val), RangeVal,
2882+ LastComplexRangeOption, Range);
29202883 break ;
29212884 }
29222885 case options::OPT_ffp_model_EQ: {
@@ -2956,8 +2919,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29562919 FPModel = Val;
29572920 FPContract = " on" ;
29582921 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);
29612925 } else if (Val == " strict" ) {
29622926 StrictFPModel = true ;
29632927 FPExceptionBehavior = " strict" ;
@@ -2966,8 +2930,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29662930 LastFpContractOverrideOption = " -ffp-model=strict" ;
29672931 TrappingMath = true ;
29682932 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);
29712936 } else
29722937 D.Diag (diag::err_drv_unsupported_option_argument)
29732938 << A->getSpelling () << Val;
@@ -3174,8 +3139,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31743139 SignedZeros = true ;
31753140 restoreFPContractState ();
31763141 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);
31793145 else
31803146 Range = LangOptions::ComplexRangeKind::CX_None;
31813147 LastComplexRangeOption = " " ;
0 commit comments