diff mbox

[RFA] Fix building cr16-elf with trunk compiler

Message ID 560B0762.9090902@redhat.com
State New
Headers show

Commit Message

Jeff Law Sept. 29, 2015, 9:49 p.m. UTC
This code from builtins.c:

   /* If we don't need too much alignment, we'll have been guaranteed
      proper alignment by get_trampoline_type.  */
   if (TRAMPOLINE_ALIGNMENT <= STACK_BOUNDARY)
     return tramp;


It's entirely conceivable that TRAMPOLINE_ALIGNMENT will be the same as 
STACK_BOUNDARY.  And if they are, then -Wtautological-compare will 
complain bitterly.

This affects the cr16 port and possibly others (I've had this fix in my 
tree while running the config-all.mk builds).

Given the real possibility that those two objects are the same and thus 
the complaint from -Wtautological-compare, it seems best to simply 
disable -Wtautological-compare for this function.

Bootstrapped and regression tested on x86_64-linux-gnu and also used to 
successfully build cr16-elf cross compilers from config-all.mk.

OK for the trunk?

Other alternatives would be to obfuscate the appropriate macros in the 
cr16 port.  That seemed wrong in this case to me.

Jeff
* builtins.c (round_trampoline_addr): Turn off -Wtautological-compare
	when compiling this function.

Comments

Bernd Schmidt Sept. 30, 2015, 12:41 p.m. UTC | #1
On 09/29/2015 11:49 PM, Jeff Law wrote:
>
> This code from builtins.c:
>
>    /* If we don't need too much alignment, we'll have been guaranteed
>       proper alignment by get_trampoline_type.  */
>    if (TRAMPOLINE_ALIGNMENT <= STACK_BOUNDARY)
>      return tramp;
>
>
> It's entirely conceivable that TRAMPOLINE_ALIGNMENT will be the same as
> STACK_BOUNDARY.  And if they are, then -Wtautological-compare will
> complain bitterly.

Eww. Can we fix the warning not to complain when the comparison involves 
macros?


Bernd
Marek Polacek Sept. 30, 2015, 12:45 p.m. UTC | #2
On Wed, Sep 30, 2015 at 02:41:36PM +0200, Bernd Schmidt wrote:
> On 09/29/2015 11:49 PM, Jeff Law wrote:
> >
> >This code from builtins.c:
> >
> >   /* If we don't need too much alignment, we'll have been guaranteed
> >      proper alignment by get_trampoline_type.  */
> >   if (TRAMPOLINE_ALIGNMENT <= STACK_BOUNDARY)
> >     return tramp;
> >
> >
> >It's entirely conceivable that TRAMPOLINE_ALIGNMENT will be the same as
> >STACK_BOUNDARY.  And if they are, then -Wtautological-compare will
> >complain bitterly.
> 
> Eww. Can we fix the warning not to complain when the comparison involves
> macros?

It already has

  /* Don't warn for various macro expansions.  */
  if (from_macro_expansion_at (loc) 
      || from_macro_expansion_at (EXPR_LOCATION (lhs))
      || from_macro_expansion_at (EXPR_LOCATION (rhs)))
    return;

and also

  /* We do not warn for constants because they are typical of macro
     expansions that test for features, sizeof, and similar.  */
  if (CONSTANT_CLASS_P (lhs) || CONSTANT_CLASS_P (rhs))
    return;

