[PATCH] Fix --help -Q output

Martin Liška mliska@suse.cz
Mon Nov 29 15:16:26 GMT 2021


There are cases where a default option value is -1 and
auto-detection happens in e.g. target.

Do not print these options. Leads to the following diff:

-  -fdelete-null-pointer-checks 		[enabled]
+  -fdelete-null-pointer-checks 		
@@ -332 +332 @@
-  -fleading-underscore        		[enabled]
+  -fleading-underscore        		
@@ -393 +393 @@
-  -fprefetch-loop-arrays      		[enabled]
+  -fprefetch-loop-arrays      		
@@ -502 +502 @@
-  -fstrict-volatile-bitfields 		[enabled]
+  -fstrict-volatile-bitfields 		
@@ -533 +533 @@
-  -ftree-loop-if-convert      		[enabled]
+  -ftree-loop-if-convert      		

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR middle-end/103438

gcc/ChangeLog:

	* opts-common.c (option_enabled): Return flag_var for BOOLEAN
	types (the can contain an unknown value -1).
---
  gcc/opts-common.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 9d1914ff2ff..c4a19b9a0b6 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1586,7 +1586,8 @@ option_flag_var (int opt_index, struct gcc_options *opts)
  }
  
  /* Return 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled,
-   or -1 if it isn't a simple on-off switch.  */
+   or -1 if it isn't a simple on-off switch (or if the value is unknown,
+   typically set later in target).  */
  
  int
  option_enabled (int opt_idx, unsigned lang_mask, void *opts)
@@ -1608,9 +1609,9 @@ option_enabled (int opt_idx, unsigned lang_mask, void *opts)
        {
        case CLVC_BOOLEAN:
  	if (option->cl_host_wide_int)
-	  return *(HOST_WIDE_INT *) flag_var != 0;
+	  return *(HOST_WIDE_INT *) flag_var;
  	else
-	  return *(int *) flag_var != 0;
+	  return *(int *) flag_var;
  
        case CLVC_EQUAL:
  	if (option->cl_host_wide_int)
-- 
2.34.0



More information about the Gcc-patches mailing list