Function pointers are now compile time constants.

const enum cannot be set to function pointer unless it's a lambda #2282.
This commit is contained in:
Christoffer Lerno
2025-07-08 12:42:16 +02:00
parent 26d5cc694a
commit 1d4ad5f1d5
4 changed files with 41 additions and 3 deletions

View File

@@ -1675,7 +1675,7 @@ bool sema_analyse_const_enum_constant_val(SemaContext *context, Decl *decl)
{
Expr *value = decl->enum_constant.value;
if (!sema_analyse_inferred_expr(context, decl->type, value)) return decl_poison(decl);
if (!sema_cast_const(value))
if (!expr_is_runtime_const(value))
{
SEMA_ERROR(value, "Expected an constant enum value.");
return decl_poison(decl);