| 1 |
// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both -fexperimental-new-constant-interpreter |
| 2 |
// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both |
| 3 |
|
| 4 |
// both-no-diagnostics |
| 5 |
|
| 6 |
struct S { |
| 7 |
int x; |
| 8 |
char c; |
| 9 |
float f; |
| 10 |
}; |
| 11 |
|
| 12 |
#define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)] |
| 13 |
|
| 14 |
struct T { |
| 15 |
DECL_BUFFER(struct S, buffer); |
| 16 |
}; |
| 17 |
|
| 18 |
int quorble() { |
| 19 |
DECL_BUFFER(struct T, buffer); |
| 20 |
((struct S *)((struct T *)buffer)->buffer)->x = 12; |
| 21 |
const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer; |
| 22 |
return s_ptr->x; |
| 23 |
} |