Add LLVM runtime checks to build path
[clang/acc.git] / test / Sema / transparent-union.c
blob90ecaadea6e774e7ff18b9c6da1f46630313562c
1 // RUN: clang -fsyntax-only -Xclang -verify %s
2 typedef union {
3 int *ip;
4 float *fp;
5 } TU __attribute__((transparent_union));
7 void f(TU);
9 void g(int *ip, float *fp, char *cp) {
10 f(ip);
11 f(fp);
12 f(cp); // expected-error{{incompatible type}}
13 f(0);
15 TU tu_ip = ip; // expected-error{{incompatible type}}
16 TU tu;
17 tu.ip = ip;
20 /* FIXME: we'd like to just use an "int" here and align it differently
21 from the normal "int", but if we do so we lose the alignment
22 information from the typedef within the compiler. */
23 typedef struct { int x, y; } __attribute__((aligned(8))) aligned_struct8;
25 typedef struct { int x, y; } __attribute__((aligned(4))) aligned_struct4;
26 typedef union {
27 aligned_struct4 s4; // expected-note{{alignment of first field}}
28 aligned_struct8 s8; // expected-warning{{alignment of field}}
29 } TU1 __attribute__((transparent_union));
31 typedef union {
32 char c; // expected-note{{size of first field is 8 bits}}
33 int i; // expected-warning{{size of field}}
34 } TU2 __attribute__((transparent_union));
36 typedef union {
37 float f; // expected-warning{{floating}}
38 } TU3 __attribute__((transparent_union));
40 typedef union { } TU4 __attribute__((transparent_union)); // expected-warning{{field}}