[clang] e538486 - [Driver] Fix erroneous warning for -fcx-limited-range and -fcx-fortran-rules. (#79821)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 06:20:40 PST 2024


Author: Zahira Ammarguellat
Date: 2024-01-31T09:20:36-05:00
New Revision: e538486e90539096e7851d0deba4ea9ed94fced2

URL: https://github.com/llvm/llvm-project/commit/e538486e90539096e7851d0deba4ea9ed94fced2
DIFF: https://github.com/llvm/llvm-project/commit/e538486e90539096e7851d0deba4ea9ed94fced2.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/range.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8d8965fdf76fb..7ceb248f7afb9 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 045d9c7d3d802..49116df2f4480 100644
--- a/clang/test/Driver/range.c
+++ b/clang/test/Driver/range.c
@@ -35,6 +35,12 @@
 // RUN: %clang -### -target x86_64 -ffast-math -fno-cx-limited-range -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=FULL %s
 
+// RUN: %clang -### -Werror -target x86_64 -fcx-limited-range -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LMTD %s
+
+// RUN: %clang -### -Werror -target x86_64 -fcx-fortran-rules -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=FRTRN %s
+
 // LMTD: -complex-range=limited
 // FULL: -complex-range=full
 // LMTD-NOT: -complex-range=fortran


        


More information about the cfe-commits mailing list