summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r--clang/test/Analysis/malloc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index bdbd96e2be4..7be29301fe6 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -902,6 +902,23 @@ int HeapAssignment() {
return 0;
}
+int *retPtr();
+int *retPtrMightAlias(int *x);
+int cmpHeapAllocationToUnknown() {
+ int zero = 0;
+ int *yBefore = retPtr();
+ int *m = malloc(8);
+ int *yAfter = retPtrMightAlias(m);
+ if (yBefore == m) {
+ return 5/zero; // expected-warning {{This statement is never executed}}
+ }
+ if (yAfter == m) {
+ return 5/zero; // expected-warning {{This statement is never executed}}
+ }
+ free(m);
+ return 0;
+}
+
// ----------------------------------------------------------------------------
// False negatives.
OpenPOWER on IntegriCloud