so why does it warn? :(

	Marek
Marek Polacek Sept. 30, 2015, 5:10 p.m. UTC | #3
On Wed, Sep 30, 2015 at 11:01:14AM -0600, Jeff Law wrote:
> On 09/30/2015 06:45 AM, Marek Polacek wrote:
> >On Wed, Sep 30, 2015 at 02:41:36PM +0200, Bernd Schmidt wrote:
> >>On 09/29/2015 11:49 PM, Jeff Law wrote:
> >>>
> >>>This code from builtins.c:
> >>>
> >>>   /* If we don't need too much alignment, we'll have been guaranteed
> >>>      proper alignment by get_trampoline_type.  */
> >>>   if (TRAMPOLINE_ALIGNMENT <= STACK_BOUNDARY)
> >>>     return tramp;
> >>>
> >>>
> >>>It's entirely conceivable that TRAMPOLINE_ALIGNMENT will be the same as
> >>>STACK_BOUNDARY.  And if they are, then -Wtautological-compare will
> >>>complain bitterly.
> >>
> >>Eww. Can we fix the warning not to complain when the comparison involves
> >>macros?
> >
> >It already has
> >
> >   /* Don't warn for various macro expansions.  */
> >   if (from_macro_expansion_at (loc)
> >       || from_macro_expansion_at (EXPR_LOCATION (lhs))
> >       || from_macro_expansion_at (EXPR_LOCATION (rhs)))
> >     return;
> >
> >and also
> >
> >   /* We do not warn for constants because they are typical of macro
> >      expansions that test for features, sizeof, and similar.  */
> >   if (CONSTANT_CLASS_P (lhs) || CONSTANT_CLASS_P (rhs))
> >     return;
> >
> >so why does it warn? :(
> If you want to dive into it, be my guest :-0  Attached is a suitable .ii
> file.

All right, let me take a look.

	Marek
Marek Polacek Oct. 6, 2015, 10:26 a.m. UTC | #4
On Wed, Sep 30, 2015 at 07:10:11PM +0200, Marek Polacek wrote:
> On Wed, Sep 30, 2015 at 11:01:14AM -0600, Jeff Law wrote:
> > On 09/30/2015 06:45 AM, Marek Polacek wrote:
> > >On Wed, Sep 30, 2015 at 02:41:36PM +0200, Bernd Schmidt wrote:
> > >>On 09/29/2015 11:49 PM, Jeff Law wrote:
> > >>>
> > >>>This code from builtins.c:
> > >>>
> > >>>   /* If we don't need too much alignment, we'll have been guaranteed
> > >>>      proper alignment by get_trampoline_type.  */
> > >>>   if (TRAMPOLINE_ALIGNMENT <= STACK_BOUNDARY)
> > >>>     return tramp;
> > >>>
> > >>>
> > >>>It's entirely conceivable that TRAMPOLINE_ALIGNMENT will be the same as
> > >>>STACK_BOUNDARY.  And if they are, then -Wtautological-compare will
> > >>>complain bitterly.
> > >>
> > >>Eww. Can we fix the warning not to complain when the comparison involves
> > >>macros?
> > >
> > >It already has
> > >
> > >   /* Don't warn for various macro expansions.  */
> > >   if (from_macro_expansion_at (loc)
> > >       || from_macro_expansion_at (EXPR_LOCATION (lhs))
> > >       || from_macro_expansion_at (EXPR_LOCATION (rhs)))
> > >     return;
> > >
> > >and also
> > >
> > >   /* We do not warn for constants because they are typical of macro
> > >      expansions that test for features, sizeof, and similar.  */
> > >   if (CONSTANT_CLASS_P (lhs) || CONSTANT_CLASS_P (rhs))
> > >     return;
> > >
> > >so why does it warn? :(
> > If you want to dive into it, be my guest :-0  Attached is a suitable .ii
> > file.
> 
> All right, let me take a look.

The problem here is that COND_EXPR in cc1plus don't have a location.  I've
opened <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863> to track this.

	Marek
diff mbox

Patch

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1592810..e4ed470 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4830,6 +4830,11 @@  expand_builtin___clear_cache (tree exp)
   return const0_rtx;
 }
 
+#if GCC_VERSION >= 6000
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtautological-compare"
+#endif
+
 /* Given a trampoline address, make sure it satisfies TRAMPOLINE_ALIGNMENT.  */
 
 static rtx
@@ -4854,6 +4859,9 @@  round_trampoline_addr (rtx tramp)
 
   return tramp;
 }
+#if GCC_VERSION >= 6000
+#pragma GCC diagnostic pop
+#endif
 
 static rtx
 expand_builtin_init_trampoline (tree exp, bool onstack)