[Flang] Fix -frelaxed-c-loc-checks being ignored when using the driver#200733
Conversation
|
@llvm/pr-subscribers-flang-driver @llvm/pr-subscribers-flang-semantics Author: ShashwathiNavada Changes
Full diff: https://github.com/llvm/llvm-project/pull/200733.diff 2 Files Affected:
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)
|
| @@ -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 | |||
There was a problem hiding this comment.
In general, we should not invoke the driver in the semantics tests because there is a lot of work that the driver does that is unnecessary.
If the issue was that the driver was not passing the option along to fc1, it is better to add a test to flang/test/Driver. For instance, something like this:
RUN: %flang -### -frelaxed-c-loc-checks %s 2>&1 | FileCheck %s
CHECK: "-fc1"
CHECK-SAME: "-frelaxed-c-loc-checks"
There was a problem hiding this comment.
Done! Thank you !!
|
@tarunprabhu I was honestly a little confused about what the Flang.cpp code was doing... I sort of thought visibility from Options.td what driving the forwarding of arguments. I have corrected that misunderstanding after digging into this code and the call chain between |
tarunprabhu
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the change.
I think it may be sufficient to just forward any options that have not been claimed, but let me check what clang does here. I can't remember off the top of my head. |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
Thanks, LG for merge !! |
-frelaxed-c-loc-checksworked 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 addingOPT_relaxed_c_locto theaddAllArgscall in Flang.cppAlso extend the existing test with a driver-mode RUN line to cover this path.