1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-pc-linux -fsyntax-only -verify -emit-llvm-only %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc void f1(void) __attribute__((alias("g1"))); g1(void)4f4a2713aSLionel Sambucvoid g1(void) { 5f4a2713aSLionel Sambuc } 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc void f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}} 8f4a2713aSLionel Sambuc 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambuc void f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}} 11f4a2713aSLionel Sambuc void g3(void); 12f4a2713aSLionel Sambuc 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc void f4() __attribute__((alias("g4"))); g4()15f4a2713aSLionel Sambucvoid g4() {} 16f4a2713aSLionel Sambuc void h4() __attribute__((alias("f4"))); 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc void f5() __attribute__((alias("g5"))); 19f4a2713aSLionel Sambuc void h5() __attribute__((alias("f5"))); g5()20f4a2713aSLionel Sambucvoid g5() {} 21f4a2713aSLionel Sambuc g6()22f4a2713aSLionel Sambucvoid g6() {} 23f4a2713aSLionel Sambuc void f6() __attribute__((alias("g6"))); 24f4a2713aSLionel Sambuc void h6() __attribute__((alias("f6"))); 25f4a2713aSLionel Sambuc g7()26f4a2713aSLionel Sambucvoid g7() {} 27f4a2713aSLionel Sambuc void h7() __attribute__((alias("f7"))); 28f4a2713aSLionel Sambuc void f7() __attribute__((alias("g7"))); 29f4a2713aSLionel Sambuc 30f4a2713aSLionel Sambuc void h8() __attribute__((alias("f8"))); g8()31f4a2713aSLionel Sambucvoid g8() {} 32f4a2713aSLionel Sambuc void f8() __attribute__((alias("g8"))); 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc void h9() __attribute__((alias("f9"))); 35f4a2713aSLionel Sambuc void f9() __attribute__((alias("g9"))); g9()36f4a2713aSLionel Sambucvoid g9() {} 37f4a2713aSLionel Sambuc 38f4a2713aSLionel Sambuc void f10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} 39f4a2713aSLionel Sambuc void g10() __attribute__((alias("f10"))); // expected-error {{alias definition is part of a cycle}} 40f4a2713aSLionel Sambuc 41f4a2713aSLionel Sambuc // FIXME: This could be a bit better, h10 is not part of the cycle, it points 42f4a2713aSLionel Sambuc // to it. 43f4a2713aSLionel Sambuc void h10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc extern int a1 __attribute__((alias("b1"))); 46f4a2713aSLionel Sambuc int b1 = 42; 47f4a2713aSLionel Sambuc 48f4a2713aSLionel Sambuc extern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}} 49f4a2713aSLionel Sambuc 50f4a2713aSLionel Sambuc extern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}} 51f4a2713aSLionel Sambuc extern int b3; 52f4a2713aSLionel Sambuc 53f4a2713aSLionel Sambuc extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}} 54f4a2713aSLionel Sambuc typedef int b4; 55*0a6a1f1dSLionel Sambuc test2_bar()56*0a6a1f1dSLionel Sambucvoid test2_bar() {} 57*0a6a1f1dSLionel Sambuc void test2_foo() __attribute__((weak, alias("test2_bar"))); 58*0a6a1f1dSLionel Sambuc void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of alias test2_foo is overridden}} 59*0a6a1f1dSLionel Sambuc test3_bar()60*0a6a1f1dSLionel Sambucvoid test3_bar() { } 61*0a6a1f1dSLionel Sambuc void test3_foo() __attribute__((section("test"))); // expected-warning {{alias will not be in section 'test' but in the same section as the aliasee}} 62*0a6a1f1dSLionel Sambuc void test3_foo() __attribute__((alias("test3_bar"))); 63*0a6a1f1dSLionel Sambuc test4_bar()64*0a6a1f1dSLionel Sambuc__attribute__((section("test"))) void test4_bar() { } 65*0a6a1f1dSLionel Sambuc void test4_foo() __attribute__((section("test"))); 66*0a6a1f1dSLionel Sambuc void test4_foo() __attribute__((alias("test4_bar"))); 67*0a6a1f1dSLionel Sambuc 68*0a6a1f1dSLionel Sambuc int test5_bar = 0; 69*0a6a1f1dSLionel Sambuc extern struct incomplete_type test5_foo __attribute__((alias("test5_bar"))); 70