[cfe-dev] #pragma diagnostic ignored and template code
Luc Bourhis
luc_j_bourhis at mac.com
Thu Sep 9 09:55:59 PDT 2010
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
==== main.cpp ====
#include "warning.hpp"
#include <iostream>
int main() {
std::cout << foo(1u) << std::endl;
return 0;
}
================
clang ignores the #pragma's completely:
~> clang++ -o main main.cpp
In file included from main.cpp:1:
./warning.hpp:6:9: warning: comparison of unsigned expression < 0 is always false
[-Wtautological-compare]
if (x < T(0)) return -x;
~ ^ ~~~~
main.cpp:5:16: note: in instantiation of function template specialization 'foo<unsigned int>' requested
here
std::cout << foo(1u) << std::endl;
^
1 warning generated.
Is that the intended behaviour?
Luc Bourhis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100909/283863c5/attachment.bin>
More information about the cfe-dev
mailing list