https://llvm.org/bugs/show_bug.cgi?id=28275
Bug ID: 28275 Summary: Static analyser doesn't respect #pragma GCC diagnostic ignored "-Wnonnull" Product: clang Version: 3.4 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Static Analyzer Assignee: kreme...@apple.com Reporter: sgubm...@mjt.me.uk CC: llvm-bugs@lists.llvm.org Classification: Unclassified I have a method that should not be passed a null pointer under normal operation, so I have declared it like so (in C): uint16_t CRC_xmodem(const uint8_t* data, const uint16_t length) __attribute__((nonnull)); but in unit testing I want to pass it a null pointer to ensure it accepts it gracefully. To avoid a compiler warning, I do this like so (in C++, using catch.hpp if that's relevant): TEST_CASE("CRC_xmodem null pointer produces zero, "[crc]") { #pragma GCC diagnostic ignored "-Wnonnull" CHECK( 0 == CRC_xmodem(NULL, 0) ); #pragma GCC diagnostic pop } This is sufficient to suppress the compile-time warnings, but scan-build still produces a warning:- snip/crc/crc_unittest.cpp:34:21: warning: Null pointer passed as an argument to a 'nonnull' parameter CHECK( 0 == CRC_xmodem(NULL, 0) ); ^ ~~~~ Currently I'm suppressing the warning using #ifndef __clang_analyzer__ but it would be tidier if the clang analyser respected the GCC pragma. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs