[cfe-dev] Pragma warning control

me22 me22.ca at gmail.com
Fri Jan 9 19:15:41 PST 2009


On Fri, Jan 9, 2009 at 17:52, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
>
> I'm thinking of implementing a pragma to control Clang warnings. This
> would look something like this (borrowing MS syntax because it makes
> sense, IMO):
>
> struct A;
>
> void f(A *a) {
> #pragma Clang warning(disable: warn_delete_incomplete)
>  // This would cause the warning, but I know it to be safe:
>  delete a;
>  // Bring warning back to its default status so that real issues aren't
> missed.
> #pragma Clang warning(default: warn_delete_incomplete)
> }
>

I think something like this would be better:

 void f(A *a) {
  #pragma Clang warning(--warn_delete_incomplete)
   delete a;
  #pragma Clang warning(++warn_delete_incomplete)
 }

So that nesting them still works, which I don't think the "default" way would.

Be nice for things like gcc's strict aliasing warnings, too.  The
build could default to the stricter, false-positive including mode,
and it could be lowered to the only false negatives mode in sections
of the code that need it.

~ Scott



More information about the cfe-dev mailing list