aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGenCXX/const-init-cxx11.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGenCXX/const-init-cxx11.cpp')
-rw-r--r--test/CodeGenCXX/const-init-cxx11.cpp74
1 files changed, 48 insertions, 26 deletions
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp
index f671e0ad8802..5127c302aa0d 100644
--- a/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/test/CodeGenCXX/const-init-cxx11.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -w -triple x86_64-elf-gnu -emit-llvm -o - %s -std=c++11 | FileCheck %s
// FIXME: The padding in all these objects should be zero-initialized.
namespace StructUnion {
@@ -19,7 +19,7 @@ namespace StructUnion {
// CHECK: @_ZN11StructUnion1aE = constant {{.*}} { i32 1, double 2.000000e+00, {{.*}} { i32 3, [4 x i8] undef } }
extern constexpr A a(1, 2.0, 3);
- // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8]* @{{.*}}, i32 0, i32 0) } }
+ // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0) } }
extern constexpr A b(4, 5, "hello");
struct B {
@@ -226,30 +226,30 @@ namespace LiteralReference {
};
// This creates a non-const temporary and binds a reference to it.
- // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 5 }, align 4
+ // CHECK: @[[TEMP:.*]] = internal global {{.*}} { i32 5 }, align 4
// CHECK: @_ZN16LiteralReference3litE = constant {{.*}} @[[TEMP]], align 8
const Lit &lit = Lit();
// This creates a const temporary as part of the reference initialization.
- // CHECK: @[[TEMP:.*]] = private constant {{.*}} { i32 5 }, align 4
+ // CHECK: @[[TEMP:.*]] = internal constant {{.*}} { i32 5 }, align 4
// CHECK: @_ZN16LiteralReference4lit2E = constant {{.*}} @[[TEMP]], align 8
const Lit &lit2 = {};
struct A { int &&r1; const int &&r2; };
struct B { A &&a1; const A &&a2; };
B b = { { 0, 1 }, { 2, 3 } };
- // CHECK: @[[TEMP0:.*]] = private global i32 0, align 4
- // CHECK: @[[TEMP1:.*]] = private constant i32 1, align 4
- // CHECK: @[[TEMPA1:.*]] = private global {{.*}} { i32* @[[TEMP0]], i32* @[[TEMP1]] }, align 8
- // CHECK: @[[TEMP2:.*]] = private global i32 2, align 4
- // CHECK: @[[TEMP3:.*]] = private constant i32 3, align 4
- // CHECK: @[[TEMPA2:.*]] = private constant {{.*}} { i32* @[[TEMP2]], i32* @[[TEMP3]] }, align 8
+ // CHECK: @[[TEMP0:.*]] = internal global i32 0, align 4
+ // CHECK: @[[TEMP1:.*]] = internal constant i32 1, align 4
+ // CHECK: @[[TEMPA1:.*]] = internal global {{.*}} { i32* @[[TEMP0]], i32* @[[TEMP1]] }, align 8
+ // CHECK: @[[TEMP2:.*]] = internal global i32 2, align 4
+ // CHECK: @[[TEMP3:.*]] = internal constant i32 3, align 4
+ // CHECK: @[[TEMPA2:.*]] = internal constant {{.*}} { i32* @[[TEMP2]], i32* @[[TEMP3]] }, align 8
// CHECK: @_ZN16LiteralReference1bE = global {{.*}} { {{.*}}* @[[TEMPA1]], {{.*}}* @[[TEMPA2]] }, align 8
struct Subobj {
int a, b, c;
};
- // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 1, i32 2, i32 3 }, align 4
+ // CHECK: @[[TEMP:.*]] = internal global {{.*}} { i32 1, i32 2, i32 3 }, align 4
// CHECK: @_ZN16LiteralReference2soE = constant {{.*}} (i8* getelementptr {{.*}} @[[TEMP]]{{.*}}, i64 4)
constexpr int &&so = Subobj{ 1, 2, 3 }.b;
@@ -258,11 +258,11 @@ namespace LiteralReference {
constexpr Derived() : Dummy{200}, Subobj{4, 5, 6} {}
};
using ConstDerived = const Derived;
- // CHECK: @[[TEMPCOMMA:.*]] = private constant {{.*}} { i32 200, i32 4, i32 5, i32 6 }
+ // CHECK: @[[TEMPCOMMA:.*]] = internal constant {{.*}} { i32 200, i32 4, i32 5, i32 6 }
// CHECK: @_ZN16LiteralReference5commaE = constant {{.*}} getelementptr {{.*}} @[[TEMPCOMMA]]{{.*}}, i64 8)
constexpr const int &comma = (1, (2, ConstDerived{}).b);
- // CHECK: @[[TEMPDERIVED:.*]] = private global {{.*}} { i32 200, i32 4, i32 5, i32 6 }
+ // CHECK: @[[TEMPDERIVED:.*]] = internal global {{.*}} { i32 200, i32 4, i32 5, i32 6 }
// CHECK: @_ZN16LiteralReference4baseE = constant {{.*}} getelementptr {{.*}} @[[TEMPDERIVED]]{{.*}}, i64 4)
constexpr Subobj &&base = Derived{};
@@ -343,15 +343,24 @@ namespace VirtualMembers {
constexpr E() : B(3), c{'b','y','e'} {}
char c[3];
};
-
- // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
+ // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*], [11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
E e;
struct nsMemoryImpl {
virtual void f();
};
- // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
+ // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
static nsMemoryImpl sGlobalMemory;
+
+ template<class T>
+ struct TemplateClass {
+ constexpr TemplateClass() : t{42} {}
+ virtual void templateMethod() {}
+
+ T t;
+ };
+ // CHECK: @_ZN14VirtualMembers1tE = global { i8**, i32 } { i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN14VirtualMembers13TemplateClassIiEE, i64 0, i64 2), i32 42 }
+ TemplateClass<int> t;
}
namespace PR13273 {
@@ -371,10 +380,10 @@ namespace PR13273 {
namespace ArrayTemporary {
struct A { const int (&x)[3]; };
struct B { const A (&x)[2]; };
- // CHECK: @[[A1:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 1, i32 2, i32 3]
- // CHECK: @[[A2:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 4, i32 5, i32 6]
- // CHECK: @[[ARR:_ZGRN14ArrayTemporary1bE.*]] = private constant [2 x {{.*}}] [{{.*}} { [3 x i32]* @[[A1]] }, {{.*}} { [3 x i32]* @[[A2]] }]
- // CHECK: @[[B:_ZGRN14ArrayTemporary1bE.*]] = private global {{.*}} { [2 x {{.*}}]* @[[ARR]] }
+ // CHECK: @[[A1:_ZGRN14ArrayTemporary1bE.*]] = internal constant [3 x i32] [i32 1, i32 2, i32 3]
+ // CHECK: @[[A2:_ZGRN14ArrayTemporary1bE.*]] = internal constant [3 x i32] [i32 4, i32 5, i32 6]
+ // CHECK: @[[ARR:_ZGRN14ArrayTemporary1bE.*]] = internal constant [2 x {{.*}}] [{{.*}} { [3 x i32]* @[[A1]] }, {{.*}} { [3 x i32]* @[[A2]] }]
+ // CHECK: @[[B:_ZGRN14ArrayTemporary1bE.*]] = internal global {{.*}} { [2 x {{.*}}]* @[[ARR]] }
// CHECK: @_ZN14ArrayTemporary1bE = constant {{.*}}* @[[B]]
B &&b = { { { { 1, 2, 3 } }, { { 4, 5, 6 } } } };
}
@@ -382,7 +391,7 @@ namespace ArrayTemporary {
namespace UnemittedTemporaryDecl {
constexpr int &&ref = 0;
extern constexpr int &ref2 = ref;
- // CHECK: @_ZGRN22UnemittedTemporaryDecl3refE_ = private global i32 0
+ // CHECK: @_ZGRN22UnemittedTemporaryDecl3refE_ = internal global i32 0
// FIXME: This declaration should not be emitted -- it isn't odr-used.
// CHECK: @_ZN22UnemittedTemporaryDecl3refE
@@ -393,11 +402,11 @@ namespace UnemittedTemporaryDecl {
// CHECK: @_ZZN12LocalVarInit3aggEvE1a = internal constant {{.*}} i32 101
// CHECK: @_ZZN12LocalVarInit4ctorEvE1a = internal constant {{.*}} i32 102
// CHECK: @_ZZN12LocalVarInit8mutable_EvE1a = private unnamed_addr constant {{.*}} i32 103
-// CHECK: @_ZGRN33ClassTemplateWithStaticDataMember1SIvE1aE_ = linkonce_odr constant i32 5
+// CHECK: @_ZGRN33ClassTemplateWithStaticDataMember1SIvE1aE_ = linkonce_odr constant i32 5, comdat
// CHECK: @_ZN33ClassTemplateWithStaticDataMember3useE = constant i32* @_ZGRN33ClassTemplateWithStaticDataMember1SIvE1aE_
-// CHECK: @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_ = linkonce_odr hidden constant i32 5
+// CHECK: @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_ = linkonce_odr hidden constant i32 5, comdat
// CHECK: @_ZN39ClassTemplateWithHiddenStaticDataMember3useE = constant i32* @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_
-// CHECK: @_ZGRZN20InlineStaticConstRef3funEvE1i_ = linkonce_odr constant i32 10
+// CHECK: @_ZGRZN20InlineStaticConstRef3funEvE1i_ = linkonce_odr constant i32 10, comdat
// Constant initialization tests go before this point,
// dynamic initialization tests go after.
@@ -488,7 +497,7 @@ namespace Unreferenced {
// We must not emit a load of 'p' here, since it's not odr-used.
int q = *p;
// CHECK-NOT: _ZN12Unreferenced1pE
- // CHECK: = load i32* @_ZN12Unreferenced1nE
+ // CHECK: = load i32, i32* @_ZN12Unreferenced1nE
// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN12Unreferenced1qE
// CHECK-NOT: _ZN12Unreferenced1pE
@@ -544,7 +553,7 @@ namespace InitFromConst {
// CHECK: call void @_ZN13InitFromConst7consumeIMNS_1SEiEEvT_(i64 0)
consume(mp);
- // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
+ // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
consume(a);
}
}
@@ -586,3 +595,16 @@ namespace ClassTemplateWithHiddenStaticDataMember {
const int &S<T>::a = 5;
const int &use = S<void>::a;
}
+
+namespace ClassWithStaticConstexprDataMember {
+struct X {
+ static constexpr const char &p = 'c';
+};
+
+// CHECK: @_ZGRN34ClassWithStaticConstexprDataMember1X1pE_
+const char *f() { return &X::p; }
+}
+
+// VirtualMembers::TemplateClass::templateMethod() must be defined in this TU,
+// not just declared.
+// CHECK: define linkonce_odr void @_ZN14VirtualMembers13TemplateClassIiE14templateMethodEv(%"struct.VirtualMembers::TemplateClass"* %this)