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]

Ping: Ping: [Patch][RFA] Warn if pointer is initialized to 'false'


Second ping.


2010/1/4 Simon Baldwin <simonb@google.com>
>
> Any opinions? ?Yes? ?No?
>
>
> 2009/12/16 Simon Baldwin <simonb@google.com>:
> > This tiny patch adds a warning when boolean 'false' is used to assign to a
> > pointer; gcc is currently silent for this case.
> >
> > Confirmed C++ dejagnu testsuite parity with the unpatched gcc, and verified
> > bootstrap of C/C++ on x86_64.
> >
> > Okay for trunk? ?Would pedwarn be preferable to warning?
> >
> >
> > cp/ChangeLog:
> > 2009-12-16 ?Simon Baldwin ?<simonb@google.com>
> >
> > ? ? ? ?* call.c (conversion_null_warnings): Warn if 'false' is used in
> > ? ? ? ?pointer assignment or initialization.
> >
> > testsuite/ChangeLog:
> > 2009-12-16 ?Simon Baldwin ?<simonb@google.com>
> >
> > ? ? ? ?* g++.dg/warn/Wconversion4.C: New.
> >
> >
> > Index: gcc/testsuite/g++.dg/warn/Wconversion4.C
> > ===================================================================
> > --- gcc/testsuite/g++.dg/warn/Wconversion4.C ? ?(revision 0)
> > +++ gcc/testsuite/g++.dg/warn/Wconversion4.C ? ?(revision 0)
> > @@ -0,0 +1,4 @@
> > +// { dg-options "-Wconversion" }
> > +
> > +void *a = true; ? // { dg-error "cannot convert" }
> > +void *b = false; ?// { dg-warning "converting 'false' to pointer type" }
> > Index: gcc/cp/call.c
> > ===================================================================
> > --- gcc/cp/call.c ? ? ? (revision 155286)
> > +++ gcc/cp/call.c ? ? ? (working copy)
> > @@ -4809,10 +4809,15 @@ conversion_null_warnings (tree totype, t
> > ? ? }
> >
> > ? /* Issue warnings if "false" is converted to a NULL pointer */
> > - ?else if (expr == boolean_false_node && fn && POINTER_TYPE_P (t))
> > - ? ?warning (OPT_Wconversion,
> > - ? ? ? ? ? ?"converting %<false%> to pointer type for argument %P of %qD",
> > - ? ? ? ? ? ?argnum, fn);
> > + ?else if (expr == boolean_false_node && POINTER_TYPE_P (t))
> > + ? ?{
> > + ? ? ?if (fn)
> > + ? ? ? warning (OPT_Wconversion,
> > + ? ? ? ? ? ? ? ?"converting %<false%> to pointer type for argument %P of %qD",
> > + ? ? ? ? ? ? ? ?argnum, fn);
> > + ? ? ?else
> > + ? ? ? warning (OPT_Wconversion, "converting %<false%> to pointer type");
> > + ? ?}
> > ?}
> >
> > ?/* Perform the conversions in CONVS on the expression EXPR. ?FN and
> >
>
>
>
> --
> Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
> Palace Road, London SW1W 9TQ | Registered in England Number: 3977902



--
Google UK Limited | Registered Office: Belgrave House, 76 Buckingham
Palace Road, London SW1W 9TQ | Registered in England Number: 3977902


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