public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: NightStrike <nightstrike@gmail.com>, David Malcolm <dmalcolm@redhat.com>
Subject: [pushed] analyzer: fix uses of alloca in testsuite
Date: Tue, 31 Jan 2023 21:27:55 -0500	[thread overview]
Message-ID: <20230201022755.825041-1-dmalcolm@redhat.com> (raw)
In-Reply-To: <22c944dff18fc7afeb9c8acd1d1e5d05e2cc6312.camel@redhat.com>

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(-)

diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
index 22ca475b2ed..2d82d02e4e2 100644
--- a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/analyzer/imprecise-floating-point-1.c b/gcc/testsuite/gcc.dg/analyzer/imprecise-floating-point-1.c
index d8a3f4884d6..7fe09fb826b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/imprecise-floating-point-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/imprecise-floating-point-1.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
 #include <stdlib.h>
 
 /* Tests warn on use of floating-point operands inside the calculation
diff --git a/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-alloca.c b/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-alloca.c
index 8c50631d8ce..87727e8ca25 100644
--- a/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-alloca.c
+++ b/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-alloca.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
 typedef __SIZE_TYPE__ size_t;
 
 int test_alloca_1 (void)
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
index c79f80d376d..cf3927fcaea 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-callbacks.c
@@ -1,3 +1,5 @@
+/* { dg-require-effective-target alloca } */
+
 #include <stdlib.h>
 
 typedef void *(*allocator_t) (size_t);
diff --git a/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-5.c b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-5.c
index eb6aae0f8cb..2a61d8ca236 100644
--- a/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-5.c
@@ -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)
diff --git a/gcc/testsuite/gcc.dg/analyzer/putenv-1.c b/gcc/testsuite/gcc.dg/analyzer/putenv-1.c
index 4c3f0ae2e74..543121258c8 100644
--- a/gcc/testsuite/gcc.dg/analyzer/putenv-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/putenv-1.c
@@ -1,4 +1,5 @@
 /* { dg-additional-options "-Wno-analyzer-null-argument" } */
+/* { dg-require-effective-target alloca } */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/gcc.dg/analyzer/write-to-string-literal-5.c b/gcc/testsuite/gcc.dg/analyzer/write-to-string-literal-5.c
index b7ac4659012..42efc49fb22 100644
--- a/gcc/testsuite/gcc.dg/analyzer/write-to-string-literal-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/write-to-string-literal-5.c
@@ -2,6 +2,7 @@
    notes) works.  */
 
 /* { dg-additional-options "-fanalyzer-show-duplicate-count" } */
+/* { dg-require-effective-target alloca } */
 
 #include "analyzer-decls.h"
 
-- 
2.26.3


       reply	other threads:[~2023-02-01  2:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <22c944dff18fc7afeb9c8acd1d1e5d05e2cc6312.camel@redhat.com>
2023-02-01  2:27 ` David Malcolm [this message]
2023-02-02  1:02   ` NightStrike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230201022755.825041-1-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nightstrike@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).