1d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola// RUN: %clang_cc1 -triple x86_64-pc-linux -fsyntax-only -verify -emit-llvm-only %s 2d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 3d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f1(void) __attribute__((alias("g1"))); 4d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g1(void) { 5d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola} 6d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 7d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}} 8d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 9d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 10d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}} 11d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g3(void); 12d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 13d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 14d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f4() __attribute__((alias("g4"))); 15d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g4() {} 16d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h4() __attribute__((alias("f4"))); 17d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 18d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f5() __attribute__((alias("g5"))); 19d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h5() __attribute__((alias("f5"))); 20d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g5() {} 21d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 22d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g6() {} 23d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f6() __attribute__((alias("g6"))); 24d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h6() __attribute__((alias("f6"))); 25d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 26d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g7() {} 27d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h7() __attribute__((alias("f7"))); 28d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f7() __attribute__((alias("g7"))); 29d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 30d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h8() __attribute__((alias("f8"))); 31d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g8() {} 32d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f8() __attribute__((alias("g8"))); 33d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 34d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid h9() __attribute__((alias("f9"))); 35d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid f9() __attribute__((alias("g9"))); 36d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolavoid g9() {} 37d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 38c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesvoid f10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} 39c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesvoid g10() __attribute__((alias("f10"))); // expected-error {{alias definition is part of a cycle}} 40c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines 41c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines// FIXME: This could be a bit better, h10 is not part of the cycle, it points 42c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines// to it. 43c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesvoid h10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} 44c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines 45d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaextern int a1 __attribute__((alias("b1"))); 46d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaint b1 = 42; 47d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 48d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaextern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}} 49d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 50d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaextern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}} 51d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaextern int b3; 52d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindola 53d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolaextern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}} 54d205498c83c1bba1004ae41299ad7138881b9480Rafael Espindolatypedef int b4; 55651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 56651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesvoid test2_bar() {} 57651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesvoid test2_foo() __attribute__((weak, alias("test2_bar"))); 584967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainarvoid test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of test2_foo is overridden}} 596bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 606bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid test3_bar() { } 616bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid test3_foo() __attribute__((section("test"))); // expected-warning {{alias will not be in section 'test' but in the same section as the aliasee}} 626bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid test3_foo() __attribute__((alias("test3_bar"))); 636bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 646bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines__attribute__((section("test"))) void test4_bar() { } 656bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid test4_foo() __attribute__((section("test"))); 666bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid test4_foo() __attribute__((alias("test4_bar"))); 67c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines 68c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesint test5_bar = 0; 69c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesextern struct incomplete_type test5_foo __attribute__((alias("test5_bar"))); 70