Skip to content

Commit a1664f6

Browse files
committed
Fix option handling in driver
1 parent 8d4d181 commit a1664f6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,15 @@ static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
822822
complexRangeKindToStr(Range)));
823823
}
824824

825-
if (Args.hasArg(options::OPT_ffast_real_mod))
826-
CmdArgs.push_back("-ffast-real-mod");
827-
if (Args.hasArg(options::OPT_fno_fast_real_mod))
828-
CmdArgs.push_back("-fno-fast-real-mod");
825+
if (llvm::opt::Arg *A =
826+
Args.getLastArg(clang::options::OPT_ffast_real_mod,
827+
clang::options::OPT_fno_fast_real_mod)) {
828+
if (A->getOption().matches(clang::options::OPT_ffast_real_mod))
829+
CmdArgs.push_back("-ffast-real-mod");
830+
else if (A->getOption().matches(
831+
clang::options::OPT_fno_fast_real_mod))
832+
CmdArgs.push_back("-fno-fast-real-mod");
833+
}
829834

830835
if (!HonorINFs && !HonorNaNs && AssociativeMath && ReciprocalMath &&
831836
ApproxFunc && !SignedZeros &&

flang/test/Driver/fast-real-mod.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
! RUN: %flang -ffast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-FAST-REAL-MOD
22
! RUN: %flang -fno-fast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-NO-FAST-REAL-MOD
3+
! RUN: %flang -fno-fast-real-mod -ffast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-FAST-REAL-MOD
4+
! RUN: %flang -ffast-real-mod -fno-fast-real-mod -### -c %s 2>&1 | FileCheck %s -check-prefix CHECK-NO-FAST-REAL-MOD
35

46
! CHECK-FAST-REAL-MOD: "-ffast-real-mod"
7+
! CHECK-FAST-REAL-MOD-NOT: "-fno-fast-real-mod"
58
! CHECK-NO-FAST-REAL-MOD: "-fno-fast-real-mod"
9+
! CHECK-NO-FAST-REAL-MOD-NOT: "-fast-real-mod"
610

711
program test
812
! nothing to be done in here

0 commit comments

Comments
 (0)