public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas: Silence GCC 10 warning tc-vax.c
@ 2020-05-26 14:41 H.J. Lu
  2020-05-27 15:54 ` Martin Sebor
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2020-05-26 14:41 UTC (permalink / raw)
  To: binutils

	PR gas/26044
	* config/tc-vax.c (md_estimate_size_before_relax): Replace
	fragP->fr_literal with &fragP->fr_literal[0].
	(md_convert_frag): Likewise.
---
 gas/ChangeLog       | 7 +++++++
 gas/config/tc-vax.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 052d180398..980a84f6cf 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR gas/26044
+	* config/tc-vax.c (md_estimate_size_before_relax): Replace
+	fragP->fr_literal with &fragP->fr_literal[0].
+	(md_convert_frag): Likewise.
+
 2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR gas/26044
diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c
index 5634566945..f606c157bc 100644
--- a/gas/config/tc-vax.c
+++ b/gas/config/tc-vax.c
@@ -381,7 +381,7 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
 	  int old_fr_fix;
 
 	  old_fr_fix = fragP->fr_fix;
-	  p = fragP->fr_literal + old_fr_fix;
+	  p = &fragP->fr_literal[0] + old_fr_fix;
 #ifdef OBJ_ELF
 	  /* If this is to an undefined symbol, then if it's an indirect
 	     reference indicate that is can mutated into a GLOB_DAT or
@@ -525,7 +525,7 @@ md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
 
   know (fragP->fr_type == rs_machine_dependent);
   where = fragP->fr_fix;
-  addressP = fragP->fr_literal + where;
+  addressP = &fragP->fr_literal[0] + where;
   opcodeP = fragP->fr_opcode;
   symbolP = fragP->fr_symbol;
   know (symbolP);
-- 
2.26.2


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

* Re: [PATCH] gas: Silence GCC 10 warning tc-vax.c
  2020-05-26 14:41 [PATCH] gas: Silence GCC 10 warning tc-vax.c H.J. Lu
@ 2020-05-27 15:54 ` Martin Sebor
  2020-05-27 16:02   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Sebor @ 2020-05-27 15:54 UTC (permalink / raw)
  To: H.J. Lu, binutils

On 5/26/20 8:41 AM, H.J. Lu via Binutils wrote:
> 	PR gas/26044
> 	* config/tc-vax.c (md_estimate_size_before_relax): Replace
> 	fragP->fr_literal with &fragP->fr_literal[0].
> 	(md_convert_frag): Likewise.
> ---
>   gas/ChangeLog       | 7 +++++++
>   gas/config/tc-vax.c | 4 ++--
>   2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/gas/ChangeLog b/gas/ChangeLog
> index 052d180398..980a84f6cf 100644
> --- a/gas/ChangeLog
> +++ b/gas/ChangeLog
> @@ -1,3 +1,10 @@
> +2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
> +
> +	PR gas/26044
> +	* config/tc-vax.c (md_estimate_size_before_relax): Replace
> +	fragP->fr_literal with &fragP->fr_literal[0].
> +	(md_convert_frag): Likewise.
> +
>   2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
>   
>   	PR gas/26044
> diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c
> index 5634566945..f606c157bc 100644
> --- a/gas/config/tc-vax.c
> +++ b/gas/config/tc-vax.c
> @@ -381,7 +381,7 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
>   	  int old_fr_fix;
>   
>   	  old_fr_fix = fragP->fr_fix;
> -	  p = fragP->fr_literal + old_fr_fix;
> +	  p = &fragP->fr_literal[0] + old_fr_fix;

For what it's worth, I'd expect the following to suppress the warning
as well without overly obfuscating the code:

   p = &fragP->fr_literal[old_fr_fix];

Either way, although I intend to suppress the warning in GCC for this
case, the GCC manual discourages using trailing arrays of non-zero
size as flexible array members, in favor of either the C99 feature
itself or the zero-length array extension (see Zero-Length.html).
If it's not overly disruptive I would suggest to consider adjusting
those accordingly.

Martin

>   #ifdef OBJ_ELF
>   	  /* If this is to an undefined symbol, then if it's an indirect
>   	     reference indicate that is can mutated into a GLOB_DAT or
> @@ -525,7 +525,7 @@ md_convert_frag (bfd *headers ATTRIBUTE_UNUSED,
>   
>     know (fragP->fr_type == rs_machine_dependent);
>     where = fragP->fr_fix;
> -  addressP = fragP->fr_literal + where;
> +  addressP = &fragP->fr_literal[0] + where;
>     opcodeP = fragP->fr_opcode;
>     symbolP = fragP->fr_symbol;
>     know (symbolP);
> 


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

* Re: [PATCH] gas: Silence GCC 10 warning tc-vax.c
  2020-05-27 15:54 ` Martin Sebor
@ 2020-05-27 16:02   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2020-05-27 16:02 UTC (permalink / raw)
  To: Martin Sebor; +Cc: Binutils

On Wed, May 27, 2020 at 8:54 AM Martin Sebor <msebor@gmail.com> wrote:
>
> On 5/26/20 8:41 AM, H.J. Lu via Binutils wrote:
> >       PR gas/26044
> >       * config/tc-vax.c (md_estimate_size_before_relax): Replace
> >       fragP->fr_literal with &fragP->fr_literal[0].
> >       (md_convert_frag): Likewise.
> > ---
> >   gas/ChangeLog       | 7 +++++++
> >   gas/config/tc-vax.c | 4 ++--
> >   2 files changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/gas/ChangeLog b/gas/ChangeLog
> > index 052d180398..980a84f6cf 100644
> > --- a/gas/ChangeLog
> > +++ b/gas/ChangeLog
> > @@ -1,3 +1,10 @@
> > +2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
> > +
> > +     PR gas/26044
> > +     * config/tc-vax.c (md_estimate_size_before_relax): Replace
> > +     fragP->fr_literal with &fragP->fr_literal[0].
> > +     (md_convert_frag): Likewise.
> > +
> >   2020-05-26  H.J. Lu  <hongjiu.lu@intel.com>
> >
> >       PR gas/26044
> > diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c
> > index 5634566945..f606c157bc 100644
> > --- a/gas/config/tc-vax.c
> > +++ b/gas/config/tc-vax.c
> > @@ -381,7 +381,7 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
> >         int old_fr_fix;
> >
> >         old_fr_fix = fragP->fr_fix;
> > -       p = fragP->fr_literal + old_fr_fix;
> > +       p = &fragP->fr_literal[0] + old_fr_fix;
>
> For what it's worth, I'd expect the following to suppress the warning
> as well without overly obfuscating the code:
>
>    p = &fragP->fr_literal[old_fr_fix];

It is equivalent to

p = &fragP->fr_literal[0] + old_fr_fix;

> Either way, although I intend to suppress the warning in GCC for this
> case, the GCC manual discourages using trailing arrays of non-zero
> size as flexible array members, in favor of either the C99 feature
> itself or the zero-length array extension (see Zero-Length.html).
> If it's not overly disruptive I would suggest to consider adjusting
> those accordingly.
>

GCC 10 should work on binutils 2.34, which can't be changed.

-- 
H.J.

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

end of thread, other threads:[~2020-05-27 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 14:41 [PATCH] gas: Silence GCC 10 warning tc-vax.c H.J. Lu
2020-05-27 15:54 ` Martin Sebor
2020-05-27 16:02   ` H.J. Lu

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