testsuite: adjust call to abort in excess-precision-12

Message ID 20231207162743.686431-1-poulhies@adacore.com
State Accepted
Headers
Series testsuite: adjust call to abort in excess-precision-12 |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès Dec. 7, 2023, 4:27 p.m. UTC
  abort() is not always available, using the builtin as done in other
tests.

gcc/testsuite/ChangeLog:

	* g++.target/i386/excess-precision-12.C: call builtin_abort instead of abort.
---
Tested on x86_64-linux and x86_64-elf.

Ok for master?

 gcc/testsuite/g++.target/i386/excess-precision-12.C | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Jakub Jelinek Dec. 7, 2023, 4:44 p.m. UTC | #1
On Thu, Dec 07, 2023 at 05:27:28PM +0100, Marc Poulhiès wrote:
> abort() is not always available, using the builtin as done in other
> tests.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.target/i386/excess-precision-12.C: call builtin_abort instead of abort.
> ---
> Tested on x86_64-linux and x86_64-elf.
> 
> Ok for master?
> 
>  gcc/testsuite/g++.target/i386/excess-precision-12.C | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/testsuite/g++.target/i386/excess-precision-12.C b/gcc/testsuite/g++.target/i386/excess-precision-12.C
> index dff48c07c8b..e59f7c3b1fb 100644
> --- a/gcc/testsuite/g++.target/i386/excess-precision-12.C
> +++ b/gcc/testsuite/g++.target/i386/excess-precision-12.C
> @@ -13,8 +13,8 @@ main (void)
>    unsigned long long int u = (1ULL << 63) + 1;
>  
>    if ((f <=> u) >= 0)
> -    abort ();
> +    __builtin_abort ();
>  
>    if ((u <=> f) <= 0)
> -    abort ();
> +    __builtin_abort ();

Why wouldn't they have abort and what else does __builtin_abort () expand
to?
There are 2000+ other tests in gcc.target/i386/ which call abort (),
not __builtin_abort (), after including <stdlib.h> directly or indirectly
or declaring it themselves.  This test in particular includes <cstdlib>

Does whatever target you are running this into provide just std::abort ()
and not abort (); from <cstdlib>?  If so, perhaps it should call
std::abort (); instead of abort ().

	Jakub
  
Marc Poulhiès Dec. 11, 2023, 1:36 p.m. UTC | #2
Hello,

> Why wouldn't they have abort and what else does __builtin_abort () expand
> to?

It expands to abort but works around the "abort is undeclared" error.

> There are 2000+ other tests in gcc.target/i386/ which call abort (),
> not __builtin_abort (), after including <stdlib.h> directly or indirectly
> or declaring it themselves.  This test in particular includes <cstdlib>
>
> Does whatever target you are running this into provide just std::abort ()
> and not abort (); from <cstdlib>?  If so, perhaps it should call
> std::abort (); instead of abort ().

You are correct, std::abort() is a better solution. cstdlib does not
include stdlib.h because I'm on a non-hosted target. I'll send a
refreshed patch.

Thanks,
Marc
  

Patch

diff --git a/gcc/testsuite/g++.target/i386/excess-precision-12.C b/gcc/testsuite/g++.target/i386/excess-precision-12.C
index dff48c07c8b..e59f7c3b1fb 100644
--- a/gcc/testsuite/g++.target/i386/excess-precision-12.C
+++ b/gcc/testsuite/g++.target/i386/excess-precision-12.C
@@ -13,8 +13,8 @@  main (void)
   unsigned long long int u = (1ULL << 63) + 1;
 
   if ((f <=> u) >= 0)
-    abort ();
+    __builtin_abort ();
 
   if ((u <=> f) <= 0)
-    abort ();
+    __builtin_abort ();
 }