aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/malloc-4.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/analyzer/malloc-4.c')
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/malloc-4.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-4.c b/gcc/testsuite/gcc.dg/analyzer/malloc-4.c
new file mode 100644
index 00000000000..94d2825a33e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-4.c
@@ -0,0 +1,20 @@
+/* { dg-additional-options "-Wno-incompatible-pointer-types" } */
+
+#include <stdlib.h>
+
+struct foo;
+struct bar;
+void *hv (struct foo **tm)
+{
+ void *p = __builtin_malloc (4);
+ *tm = p;
+ if (!p)
+ abort ();
+ return p; /* { dg-warning "leak of 'tm'" } */
+}
+
+void a5 (void)
+{
+ struct bar *qb = NULL;
+ hv (&qb);
+} /* { dg-warning "leak of '\\(struct foo\\)qb'" } */