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

via flang-commits flang-commits at lists.llvm.org
Sun May 31 23:56:07 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: ShashwathiNavada

<details>
<summary>Changes</summary>

`-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 path 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/200733.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+2-1) 
- (modified) flang/test/Semantics/c_loc01-relaxed.f90 (+1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 892a455167205..8b6e83528fecf 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -261,7 +261,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});
   if (Args.hasArg(options::OPT_fcoarray))
     CmdArgs.push_back("-fcoarray");
 }
diff --git a/flang/test/Semantics/c_loc01-relaxed.f90 b/flang/test/Semantics/c_loc01-relaxed.f90
index 714d4acd5e06f..bfb036b6c0580 100644
--- a/flang/test/Semantics/c_loc01-relaxed.f90
+++ b/flang/test/Semantics/c_loc01-relaxed.f90
@@ -1,4 +1,5 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1 -frelaxed-c-loc-checks
+! RUN: %python %S/test_errors.py %s %flang -frelaxed-c-loc-checks
 module m
   use iso_c_binding
   type haslen(L)

``````````

</details>


https://github.com/llvm/llvm-project/pull/200733


More information about the flang-commits mailing list