Skip to content

Commit 97839a8

Browse files
author
Andy Kaylor
authored
[Driver] Clean up fp-contract handling in clang driver (#99723)
This change refactors the fp-contract handling in RenderFloatingPointOptions in the clang driver code and fixes some inconsistencies in the way warnings are reported for changes in the fp-contract behavior.
1 parent ea222be commit 97839a8

File tree

3 files changed

+130
-81
lines changed

3 files changed

+130
-81
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
28672867
// If one wasn't given by the user, don't pass it here.
28682868
StringRef FPContract;
28692869
StringRef LastSeenFfpContractOption;
2870+
StringRef LastFpContractOverrideOption;
28702871
bool SeenUnsafeMathModeOption = false;
28712872
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
28722873
!JA.isOffloading(Action::OFK_HIP))
@@ -2908,6 +2909,27 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29082909
SeenUnsafeMathModeOption = true;
29092910
};
29102911

2912+
// Lambda to consolidate common handling for fp-contract
2913+
auto restoreFPContractState = [&]() {
2914+
// CUDA and HIP don't rely on the frontend to pass an ffp-contract option.
2915+
// For other targets, if the state has been changed by one of the
2916+
// unsafe-math umbrella options a subsequent -fno-fast-math or
2917+
// -fno-unsafe-math-optimizations option reverts to the last value seen for
2918+
// the -ffp-contract option or "on" if we have not seen the -ffp-contract
2919+
// option. If we have not seen an unsafe-math option or -ffp-contract,
2920+
// we leave the FPContract state unchanged.
2921+
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
2922+
!JA.isOffloading(Action::OFK_HIP)) {
2923+
if (LastSeenFfpContractOption != "")
2924+
FPContract = LastSeenFfpContractOption;
2925+
else if (SeenUnsafeMathModeOption)
2926+
FPContract = "on";
2927+
}
2928+
// In this case, we're reverting to the last explicit fp-contract option
2929+
// or the platform default
2930+
LastFpContractOverrideOption = "";
2931+
};
2932+
29112933
if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
29122934
CmdArgs.push_back("-mlimit-float-precision");
29132935
CmdArgs.push_back(A->getValue());
@@ -3009,7 +3031,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30093031
AssociativeMath = false;
30103032
ReciprocalMath = false;
30113033
SignedZeros = true;
3012-
FPContract = "on";
30133034

30143035
StringRef Val = A->getValue();
30153036
if (OFastEnabled && Val != "fast") {
@@ -3026,14 +3047,18 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30263047
if (Val == "fast") {
30273048
FPModel = Val;
30283049
applyFastMath();
3050+
// applyFastMath sets fp-contract="fast"
3051+
LastFpContractOverrideOption = "-ffp-model=fast";
30293052
} else if (Val == "precise") {
30303053
FPModel = Val;
30313054
FPContract = "on";
3055+
LastFpContractOverrideOption = "-ffp-model=precise";
30323056
} else if (Val == "strict") {
30333057
StrictFPModel = true;
30343058
FPExceptionBehavior = "strict";
30353059
FPModel = Val;
30363060
FPContract = "off";
3061+
LastFpContractOverrideOption = "-ffp-model=strict";
30373062
TrappingMath = true;
30383063
RoundingFPMath = true;
30393064
} else
@@ -3112,8 +3137,15 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31123137
StringRef Val = A->getValue();
31133138
if (Val == "fast" || Val == "on" || Val == "off" ||
31143139
Val == "fast-honor-pragmas") {
3140+
if (Val != FPContract && LastFpContractOverrideOption != "") {
3141+
D.Diag(clang::diag::warn_drv_overriding_option)
3142+
<< LastFpContractOverrideOption
3143+
<< Args.MakeArgString("-ffp-contract=" + Val);
3144+
}
3145+
31153146
FPContract = Val;
31163147
LastSeenFfpContractOption = Val;
3148+
LastFpContractOverrideOption = "";
31173149
} else
31183150
D.Diag(diag::err_drv_unsupported_option_argument)
31193151
<< A->getSpelling() << Val;
@@ -3192,32 +3224,29 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31923224
TrappingMath = false;
31933225
FPExceptionBehavior = "";
31943226
FPContract = "fast";
3227+
LastFpContractOverrideOption = "-funsafe-math-optimizations";
31953228
SeenUnsafeMathModeOption = true;
31963229
break;
31973230
case options::OPT_fno_unsafe_math_optimizations:
31983231
AssociativeMath = false;
31993232
ReciprocalMath = false;
32003233
SignedZeros = true;
32013234
ApproxFunc = false;
3202-
3203-
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
3204-
!JA.isOffloading(Action::OFK_HIP)) {
3205-
if (LastSeenFfpContractOption != "") {
3206-
FPContract = LastSeenFfpContractOption;
3207-
} else if (SeenUnsafeMathModeOption)
3208-
FPContract = "on";
3209-
}
3235+
restoreFPContractState();
32103236
break;
32113237

