Skip some builtins tests if there is no C99 runtime

Richard Sandiford rsandifo@nildram.co.uk
Wed Sep 19 13:41:00 GMT 2007


This patch is part 2/2 of the change described here:

    http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01539.html

Four gcc.dg/builtins* tests are testing things that only work on
TARGET_C99_FUNCTIONS targets:

    builtins-20.c:
        carg{f,l} -> atan2{f,l}.

        atan2 is only implicitly defined on C99 targets

    builtins-59.c:
        sincos -> cexpi

        The optimisation is explicitly conditional on TARGET_C99_FUNCTIONS
        (fold_builtin_sincos).

    builtins-61.c:
        cexp -> cexpi

        The optimisation is explicitly conditional on TARGET_C99_FUNCTIONS
        (fold_builtin_cexp).

    builtins-62.c:
        sin,cos -> cexpi

        The optimisation is gated on TARGET_C99_FUNCTIONS ||
        TARGET_HAS_SINCOS (gate_cse_sincos).  However, at the moment,
        TARGET_HAS_SINCOS => TARGET_C99_FUNCTIONS.

This patch therefore borrows H-J's idea of using builtin-config.h,
but this time compiling it with the flags specified by
add_options_for_c99_runtime.  I read the file into the harness
to keep it cross-host friendly.  (We could have used a download-
test-delete sequence instead, but what the patch does seems easier,
and has the advantage of using the same path for native and cross hosts.)

I also commonised the cut-&-pasted caching code in
check_no_compiler_messages and check_no_messages_and_pattern,
so that it was easy to add a third instance here.  It might be
nice to use the new function for other check_effective_target_*
procedures too, but that's a much bigger change.

When making the builtins-20.c tests conditional on HAVE_C99_RUNTIME,
I also moved them to the end of the function, because the other
functions in the file also do the C99-specific tests last.

Tested on x86_64-linux-gnu, where all tests continue to run and pass.
Also tested on mipsisa64-elfoabi, where the tests are now correctly
skipped.  OK to install?

Richard


gcc/testsuite/
	* lib/target-supports.exp (check_cached_effective_target): New
	procedure.
	(check_no_compiler_messages, check_no_messages_and_pattern): Use it.
	(check_effective_target_c99_runtime): New procedure.
	* gcc.dg/builtins-20.c (test3f): Wrap cargf check in HAVE_C99_RUNTIME.
	(test3l): Likewise cargl.
	* gcc.dg/builtins-59.c: Require c99_runtime.
	* gcc.dg/builtins-61.c: Likewise.
	* gcc.dg/builtins-62.c: Likewise.

Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp	2007-09-19 13:42:58.000000000 +0100
+++ gcc/testsuite/lib/target-supports.exp	2007-09-19 13:45:27.000000000 +0100
@@ -87,43 +87,41 @@ proc current_target_name { } {
 }
 
 # Implement an effective-target check for property PROP by invoking
-# the compiler and seeing if it prints any messages.  Assume that the
-# property holds if the compiler doesn't print anything.  The other
-# arguments are as for get_compiler_messages, starting with TYPE.
-proc check_no_compiler_messages {prop args} {
+# the Tcl command ARGS and seeing if it returns true.
+
+proc check_cached_effective_target { prop args } {
     global et_cache
 
     set target [current_target_name]
     if {![info exists et_cache($prop,target)]
 	|| $et_cache($prop,target) != $target} {
-	verbose "check_no_compiler_messages $prop: compiling source for $target" 2
+	verbose "check_cached_effective_target $prop: checking $target" 2
 	set et_cache($prop,target) $target
-	set et_cache($prop,value) \
-	    [string match "" [eval get_compiler_messages $prop 0 $args]]
+	set et_cache($prop,value) [uplevel eval $args]
     }
     set value $et_cache($prop,value)
-    verbose "check_no_compiler_messages $prop: returning $value for $target" 2
+    verbose "check_cached_effective_target $prop: returning $value for $target" 2
     return $value
 }
 
+# Implement an effective-target check for property PROP by invoking
+# the compiler and seeing if it prints any messages.  Assume that the
+# property holds if the compiler doesn't print anything.  The other
+# arguments are as for get_compiler_messages, starting with TYPE.
+proc check_no_compiler_messages {prop args} {
+    return [check_cached_effective_target $prop {
+	string match "" [eval get_compiler_messages $prop 0 $args]
+    }]
+}
+
 # Similar to check_no_compiler_messages, but also verify that the regular
 # expression PATTERN matches the compiler's output.
 proc check_no_messages_and_pattern {prop pattern args} {
-    global et_cache
-
-    set target [current_target_name]
-    if {![info exists et_cache($prop,target)]
-	|| $et_cache($prop,target) != $target} {
-	verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
-	set et_cache($prop,target) $target
+    return [check_cached_effective_target $prop {
 	set results [eval get_compiler_messages $prop 1 $args]
-	set et_cache($prop,value) \
-	    [expr [string match "" [lindex $results 0]] \
-		 && [regexp $pattern [lindex $results 1]]]
-    }
-    set value $et_cache($prop,value)
-    verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
-    return $value
+	expr { [string match "" [lindex $results 0]]
+	       && [regexp $pattern [lindex $results 1]] }
+    }]
 }
 
 ###############################
@@ -2516,3 +2514,22 @@ proc add_options_for_c99_runtime { flags
     }
     return $flags
 }
