@@ -38,6 +38,17 @@ struct S {
38
38
#define TERNARY LITERAL_BOOL ? 1 : 2
39
39
#define MEMBER LITERAL_STRUCT.i
40
40
41
+ #define STMT_EXPR \
42
+ ({ \
43
+ int builtin = BUILTIN; \
44
+ char indexing = INDEXING; \
45
+ float mixed = MIXED_ARITHMETIC; \
46
+ for (int i = 0; i < builtin; i++) { \
47
+ mixed += (float)indexing; \
48
+ } \
49
+ mixed; \
50
+ })
51
+
41
52
void local_muts () {
42
53
int literal_int = LITERAL_INT ;
43
54
bool literal_bool = LITERAL_BOOL ;
@@ -72,6 +83,7 @@ void local_muts() {
72
83
const struct S * ref_struct = REF_LITERAL ;
73
84
int ternary = TERNARY ;
74
85
int member = MEMBER ;
86
+ float stmt_expr = STMT_EXPR ;
75
87
}
76
88
77
89
void local_consts () {
@@ -108,6 +120,7 @@ void local_consts() {
108
120
const struct S * const ref_struct = REF_LITERAL ;
109
121
const int ternary = TERNARY ;
110
122
const int member = MEMBER ;
123
+ const float stmt_expr = STMT_EXPR ;
111
124
}
112
125
113
126
// TODO These are declared in the global scope and thus clash,
@@ -147,6 +160,7 @@ void local_static_consts() {
147
160
static const struct S * const ref_struct = REF_LITERAL ;
148
161
static const int ternary = TERNARY ;
149
162
static const int member = MEMBER ;
163
+ static const float stmt_expr = STMT_EXPR ;
150
164
}
151
165
#endif
152
166
@@ -187,6 +201,7 @@ static const char *const global_static_const_ref_indexing = REF_MACRO;
187
201
static const struct S * const global_static_const_ref_struct = REF_LITERAL ;
188
202
static const int global_static_const_ternary = TERNARY ;
189
203
static const int global_static_const_member = MEMBER ;
204
+ // static const float global_static_const_stmt_expr = STMT_EXPR; // Statement expression not allowed at file scope.
190
205
191
206
void global_static_consts () {
192
207
// Need to use `static`s or else they'll be removed when translated.
@@ -223,6 +238,7 @@ void global_static_consts() {
223
238
(void )global_static_const_ref_struct ;
224
239
(void )global_static_const_ternary ;
225
240
(void )global_static_const_member ;
241
+ // (void)global_static_const_stmt_expr;
226
242
}
227
243
228
244
// global consts
@@ -260,6 +276,7 @@ const char *const global_const_ref_indexing = REF_MACRO;
260
276
const struct S * const global_const_ref_struct = REF_LITERAL ;
261
277
const int global_const_ternary = TERNARY ;
262
278
const int global_const_member = MEMBER ;
279
+ // const float global_const_stmt_expr = STMT_EXPR; // Statement expression not allowed at file scope.
263
280
264
281
typedef unsigned long long U64 ;
265
282
0 commit comments