xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/global-llvm-constant.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct A {
4*f4a2713aSLionel Sambuc   A() { x = 10; }
5*f4a2713aSLionel Sambuc   int x;
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc const A x;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // CHECK: @_ZL1x = internal global
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct X {
13*f4a2713aSLionel Sambuc   int (*fp)(int, int);
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc int add(int x, int y) { return x + y; }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // CHECK: @x2 = constant
19*f4a2713aSLionel Sambuc extern const X x2;
20*f4a2713aSLionel Sambuc const X x2 = { &add };
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc struct X1 {
23*f4a2713aSLionel Sambuc   mutable int i;
24*f4a2713aSLionel Sambuc };
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc struct X2 {
27*f4a2713aSLionel Sambuc   X1 array[3];
28*f4a2713aSLionel Sambuc };
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc // CHECK: @x2b = global
31*f4a2713aSLionel Sambuc extern const X2 x2b;
32*f4a2713aSLionel Sambuc const X2 x2b = { { { 1 }, { 2 }, { 3 } } };
33