#define O_CREAT 0x100
typedef int mode_t;
typedef unsigned long size_t;
enum { TRUE = 1 };
int open(const char *pathname, int flags) __attribute__((enable_if(!(flags & O_CREAT), "must specify mode when using O_CREAT"))) __attribute__((overloadable)); int open(const char *pathname, int flags, mode_t mode) __attribute__((overloadable));
void test1(void) {
#ifndef CODEGEN
open("path", O_CREAT); #endif
open("path", O_CREAT, 0660);
open("path", 0);
open("path", 0, 0);
}
size_t __strnlen_chk(const char *s, size_t requested_amount, size_t s_len);
size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__asm__("strnlen_real1");
__attribute__((always_inline))
inline size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
{
return __strnlen_chk(s, maxlen, __builtin_object_size(s, 0));
}
size_t strnlen(const char *s, size_t maxlen)
__attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
__attribute__((enable_if(maxlen <= __builtin_object_size(s, 0),
"chosen when 'maxlen' is known to be less than or equal to the buffer size")))
__asm__("strnlen_real2");
size_t strnlen(const char *s, size_t maxlen) __attribute__((overloadable))
__attribute__((enable_if(__builtin_object_size(s, 0) != -1,
"chosen when target buffer size is known")))
__attribute__((enable_if(maxlen > __builtin_object_size(s, 0),
"chosen when 'maxlen' is larger than the buffer size")))
__attribute__((unavailable("'maxlen' is larger than the buffer size")));
void test2(const char *s, int i) {
const char c[123];
strnlen(s, i);
strnlen(s, 999);
strnlen(c, 1);
strnlen(c, i);
#ifndef CODEGEN
strnlen(c, 999); #endif
}
int isdigit(int c) __attribute__((overloadable));
int isdigit(int c) __attribute__((overloadable)) __attribute__((enable_if(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
__attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
void test3(int c) {
isdigit(c); isdigit(10); #ifndef CODEGEN
isdigit(-10); #endif
}
int isdigit2(int c) __attribute__((overloadable));
int isdigit2(int c) __attribute__((overloadable)) __attribute__((__enable_if__(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
__attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
void test4(int c) {
isdigit2(c);
isdigit2(10);
#ifndef CODEGEN
isdigit2(-10); #endif
}
void test5(void) {
int (*p1)(int) = &isdigit2;
int (*p2)(int) = isdigit2;
void *p3 = (void *)&isdigit2;
void *p4 = (void *)isdigit2;
}
#ifndef CODEGEN
__attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) void f1(int n);
int n __attribute__((enable_if(1, "always chosen")));
void f(int n) __attribute__((enable_if("chosen when 'n' is zero", n == 0)));
void f(int n) __attribute__((enable_if()));
void f(int n) __attribute__((enable_if(unresolvedid, "chosen when 'unresolvedid' is non-zero")));
int global;
void f(int n) __attribute__((enable_if(global == 0, "chosen when 'global' is zero")));
enum { cst = 7 };
void return_cst(void) __attribute__((overloadable)) __attribute__((enable_if(cst == 7, "chosen when 'cst' is 7")));
void test_return_cst(void) { return_cst(); }
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(1, "always chosen")));
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(0, "never chosen")));
void f2(void) __attribute__((overloadable)) __attribute__((enable_if(TRUE, "always chosen #2")));
void test6(void) {
void (*p1)(void) = &f2; void (*p2)(void) = f2; void *p3 = (void*)&f2; void *p4 = (void*)f2; }
void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m >= 0, "positive")));
void f3(int m) __attribute__((overloadable)) __attribute__((enable_if(m < 0, "negative")));
void test7(void) {
void (*p1)(int) = &f3; void (*p2)(int) = f3; void *p3 = (void*)&f3; void *p4 = (void*)f3; }
void f4(int m) __attribute__((enable_if(0, "")));
void test8(void) {
void (*p1)(int) = &f4; void (*p2)(int) = f4; }
void regular_enable_if(int a) __attribute__((enable_if(a, ""))); void PR27122_ext(void) {
regular_enable_if(0, 2); regular_enable_if(1, 2); regular_enable_if(); }
void variadic_enable_if(int a, ...) __attribute__((enable_if(a, ""))); void variadic_test(void) {
variadic_enable_if(1);
variadic_enable_if(1, 2);
variadic_enable_if(1, "c", 3);
variadic_enable_if(0); variadic_enable_if(0, 2); variadic_enable_if(0, "c", 3);
int m;
variadic_enable_if(1);
variadic_enable_if(1, m);
variadic_enable_if(1, m, "c");
variadic_enable_if(0); variadic_enable_if(0, m); variadic_enable_if(0, m, 3); }
#endif