https://github.com/ShashwathiNavada created 
https://github.com/llvm/llvm-project/pull/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 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.

>From 41e30ff1295e902804a2e013deb775a86062ab1c Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <[email protected]>
Date: Mon, 1 Jun 2026 01:51:03 -0500
Subject: [PATCH] [Flang] Fix -frelaxed-c-loc-checks being ignored when using
 the driver

---
 clang/lib/Driver/ToolChains/Flang.cpp    | 3 ++-
 flang/test/Semantics/c_loc01-relaxed.f90 | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

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)

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to