[pushed] analyzer: fix uses of alloca in testsuite
Checks
Commit Message
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r13-5615-gd03ae4be2c6d48.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/call-summaries-2.c: Add
dg-require-effective-target alloca.
* gcc.dg/analyzer/imprecise-floating-point-1.c: Likewise.
* gcc.dg/analyzer/infinite-recursion-alloca.c: Likewise.
* gcc.dg/analyzer/malloc-callbacks.c: Likewise.
* gcc.dg/analyzer/out-of-bounds-5.c: Likewise. Remove includes
of <stdio.h> and <alloca.h>. Use "__builtin_free" rather than
"free", to match uses of "__builtin_malloc".
* gcc.dg/analyzer/putenv-1.c: Add dg-require-effective-target
alloca.
* gcc.dg/analyzer/write-to-string-literal-5.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c | 1 +
.../gcc.dg/analyzer/imprecise-floating-point-1.c | 2 ++
.../gcc.dg/analyzer/infinite-recursion-alloca.c | 2 ++
gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c | 2 ++
gcc/testsuite/gcc.dg/analyzer/out-of-bounds-5.c | 9 ++++-----
gcc/testsuite/gcc.dg/analyzer/putenv-1.c | 1 +
.../gcc.dg/analyzer/write-to-string-literal-5.c | 1 +
7 files changed, 13 insertions(+), 5 deletions(-)
Comments
On Tue, Jan 31, 2023 at 9:27 PM David Malcolm <dmalcolm@redhat.com> wrote:
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
> Pushed to trunk as r13-5615-gd03ae4be2c6d48.
>
> gcc/testsuite/ChangeLog:
> * gcc.dg/analyzer/call-summaries-2.c: Add
> dg-require-effective-target alloca.
> * gcc.dg/analyzer/imprecise-floating-point-1.c: Likewise.
> * gcc.dg/analyzer/infinite-recursion-alloca.c: Likewise.
> * gcc.dg/analyzer/malloc-callbacks.c: Likewise.
> * gcc.dg/analyzer/out-of-bounds-5.c: Likewise. Remove includes
> of <stdio.h> and <alloca.h>. Use "__builtin_free" rather than
> "free", to match uses of "__builtin_malloc".
> * gcc.dg/analyzer/putenv-1.c: Add dg-require-effective-target
> alloca.
> * gcc.dg/analyzer/write-to-string-literal-5.c: Likewise.
Thanks for this fix, these all pass now on Windows.
I hope I'm not being pedantic, but there's still a remaining
inconsistency in that some parts of the test use memcpy (like test6),
and others use __builtin_memcpy (like test98). There isn't a call to
__builtin_memset(), but there is a call to memset(). Maybe these
differences are intentional, though. If they aren't, and you wanted
to reduce it further, you could remove string.h and use the builtins.
You could also include stddef.h instead of stdlib.h, if all you need
is size_t.
@@ -1,4 +1,5 @@
/* { dg-additional-options "-fanalyzer-call-summaries --param analyzer-min-snodes-for-call-summary=0" } */
+/* { dg-require-effective-target alloca } */
/* There need to be at least two calls to a function for the
call-summarization code to be used.
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
#include <stdlib.h>
/* Tests warn on use of floating-point operands inside the calculation
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
typedef __SIZE_TYPE__ size_t;
int test_alloca_1 (void)
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
#include <stdlib.h>
typedef void *(*allocator_t) (size_t);
@@ -1,9 +1,8 @@
/* { dg-additional-options "-Wno-unused-but-set-variable" } */
+/* { dg-require-effective-target alloca } */
#include <string.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <alloca.h>
#include <stdint.h>
/* Tests with symbolic values. */
@@ -14,7 +13,7 @@ void test1 (size_t size)
if (!buf) return;
buf[size] = '\0'; /* { dg-warning "heap-based buffer overflow" } */
- free (buf);
+ __builtin_free (buf);
}
void test2 (size_t size)
@@ -23,7 +22,7 @@ void test2 (size_t size)
if (!buf) return;
buf[size + 1] = '\0'; /* { dg-warning "heap-based buffer overflow" } */
- free (buf);
+ __builtin_free (buf);
}
void test3 (size_t size, size_t op)
@@ -32,7 +31,7 @@ void test3 (size_t size, size_t op)
if (!buf) return;
buf[size + op] = '\0'; /* { dg-warning "heap-based buffer overflow" } */
- free (buf);
+ __builtin_free (buf);
}
void test4 (size_t size, unsigned short s)
@@ -1,4 +1,5 @@
/* { dg-additional-options "-Wno-analyzer-null-argument" } */
+/* { dg-require-effective-target alloca } */
#include <stdio.h>
#include <stdlib.h>
@@ -2,6 +2,7 @@
notes) works. */
/* { dg-additional-options "-fanalyzer-show-duplicate-count" } */
+/* { dg-require-effective-target alloca } */
#include "analyzer-decls.h"