mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Allow inline enum values to define sizes.
This commit is contained in:
@@ -39,7 +39,7 @@ bool sema_resolve_array_like_len(SemaContext *context, TypeInfo *type_info, Arra
|
||||
Expr *len_expr = type_info->array.len;
|
||||
|
||||
// Analyse it.
|
||||
if (!sema_analyse_expr(context, len_expr)) return type_info_poison(type_info);
|
||||
if (!sema_analyse_expr_rhs(context, type_isz, len_expr, false, NULL, false)) return type_info_poison(type_info);
|
||||
|
||||
// A constant expression is assumed.
|
||||
if (!sema_cast_const(len_expr))
|
||||
|
||||
@@ -3,7 +3,7 @@ const int CONSTANT = 1;
|
||||
int[CONSTANT] a2;
|
||||
int[3] a3 = { [CONSTANT] = 1 };
|
||||
const bool B = true;
|
||||
int[B] c2; // #error: Expected an integer
|
||||
int[B] c2; // #error: cannot implicitly be converted
|
||||
|
||||
int non_constant = 10;
|
||||
int[non_constant] b; // #error: Expected a constant value as
|
||||
|
||||
7
test/test_suite/enumerations/inline_enum_size.c3
Normal file
7
test/test_suite/enumerations/inline_enum_size.c3
Normal file
@@ -0,0 +1,7 @@
|
||||
enum Bar : inline usz
|
||||
{
|
||||
FOO,
|
||||
BAR,
|
||||
}
|
||||
|
||||
int[Bar.BAR] x;
|
||||
Reference in New Issue
Block a user