On 03.05.20 18:27, Kamil Rytarowski wrote:
On 01.05.2020 21:49, Andreas Tobler wrote:
Hi all,

FreeBSD does not have the alloca.h header. Do not include it in the test
cases which do include alloca.h.

There are two versions of this patch available, the one attached which
uses ifdef or another one which defines alloca with __builtin_alloca.

I tested both approaches and they work on FreeBSD. I do not know which
one you prefer.

Opinions welcome.

Ok for trunk?
TIA,
Andreas

Please include in your patch "|| defined(__NetBSD__)".

is this ok for you?

This is one reason why I'd prefer #define alloca __builtin_alloca and leave the include away.....

Andreas
From 70165e30fb5b4398c903b4522d6496c7da7c12fa Mon Sep 17 00:00:00 2001
From: Andreas Tobler <andre...@gcc.gnu.org>
Date: Fri, 1 May 2020 21:10:39 +0200
Subject: [PATCH] testsuite: analyzer: Fix header include for Free/NetBSD

FreeBSD and NetBSD do not have the alloca.h header.
Fix this with ifndef on alloca.h.
---
 gcc/testsuite/ChangeLog                        | 8 ++++++++
 gcc/testsuite/gcc.dg/analyzer/alloca-leak.c    | 5 ++++-
 gcc/testsuite/gcc.dg/analyzer/data-model-1.c   | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-1.c       | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c | 2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 185f9ea725e..3f7b409bd42 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-03  Andreas Tobler  <andre...@gcc.gnu.org>
+
+       * gcc.dg/analyzer/alloca-leak.c: Do not include
+         alloca.h for Free/NetBSD.
+       * gcc.dg/analyzer/data-model-1.c: Likewise
+       * gcc.dg/analyzer/malloc-1.c: Likewise.
+       * gcc.dg/analyzer/malloc-paths-8.c: Likewise.
+
 2020-05-01  H.J. Lu  <hongjiu...@intel.com>
 
        PR target/93492
diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c 
b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
index 6d9fe3431ce..631e81b8cf4 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,8 @@
+#if defined (__FreeBSD__) || defined(__NetBSD__)
+#include <stdlib.h>
+#else
 #include <alloca.h>
-
+#endif
 void *test (void)
 {
   void *ptr = alloca (64);
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c 
b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index 1db99133d50..f06651802a5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include <alloca.h>
+#endif
 #include "analyzer-decls.h"
 
 struct foo
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 3024e546137..046e3353192 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,6 @@
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include <alloca.h>
+#endif
 #include <stdlib.h>
 
 extern int foo (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
index 10b97a05402..d55d6350da8 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,9 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */
 
 #include <stddef.h>
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include <alloca.h>
+#endif
 #include <stdlib.h>
 
 extern void do_stuff (const void *);
-- 
2.24.1

Reply via email to