+2020-01-30 David Malcolm <dmalcolm@redhat.com>
+
+ * gcc.dg/analyzer/malloc-1.c: Remove include of <string.h>.
+ Use __builtin_ forms of memset and strlen throughout.
+
2020-01-30 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/analyzer/conditionals-2.c: Move to...
#include <alloca.h>
#include <stdlib.h>
-#include <string.h>
extern int foo (void);
extern int bar (void);
void *ptr = malloc(4096);
if (!ptr)
return;
- memset(ptr, 0, 4096);
+ __builtin_memset(ptr, 0, 4096);
free(ptr);
}
void *ptr = malloc(4096);
if (!ptr)
return NULL;
- memset(ptr, 0, 4096);
+ __builtin_memset(ptr, 0, 4096);
return ptr;
/* This needs phi nodes to affect equivalence classes, or we get a false report
of a leak. */
void *ptr = malloc(4096);
if (!ptr)
return -1;
- memset(ptr, 0, 4096);
+ __builtin_memset(ptr, 0, 4096);
free(ptr);
return 0;
}
void *ptr = malloc(4096);
if (!ptr)
return;
- memset(ptr, 0, 4096);
+ __builtin_memset(ptr, 0, 4096);
free(ptr);
}
void *test_37a (void)
{
void *ptr = malloc(4096); /* { dg-message "this call could return NULL" } */
- memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected" } */
+ __builtin_memset(ptr, 0, 4096); /* { dg-warning "use of possibly-NULL 'ptr' where non-null expected" } */
return ptr;
}
void *p = malloc(4096);
void *q = malloc(4096); /* { dg-message "this call could return NULL" } */
if (p) {
- memset(p, 0, 4096); /* Not a bug: checked */
+ __builtin_memset(p, 0, 4096); /* Not a bug: checked */
} else {
- memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected" } */
+ __builtin_memset(q, 0, 4096); /* { dg-warning "use of possibly-NULL 'q' where non-null expected" } */
}
free(p);
free(q);
int retval = maybe_alloc (&p); /* this might write to "p". */
if (retval)
return (retval);
- p_size = strlen(p); /* { dg-bogus "non-null expected" } */
+ p_size = __builtin_strlen(p); /* { dg-bogus "non-null expected" } */
free (p);
}
return p_size;