On Fri, 21 Oct 2022, Florian Weimer via Gcc wrote:

> What should we do about these when they are not relevant to what's being
> tested?  For example, gcc/testsuite/gcc.c-torture/execute/ieee/mzero6.c
> has this:
> 
>   int main ()
>   {
>     if (__builtin_copysign (1.0, func (0.0 / -5.0, 10)) != -1.0)
>       abort ();
>     exit (0);
>   }
> 
> but no include files, so abort and exit are implicitly declared.
> 
> Should we inject a header with -include with the most common
> declarations (which includes at least abort and exit)?  Or add the
> missing #include directives?  But the latter might not work for
> freestanding targets.

If it's clear the test is testing something other than those implicit 
function declarations, either declaring the functions or using 
__builtin_exit and __builtin_abort seems reasonable.

> Implicit ints and function declarations without prototypes are also
> common (not just for main).
> 
> Other tests look like they might be intended to be built in C89 mode,
> e.g.  gcc/testsuite/gcc.c-torture/compile/386.c, although it's not
> immediately obvious to me what they test.

For tests that might be deliberately testing implicit function 
declarations or unprototyped functions, it's probably better to use 
explicit options that avoid errors (note that the c-torture tests already 
use -w to disable all warnings).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to