+
+# Return 1 if the target provides a full C99 runtime.
+
+proc check_effective_target_c99_runtime { } {
+    return [check_cached_effective_target c99_runtime {
+	global srcdir
+
+	set file [open "$srcdir/gcc.dg/builtins-config.h"]
+	set contents [read $file]
+	close $file
+	append contents {
+	    #ifndef HAVE_C99_RUNTIME
+	    #error FOO
+	    #endif
+	}
+	string match "" [get_compiler_messages c99_runtime 0 assembly \
+			     $contents [add_options_for_c99_runtime ""]]
+    }]
+}
Index: gcc/testsuite/gcc.dg/builtins-20.c
===================================================================
--- gcc/testsuite/gcc.dg/builtins-20.c	2007-09-19 13:42:58.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtins-20.c	2007-09-19 13:45:49.000000000 +0100
@@ -449,9 +449,6 @@ void test2f(float x, float y)
 
 void test3f(__complex__ float x, __complex__ float y, int i)
 {
-  if (cargf(x) != atan2f(__imag__ x, __real__ x))
-    link_error ();
-
   if (ccosf(x) != ccosf(-x))
     link_error();
 
@@ -502,6 +499,11 @@ void test3f(__complex__ float x, __compl
 
   if (ctanf(~(x/y)) != -ctanf(~(x/-y)))
     link_error();
+
+#ifdef HAVE_C99_RUNTIME
+  if (cargf(x) != atan2f(__imag__ x, __real__ x))
+    link_error ();
+#endif
 }
 
 void test1l(long double x)
@@ -674,9 +676,6 @@ void test2l(long double x, long double y
 
 void test3l(__complex__ long double x, __complex__ long double y, int i)
 {
-  if (cargl(x) != atan2l(__imag__ x, __real__ x))
-    link_error ();
-
   if (ccosl(x) != ccosl(-x))
     link_error();
 
@@ -727,6 +726,11 @@ void test3l(__complex__ long double x, _
 
   if (ctanl(~(x/y)) != -ctanl(~(x/-y)))
     link_error();
+
+#ifdef HAVE_C99_RUNTIME
+  if (cargl(x) != atan2l(__imag__ x, __real__ x))
+    link_error ();
+#endif
 }
 
 int main()
Index: gcc/testsuite/gcc.dg/builtins-59.c
===================================================================
--- gcc/testsuite/gcc.dg/builtins-59.c	2007-09-19 13:42:45.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtins-59.c	2007-09-19 13:45:27.000000000 +0100
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fdump-tree-gimple" } */
+/* { dg-require-effective-target c99_runtime } */
 
 double test (double x)
 {
Index: gcc/testsuite/gcc.dg/builtins-61.c
===================================================================
--- gcc/testsuite/gcc.dg/builtins-61.c	2007-09-19 13:42:45.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtins-61.c	2007-09-19 13:45:27.000000000 +0100
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -ffast-math -fdump-tree-optimized" } */
+/* { dg-require-effective-target c99_runtime } */
 
 double test1 (double x)
 {
Index: gcc/testsuite/gcc.dg/builtins-62.c
===================================================================
--- gcc/testsuite/gcc.dg/builtins-62.c	2007-09-19 13:42:45.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtins-62.c	2007-09-19 13:45:27.000000000 +0100
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O -ffinite-math-only -fdump-tree-optimized" } */
+/* { dg-require-effective-target c99_runtime } */
 
 double test1 (double x)
 {



More information about the Gcc-patches mailing list