1 // RUN: %clang_cc1 -triple %itanium_abi_triple -verify %s
2 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++98 | FileCheck %s --check-prefix=CHECK-CXX98
3 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++11 | FileCheck %s --check-prefix=CHECK-CXX11
4 // expected-no-diagnostics
5 
6 #if __cplusplus >= 201103L
7 // CHECK-CXX11: @_ZZ15InitRefWithListvE1r = internal constant i32* @_ZGRZ15InitRefWithListvE1r_
8 // CHECK-CXX11: @_ZGRZ15InitRefWithListvE1r_ = internal constant i32 123
InitRefWithList()9 int InitRefWithList() { static const int &r = {123}; return r; }
10 #endif
11 
12 struct XPTParamDescriptor {};
13 struct nsXPTParamInfo {
14   nsXPTParamInfo(const XPTParamDescriptor& desc);
15 };
a(XPTParamDescriptor * params)16 void a(XPTParamDescriptor *params) {
17   const nsXPTParamInfo& paramInfo = params[0];
18 }
19 
20 // CodeGen of reference initialized const arrays.
21 namespace PR5911 {
f(const T (& a)[N])22   template <typename T, int N> int f(const T (&a)[N]) { return N; }
23   int iarr[] = { 1 };
test()24   int test() { return f(iarr); }
25 }
26 
27 // radar 7574896
28 struct Foo { int foo; };
29 Foo& ignoreSetMutex = *(new Foo);
30 
31 // Binding to a bit-field that requires a temporary.
32 struct { int bitfield : 3; } s = { 3 };
33 const int &s2 = s.bitfield;
34 
35 // In C++98, this forms a reference to itself. In C++11 onwards, this performs
36 // copy-construction.
37 struct SelfReference { SelfReference &r; };
38 extern SelfReference self_reference_1;
39 SelfReference self_reference_2 = {self_reference_1};
40 // CHECK-CXX98: @self_reference_2 = {{.*}}global %[[SELF_REF:.*]] { %[[SELF_REF]]* @self_reference_1 }
41 // CHECK-CXX11: @self_reference_2 = {{(dso_local )?}}global %[[SELF_REF:.*]] zeroinitializer
42 // CHECK-CXX11: call {{.*}}memcpy{{.*}} @self_reference_2 {{.*}} @self_reference_1
43