1 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only -DCHECK_ALIASES %s 3 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s 4 // RUN: %clang_cc1 -triple x86_64-apple-macosx -verify -emit-llvm-only %s 5 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -verify -emit-llvm-only %s 6 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvcu -verify -emit-llvm-only %s 7 8 #if defined(_WIN32) && !defined(__aarch64__) 9 void foo(void) {} 10 void bar(void) __attribute__((ifunc("foo"))); 11 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}} 12 13 #else 14 #if defined(CHECK_ALIASES) 15 void *f1_ifunc(void); 16 void f1(void) __attribute__((ifunc("f1_ifunc"))); 17 // expected-error@-1 {{ifunc must point to a defined function}} 18 // expected-note@-2 {{must refer to its mangled name}} 19 20 void *f2_a(void) __attribute__((alias("f2_b"))); 21 void *f2_b(void) __attribute__((ifunc("f2_a"))); 22 // expected-error@-1 {{ifunc definition is part of a cycle}} 23 24 void *f3_a(void) __attribute__((ifunc("f3_b"))); 25 // expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}} 26 void *f3_b(void) __attribute__((weak, alias("f3_c"))); 27 void *f3_c(void) { return 0; } 28 29 void f4_ifunc(void) {} 30 void f4(void) __attribute__((ifunc("f4_ifunc"))); 31 // expected-error@-1 {{ifunc resolver function must return a pointer}} 32 33 int f5_resolver_gvar; 34 void f5(void) __attribute__((ifunc("f5_resolver_gvar"))); 35 // expected-error@-1 {{ifunc must point to a defined function}} 36 37 void *f6_resolver_resolver(void) { return 0; } 38 void *f6_resolver(void) __attribute__((ifunc("f6_resolver_resolver"))); 39 void f6(void) __attribute__((ifunc("f6_resolver"))); 40 // expected-error@-1 {{ifunc must point to a defined function}} 41 42 #elif defined(__APPLE__) 43 44 // NOTE: aliases are not supported on Darwin, so the above tests are not relevant. 45 46 #define STR2(X) #X 47 #define STR(X) STR2(X) 48 #define PREFIX STR(__USER_LABEL_PREFIX__) 49 50 void f1a(void) __asm("f1"); 51 void f1a(void) {} 52 // expected-note@-1 {{previous definition is here}} 53 void f1(void) __attribute__((ifunc(PREFIX "f1_ifunc"))) __asm("f1"); 54 // expected-error@-1 {{definition with same mangled name '<U+0001>f1' as another definition}} 55 void *f1_ifunc(void) { return 0; } 56 57 void *f6_ifunc(int i); 58 void __attribute__((ifunc(PREFIX "f6_ifunc"))) f6(void) {} 59 // expected-error@-1 {{definition 'f6' cannot also be an ifunc}} 60 61 #else 62 void f1a(void) __asm("f1"); 63 void f1a(void) {} 64 // expected-note@-1 {{previous definition is here}} 65 void f1(void) __attribute__((ifunc("f1_ifunc"))); 66 // expected-error@-1 {{definition with same mangled name 'f1' as another definition}} 67 void *f1_ifunc(void) { return 0; } 68 69 void *f6_ifunc(int i); 70 void __attribute__((ifunc("f6_ifunc"))) f6(void) {} 71 // expected-error@-1 {{definition 'f6' cannot also be an ifunc}} 72 73 #endif 74 #endif 75