Patch for -Wcast-qual handling of function types

Richard Sandiford rsandifo@redhat.com
Thu Jan 17 03:37:00 GMT 2002


"Joseph S. Myers" <jsm28@cam.ac.uk> writes:
> >         * gcc.dg/20020117-1.c: New test.
> 
> I'd suggest a more meaningful name, such as cast-qual-2.c.

OK.

> > + /* Test whether the const and volatile function extensions conflict with
> > +    -Wcast-qual.  */
> > + /* { dg-do compile } */
> > + /* { dg-options "-Wcast-qual" } */
> > + 
> > + typedef int (*foo_t) (void);
> > + static int foo (void) { return 1; }
> > + foo_t fooptr = (foo_t) foo; /* { dg-bogus "discards qualifiers" } */
> > + 
> > + typedef void (bar_t) (void);
> > + volatile bar_t bar;
> > + bar_t *barptr = (bar_t *) bar; /* { dg-bogus "discards qualifiers" } */
> 
> You ought to test both cases: test for the correct warning when qualifiers
> are added, as well as the bogus one when they are removed.

So you think we should warn when qualifiers are added?  I wasn't
sure it was appropriate to add a "new" warning so long after the
extension was introduced.

Richard



More information about the Gcc-patches mailing list