On 04.05.20 12:10, Kamil Rytarowski wrote:
On 04.05.2020 12:04, Jakub Jelinek wrote:
On Mon, May 04, 2020 at 11:49:27AM +0200, Kamil Rytarowski wrote:
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

It looks fine to me now.

Personally, I would include stdlib.h unconditionally and alloca.h on
!FreeBSD && !NetBSD.

It just just a test.
Perhaps it could
#include <stdlib.h>
#if __has_include(<alloca.h>)
#include <alloca.h>
#endif
?

        Jakub


This looks fine too.


K, fine with me. I'll commit this solution once I finished testing. Thanks,
Andreas

+2020-05-07  Andreas Tobler  <andre...@gcc.gnu.org>
+
+       * gcc.dg/analyzer/alloca-leak.c: Include alloca.h only if
+         available.
+       * gcc.dg/analyzer/data-model-1.c: Likewise
+       * gcc.dg/analyzer/malloc-1.c: Likewise.
+       * gcc.dg/analyzer/malloc-paths-8.c: Likewise.

diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
index 6d9fe3431ce..e4717a1bbb3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,6 @@
-#include <alloca.h>
-
+#include <stdlib.h>
+#if __has_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..32559952e34 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <alloca.h>
+#if __has_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..0f3f1fc760a 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,5 @@
-#include <alloca.h>
+#if __has_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..35035d27ff7 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,8 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */

 #include <stddef.h>
-#include <alloca.h>
+#if __has_include(<alloca.h>)
+#endif
 #include <stdlib.h>

 extern void do_stuff (const void *);

Reply via email to