diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-17 02:14:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-17 02:14:31 +0000 |
commit | 5f3d0aef115e9a0b42701fc8957ad7d33e8db187 (patch) | |
tree | d88d3b7ce079a76cfa90a934310d1db10d097f85 | |
parent | 574aa40703ffb2fddad5b076cec1c2fc27f0b2d3 (diff) |
start converting over to attr(overloadable). Unfortunately, this
produces really horrible diagnostics when overload ambiguities
happen:
t.c:10:10: error: call to '__tg_acos' is ambiguous; candidates are:
return acos(x);
^~~~
In file included from t.c:1:
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
A possible fix is to just not use macros for this, which I'll probably go for,
but it would be nice to emit the type at the call, so we know what we asked for!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64720 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Headers/tgmath-sofar.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Headers/tgmath-sofar.h b/lib/Headers/tgmath-sofar.h index 07cad5a188..0377909c56 100644 --- a/lib/Headers/tgmath-sofar.h +++ b/lib/Headers/tgmath-sofar.h @@ -32,11 +32,26 @@ #ifndef __cplusplus #include <complex.h> +#define __TG_UNARY_OVERLOAD(TYPE, SRCFN, DSTFN) \ + static TYPE __attribute__((overloadable, always_inline)) __tg_ ## SRCFN(TYPE x) { return DSTFN(x); } + + +/* __TG_RC_1 - Unary functions defined on both real and complex values. */ +#define __TG_RC_1(op, REALFN, COMPLEXFN) \ + __TG_UNARY_OVERLOAD(float, REALFN, REALFN ## f) \ + __TG_UNARY_OVERLOAD(double, REALFN, REALFN) \ + __TG_UNARY_OVERLOAD(long double, REALFN, REALFN ## l) \ + __TG_UNARY_OVERLOAD(_Complex float, REALFN, COMPLEXFN ## f) \ + __TG_UNARY_OVERLOAD(_Complex double, REALFN, COMPLEXFN) \ + __TG_UNARY_OVERLOAD(_Complex long double, REALFN, COMPLEXFN ## l) + /* C99 7.22p4, functions in both math.h and complex.h. */ -#define acos(x) \ - __builtin_overload(1, x, cacosl, cacos, cacosf, acosl, acos, acosf) -#define asin(x) \ - __builtin_overload(1, x, casinl, casin, casinf, asinl, asin, asinf) +__TG_RC_1(x, acos, cacos) +#define acos(x) __tg_acos(x) +__TG_RC_1(x, asin, casin) +#define asin(x) __tg_asin(x) + + #define atan(x) \ __builtin_overload(1, x, catanl, catan, catanf, atanl, atan, atanf) #define acosh(x) \ |