32123238
case options::OPT_Ofast:
32133239
// If -Ofast is the optimization level, then -ffast-math should be enabled
32143240
if (!OFastEnabled)
32153241
continue;
32163242
[[fallthrough]];
3217-
case options::OPT_ffast_math: {
3243+
case options::OPT_ffast_math:
32183244
applyFastMath();
3245+
if (A->getOption().getID() == options::OPT_Ofast)
3246+
LastFpContractOverrideOption = "-Ofast";
3247+
else
3248+
LastFpContractOverrideOption = "-ffast-math";
32193249
break;
3220-
}
32213250
case options::OPT_fno_fast_math:
32223251
HonorINFs = true;
32233252
HonorNaNs = true;
@@ -3229,16 +3258,11 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
32293258
ReciprocalMath = false;
32303259
ApproxFunc = false;
32313260
SignedZeros = true;
3232-
// -fno_fast_math restores default fpcontract handling
3233-
if (!JA.isDeviceOffloading(Action::OFK_Cuda) &&
3234-
!JA.isOffloading(Action::OFK_HIP)) {
3235-
if (LastSeenFfpContractOption != "") {
3236-
FPContract = LastSeenFfpContractOption;
3237-
} else if (SeenUnsafeMathModeOption)
3238-
FPContract = "on";
3239-
}
3261+
restoreFPContractState();
3262+
LastFpContractOverrideOption = "";
32403263
break;
3241-
}
3264+
} // End switch (A->getOption().getID())
3265+
32423266
// The StrictFPModel local variable is needed to report warnings
32433267
// in the way we intend. If -ffp-model=strict has been used, we
32443268
// want to report a warning for the next option encountered that
@@ -3256,12 +3280,17 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
32563280
else {
32573281
StrictFPModel = false;
32583282
FPModel = "";
3283+
// The warning for -ffp-contract would have been reported by the
3284+
// OPT_ffp_contract_EQ handler above. A special check here is needed
3285+
// to avoid duplicating the warning.
32593286
auto RHS = (A->getNumValues() == 0)
32603287
? A->getSpelling()
32613288
: Args.MakeArgString(A->getSpelling() + A->getValue());
3262-
if (RHS != "-ffp-model=strict")
3263-
D.Diag(clang::diag::warn_drv_overriding_option)
3264-
<< "-ffp-model=strict" << RHS;
3289+
if (A->getSpelling() != "-ffp-contract=") {
3290+
if (RHS != "-ffp-model=strict")
3291+
D.Diag(clang::diag::warn_drv_overriding_option)
3292+
<< "-ffp-model=strict" << RHS;
3293+
}
32653294
}
32663295
}
32673296

@@ -3343,21 +3372,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
33433372
// individual features enabled by -ffast-math instead of the option itself as
33443373
// that's consistent with gcc's behaviour.
33453374
if (!HonorINFs && !HonorNaNs && !MathErrno && AssociativeMath && ApproxFunc &&
3346-
ReciprocalMath && !SignedZeros && !TrappingMath && !RoundingFPMath) {
3375+
ReciprocalMath && !SignedZeros && !TrappingMath && !RoundingFPMath)
33473376
CmdArgs.push_back("-ffast-math");
3348-
if (FPModel == "fast") {
3349-
if (FPContract == "fast")
3350-
// All set, do nothing.
3351-
;
3352-
else if (FPContract.empty())
3353-
// Enable -ffp-contract=fast
3354-
CmdArgs.push_back(Args.MakeArgString("-ffp-contract=fast"));
3355-
else
3356-
D.Diag(clang::diag::warn_drv_overriding_option)
3357-
<< "-ffp-model=fast"
3358-
<< Args.MakeArgString("-ffp-contract=" + FPContract);
3359-
}
3360-
}
33613377

33623378
// Handle __FINITE_MATH_ONLY__ similarly.
33633379
if (!HonorINFs && !HonorNaNs)

