On Mon, Apr 1, 2013 at 12:42 PM, YunZhong Gao <[email protected]> wrote:
> static_assert does not seem to work with C programs > That's why I said to use _Static_assert. :-) > and tgmath does not seem to work with C++ programs. > > Using an array declaration works as Richard described, and > I update my patch accordingly. > Thanks, committed in r181527, with s/static_check/_Static_assert/, and with the test disabled for freestanding implementations (<tgmath.h> includes <math.h> -- this is still relying on system headers more than I'd like, but that seems hard to avoid). > http://llvm-reviews.chandlerc.com/D595 > > CHANGE SINCE LAST DIFF > http://llvm-reviews.chandlerc.com/D595?vs=1447&id=1470#toc > > Files: > lib/Headers/tgmath.h > test/Headers/tgmath.c > > Index: lib/Headers/tgmath.h > =================================================================== > --- lib/Headers/tgmath.h > +++ lib/Headers/tgmath.h > @@ -1340,15 +1340,15 @@ > > // creal > > -static float _Complex > +static float > _TG_ATTRS > __tg_creal(float __x) {return __x;} > > -static double _Complex > +static double > _TG_ATTRS > __tg_creal(double __x) {return __x;} > > -static long double _Complex > +static long double > _TG_ATTRS > __tg_creal(long double __x) {return __x;} > > Index: test/Headers/tgmath.c > =================================================================== > --- test/Headers/tgmath.c > +++ test/Headers/tgmath.c > @@ -0,0 +1,39 @@ > +// RUN: %clang -fsyntax-only %s > + > +#include <tgmath.h> > + > +#define static_check(x) extern char dummy_array[(x) ? 1 : -1] > + > +float f; > +double d; > +long double l; > + > +float complex fc; > +double complex dc; > +long double complex lc; > + > +// creal > + > +static_check(sizeof(creal(f)) == sizeof(f)); > +static_check(sizeof(creal(d)) == sizeof(d)); > +static_check(sizeof(creal(l)) == sizeof(l)); > + > +static_check(sizeof(creal(fc)) == sizeof(f)); > +static_check(sizeof(creal(dc)) == sizeof(d)); > +static_check(sizeof(creal(lc)) == sizeof(l)); > + > +// fabs > + > +static_check(sizeof(fabs(f)) == sizeof(f)); > +static_check(sizeof(fabs(d)) == sizeof(d)); > +static_check(sizeof(fabs(l)) == sizeof(l)); > + > +static_check(sizeof(fabs(fc)) == sizeof(f)); > +static_check(sizeof(fabs(dc)) == sizeof(d)); > +static_check(sizeof(fabs(lc)) == sizeof(l)); > + > +// logb > + > +static_check(sizeof(logb(f)) == sizeof(f)); > +static_check(sizeof(logb(d)) == sizeof(d)); > +static_check(sizeof(logb(l)) == sizeof(l)); >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
