diff options
| author | Eric Fiselier <eric@efcs.ca> | 2015-10-09 00:17:57 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2015-10-09 00:17:57 +0000 |
| commit | 18677d51e04af0b4a11212047dbbeefdd0231869 (patch) | |
| tree | 9829d5ec07c89a8bfaeecf56ef346f3f416458a9 /clang/test/Sema | |
| parent | ebef256269997b5466d387c2a8b0ce93b34142eb (diff) | |
| download | bcm5719-llvm-18677d51e04af0b4a11212047dbbeefdd0231869.tar.gz bcm5719-llvm-18677d51e04af0b4a11212047dbbeefdd0231869.zip | |
Skip NonNull sema checks in unevaluated contexts.
Summary:
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. Change this behavior so that the non-null warnings use DiagRuntimeBehavior so they wont emit when they won't be evaluated.
Reviewers: majnemer, rsmith
Subscribers: mclow.lists, cfe-commits
Differential Revision: http://reviews.llvm.org/D13408
llvm-svn: 249787
Diffstat (limited to 'clang/test/Sema')
| -rw-r--r-- | clang/test/Sema/non-null-warning.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/test/Sema/non-null-warning.c b/clang/test/Sema/non-null-warning.c index 024ef1eca66..7dfa3900cbb 100644 --- a/clang/test/Sema/non-null-warning.c +++ b/clang/test/Sema/non-null-warning.c @@ -37,6 +37,9 @@ int * ret_nonnull() { return 0; // expected-warning {{null returned from function that requires a non-null return value}} } +#define SAFE_CALL(X) if (X) foo(X) int main () { foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}} + (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context. + SAFE_CALL(0); // expect no diagnostic for unreachable code. } |

