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) {
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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits