[clang] Fix erroneous warning. (PR #79821)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 29 05:27:49 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Zahira Ammarguellat (zahiraam)
<details>
<summary>Changes</summary>
This patch is to remove erroneous warning. See https://godbolt.org/z/bYP8P8nqY
---
Full diff: https://github.com/llvm/llvm-project/pull/79821.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1)
- (modified) clang/test/Driver/range.c (+4)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d8965fdf76fb8a..7ceb248f7afb99e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2705,7 +2705,7 @@ static StringRef EnumComplexRangeToStr(LangOptions::ComplexRangeKind Range) {
static void EmitComplexRangeDiag(const Driver &D,
LangOptions::ComplexRangeKind Range1,
LangOptions::ComplexRangeKind Range2) {
- if (Range1 != LangOptions::ComplexRangeKind::CX_Full)
+ if (Range1 != Range2 && Range1 != LangOptions::ComplexRangeKind::CX_None)
D.Diag(clang::diag::warn_drv_overriding_option)
<< EnumComplexRangeToStr(Range1) << EnumComplexRangeToStr(Range2);
}
diff --git a/clang/test/Driver/range.c b/clang/test/Driver/range.c
index 045d9c7d3d802ae..023b5cffbe3e0e4 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -35,6 +35,9 @@
// RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=FULL %s
+// RUN: %clang -c -target x86_64 -fcx-limited-range %s -Xclang -verify=range
+// RUN: %clang -c -target x86_64 -fcx-fortran-rules %s -Xclang -verify=range
+
// LMTD: -complex-range=limited
// FULL: -complex-range=full
// LMTD-NOT: -complex-range=fortran
@@ -44,3 +47,4 @@
// CHECK-NOT: -complex-range=fortran
// WARN1: warning: overriding '-fcx-limited-range' option with '-fcx-fortran-rules' [-Woverriding-option]
// WARN2: warning: overriding '-fcx-fortran-rules' option with '-fcx-limited-range' [-Woverriding-option]
+// range-no-diagnostics
``````````
</details>
https://github.com/llvm/llvm-project/pull/79821
More information about the cfe-commits
mailing list