static_assert does not seem to work with C programs
  and tgmath does not seem to work with C++ programs.

  Using an array declaration works as Richard described, and
  I update my patch accordingly.

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));
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

Reply via email to