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

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Tue Mar 20 00:03:00 GMT 2007


> Date: Mon, 19 Mar 2007 13:09:13 -0400 (EDT)
> From: "Kaveh R. GHAZI" <ghazi@caip.rutgers.edu>

> On Sun, 18 Mar 2007, Hans-Peter Nilsson wrote:
> > +# 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 ]
> > +}
> 
> I'm not sure this bit is right.  Certain targets (solaris, darwin?)
> require special flags to compile builtins-config.h cleanly and activate
> C99 mode.  With your test, they will fail this check and bypass any test
> marked with c99_math.

Bypassing these tests for targets that need special care to
activate C99 is right in this case, IMHO.  Of course, the code
above could be augmented by tests and options for those targets
where special care is needed, but then all the tests would also
have to have special dg-options for them, as below.  I went for
simplicity; there are plenty of primary targets where the
c99-enabled optimizations are exercised and the extra coverage
for special-care targets gives little but extra complexity.

> Is there a way to just use the existing idiom in all the tests by wrapping
> the offending code with HAVE_C99_RUNTIME and avoid the new "target
> supports" check?

Not really, the "existing idiom" doesn't carry over to the other
tests.  You'd add dg-options lines for each such target like
what follows, and still have to solve the problem of making e.g.
dg-final tests pass where HAVE_C99_RUNTIME isn't defined; you
can't always hope to use a #ifdef HAVE_C99_RUNTIME test_it #else
make_it_pass #endif.  Compare to the single dg-require line.

--- builtins-59.c.c99_math	2007-03-18 12:52:50.000000000 +0100
+++ builtins-59.c.bloat	2007-03-19 23:48:58.000000000 +0100
@@ -1,11 +1,17 @@
 /* { dg-do compile } */
-/* { dg-require-effective-target c99_math } */
 /* { dg-options "-fdump-tree-gimple" } */
+/* { dg-options "-fdump-tree-gimple -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
+/* { dg-options "-fdump-tree-gimple -std=c99" { target *-*-solaris2* } } */
+#include "builtins-config.h"
 
 double test (double x)
 {
   double s, c;
+#ifdef HAVE_C99_RUNTIME
   __builtin_sincos (x, &s, &c);
+#else
+  __builtin_cexpi (x*some_lame_expression(&s, &c));
+#endif
   return s + c;
 }


The original patch is IMHO the better choice.

brgds, H-P



More information about the Gcc-patches mailing list