analyzer: don't assume target has alloca [PR102779]

gcc/testsuite/ChangeLog:
	PR analyzer/102779
	* gcc.dg/analyzer/capacity-1.c: Add dg-require-effective-target
	alloca.  Use __builtin_alloca rather than alloca.
	* gcc.dg/analyzer/capacity-3.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2021-11-15 18:23:08 -05:00
parent 8c693978dd
commit a80d4e098b
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,5 @@
/* { dg-require-effective-target alloca } */
#include <stdlib.h>
#include "analyzer-decls.h"
@ -53,7 +55,7 @@ test_malloc (void)
void
test_alloca (size_t sz)
{
void *p = alloca (sz);
void *p = __builtin_alloca (sz);
__analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(sz_\[^\n\r\]*\\)'" } */
}

View File

@ -1,10 +1,12 @@
/* { dg-require-effective-target alloca } */
#include <stdlib.h>
#include "analyzer-decls.h"
static void __attribute__((noinline))
__analyzer_callee_1 (size_t inner_sz)
{
void *p = alloca (inner_sz);
void *p = __builtin_alloca (inner_sz);
__analyzer_dump_capacity (p); /* { dg-warning "capacity: 'INIT_VAL\\(outer_sz_\[^\n\r\]*\\)'" } */
}