File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -863,8 +863,12 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
863
863
return this ->VisitPointerArithBinOp (BO);
864
864
}
865
865
866
- // Assignmentes require us to evalute the RHS first.
866
+ // Assignments require us to evalute the RHS first.
867
867
if (BO->getOpcode () == BO_Assign) {
868
+ // We don't support assignments in C.
869
+ if (!Ctx.getLangOpts ().CPlusPlus )
870
+ return this ->emitInvalid (BO);
871
+
868
872
if (!visit (RHS) || !visit (LHS))
869
873
return false ;
870
874
if (!this ->emitFlip (*LT, *RT, BO))
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments