This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Hi Richard

On Thu, 2009-01-22 at 10:51 +0100, Richard Guenther wrote:

> > Well, it's not only used on void * pointer variables so we may as well
> > want to prohibit use on lets say bitmap * variables (if somebody
> > forgot a dereference).
> 
> Of course in this case we'd get a warning from the NULL assignment
> - if you change the type of NULL to bitmap here.  Can you check
> if that works (give a proper warning)?

Yes, it does.  Here is a small test case.  Without casting NULL to
bitmap, no warnings are produced.  With the cast, one warning is
produced:

foo.C: In function âint main()â:
foo.C:17: error: invalid conversion from âint*â to âcharâ

     1  #include <stdlib.h>
     2
     3  typedef int * bitmap;
     4  extern void bitmap_obstack_free (bitmap);
     5
     6  #define BITMAP_FREE(BITMAP) \
     7    ((void) (bitmap_obstack_free ((bitmap) BITMAP), (BITMAP) = (bitmap) NULL))
     8
     9  int main()
    10  {
    11    bitmap x; 
    12    void * y;
    13    char z;
    14
    15    BITMAP_FREE (x);
    16    BITMAP_FREE (y);
    17    BITMAP_FREE (z);
    18   
    19    return 0;
    20  }

Are you happy with the definition of BITMAP_FREE given above?

Cheers, Ben



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]