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