xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/internal-linkage.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc struct Global { Global(); };
XX4f4a2713aSLionel Sambuc template<typename T> struct X { X() {} };
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc namespace {
Anon__anon25f9cc920111::Anon8f4a2713aSLionel Sambuc   struct Anon { Anon() {} };
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc   // CHECK: @_ZN12_GLOBAL__N_15anon0E = internal global
11f4a2713aSLionel Sambuc   Global anon0;
12f4a2713aSLionel Sambuc }
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc // CHECK: @anon1 = internal global
15f4a2713aSLionel Sambuc Anon anon1;
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // CHECK: @anon2 = internal global
18f4a2713aSLionel Sambuc X<Anon> anon2;
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc // rdar: // 8071804
21f4a2713aSLionel Sambuc char const * const xyzzy = "Hello, world!";
22f4a2713aSLionel Sambuc extern char const * const xyzzy;
23f4a2713aSLionel Sambuc 
test1()24f4a2713aSLionel Sambuc char const * const *test1()
25f4a2713aSLionel Sambuc {
26f4a2713aSLionel Sambuc    // CHECK: @_ZL5xyzzy = internal constant
27f4a2713aSLionel Sambuc     return &xyzzy;
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc static char const * const static_xyzzy = "Hello, world!";
31f4a2713aSLionel Sambuc extern char const * const static_xyzzy;
32f4a2713aSLionel Sambuc 
test2()33f4a2713aSLionel Sambuc char const * const *test2()
34f4a2713aSLionel Sambuc {
35f4a2713aSLionel Sambuc     // CHECK: @_ZL12static_xyzzy = internal constant
36f4a2713aSLionel Sambuc     return &static_xyzzy;
37f4a2713aSLionel Sambuc }
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc static char const * static_nonconst_xyzzy = "Hello, world!";
40f4a2713aSLionel Sambuc extern char const * static_nonconst_xyzzy;
41f4a2713aSLionel Sambuc 
test3()42f4a2713aSLionel Sambuc char const * *test3()
43f4a2713aSLionel Sambuc {
44f4a2713aSLionel Sambuc     // CHECK: @_ZL21static_nonconst_xyzzy = internal global
45f4a2713aSLionel Sambuc     return &static_nonconst_xyzzy;
46f4a2713aSLionel Sambuc }
47f4a2713aSLionel Sambuc 
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc char const * extern_nonconst_xyzzy = "Hello, world!";
50f4a2713aSLionel Sambuc extern char const * extern_nonconst_xyzzy;
51f4a2713aSLionel Sambuc 
test4()52f4a2713aSLionel Sambuc char const * *test4()
53f4a2713aSLionel Sambuc {
54f4a2713aSLionel Sambuc     // CHECK: @extern_nonconst_xyzzy = global
55f4a2713aSLionel Sambuc     return &extern_nonconst_xyzzy;
56f4a2713aSLionel Sambuc }
57f4a2713aSLionel Sambuc 
58f4a2713aSLionel Sambuc // PR10120
59f4a2713aSLionel Sambuc template <typename T> class klass {
60f4a2713aSLionel Sambuc     virtual void f();
61f4a2713aSLionel Sambuc };
62f4a2713aSLionel Sambuc namespace { struct S; }
foo()63f4a2713aSLionel Sambuc void foo () { klass<S> x; }
64f4a2713aSLionel Sambuc // CHECK: @_ZTV5klassIN12_GLOBAL__N_11SEE = internal unnamed_addr constant
65