Dmitry Polukhin | 85eda12 | 2016-04-11 07:48:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s |
Benjamin Kramer | b8b2f3f | 2016-04-11 10:16:37 +0000 | [diff] [blame] | 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 |
Dmitry Polukhin | 85eda12 | 2016-04-11 07:48:59 +0000 | [diff] [blame] | 4 | |
| 5 | #if defined(_WIN32) |
| 6 | void foo() {} |
| 7 | void bar() __attribute__((ifunc("foo"))); |
Erich Keane | 7544967 | 2017-12-20 18:51:08 +0000 | [diff] [blame] | 8 | //expected-warning@-1 {{unknown attribute 'ifunc' ignored}} |
Dmitry Polukhin | 85eda12 | 2016-04-11 07:48:59 +0000 | [diff] [blame] | 9 | |
| 10 | #else |
| 11 | #if defined(CHECK_ALIASES) |
| 12 | void* f1_ifunc(); |
| 13 | void f1() __attribute__((ifunc("f1_ifunc"))); |
| 14 | //expected-error@-1 {{ifunc must point to a defined function}} |
| 15 | |
| 16 | void* f2_a() __attribute__((ifunc("f2_b"))); |
| 17 | //expected-error@-1 {{ifunc definition is part of a cycle}} |
| 18 | void* f2_b() __attribute__((ifunc("f2_a"))); |
| 19 | //expected-error@-1 {{ifunc definition is part of a cycle}} |
| 20 | |
| 21 | void* f3_a() __attribute__((ifunc("f3_b"))); |
| 22 | //expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}} |
| 23 | void* f3_b() __attribute__((weak, alias("f3_c"))); |
| 24 | void* f3_c() { return 0; } |
| 25 | |
| 26 | void f4_ifunc() {} |
| 27 | void f4() __attribute__((ifunc("f4_ifunc"))); |
| 28 | //expected-error@-1 {{ifunc resolver function must return a pointer}} |
| 29 | |
| 30 | void* f5_ifunc(int i) { return 0; } |
| 31 | void f5() __attribute__((ifunc("f5_ifunc"))); |
| 32 | //expected-error@-1 {{ifunc resolver function must have no parameters}} |
| 33 | |
| 34 | #else |
| 35 | void f1a() __asm("f1"); |
| 36 | void f1a() {} |
| 37 | //expected-note@-1 {{previous definition is here}} |
| 38 | void f1() __attribute__((ifunc("f1_ifunc"))); |
| 39 | //expected-error@-1 {{definition with same mangled name as another definition}} |
| 40 | void* f1_ifunc() { return 0; } |
| 41 | |
Serge Pavlov | 947719b | 2017-02-18 06:04:15 +0000 | [diff] [blame] | 42 | void* f6_ifunc(int i); |
| 43 | void __attribute__((ifunc("f6_ifunc"))) f6() {} |
| 44 | //expected-error@-1 {{definition 'f6' cannot also be an ifunc}} |
| 45 | |
Dmitry Polukhin | 85eda12 | 2016-04-11 07:48:59 +0000 | [diff] [blame] | 46 | #endif |
| 47 | #endif |