1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s 2*f4a2713aSLionel Sambuc // PR 4349 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc union reg 5*f4a2713aSLionel Sambuc { 6*f4a2713aSLionel Sambuc unsigned char b[2][2]; 7*f4a2713aSLionel Sambuc unsigned short w[2]; 8*f4a2713aSLionel Sambuc unsigned int d; 9*f4a2713aSLionel Sambuc }; 10*f4a2713aSLionel Sambuc struct cpu 11*f4a2713aSLionel Sambuc { 12*f4a2713aSLionel Sambuc union reg pc; 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc extern struct cpu cpu; 15*f4a2713aSLionel Sambuc struct svar 16*f4a2713aSLionel Sambuc { 17*f4a2713aSLionel Sambuc void *ptr; 18*f4a2713aSLionel Sambuc }; 19*f4a2713aSLionel Sambuc // CHECK: @svars1 = global [1 x %struct.svar] [%struct.svar { i8* bitcast (%struct.cpu* @cpu to i8*) }] 20*f4a2713aSLionel Sambuc struct svar svars1[] = 21*f4a2713aSLionel Sambuc { 22*f4a2713aSLionel Sambuc { &((cpu.pc).w[0]) } 23*f4a2713aSLionel Sambuc }; 24*f4a2713aSLionel Sambuc // CHECK: @svars2 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 1) }] 25*f4a2713aSLionel Sambuc struct svar svars2[] = 26*f4a2713aSLionel Sambuc { 27*f4a2713aSLionel Sambuc { &((cpu.pc).b[0][1]) } 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc // CHECK: @svars3 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 2) }] 30*f4a2713aSLionel Sambuc struct svar svars3[] = 31*f4a2713aSLionel Sambuc { 32*f4a2713aSLionel Sambuc { &((cpu.pc).w[1]) } 33*f4a2713aSLionel Sambuc }; 34*f4a2713aSLionel Sambuc // CHECK: @svars4 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 3) }] 35*f4a2713aSLionel Sambuc struct svar svars4[] = 36*f4a2713aSLionel Sambuc { 37*f4a2713aSLionel Sambuc { &((cpu.pc).b[1][1]) } 38*f4a2713aSLionel Sambuc }; 39