public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5824] Fix --help -Q output
@ 2021-12-07 13:38 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-12-07 13:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8e836af61b7027c0819da62c12a8d18b7c46f3fc

commit r12-5824-g8e836af61b7027c0819da62c12a8d18b7c46f3fc
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Nov 29 14:46:47 2021 +0100

    Fix --help -Q output
    
            PR middle-end/103438
    
    gcc/ChangeLog:
    
            * config/s390/s390.c (s390_valid_target_attribute_inner_p):
            Use new enum CLVC_INTEGER.
            * opt-functions.awk: Use new CLVC_INTEGER.
            * opts-common.c (set_option): Likewise.
            (option_enabled): Return -1,0,1 for CLVC_INTEGER.
            (get_option_state): Use new CLVC_INTEGER.
            (control_warning_option): Likewise.
            * opts.h (enum cl_var_type): Likewise.

Diff:
---
 gcc/config/s390/s390.c |  2 +-
 gcc/opt-functions.awk  |  2 +-
 gcc/opts-common.c      | 21 ++++++++++++++-------
 gcc/opts.h             |  4 ++--
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 510e7f58a3b..3a22f7833a9 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -15926,7 +15926,7 @@ s390_valid_target_attribute_inner_p (tree args,
 	  new_opts_set->x_target_flags |= mask;
 	}
 
-      else if (cl_options[opt].var_type == CLVC_BOOLEAN)
+      else if (cl_options[opt].var_type == CLVC_INTEGER)
 	{
 	  int value;
 
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 9bc85604066..ffe4eb92027 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -303,7 +303,7 @@ function var_set(flags)
 		return "0, CLVC_STRING, 0"
 	if (flag_set_p("ByteSize", flags))
 		return "0, CLVC_SIZE, 0"
-	return "0, CLVC_BOOLEAN, 0"
+	return "0, CLVC_INTEGER, 0"
 }
 
 # Given that an option called NAME has flags FLAGS, return an initializer
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 9d1914ff2ff..ef2130e318f 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1458,7 +1458,7 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
 
   switch (option->var_type)
     {
-    case CLVC_BOOLEAN:
+    case CLVC_INTEGER:
 	if (option->cl_host_wide_int)
 	  {
 	    *(HOST_WIDE_INT *) flag_var = value;
@@ -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)
@@ -1606,11 +1607,17 @@ option_enabled (int opt_idx, unsigned lang_mask, void *opts)
   if (flag_var)
     switch (option->var_type)
       {
-      case CLVC_BOOLEAN:
+      case CLVC_INTEGER:
 	if (option->cl_host_wide_int)
-	  return *(HOST_WIDE_INT *) flag_var != 0;
+	  {
+	    HOST_WIDE_INT v = *(HOST_WIDE_INT *) flag_var;
+	    return v != 0 ? (v < 0 ? -1 : 1) : 0;
+	  }
 	else
-	  return *(int *) flag_var != 0;
+	  {
+	    int v = *(int *) flag_var;
+	    return v != 0 ? (v < 0 ? -1 : 1) : 0;
+	  }
 
       case CLVC_EQUAL:
 	if (option->cl_host_wide_int) 
@@ -1658,7 +1665,7 @@ get_option_state (struct gcc_options *opts, int option,
 
   switch (cl_options[option].var_type)
     {
-    case CLVC_BOOLEAN:
+    case CLVC_INTEGER:
     case CLVC_EQUAL:
     case CLVC_SIZE:
       state->data = flag_var;
@@ -1725,7 +1732,7 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg,
       const struct cl_option *option = &cl_options[opt_index];
 
       /* -Werror=foo implies -Wfoo.  */
-      if (option->var_type == CLVC_BOOLEAN
+      if (option->var_type == CLVC_INTEGER
 	  || option->var_type == CLVC_ENUM
 	  || option->var_type == CLVC_SIZE)
 	{
diff --git a/gcc/opts.h b/gcc/opts.h
index f5bc9a3149c..4c2b77ec0f0 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -24,8 +24,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR.  */
 enum cl_var_type {
-  /* The switch is enabled when FLAG_VAR is nonzero.  */
-  CLVC_BOOLEAN,
+  /* The switch is an integer value.  */
+  CLVC_INTEGER,
 
   /* The switch is enabled when FLAG_VAR == VAR_VALUE.  */
   CLVC_EQUAL,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-07 13:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 13:38 [gcc r12-5824] Fix --help -Q output Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).