blob: 16fd0dfc98206a48f31391d2053a8931c37ccdd2 [file] [log] [blame]
Dmitry Polukhin85eda122016-04-11 07:48:59 +00001// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
Benjamin Kramerb8b2f3f2016-04-11 10:16:37 +00002// 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 Polukhin85eda122016-04-11 07:48:59 +00004
5#if defined(_WIN32)
6void foo() {}
7void bar() __attribute__((ifunc("foo")));
Erich Keane75449672017-12-20 18:51:08 +00008//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
Dmitry Polukhin85eda122016-04-11 07:48:59 +00009
10#else
11#if defined(CHECK_ALIASES)
12void* f1_ifunc();
13void f1() __attribute__((ifunc("f1_ifunc")));
14//expected-error@-1 {{ifunc must point to a defined function}}
15
16void* f2_a() __attribute__((ifunc("f2_b")));
17//expected-error@-1 {{ifunc definition is part of a cycle}}
18void* f2_b() __attribute__((ifunc("f2_a")));
19//expected-error@-1 {{ifunc definition is part of a cycle}}
20
21void* 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}}
23void* f3_b() __attribute__((weak, alias("f3_c")));
24void* f3_c() { return 0; }
25
26void f4_ifunc() {}
27void f4() __attribute__((ifunc("f4_ifunc")));
28//expected-error@-1 {{ifunc resolver function must return a pointer}}
29
30void* f5_ifunc(int i) { return 0; }
31void f5() __attribute__((ifunc("f5_ifunc")));
32//expected-error@-1 {{ifunc resolver function must have no parameters}}
33
34#else
35void f1a() __asm("f1");
36void f1a() {}
37//expected-note@-1 {{previous definition is here}}
38void f1() __attribute__((ifunc("f1_ifunc")));
39//expected-error@-1 {{definition with same mangled name as another definition}}
40void* f1_ifunc() { return 0; }
41
Serge Pavlov947719b2017-02-18 06:04:15 +000042void* f6_ifunc(int i);
43void __attribute__((ifunc("f6_ifunc"))) f6() {}
44//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
45
Dmitry Polukhin85eda122016-04-11 07:48:59 +000046#endif
47#endif