clang/test/Driver/fp-contract.c

Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
// the options -ffast-math, -fno-fast-math, funsafe-math-optimizations,
33
// fno-unsafe-math-optimizations.
44

5+
// These warning checks are above the run lines because the warning is reported
6+
// before the drive options that are checked below the run lines.
7+
// WARN_FM_OFF: warning: overriding '-ffast-math' option with '-ffp-contract=off'
8+
// WARN_FM_ON: warning: overriding '-ffast-math' option with '-ffp-contract=on'
9+
// WARN_FM_FHP: warning: overriding '-ffast-math' option with '-ffp-contract=fast-honor-pragmas'
10+
// WARN_UM_OFF: warning: overriding '-funsafe-math-optimizations' option with '-ffp-contract=off'
11+
// WARN_UM_ON: warning: overriding '-funsafe-math-optimizations' option with '-ffp-contract=on'
12+
513
// ffast-math, fno-fast-math
614
// RUN: %clang -### -ffast-math -c %s 2>&1 \
715
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
@@ -10,19 +18,19 @@
1018
// RUN: %clang -### -fno-fast-math -c %s 2>&1 \
1119
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
1220

13-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=on -c %s 2>&1 \
14-
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
21+
// RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \
22+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
1523
// CHECK-FPC-ON: "-ffp-contract=on"
1624

17-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=off -c %s 2>&1 \
18-
// RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
25+
// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
26+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
1927
// CHECK-FPC-OFF: "-ffp-contract=off"
2028

2129
// RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -c %s 2>&1 \
2230
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
2331

24-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=fast-honor-pragmas -c %s 2>&1 \
25-
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST-HONOR %s
32+
// RUN: %clang -### -ffast-math -ffp-contract=fast-honor-pragmas -c %s 2>&1 \
33+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST-HONOR,WARN_FM_FHP %s
2634
// CHECK-FPC-FAST-HONOR: "-ffp-contract=fast-honor-pragmas"
2735

2836
// RUN: %clang -### -Werror -ffp-contract=fast -ffast-math -c %s 2>&1 \
@@ -43,23 +51,23 @@
4351
// RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -ffp-contract=on -c %s 2>&1 \
4452
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
4553

46-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=on -ffp-contract=off -c %s 2>&1 \
47-
// RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
54+
// RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=off -c %s 2>&1 \
55+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_ON %s
4856

49-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=on -ffp-contract=fast -c %s 2>&1 \
50-
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
57+
// RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=fast -c %s 2>&1 \
58+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_FM_ON %s
5159

52-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=off -ffp-contract=on -c %s 2>&1 \
53-
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
60+
// RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=on -c %s 2>&1 \
61+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_OFF %s
5462

55-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=off -ffp-contract=fast \
56-
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
63+
// RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=fast \
64+
// RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_FM_OFF %s
5765

58-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=on -fno-fast-math -c %s 2>&1 \
59-
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
66+
// RUN: %clang -### -ffast-math -ffp-contract=on -fno-fast-math -c %s 2>&1 \
67+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
6068

61-
// RUN: %clang -### -Werror -ffast-math -ffp-contract=off -fno-fast-math -c %s 2>&1 \
62-
// RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
69+
// RUN: %clang -### -ffast-math -ffp-contract=off -fno-fast-math -c %s 2>&1 \
70+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
6371

6472
// RUN: %clang -### -Werror -ffast-math -ffp-contract=fast -fno-fast-math -c %s 2>&1 \
6573
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
@@ -112,24 +120,24 @@
112120
// RUN: %clang -### -Werror -fno-fast-math -ffast-math -ffp-contract=fast \
113121
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
114122

115-
// RUN: %clang -### -Werror -fno-fast-math -ffast-math -ffp-contract=on \
116-
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
123+
// RUN: %clang -### -fno-fast-math -ffast-math -ffp-contract=on \
124+
// RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_FM_ON %s
117125

118-
// RUN: %clang -### -Werror -fno-fast-math -ffast-math -ffp-contract=off \
119-
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
126+
// RUN: %clang -### -fno-fast-math -ffast-math -ffp-contract=off \
127+
// RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_FM_OFF %s
120128

121129
// funsafe-math-optimizations, fno-unsafe-math-optimizations
122-
// RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \
130+
// RUN: %clang -### -Werror -funsafe-math-optimizations -c %s 2>&1 \
123131
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
124132

