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

Ben Elliston
Tue Jan 20 03:53:00 GMT 2009

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

Tested with a bootstrap on x86_64-linux.  OK for the trunk?


2009-01-20  Ben Elliston  <>

	* 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.
	* (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.  */
--- (revision 143507)
+++ (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