[clang] [flang] Ignore -f[no-]realloc-lhs. (PR #120320)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 17 14:27:59 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Slava Zakharin (vzakhari)

<details>
<summary>Changes</summary>

After #<!-- -->120165 clang started complaining about unknown
option -f[no-]realloc-lhs. This change fixes it to ignore
the option like it used to be.


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


2 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+2-2) 
- (added) clang/test/Driver/frealloc-lhs.cpp (+7) 


``````````diff
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 7b544d2534d469..bc3c548da8b96c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3465,7 +3465,7 @@ defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers"
   PosFlag<SetTrue>>;
 def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group<f_Group>,
   HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">,
-  Visibility<[FlangOption, FC1Option]>;
+  Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>;
 def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group<f_Group>,
   HelpText<"Disable the use of stack protectors">;
 def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group<f_Group>,
@@ -4300,7 +4300,7 @@ defm stack_size_section : BoolFOption<"stack-size-section",
           "Emit section containing metadata on function stack sizes">,
   NegFlag<SetFalse>>;
 def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group<f_Group>,
-  Visibility<[FlangOption, FC1Option]>,
+  Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>,
   HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">;
 def fstack_usage : Flag<["-"], "fstack-usage">, Group<f_Group>,
   HelpText<"Emit .su file containing information on function stack sizes">;
diff --git a/clang/test/Driver/frealloc-lhs.cpp b/clang/test/Driver/frealloc-lhs.cpp
new file mode 100644
index 00000000000000..792247deaaa2c1
--- /dev/null
+++ b/clang/test/Driver/frealloc-lhs.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -Wunused-command-line-argument -frealloc-lhs -### %s 2> %t
+// RUN: FileCheck < %t %s --check-prefix=REALLOCLHS
+// RUN: %clang -Wunused-command-line-argument -fno-realloc-lhs -### %s 2> %t
+// RUN: FileCheck < %t %s --check-prefix=NOREALLOCLHS
+
+// CHECK: argument unused during compilation: '-frealloc-lhs'
+// CHECK: argument unused during compilation: '-fno-realloc-lhs'

``````````

</details>


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


More information about the cfe-commits mailing list