Skip to content

Commit e538486

Browse files
authored
[Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (#79821)
The options `-fcx-limited-range` and `-fcx-fortran-rules` were added in _https://github.com/llvm/llvm-project/pull/70244_ The code adding the options introduced an erroneous warning. `$ clang -c -fcx-limited-range t1.c` `clang: warning: overriding '' option with '-fcx-limited-range' [-Woverriding-option]` and `$ clang -c -fcx-fortran-rules t1.c` `clang: warning: overriding '' option with '-fcx-fortran-rules' [-Woverriding-option]` The warning doesn't make sense. This patch removes it.
1 parent de75e50 commit e538486

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ static StringRef EnumComplexRangeToStr(LangOptions::ComplexRangeKind Range) {
27052705
static void EmitComplexRangeDiag(const Driver &D,
27062706
LangOptions::ComplexRangeKind Range1,
27072707
LangOptions::ComplexRangeKind Range2) {
2708-
if (Range1 != LangOptions::ComplexRangeKind::CX_Full)
2708+
if (Range1 != Range2 && Range1 != LangOptions::ComplexRangeKind::CX_None)
27092709
D.Diag(clang::diag::warn_drv_overriding_option)
27102710
<< EnumComplexRangeToStr(Range1) << EnumComplexRangeToStr(Range2);
27112711
}

clang/test/Driver/range.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
// RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 2>&1 \
3636
// RUN: | FileCheck --check-prefix=FULL %s
3737

38+
// RUN: %clang -### -Werror -target x86_64 -fcx-limited-range -c %s 2>&1 \
39+
// RUN: | FileCheck --check-prefix=LMTD %s
40+
41+
// RUN: %clang -### -Werror -target x86_64 -fcx-fortran-rules -c %s 2>&1 \
42+
// RUN: | FileCheck --check-prefix=FRTRN %s
43+
3844
// LMTD: -complex-range=limited
3945
// FULL: -complex-range=full
4046
// LMTD-NOT: -complex-range=fortran

0 commit comments

Comments
 (0)