32 lines · c
1// RUN: %clang_cc1 -w -emit-llvm %s -O1 -o - | FileCheck %s2// This used to "check for bug compatibility with gcc".3// Now it checks that that the "weak" declaration makes the value4// fully interposable whereas a "selectany" one is handled as constant5// and propagated.6 7// CHECK: @x = weak {{.*}}constant i32 1238const int x __attribute((weak)) = 123;9 10// CHECK: @y = weak_odr {{.*}}constant i32 23411const int y __attribute((selectany)) = 234;12 13int* f(void) {14 return &x;15}16 17int g(void) {18 // CHECK: load i32, ptr @x19 // CHECK-NOT: ret i32 12320 return *f();21}22 23int *k(void) {24 return &y;25}26 27int l(void) {28 // CHECK-NOT: load i32, ptr @y29 // CHECK: ret i32 23430 return *k();31}32