Skip to content

[flang] Ignore -f[no-]realloc-lhs. #120320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[flang] Ignore -f[no-]realloc-lhs. #120320

wants to merge 1 commit into from

Conversation

vzakhari
Copy link
Contributor

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.

After llvm#120165 clang started complaining about unknown
option -f[no-]realloc-lhs. This change fixes it to ignore
the option like it used to be.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Dec 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Slava Zakharin (vzakhari)

Changes

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 --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'

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #120165 clang started complaining about unknown option -f[no-]realloc-lhs.

Was this on an existing test?

@@ -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]>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this now show up in clang --help and online guide? Is that what we want?
Is CLOption for Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this now show up in clang --help and online guide? Is that what we want? Is CLOption for Windows?

Good point! Yes, clang --help now shows it, and I think we do not want this. I will check how I can resolve this. Any advices are welcome.

Yes, CLOption is for Windows driver.

@vzakhari
Copy link
Contributor Author

After #120165 clang started complaining about unknown option -f[no-]realloc-lhs.

Was this on an existing test?

I noticed it when trying to compile a Fortran/C mix test where flang/clang were used as compilers and I passed -fno-realloc-lhs in flags that were used for both. Maybe it is not the right way to do it, but clang just ignored the option before my previous change.

@kiranchandramohan
Copy link
Contributor

After #120165 clang started complaining about unknown option -f[no-]realloc-lhs.

Was this on an existing test?

I noticed it when trying to compile a Fortran/C mix test where flang/clang were used as compilers and I passed -fno-realloc-lhs in flags that were used for both. Maybe it is not the right way to do it, but clang just ignored the option before my previous change.

I am guessing that this might be the case for all Fortran flags we switched over from the gfortran group to the Flang group. Previously clang could be used for forwarding Fortran options to gcc/gfortran. But this is not the case anymore.

For example, i think ffree-form flag would have showed similar behaviour after commit 3a1513c.

In short I think the present behaviour is OK. But if you and others feel otherwise feel free to push forward.

@vzakhari
Copy link
Contributor Author

Okay, I do not see an easy way to allow this option for clang without printing it in the --help output, so I guess I will let it behave same way as the other Flang-only options.

@vzakhari vzakhari closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants