[llvm-bugs] [Bug 28275] New: Static analyser doesn't respect #pragma GCC diagnostic ignored "-Wnonnull"
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 23 01:50:50 PDT 2016
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: kremenek at apple.com
Reporter: sgubmvll at mjt.me.uk
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160623/78b8937b/attachment.html>
More information about the llvm-bugs
mailing list