1// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
2// RUN: FileCheck --input-file=%t %s
3
4// CHECK: declare extern_weak void @test1_f()
5void test1_f(void);
6static void test1_g(void) __attribute__((weakref("test1_f")));
7void test1_h(void) {
8  test1_g();
9}
10
11// CHECK-LABEL: define void @test2_f()
12void test2_f(void) {}
13static void test2_g(void) __attribute__((weakref("test2_f")));
14void test2_h(void) {
15  test2_g();
16}
17
18// CHECK: declare void @test3_f()
19void test3_f(void);
20static void test3_g(void) __attribute__((weakref("test3_f")));
21void test3_foo(void) {
22  test3_f();
23}
24void test3_h(void) {
25  test3_g();
26}
27
28// CHECK-LABEL: define void @test4_f()
29void test4_f(void);
30static void test4_g(void) __attribute__((weakref("test4_f")));
31void test4_h(void) {
32  test4_g();
33}
34void test4_f(void) {}
35
36// CHECK: declare void @test5_f()
37void test5_f(void);
38static void test5_g(void) __attribute__((weakref("test5_f")));
39void test5_h(void) {
40  test5_g();
41}
42void test5_foo(void) {
43  test5_f();
44}
45
46// CHECK: declare extern_weak void @test6_f()
47void test6_f(void) __attribute__((weak));
48static void test6_g(void) __attribute__((weakref("test6_f")));
49void test6_h(void) {
50  test6_g();
51}
52void test6_foo(void) {
53  test6_f();
54}
55
56// CHECK: declare extern_weak void @test8_f()
57static void test8_g(void) __attribute__((weakref("test8_f")));
58void test8_h(void) {
59  if (test8_g)
60    test8_g();
61}
62// CHECK: declare extern_weak void @test7_f()
63void test7_f(void);
64static void test7_g(void) __attribute__((weakref("test7_f")));
65static void *const test7_zed = (void *) &test7_g;
66void* test7_h(void) {
67  return test7_zed;
68}
69