[cfe-dev] #pragma diagnostic ignored and template code

Chris Lattner clattner at apple.com
Thu Sep 9 11:29:16 PDT 2010


On Sep 9, 2010, at 9:55 AM, Luc Bourhis wrote:

> Hi,
> 
> consider the trivial source code
> 
> ==== warning.cpp ====
> 
> #pragma clang diagnostic push
> #pragma clang diagnostic ignored "-Wtautological-compare"
> 
> unsigned foo(unsigned x) {
>  if (x < 0) return -x;
>  return x;
> }
> 
> #pragma clang diagnostic pop
...
> Is that the intended behaviour?

No, it's a bug.  A similar problem occurs with inline methods in classes:

class foo {
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wtautological-compare"

  void bar() {
    ...
  }

  #pragma .. pop
};

This is certainly a bug, but it's not trivial to fix.

-Chris



More information about the cfe-dev mailing list