summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/global-init.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-10-31 20:41:46 +0000
committerAnders Carlsson <andersca@mac.com>2010-10-31 20:41:46 +0000
commit18275091767ec1ca1ca023372321e737cc88027b (patch)
treec8da1985ccbc6452160dad21c4b86314e9230914 /clang/test/CodeGenCXX/global-init.cpp
parent3dbe6cc155c69ca08a04a0c29d4335774db95ef9 (diff)
downloadbcm5719-llvm-18275091767ec1ca1ca023372321e737cc88027b.tar.gz
bcm5719-llvm-18275091767ec1ca1ca023372321e737cc88027b.zip
Teach the constant expr evaluator about derived-to-base casts when no virtual bases are involved. Fixes PR5974.
llvm-svn: 117868
Diffstat (limited to 'clang/test/CodeGenCXX/global-init.cpp')
-rw-r--r--clang/test/CodeGenCXX/global-init.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/global-init.cpp b/clang/test/CodeGenCXX/global-init.cpp
index 6ff9598afce..f89e9781319 100644
--- a/clang/test/CodeGenCXX/global-init.cpp
+++ b/clang/test/CodeGenCXX/global-init.cpp
@@ -17,6 +17,11 @@ struct D { ~D(); };
// It's okay if we ever implement the IR-generation optimization to remove this.
// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8]*
+// PR6205: The casts should not require global initializers
+// CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
+// CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* bitcast (%"struct.PR5974::C"* @_ZN6PR59741cE to %"struct.PR5974::A"*), align 8
+// CHECK: @_ZN6PR59741bE = global %"struct.PR5974::A"* bitcast (i8* getelementptr (%"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0, i64 4) to %"struct.PR5974::A"*), align 8
+
// CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
A a;
@@ -64,6 +69,17 @@ namespace test3 {
const char *test() { return var; }
}
+namespace PR5974 {
+ struct A { int a; };
+ struct B { int b; };
+ struct C : A, B { int c; };
+
+ extern C c;
+
+ // These should not require global initializers.
+ A* a = &c;
+ B* b = &c;
+}
// CHECK: define internal void [[TEST1_Z_INIT:@.*]]()
// CHECK: load i32* @_ZN5test1L1yE
// CHECK-NEXT: xor
OpenPOWER on IntegriCloud