public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v4] driver: fix a problem with implementation of -falign-foo=0 [PR96247]
@ 2020-07-27 12:05 Hu Jiangping
  2020-07-27 17:24 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Hu Jiangping @ 2020-07-27 12:05 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford, segher

Hi!

This patch makes the -falign-foo=0 work as described in the
documentation. Thanks for all the suggestions.

v4: do changes for coding conventions
v3: make change more readable and self-consistent

Changelog:
2020-07-27  Hu Jiangping  <hujiangping@cn.fujitsu.com>

	PR driver/96247
	* opts.c (check_alignment_argument): Set the -falign-Name
	on/off flag on and set the -falign-Name string value null,
	when the command-line specified argument is zero.

Tested on x86_64.

Regards!
Hujp

---
 gcc/opts.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/gcc/opts.c b/gcc/opts.c
index 499eb900643..574b28416fb 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2004,13 +2004,21 @@ parse_and_check_align_values (const char *flag,
 }
 
 /* Check that alignment value FLAG for -falign-NAME is valid at a given
-   location LOC.  */
+   location LOC. OPT_STR points to the stored -falign-NAME=argument and
+   OPT_FLAG points to the associated -falign-NAME on/off flag.  */
 
 static void
-check_alignment_argument (location_t loc, const char *flag, const char *name)
+check_alignment_argument (location_t loc, const char *flag, const char *name,
+                        int *opt_flag, const char **opt_str)
 {
   auto_vec<unsigned> align_result;
   parse_and_check_align_values (flag, name, align_result, true, loc);
+
+  if (align_result.length() >= 1 && align_result[0] == 0)
+    {
+      *opt_flag = 1;
+      *opt_str = NULL;
+    }
 }
 
 /* Print help when OPT__help_ is set.  */
@@ -2785,19 +2793,27 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_falign_loops_:
-      check_alignment_argument (loc, arg, "loops");
+      check_alignment_argument (loc, arg, "loops",
+                                &opts->x_flag_align_loops,
+                                &opts->x_str_align_loops);
       break;
 
     case OPT_falign_jumps_:
-      check_alignment_argument (loc, arg, "jumps");
+      check_alignment_argument (loc, arg, "jumps",
+                                &opts->x_flag_align_jumps,
+                                &opts->x_str_align_jumps);
       break;
 
     case OPT_falign_labels_:
-      check_alignment_argument (loc, arg, "labels");
+      check_alignment_argument (loc, arg, "labels",
+                                &opts->x_flag_align_labels,
+                                &opts->x_str_align_labels);
       break;
 
     case OPT_falign_functions_:
-      check_alignment_argument (loc, arg, "functions");
+      check_alignment_argument (loc, arg, "functions",
+                                &opts->x_flag_align_functions,
+                                &opts->x_str_align_functions);
       break;
 
     case OPT_ftabstop_:
-- 
2.17.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] driver: fix a problem with implementation of -falign-foo=0 [PR96247]
  2020-07-27 12:05 [PATCH v4] driver: fix a problem with implementation of -falign-foo=0 [PR96247] Hu Jiangping
@ 2020-07-27 17:24 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2020-07-27 17:24 UTC (permalink / raw)
  To: Hu Jiangping; +Cc: gcc-patches, segher

Hu Jiangping <hujiangping@cn.fujitsu.com> writes:
> Hi!
>
> This patch makes the -falign-foo=0 work as described in the
> documentation. Thanks for all the suggestions.
>
> v4: do changes for coding conventions
> v3: make change more readable and self-consistent
>
> Changelog:
> 2020-07-27  Hu Jiangping  <hujiangping@cn.fujitsu.com>
>
> 	PR driver/96247
> 	* opts.c (check_alignment_argument): Set the -falign-Name
> 	on/off flag on and set the -falign-Name string value null,
> 	when the command-line specified argument is zero.

Thanks, pushed to master.

Richard

>
> Tested on x86_64.
>
> Regards!
> Hujp
>
> ---
>  gcc/opts.c | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 499eb900643..574b28416fb 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -2004,13 +2004,21 @@ parse_and_check_align_values (const char *flag,
>  }
>  
>  /* Check that alignment value FLAG for -falign-NAME is valid at a given
> -   location LOC.  */
> +   location LOC. OPT_STR points to the stored -falign-NAME=argument and
> +   OPT_FLAG points to the associated -falign-NAME on/off flag.  */
>  
>  static void
> -check_alignment_argument (location_t loc, const char *flag, const char *name)
> +check_alignment_argument (location_t loc, const char *flag, const char *name,
> +                        int *opt_flag, const char **opt_str)
>  {
>    auto_vec<unsigned> align_result;
>    parse_and_check_align_values (flag, name, align_result, true, loc);
> +
> +  if (align_result.length() >= 1 && align_result[0] == 0)
> +    {
> +      *opt_flag = 1;
> +      *opt_str = NULL;
> +    }
>  }
>  
>  /* Print help when OPT__help_ is set.  */
> @@ -2785,19 +2793,27 @@ common_handle_option (struct gcc_options *opts,
>        break;
>  
>      case OPT_falign_loops_:
> -      check_alignment_argument (loc, arg, "loops");
> +      check_alignment_argument (loc, arg, "loops",
> +                                &opts->x_flag_align_loops,
> +                                &opts->x_str_align_loops);
>        break;
>  
>      case OPT_falign_jumps_:
> -      check_alignment_argument (loc, arg, "jumps");
> +      check_alignment_argument (loc, arg, "jumps",
> +                                &opts->x_flag_align_jumps,
> +                                &opts->x_str_align_jumps);
>        break;
>  
>      case OPT_falign_labels_:
> -      check_alignment_argument (loc, arg, "labels");
> +      check_alignment_argument (loc, arg, "labels",
> +                                &opts->x_flag_align_labels,
> +                                &opts->x_str_align_labels);
>        break;
>  
>      case OPT_falign_functions_:
> -      check_alignment_argument (loc, arg, "functions");
> +      check_alignment_argument (loc, arg, "functions",
> +                                &opts->x_flag_align_functions,
> +                                &opts->x_str_align_functions);
>        break;
>  
>      case OPT_ftabstop_:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-27 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 12:05 [PATCH v4] driver: fix a problem with implementation of -falign-foo=0 [PR96247] Hu Jiangping
2020-07-27 17:24 ` Richard Sandiford

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).