Anders Waldenborg 86f9cf88cb [clang] Add tests for (const) weak variables
This adds tests checking the behavior of const variables declared with
weak attribute.

Both checking that they can not be used in places where a constant
expression is required and that a dynamic initializer is emitted when
used as an initializer expression.

Differential Revision: https://reviews.llvm.org/D126578
2022-06-01 20:18:54 +02:00

12 lines
298 B
C++

// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
extern const int W __attribute__((weak)) = 99;
const int S = 77;
// CHECK: @C1 = {{.*}} 77
extern const int C1 = S;
// CHECK: %0 = load {{.*}} @W
// CHECK-NEXT: store {{.*}} %0, {{.*}} @C2
extern const int C2 = W;