int var __attribute__((overloadable)); void bad_attr_target(int) [[clang::overloadable]]; void params(void) __attribute__((overloadable(12)));
int *f(int) __attribute__((overloadable)); float *f(float);
int *f(int); double *f(double) __attribute__((overloadable));
int isdigit(int) __attribute__((overloadable));
void test_f(int iv, float fv, double dv) {
int *ip = f(iv);
float *fp = f(fv);
double *dp = f(dv);
}
int *accept_funcptr(int (*)()) __attribute__((overloadable)); float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable));
void test_funcptr(int (*f1)(int, double),
int (*f2)(int, float)) {
float *fp = accept_funcptr(f1);
accept_funcptr(f2); }
struct X { int x; float y; };
struct Y { int x; float y; };
int* accept_struct(struct X x) __attribute__((__overloadable__));
float* accept_struct(struct Y y) __attribute__((overloadable));
void test_struct(struct X x, struct Y y) {
int *ip = accept_struct(x);
float *fp = accept_struct(y);
}
double *f(int) __attribute__((overloadable));
double promote(float) __attribute__((__overloadable__));
double promote(double) __attribute__((__overloadable__));
long double promote(long double) __attribute__((__overloadable__));
void promote(...) __attribute__((__overloadable__, __unavailable__));
void test_promote(short* sp) {
promote(1.0);
promote(sp); }
typedef double Double;
typedef Double DoubleVec __attribute__((vector_size(16)));
typedef int Int;
typedef Int IntVec __attribute__((vector_size(16)));
double magnitude(DoubleVec) __attribute__((__overloadable__));
double magnitude(IntVec) __attribute__((__overloadable__));
double test_p6600(DoubleVec d) {
return magnitude(d) * magnitude(d);
}
extern int __attribute__((overloadable)) f0(); typedef int f1_type();
f1_type __attribute__((overloadable)) f1;
void test() {
f0();
f1();
}
void before_local_1(int) __attribute__((overloadable));
void before_local_2(int); void before_local_3(int) __attribute__((overloadable));
void local() {
void before_local_1(char);
void before_local_2(char); void before_local_3(char) __attribute__((overloadable));
void after_local_1(char);
void after_local_2(char) __attribute__((overloadable));
void after_local_3(char) __attribute__((overloadable));
}
void after_local_1(int) __attribute__((overloadable));
void after_local_2(int);
void after_local_3(int) __attribute__((overloadable));
void conversions() {
void foo(char *c) __attribute__((overloadable));
void foo(char *c) __attribute__((overloadable, enable_if(c, "nope.jpg")));
void *ptr;
foo(ptr);
void multi_type(unsigned char *c) __attribute__((overloadable));
void multi_type(signed char *c) __attribute__((overloadable));
unsigned char *c;
multi_type(c);
}
void fn_type_conversions() {
void foo(void *c) __attribute__((overloadable));
void foo(char *c) __attribute__((overloadable));
void (*ptr1)(void *) = &foo;
void (*ptr2)(char *) = &foo;
void (*ambiguous)(int *) = &foo; void *vp_ambiguous = &foo;
void (*specific1)(int *) = (void (*)(void *))&foo; void *specific2 = (void (*)(void *))&foo;
void disabled(void *c) __attribute__((overloadable, enable_if(0, "")));
void disabled(int *c) __attribute__((overloadable, enable_if(c, "")));
void disabled(char *c) __attribute__((overloadable, enable_if(1, "The function name lies.")));
void (*dptr1)(char *c) = &disabled;
void (*dptr2)(void *c) = &disabled; void (*dptr3)(int *c) = &disabled;
void *specific_disabled = &disabled;
}
void incompatible_pointer_type_conversions() {
char charbuf[1];
unsigned char ucharbuf[1];
int intbuf[1];
void foo(char *c) __attribute__((overloadable));
void foo(short *c) __attribute__((overloadable));
foo(charbuf);
foo(ucharbuf); foo(intbuf);
void bar(unsigned char *c) __attribute__((overloadable));
void bar(signed char *c) __attribute__((overloadable));
bar(charbuf); bar(ucharbuf);
bar(intbuf); }
void dropping_qualifiers_is_incompatible() {
const char ccharbuf[1];
volatile char vcharbuf[1];
void foo(char *c) __attribute__((overloadable));
void foo(const volatile unsigned char *c) __attribute__((overloadable));
foo(ccharbuf); foo(vcharbuf); }
void overloadable_with_global() {
void wg_foo(void) __attribute__((overloadable)); void wg_foo(int) __attribute__((overloadable));
}
int wg_foo;
#if !__has_extension(overloadable_unmarked)
#error "We should have unmarked overload support"
#endif
void to_foo0(int);
void to_foo0(double) __attribute__((overloadable)); void to_foo0(int);
void to_foo0(double); void to_foo0(int);
void to_foo1(int) __attribute__((overloadable)); void to_foo1(double);
void to_foo1(int); void to_foo1(double);
void to_foo1(int);
void to_foo2(int); void to_foo2(double) __attribute__((overloadable)); void to_foo2(int) __attribute__((overloadable)); void to_foo2(double); void to_foo2(int);
void to_foo2(double); void to_foo2(int);
void to_foo3(int);
void to_foo3(double) __attribute__((overloadable)); void to_foo3(int);
void to_foo3(double);
void to_foo4(int) __attribute__((overloadable)); void to_foo4(int); void to_foo4(double) __attribute__((overloadable));
void to_foo5(int);
void to_foo5(int); void to_foo5(float) __attribute__((overloadable));
void to_foo5(double); void to_foo5(float) __attribute__((overloadable));
void to_foo5(short); void to_foo5(long); void to_foo5(double) __attribute__((overloadable));
void to_foo6(int) __attribute__((enable_if(1, ""), overloadable)); void to_foo6(int) __attribute__((enable_if(1, ""))); void to_foo6(int) __attribute__((enable_if(1, ""), overloadable));
void to_foo7(int) __attribute__((enable_if(1, ""))); void to_foo7(int) __attribute__((enable_if(1, ""), overloadable)); void to_foo7(int) __attribute__((enable_if(1, "")));
void to_foo8(char *__attribute__((pass_object_size(0))))
__attribute__((enable_if(1, "")));
void to_foo8(char *__attribute__((pass_object_size(0))))
__attribute__((overloadable));
void to_foo9(int); void to_foo9(int) __attribute__((overloadable)); void to_foo9(float); void to_foo9(float) __attribute__((overloadable));
void to_foo9(double); void to_foo9(double) __attribute__((overloadable));
void to_foo10(int) __attribute__((overloadable));
void to_foo10(double); void to_foo10(float); void to_foo10(float); void to_foo10(float);
void typeof_function_is_not_a_pointer() {
void not_a_pointer(void *) __attribute__((overloadable));
void not_a_pointer(char *__attribute__((pass_object_size(1))))
__attribute__((overloadable));
__typeof__(not_a_pointer) *fn;
void take_fn(void (*)(void *));
take_fn(fn);
}
__attribute__((overloadable)) void can_overload_1(...); void can_overload_2(...) __attribute__((overloadable)); [[clang::overloadable]] void can_overload_3(...); void can_overload_4 [[clang::overloadable]] (...); void cannot_overload(...) [[clang::overloadable]];