[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / attr-ifunc.c
bloba0659ae773dd1ec2b8446bdcdef8129d14341609
1 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_ALIASES %s
3 // RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
5 #if defined(_WIN32)
6 void foo(void) {}
7 void bar(void) __attribute__((ifunc("foo")));
8 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
10 #else
11 #if defined(CHECK_ALIASES)
12 void *f1_ifunc(void);
13 void f1(void) __attribute__((ifunc("f1_ifunc")));
14 // expected-error@-1 {{ifunc must point to a defined function}}
16 void *f2_a(void) __attribute__((alias("f2_b")));
17 void *f2_b(void) __attribute__((ifunc("f2_a")));
18 // expected-error@-1 {{ifunc definition is part of a cycle}}
20 void *f3_a(void) __attribute__((ifunc("f3_b")));
21 // expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
22 void *f3_b(void) __attribute__((weak, alias("f3_c")));
23 void *f3_c(void) { return 0; }
25 void f4_ifunc(void) {}
26 void f4(void) __attribute__((ifunc("f4_ifunc")));
27 // expected-error@-1 {{ifunc resolver function must return a pointer}}
29 int f5_resolver_gvar;
30 void f5(void) __attribute__((ifunc("f5_resolver_gvar")));
31 // expected-error@-1 {{ifunc must point to a defined function}}
33 void *f6_resolver_resolver(void) { return 0; }
34 void *f6_resolver(void) __attribute__((ifunc("f6_resolver_resolver")));
35 void f6(void) __attribute__((ifunc("f6_resolver")));
36 // expected-error@-1 {{ifunc must point to a defined function}}
38 #else
39 void f1a(void) __asm("f1");
40 void f1a(void) {}
41 // expected-note@-1 {{previous definition is here}}
42 void f1(void) __attribute__((ifunc("f1_ifunc")));
43 // expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
44 void *f1_ifunc(void) { return 0; }
46 void *f6_ifunc(int i);
47 void __attribute__((ifunc("f6_ifunc"))) f6(void) {}
48 // expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
50 #endif
51 #endif