Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / array-alignment.cpp
blobd98d773d3ed2a1ba56c336901d985f3ab8881890
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 typedef char __attribute__((aligned(2))) AlignedChar;
4 typedef AlignedChar arrayType0[4]; // expected-error {{size of array element}}
6 struct __attribute__((aligned(8))) AlignedStruct {
7 int m0;
8 };
10 struct __attribute__((packed)) PackedStruct {
11 char m0;
12 int i0;
15 typedef PackedStruct AlignedPackedStruct __attribute__((aligned(4)));
16 typedef AlignedPackedStruct arrayType1[4]; // expected-error {{(5 bytes) isn't a multiple of its alignment (4 bytes)}}
18 AlignedChar a0[1]; // expected-error {{size of array element}}
19 AlignedStruct a1[1];
20 AlignedPackedStruct a2[1]; // expected-error {{size of array element}}
22 struct S {
23 AlignedChar m0[1]; // expected-error {{size of array element}}
24 AlignedStruct m1[1];
25 AlignedPackedStruct m2[1]; // expected-error {{size of array element}}
28 void test(char *p) {
29 auto p0 = (AlignedChar(*)[1])p; // expected-error {{size of array element}}
30 auto r0 = (AlignedChar(&)[1])(*p); // expected-error {{size of array element}}
31 auto p1 = new AlignedChar[1]; // expected-error {{size of array element}}
32 auto p2 = (AlignedStruct(*)[1])p;
33 auto p3 = new AlignedStruct[1];
34 auto p4 = (AlignedPackedStruct(*)[1])p; // expected-error {{size of array element}}
35 auto p5 = new AlignedPackedStruct[1]; // expected-error {{size of array element}}
36 auto p6 = new AlignedPackedStruct;