attributes.c revision 2968b7741da535810250b919c95d12105882d19f
1// RUN: clang-cc -emit-llvm -o %t %s &&
2// RUN: grep 't1.*noreturn' %t &&
3// RUN: grep 't2.*nounwind' %t &&
4// RUN: grep 'weak.*t3' %t &&
5// RUN: grep 'hidden.*t4' %t &&
6// RUN: grep 't5.*weak' %t &&
7// RUN: grep 't6.*protected' %t &&
8// RUN: grep 't7.*noreturn' %t &&
9// RUN: grep 't7.*nounwind' %t &&
10// RUN: grep 't9.*alias.*weak.*t8' %t &&
11// RUN: grep '@t10().*section "SECT"' %t &&
12// RUN: grep '@t11().*section "SECT"' %t &&
13// RUN: grep '@t12 =.*section "SECT"' %t &&
14// RUN: grep '@t13 =.*section "SECT"' %t &&
15// RUN: grep '@t14.x =.*section "SECT"' %t
16// RUN: grep 'declare extern_weak i32 @t15()' %t &&
17// RUN: grep '@t16 = extern_weak global i32' %t &&
18
19void t1() __attribute__((noreturn));
20void t1() {}
21
22void t2() __attribute__((nothrow));
23void t2() {}
24
25void t3() __attribute__((weak));
26void t3() {}
27
28void t4() __attribute__((visibility("hidden")));
29void t4() {}
30
31int t5 __attribute__((weak)) = 2;
32
33int t6 __attribute__((visibility("protected")));
34
35void t7() __attribute__((noreturn, nothrow));
36void t7() {}
37
38void __t8() {}
39void t9() __attribute__((weak, alias("__t8")));
40
41void t10(void) __attribute__((section("SECT")));
42void t10(void) {}
43void __attribute__((section("SECT"))) t11(void) {}
44
45int t12 __attribute__((section("SECT")));
46struct s0 { int x; };
47struct s0 t13 __attribute__((section("SECT"))) = { 0 };
48
49void t14(void) {
50  static int x __attribute__((section("SECT"))) = 0;
51}
52
53int __attribute__((weak_import)) t15(void);
54extern int t16 __attribute__((weak_import));
55int t17() {
56  return t15() + t16;
57}
58
59// RUN: grep '@t18 = global i[0-9]* 1, align .*' %t &&
60extern int t18 __attribute__((weak_import));
61int t18 = 1;
62
63// RUN: grep 'define i[0-9]* @t19() nounwind {' %t &&
64extern int t19(void) __attribute__((weak_import));
65int t19(void) {
66  return 10;
67}
68
69// RUN: true
70