[RFA:] fix lack of #ifdef HAVE_C99_RUNTIME in builtins-20.c and elsewhere

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Sun Mar 18 13:46:00 GMT 2007

I see lots of errors for the builtins cases for cris-axis-elf (for example with -r123028):
FAIL: gcc.dg/builtins-20.c (test for excess errors)
FAIL: gcc.dg/builtins-59.c scan-tree-dump __builtin_cexpi
FAIL: gcc.dg/builtins-59.c scan-tree-dump-not sincos
FAIL: gcc.dg/builtins-61.c scan-tree-dump cexpi
FAIL: gcc.dg/builtins-61.c scan-tree-dump sin
FAIL: gcc.dg/builtins-61.c scan-tree-dump cos
FAIL: gcc.dg/builtins-61.c scan-tree-dump return 0.0
FAIL: gcc.dg/builtins-62.c scan-tree-dump-times cexpi 3

The gcc.log says:
FAIL: gcc.dg/builtins-20.c (test for excess errors)
Excess errors:
builtins-20.c:(.text+0x34): undefined reference to `_cargl'
builtins-20.c:(.text+0x46): undefined reference to `_atan2l'
builtins-20.c:(.text+0x66): undefined reference to `_link_error'
builtins-20.c:(.text+0x82): undefined reference to `_cargf'
builtins-20.c:(.text+0xa8): undefined reference to `_link_error'

And with -g added, the location is a bit clearer:
/home/hp/combined2/cris-regobj/cris-unknown-elf/./libgloss/cris/crtn.obuiltins-20.o: In function `test3l':
/home/hp/combined2/combined/gcc/testsuite/gcc.dg/builtins-20.c:678: undefined reference to `_cargl'
/home/hp/combined2/combined/gcc/testsuite/gcc.dg/builtins-20.c:678: undefined reference to `_atan2l'
/home/hp/combined2/combined/gcc/testsuite/gcc.dg/builtins-20.c:679: undefined reference to `_link_error'
builtins-20.o: In function `test3f':
/home/hp/combined2/combined/gcc/testsuite/gcc.dg/builtins-20.c:453: undefined reference to `_cargf'
/home/hp/combined2/combined/gcc/testsuite/gcc.dg/builtins-20.c:454: undefined reference to `_link_error'

but at:
Roger made an effort to adjust the tests
non-TARGET_C99_FUNCTIONS systems (like ports using newlib) so I
thought it wouldn't be that.  Did c99 calls slip in after that,
not being #ifdef-guarded?

For the other tests, gcc.log doesn't offer any further
information; it just repeats the scan-tree-dump failure, but
looking at the tests and at gcc/builtins.c it seems those test
are intended for C99-math systems only.

This patch covers just the tests mentioned above; there may be
others.  I'm not really sure whether there are real bugs here.
If you see something that shouldn't be affected by
TARGET_C99_FUNCTIONS, please tell and I'll open PR's.  It might
matter that cris-axis-elf floating-point is all-software and
sizeof (long double) == sizeof (double) (i.e. same thing).
Perhaps this is what's causing for example the atan2-tests in
builtins-20.c which seem to require atan insns, see
expand_builtin_mathfn_2.  If so, those tests are misplaced in
builtins-20 and should be split out into tests guarded by checks
for targets with such insns or perhaps large_long_double.

Testsuite changes also tested on native

Ok to commit?

:ADDPATCH testsuite:

	* gcc.dg/builtins-59.c, gcc.dg/builtins-61.c,
	gcc.dg/builtins-62.c: Require c99_math.
	* gcc.dg/builtins-20.c (test3f, test3l): Wrap cargf, cargl, atan2f
	and atan2l test in #ifdef HAVE_C99_RUNTIME.
	* lib/target-supports.exp (check_effective_target_c99_math): New.
Index: gcc.dg/builtins-62.c
--- gcc.dg/builtins-62.c	(revision 123028)
+++ gcc.dg/builtins-62.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target c99_math } */
 /* { dg-options "-O -ffinite-math-only -fdump-tree-optimized" } */
 double test1 (double x)
Index: gcc.dg/builtins-59.c
--- gcc.dg/builtins-59.c	(revision 123028)
+++ gcc.dg/builtins-59.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target c99_math } */
 /* { dg-options "-fdump-tree-gimple" } */
 double test (double x)
Index: gcc.dg/builtins-61.c
--- gcc.dg/builtins-61.c	(revision 123028)
+++ gcc.dg/builtins-61.c	(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target c99_math } */
 /* { dg-options "-O -ffast-math -fdump-tree-optimized" } */
 double test1 (double x)
Index: gcc.dg/builtins-20.c
--- gcc.dg/builtins-20.c	(revision 123028)
+++ gcc.dg/builtins-20.c	(working copy)
@@ -450,8 +450,10 @@ void test2f(float x, float y)
 void test3f(__complex__ float x, __complex__ float y, int i)
+#ifdef HAVE_C99_RUNTIME
   if (cargf(x) != atan2f(__imag__ x, __real__ x))
     link_error ();
   if (ccosf(x) != ccosf(-x))
@@ -675,8 +677,10 @@ void test2l(long double x, long double y
 void test3l(__complex__ long double x, __complex__ long double y, int i)
+#ifdef HAVE_C99_RUNTIME
   if (cargl(x) != atan2l(__imag__ x, __real__ x))
     link_error ();
   if (ccosl(x) != ccosl(-x))
Index: lib/target-supports.exp
--- lib/target-supports.exp	(revision 123028)
+++ lib/target-supports.exp	(working copy)
@@ -2228,3 +2228,16 @@ proc check_effective_target_wchar { } {
 	#include <wchar.h>
+# Return 1 if the target has c99 math functions as implied by
+# the target macro TARGET_C99_FUNCTIONS.
+proc check_effective_target_c99_math { } {
+    global srcdir
+    return [check_no_compiler_messages c99_math assembly {
+	#include "builtins-config.h"
+	#ifndef HAVE_C99_RUNTIME
+	#error "No HAVE_C99_RUNTIME"
+	#endif
+    } -I$srcdir/gcc.dg ]

brgds, H-P

More information about the Gcc-patches mailing list