[PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 3 02:02:38 PDT 2015
EricWF created this revision.
EricWF added reviewers: rsmith, majnemer.
EricWF added subscribers: cfe-commits, mclow.lists.
Currently when a function annotated with __attribute__((nonnull)) is called in an unevaluated context with a null argument a -Wnonnull warning is emitted.
This warning seems like a false positive unless the call expression is potentially evaluated.
Disclaimer: I have no idea what I'm doing.
http://reviews.llvm.org/D13408
Files:
lib/Sema/SemaChecking.cpp
test/Sema/non-null-warning.c
Index: test/Sema/non-null-warning.c
===================================================================
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -39,4 +39,5 @@
int main () {
foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
+ (void)sizeof(foo(0)); // expect no warning when in an unevaluated context.
}
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1348,7 +1348,8 @@
}
if (FDecl || Proto) {
- CheckNonNullArguments(*this, FDecl, Proto, Args, Loc);
+ if (!isUnevaluatedContext())
+ CheckNonNullArguments(*this, FDecl, Proto, Args, Loc);
// Type safety checking.
if (FDecl) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13408.36430.patch
Type: text/x-patch
Size: 800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151003/dc34994d/attachment.bin>
More information about the cfe-commits
mailing list