[clang] 364a883 - [Flang] Fix -frelaxed-c-loc-checks being ignored when using the driver (#200733)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 00:06:04 PDT 2026


Author: ShashwathiNavada
Date: 2026-06-04T12:35:57+05:30
New Revision: 364a8837a9d67135d050fe594ba51e319fbab938

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

LOG: [Flang] Fix -frelaxed-c-loc-checks being ignored when using the driver (#200733)

`-frelaxed-c-loc-checks` worked correctly when passed directly to -fc1,
but was silently ignored when using the driver (e.g., flang -c
-frelaxed-c-loc-checks), causing the flag to go unused. This patch fixes
it by adding `OPT_relaxed_c_loc` to the `addAllArgs` call in Flang.cpp
Also extend the existing test with a driver-mode RUN line to cover this
path.

Added: 
    flang/test/Driver/frelaxed-c-loc-checks.f90

Modified: 
    clang/lib/Driver/ToolChains/Flang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 6d40b30e62036..ecdf5e46565b6 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -263,7 +263,8 @@ void Flang::addCodegenOptions(const ArgList &Args,
        options::OPT_frepack_arrays_contiguity_EQ,
        options::OPT_fstack_repack_arrays, options::OPT_fno_stack_repack_arrays,
        options::OPT_ftime_report, options::OPT_ftime_report_EQ,
-       options::OPT_funroll_loops, options::OPT_fno_unroll_loops});
+       options::OPT_funroll_loops, options::OPT_fno_unroll_loops,
+       options::OPT_relaxed_c_loc});
 
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
   addSeparateSectionFlags(Triple, Args, CmdArgs);

diff  --git a/flang/test/Driver/frelaxed-c-loc-checks.f90 b/flang/test/Driver/frelaxed-c-loc-checks.f90
new file mode 100644
index 0000000000000..320818ca707d3
--- /dev/null
+++ b/flang/test/Driver/frelaxed-c-loc-checks.f90
@@ -0,0 +1,4 @@
+! Check that -frelaxed-c-loc-checks is forwarded from the driver to fc1.
+! RUN: %flang -### -frelaxed-c-loc-checks %s 2>&1 | FileCheck %s
+! CHECK: "-fc1"
+! CHECK-SAME: "-frelaxed-c-loc-checks"


        


More information about the cfe-commits mailing list