Message ID | 560B0762.9090902@redhat.com |
---|---|
State | New |
Headers | show |
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
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
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
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 --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)