analyzer: Use __builtin_alloca in gcc.dg/analyzer/call-summaries-2.c

Message ID yddmt8hpzro.fsf@CeBiTec.Uni-Bielefeld.DE
State Committed
Commit 603af25815523ba9e39e9b441cde5308423a9238
Headers
Series analyzer: Use __builtin_alloca in gcc.dg/analyzer/call-summaries-2.c |

Commit Message

Rainer Orth Nov. 23, 2022, 1:27 p.m. UTC
  gcc.dg/analyzer/call-summaries-2.c currently FAILs on Solaris:

FAIL: gcc.dg/analyzer/call-summaries-2.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c:468:12: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c:468:12: warning: incompatible implicit decl

alloca is only declared in <alloca.h>, which isn't included indirectly
anywhere.  To avoid this, I switched the test to use __builtin_alloca
instead, following the vast majority of analyzer tests that use alloca.

Tested no i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

Ok for trunk?

There are a handful of tests that explicitly include <alloca.h> instead,
which is of course an alternative if preferred.

	Rainer
  

Comments

David Malcolm Nov. 23, 2022, 2:58 p.m. UTC | #1
On Wed, 2022-11-23 at 14:27 +0100, Rainer Orth wrote:
> gcc.dg/analyzer/call-summaries-2.c currently FAILs on Solaris:
> 
> FAIL: gcc.dg/analyzer/call-summaries-2.c (test for excess errors)
> 
> Excess errors:
> /vol/gcc/src/hg/master/local/gcc/testsuite/gcc.dg/analyzer/call-
> summaries-2.c:468:12: warning: implicit declaration of function
> 'alloca' [-Wimplicit-function-declaration]
> /vol/gcc/src/hg/master/local/gcc/testsuite/gcc.dg/analyzer/call-
> summaries-2.c:468:12: warning: incompatible implicit decl
> 
> alloca is only declared in <alloca.h>, which isn't included
> indirectly
> anywhere.  To avoid this, I switched the test to use __builtin_alloca
> instead, following the vast majority of analyzer tests that use
> alloca.
> 
> Tested no i386-pc-solaris2.11, sparc-sun-solaris2.11, and
> x86_64-pc-linux-gnu.
> 
> Ok for trunk?

Yes

Thanks
Dave

> 
> There are a handful of tests that explicitly include <alloca.h>
> instead,
> which is of course an alternative if preferred.
> 
>         Rainer
>
  

Patch

diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
--- a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
@@ -465,7 +465,7 @@  int test_returns_external_result (void)
 
 int uses_alloca (int i)
 {
-  int *p = alloca (sizeof (int));
+  int *p = __builtin_alloca (sizeof (int));
   *p = i;
   return *p;
 }