125-
// RUN: %clang -### -fno-unsafe-math-optimizations -c %s 2>&1 \
133+
// RUN: %clang -### -Werror -fno-unsafe-math-optimizations -c %s 2>&1 \
126134
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
127135

128-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=on -c %s 2>&1 \
129-
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
136+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on -c %s 2>&1 \
137+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
130138

131-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
132-
// RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
139+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
140+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
133141

134142
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast -c %s 2>&1 \
135143
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
@@ -151,27 +159,27 @@
151159
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast \
152160
// RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
153161

154-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=on \
155-
// RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
162+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
163+
// RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_ON %s
156164

157-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=on \
165+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
158166
// RUN: -ffp-contract=fast -c %s 2>&1 \
159-
// RUN: | FileCheck --check-prefix=CHECK-FPC-FAST %s
167+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_UM_ON %s
160168

161-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=off \
162-
// RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
169+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
170+
// RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_OFF %s
163171

164-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=off \
172+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
165173
// RUN: -ffp-contract=fast \
166-
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
174+
// RUN: -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-FAST,WARN_UM_OFF %s
167175

168-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=on \
176+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=on \
169177
// RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
170-
// RUN: | FileCheck --check-prefix=CHECK-FPC-ON %s
178+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
171179

172-
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=off \
180+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off \
173181
// RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
174-
// RUN: | FileCheck --check-prefix=CHECK-FPC-OFF %s
182+
// RUN: | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
175183

176184
// RUN: %clang -### -Werror -funsafe-math-optimizations -ffp-contract=fast \
177185
// RUN: -fno-unsafe-math-optimizations -c %s 2>&1 \
@@ -229,9 +237,21 @@
229237
// RUN: -ffp-contract=fast \
230238
// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
231239

232-
// RUN: %clang -### -Werror -fno-unsafe-math-optimizations -funsafe-math-optimizations \
233-
// RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
240+
// RUN: %clang -### -fno-unsafe-math-optimizations -funsafe-math-optimizations \
241+
// RUN: -ffp-contract=on -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-ON,WARN_UM_ON %s
234242

235-
// RUN: %clang -### -Werror -fno-unsafe-math-optimizations -funsafe-math-optimizations \
236-
// RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
243+
// RUN: %clang -### -fno-unsafe-math-optimizations -funsafe-math-optimizations \
244+
// RUN: -ffp-contract=off -c %s 2>&1 | FileCheck --check-prefixes=CHECK-FPC-OFF,WARN_UM_OFF %s
245+
246+
// RUN: %clang -### -funsafe-math-optimizations -ffp-contract=off -c %s 2>&1 \
247+
// RUN: | FileCheck --check-prefix=WARN_UM_OFF %s
248+
249+
// This case should not warn
250+
// RUN: %clang -### -Werror -funsafe-math-optimizations \
251+
// RUN: -fno-unsafe-math-optimizations -ffp-contract=off -c %s
252+
253+
// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
254+
// RUN: | FileCheck --check-prefix=WARN_FM_OFF %s
237255

256+
// This case should not warn
257+
// RUN: %clang -### -Werror -ffast-math -fno-fast-math -ffp-contract=off -c %s

clang/test/Driver/fp-model.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@
8181
// RUN: | FileCheck --check-prefix=WARN13 %s
8282
// WARN13: warning: overriding '-ffp-model=strict' option with '-fapprox-func' [-Woverriding-option]
8383

84+
// RUN: %clang -### -ffp-model=precise -ffp-contract=off -c %s 2>&1 \
85+
// RUN: | FileCheck --check-prefix=WARN14 %s
86+
// WARN14: warning: overriding '-ffp-model=precise' option with '-ffp-contract=off' [-Woverriding-option]
87+
88+
// RUN: %clang -### -ffp-model=precise -ffp-contract=fast -c %s 2>&1 \
89+
// RUN: | FileCheck --check-prefix=WARN15 %s
90+
// WARN15: warning: overriding '-ffp-model=precise' option with '-ffp-contract=fast' [-Woverriding-option]
91+
92+
// RUN: %clang -### -ffp-model=strict -fassociative-math -ffp-contract=on \
93+
// RUN: -c %s 2>&1 | FileCheck --check-prefix=WARN16 %s
94+
// WARN16: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-option]
95+
// WARN16: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-option]
96+
8497
// RUN: %clang -### -c %s 2>&1 \
8598
// RUN: | FileCheck --check-prefix=CHECK-NOROUND %s
8699
// CHECK-NOROUND: "-cc1"

0 commit comments

Comments
 (0)