PATCH: eliminate -Wc++compat-warning from dominance.c

Richard Guenther richard.guenther@gmail.com
Tue Jan 20 09:20:00 GMT 2009


On Tue, Jan 20, 2009 at 4:22 AM, Ben Elliston <bje@au1.ibm.com> wrote:
> This patch eliminates an `implicit conversion from void *' warning when
> compiling dominance.c with the bootstrap compiler (and, hence, this file
> can also be removed from the set that need -Wno-error).
>
> The problem here is that an explicit cast from void * to bitmap is
> diagnosed by -Wc++compat, but the BITMAP_FREE macro uses its single
> argument as the lvalue of an assignment to NULL:
>
>  /* Do any cleanup needed on a bitmap when it is no longer used.  */
>  #define BITMAP_FREE(BITMAP)                   \
>        ((void)(bitmap_obstack_free (BITMAP), (BITMAP) = NULL))
>
> The presence of the cast in the macro invocation produces a diagnostic
> about the cast on the lvalue.  For this one instance in dominance.c, I
> propose to expand the macro by hand and adjust it accordingly, with a
> comment to allow this case to be found if the BITMAP_FREE interface or
> associated data structures were to be changed in the future.  I did
> consider the idea of making BITMAP_FREE a new static inline function in
> bitmap.h, but the need to set the bitmap value to NULL would require
> every call to pass the bitmap by reference, and I felt that this was too
> invasive.
>
> Tested with a bootstrap on x86_64-linux.  OK for the trunk?

No.  Can you instead try fixing BITMAP_FREE to do sth like

#define BITMAP_FREE(BITMAP)                   \
       ((void)(bitmap_obstack_free (__builtin_types_compatible_p
(BITMAP, void *) ? (bitmap)BITMAP : BITMAP), (BITMAP) = NULL))

guarded properly for GCC being available.  The idea would be to allow
void * arguments but not other pointer arguments here.

No idea if that works of course ;)

Richard.

> Ben
>
>
> 2009-01-20  Ben Elliston  <bje@au.ibm.com>
>
>        * dominance.c (iterate_fix_dominators): Replace invocation of
>        BITMAP_FREE with a manual expansion of this macro to eliminate an
>        `implicit cast from void *' warning.
>        * Makefile.in (dominance.o-warn): Remove.
>
> Index: dominance.c
> ===================================================================
> --- dominance.c (revision 143507)
> +++ dominance.c (working copy)
> @@ -1321,7 +1321,13 @@
>        }
>     }
>   for (y = 0; y < g->n_vertices; y++)
> -    BITMAP_FREE (g->vertices[y].data);
> +    {
> +      /* This is a use of BITMAP_FREE, manually expanded to avoid the
> +        (bitmap) cast being applied to the lvalue in the NULL
> +        assignment.  */
> +      bitmap_obstack_free ((bitmap) g->vertices[y].data);
> +      g->vertices[y].data = NULL;
> +    }
>   pointer_map_destroy (map);
>
>   /* Find the dominator tree of G.  */
> Index: Makefile.in
> ===================================================================
> --- Makefile.in (revision 143507)
> +++ Makefile.in (working copy)
> @@ -179,8 +179,6 @@
>  SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
>  # dfp.c contains alias violations
>  dfp.o-warn = -Wno-error
> -# dominance.c contains a -Wc++compat warning.
> -dominance.o-warn = -Wno-error
>  # mips-tfile.c contains -Wcast-qual warnings.
>  mips-tfile.o-warn = -Wno-error
>
>
>
>



More information about the Gcc-patches mailing list