forked from OSchip/llvm-project
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! llvm-svn: 64720
This commit is contained in:
parent
cba4b6f83d
commit
4e843feddc
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue