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