xref: /llvm-project/clang/test/CodeGenCXX/const-dynamic-init.cpp (revision 21aa107eb79f8ddc5e7ca4e8f3476338dfa90049)
1*21aa107eSMomchil Velikov // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
2*21aa107eSMomchil Velikov 
3*21aa107eSMomchil Velikov __attribute__((section("A")))
4*21aa107eSMomchil Velikov const int a = 1;
f()5*21aa107eSMomchil Velikov const int *f() { return &a; }
6*21aa107eSMomchil Velikov // CHECK: @_ZL1a = internal constant i32 1, section "A"
7*21aa107eSMomchil Velikov 
8*21aa107eSMomchil Velikov int init();
9*21aa107eSMomchil Velikov __attribute__((section("B")))
10*21aa107eSMomchil Velikov const int b = init();
11*21aa107eSMomchil Velikov // Even if it's const-qualified, it must not be LLVM IR `constant` since it's
12*21aa107eSMomchil Velikov // dynamically initialised.
13*21aa107eSMomchil Velikov // CHECK: @_ZL1b = internal global i32 0, section "B"
14*21aa107eSMomchil Velikov 
15*21aa107eSMomchil Velikov __attribute__((section("C")))
16*21aa107eSMomchil Velikov int c = 2;
17*21aa107eSMomchil Velikov // CHECK: @c = {{.*}}global i32 2, section "C"
18*21aa107eSMomchil Velikov 
19*21aa107eSMomchil Velikov __attribute__((section("D")))
20*21aa107eSMomchil Velikov int d = init();
21*21aa107eSMomchil Velikov // CHECK: @d = {{.*}}global i32 0, section "D"
22*21aa107eSMomchil Velikov 
23*21aa107eSMomchil Velikov __attribute__((section("E")))
24*21aa107eSMomchil Velikov int e;
25*21aa107eSMomchil Velikov // CHECK: @e = {{.*}}global i32 0, section "E", align 4
26