]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: don't assume target has alloca [PR102779]
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 15 Nov 2021 23:23:08 +0000 (18:23 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 17 Nov 2021 01:59:49 +0000 (20:59 -0500)
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>
gcc/testsuite/gcc.dg/analyzer/capacity-1.c
gcc/testsuite/gcc.dg/analyzer/capacity-3.c

index 9ea41f72e1d286f0bb46bd8cff869e0ede92e094..2d12483329664264f0968ba91cb067c493d83bc4 100644 (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\]*\\)'" } */
 }
 
index 41e282cee92deb35b99d450e04c63c3f451800f2..c099ff5725d800c6b8d277d5815724a3c493f069 100644 (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\]*\\)'" } */
 }