Timm Baeder 51295d6d56
[clang][bytecode] Reject assignments in C (#136126)
Similar to what the current interpreter does.
2025-04-17 13:39:27 +02:00

24 lines
567 B
C

// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both
// both-no-diagnostics
struct S {
int x;
char c;
float f;
};
#define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
struct T {
DECL_BUFFER(struct S, buffer);
};
int quorble() {
DECL_BUFFER(struct T, buffer);
((struct S *)((struct T *)buffer)->buffer)->x = 12;
const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer;
return s_ptr->x;
}