brintos

brintos / llvm-project-archived public Read only

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