Update to constdef

This commit is contained in:
Christoffer Lerno
2026-02-19 12:16:46 +01:00
committed by Christoffer Lerno
parent 0387d7666d
commit 5a82f672b5
52 changed files with 189 additions and 182 deletions

View File

@@ -68,7 +68,7 @@ Decl *decl_new_with_type(const char *name, SourceSpan span, DeclKind decl_type)
case DECL_ENUM:
kind = TYPE_ENUM;
break;
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
kind = TYPE_CONST_ENUM;
break;
case DECL_TYPEDEF:
@@ -127,7 +127,7 @@ const char *decl_to_a_name(Decl *decl)
case DECL_ALIAS: case DECL_ALIAS_PATH: case DECL_TYPE_ALIAS: return "an alias";
case DECL_TYPEDEF: return "a distinct type";
case DECL_ENUM: return "an enum";
case DECL_CONST_ENUM: return "a raw enum";
case DECL_CONSTDEF: return "a set of constants";
case DECL_ENUM_CONSTANT: return "an enum value";
case DECL_ERASED: return "an erased declaration";
case DECL_FAULT: return "a fault";
@@ -346,7 +346,7 @@ bool decl_may_be_generic(Decl *decl)
case DECL_GENERIC_INSTANCE:
case DECL_IMPORT:
case DECL_LABEL:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
return false;
case DECL_ATTRIBUTE:
case DECL_BITSTRUCT:

View File

@@ -565,7 +565,7 @@ typedef struct
AstId docs;
union
{
struct
struct // Function related
{
bool attr_inline : 1;
bool attr_noinline : 1;
@@ -593,7 +593,7 @@ typedef struct
Decl **lambda_ct_parameters;
};
};
struct
struct // Macro related
{
DeclId body_param;
CompilationUnit *unit;
@@ -4328,7 +4328,7 @@ INLINE void expr_rewrite_const_int(Expr *expr, Type *type, uint64_t v)
expr->type = type;
expr->resolve_status = RESOLVE_DONE;
TypeKind kind = type_flatten(type)->type_kind;
(&expr->const_expr)->ixx.i.high = 0;
expr->const_expr.ixx.i.high = 0;
if (type_kind_is_signed(kind))
{
if (v > (uint64_t)INT64_MAX) (&expr->const_expr)->ixx.i.high = UINT64_MAX;
@@ -4350,10 +4350,10 @@ INLINE void expr_rewrite_const_int(Expr *expr, Type *type, uint64_t v)
break;
}
}
(&expr->const_expr)->ixx.i.low = v;
(&expr->const_expr)->ixx.type = kind;
(&expr->const_expr)->is_character = false;
(&expr->const_expr)->const_kind = CONST_INTEGER;
expr->const_expr.ixx.i.low = v;
expr->const_expr.ixx.type = kind;
expr->const_expr.is_character = false;
expr->const_expr.const_kind = CONST_INTEGER;
}
INLINE void expr_rewrite_to_int_to_float(Expr *expr, Type *type)

View File

@@ -164,7 +164,7 @@ void decl_register(CompilationUnit *unit, Decl *decl)
case DECL_BITSTRUCT:
case DECL_TYPEDEF:
case DECL_ENUM:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_STRUCT:
case DECL_TYPE_ALIAS:
case DECL_UNION:
@@ -273,7 +273,7 @@ void unit_register_global_decl(CompilationUnit *unit, Decl *decl)
vec_add(unit->generic_defines, decl);
decl_register(unit, decl);
return;
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_ENUM:
ASSERT(decl->name);
vec_add(unit->enums, decl);

View File

@@ -1117,7 +1117,7 @@ Decl *copy_decl(CopyStruct *c, Decl *decl)
break;
case DECL_FAULT:
break;
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
copy_decl_type(copy);
MACRO_COPY_TYPE_LIST(copy->interfaces);
MACRO_COPY_DECL_METHODS(copy->method_table);

View File

@@ -1050,7 +1050,7 @@ typedef enum
DECL_LABEL,
DECL_MACRO,
DECL_INTERFACE,
DECL_CONST_ENUM,
DECL_CONSTDEF,
DECL_STRUCT,
DECL_TYPE_ALIAS,
DECL_UNION,
@@ -1579,7 +1579,7 @@ typedef enum
TOKEN_BREAK,
TOKEN_CASE,
TOKEN_CATCH,
TOKEN_CENUM,
TOKEN_CONSTDEF,
TOKEN_CONST,
TOKEN_CONTINUE,
TOKEN_DEFAULT,

View File

@@ -95,7 +95,7 @@ static inline const char *decl_type_to_string(Decl *type)
case DECL_STRUCT: return "struct";
case DECL_UNION: return "union";
case DECL_TYPE_ALIAS: return "type_alias";
case DECL_CONST_ENUM: return "raw_enum";
case DECL_CONSTDEF: return "constdef";
case DECL_BODYPARAM:
case DECL_DECLARRAY:
case DECL_ERASED:

View File

@@ -1036,7 +1036,7 @@ static void llvm_emit_type_decls(GenContext *context, Decl *decl)
case DECL_UNION:
case DECL_ENUM:
case DECL_BITSTRUCT:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
llvm_get_typeid(context, decl->type);
break;
}
@@ -1389,7 +1389,7 @@ LLVMValueRef llvm_get_ref(GenContext *c, Decl *decl)
case DECL_CT_ASSERT:
case DECL_TYPEDEF:
case DECL_ENUM:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_ENUM_CONSTANT:
case DECL_IMPORT:
case DECL_ALIAS_PATH:

View File

@@ -25,7 +25,7 @@ static inline LLVMTypeRef llvm_type_from_decl(GenContext *c, Decl *decl)
UNREACHABLE_VOID
case DECL_TYPE_ALIAS:
return llvm_get_type(c, decl->type);
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
return llvm_get_type(c, decl->enums.type_info->type);
case DECL_TYPEDEF:
return llvm_get_type(c, decl->distinct->type);

View File

@@ -13,7 +13,7 @@ typedef enum FunctionParse_
FUNC_PARSE_INTERFACE,
} FunctionParse;
static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const);
static inline Decl *parse_enum_declaration(ParseContext *c);
static inline Decl *parse_func_definition(ParseContext *c, AstId contracts, FunctionParse parse_kind);
static inline bool parse_bitstruct_body(ParseContext *c, Decl *decl);
static inline bool parse_enum_param_list(ParseContext *c, Decl*** parameters_ref, ArrayIndex *inline_index);
@@ -23,7 +23,6 @@ static bool parse_attributes_for_global(ParseContext *c, Decl *decl);
INLINE bool parse_decl_initializer(ParseContext *c, Decl *decl);
INLINE Decl *decl_new_var_current(ParseContext *c, TypeInfo *type, VarDeclKind kind);
static bool parse_contracts(ParseContext *c, AstId *contracts_ref);
static Ast *contracts_first_real(AstId contracts);
INLINE Decl *decl_new_var_current(ParseContext *c, TypeInfo *type, VarDeclKind kind)
{
@@ -2289,10 +2288,6 @@ static inline Decl *parse_bitstruct_declaration(ParseContext *c)
static inline Decl *parse_top_level_const_declaration(ParseContext *c, bool is_extern)
{
if (!is_extern && peek(c) == TOKEN_ENUM)
{
return parse_enum_declaration(c, true);
}
ASSIGN_DECL_OR_RET(Decl *decl, parse_const_declaration(c, true, is_extern), poisoned_decl);
CONSUME_EOS_OR_RET(poisoned_decl);
return decl;
@@ -2795,7 +2790,7 @@ static inline bool parse_enum_param_list(ParseContext *c, Decl*** parameters_ref
return true;
}
static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility visibility, bool is_single_value, bool is_const_enum)
static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility visibility, bool is_single_value, bool is_constdef)
{
Decl **values = NULL;
bool deprecate_warn = true;
@@ -2803,7 +2798,7 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi
{
if (!parse_element_contract(c, "enum values")) return false;
Decl *enum_const = decl_new(DECL_ENUM_CONSTANT, symstr(c), c->span);
if (is_const_enum) enum_const->enum_constant.is_raw = is_const_enum;
if (is_constdef) enum_const->enum_constant.is_raw = is_constdef;
enum_const->visibility = visibility;
const char *name = enum_const->name;
if (!consume_const_name(c, "enum constant")) return false;
@@ -2820,7 +2815,7 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi
if (try_consume(c, TOKEN_EQ))
{
Expr **args = NULL;
if (!is_const_enum && deprecate_warn)
if (!is_constdef && deprecate_warn)
{
deprecate_warn = false;
print_deprecation_at(c->prev_span, "Use () declaration of associated values instead.");
@@ -2828,7 +2823,7 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi
if (is_single_value || !tok_is(c, TOKEN_LBRACE))
{
ASSIGN_EXPR_OR_RET(Expr *single, parse_constant_expr(c), false);
if (is_const_enum)
if (is_constdef)
{
enum_const->enum_constant.value = single;
goto NEXT;
@@ -2862,7 +2857,7 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi
}
enum_const->enum_constant.associated = args;
}
else if (!is_const_enum && try_consume(c, TOKEN_LBRACE))
else if (!is_constdef && try_consume(c, TOKEN_LBRACE))
{
Expr **args = NULL;
while (1)
@@ -2913,13 +2908,13 @@ NEXT:
* enum_body ::= enum_def (',' enum_def)* ','?
* enum_def ::= CONST_IDENT ('(' arg_list ')')?
*/
static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const)
static inline Decl *parse_enum_declaration(ParseContext *c)
{
if (is_const) advance_and_verify(c, TOKEN_CONST);
if (tok_is(c, TOKEN_CENUM))
bool is_constdef = false;
if (tok_is(c, TOKEN_CONSTDEF))
{
advance_and_verify(c, TOKEN_CENUM);
is_const = true;
advance_and_verify(c, TOKEN_CONSTDEF);
is_constdef = true;
}
else
{
@@ -2928,23 +2923,22 @@ static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const)
const char *name = symstr(c);
SourceSpan span = c->span;
if (!consume_type_name(c, "enum")) return poisoned_decl;
if (!consume_type_name(c, is_constdef ? "constdef" : "enum" )) return poisoned_decl;
TypeInfo **interfaces = NULL;
if (!parse_interface_impls(c, &interfaces)) return poisoned_decl;
TypeInfo *type = NULL;
bool val_is_inline = false;
ArrayIndex inline_index = -1;
bool is_const_enum = is_const;
Decl **param_list = NULL;
if (try_consume(c, TOKEN_COLON))
{
if (!is_const)
if (!is_constdef)
{
is_const_enum = try_consume(c, TOKEN_CONST);
if (is_const_enum)
is_constdef = try_consume(c, TOKEN_CONST);
if (is_constdef)
{
print_deprecation_at(c->prev_span, "Declare const enums using 'const enum' instead.");
print_deprecation_at(c->prev_span, "Declare constdefs using 'constdef' instead.");
}
}
if (!tok_is(c, TOKEN_LPAREN) && !tok_is(c, TOKEN_LBRACE))
@@ -2953,14 +2947,14 @@ static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const)
ASSIGN_TYPE_OR_RET(type, parse_optional_type_no_generic(c), poisoned_decl);
if (type->optional)
{
RETURN_PRINT_ERROR_AT(poisoned_decl, type, "An enum can't have an optional type.");
RETURN_PRINT_ERROR_AT(poisoned_decl, type, "An enum or constdef can't have an optional type.");
}
}
if (is_const_enum)
if (is_constdef)
{
if (tok_is(c, TOKEN_LPAREN))
{
PRINT_ERROR_HERE("Const enums cannot have associated values.");
PRINT_ERROR_HERE("Constdefs cannot have associated values.");
return poisoned_decl;
}
}
@@ -2970,7 +2964,7 @@ static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const)
}
}
Decl *decl = decl_new_with_type(name, span, is_const_enum ? DECL_CONST_ENUM : DECL_ENUM);
Decl *decl = decl_new_with_type(name, span, is_constdef ? DECL_CONSTDEF : DECL_ENUM);
decl->interfaces = interfaces;
if (param_list) decl->enums.parameters = param_list;
if (!parse_attributes_for_global(c, decl)) return poisoned_decl;
@@ -2980,9 +2974,9 @@ static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const)
decl->enums.type_info = type ? type : type_info_new_base(type_int, decl->span);
decl->enums.inline_index = (int16_t)inline_index;
decl->enums.inline_value = is_const_enum ? false : val_is_inline;
if (is_const_enum && val_is_inline) decl->is_substruct = true;
if (!parse_enum_values(c, &decl->enums.values, visibility, is_const_enum || expected_parameters == 1, is_const_enum)) return poisoned_decl;
decl->enums.inline_value = is_constdef ? false : val_is_inline;
if (is_constdef && val_is_inline) decl->is_substruct = true;
if (!parse_enum_values(c, &decl->enums.values, visibility, is_constdef || expected_parameters == 1, is_constdef)) return poisoned_decl;
return decl;
}
@@ -3642,8 +3636,8 @@ Decl *parse_top_level_statement(ParseContext *c, ParseContext **context_out)
decl = parse_macro_declaration(c, contracts);
break;
case TOKEN_ENUM:
case TOKEN_CENUM:
decl = parse_enum_declaration(c, false);
case TOKEN_CONSTDEF:
decl = parse_enum_declaration(c);
attach_contracts = true;
break;
case TOKEN_FAULTDEF:

View File

@@ -1444,7 +1444,7 @@ Ast *parse_stmt(ParseContext *c)
case TOKEN_BIT_AND_ASSIGN:
case TOKEN_BIT_OR_ASSIGN:
case TOKEN_BIT_XOR_ASSIGN:
case TOKEN_CENUM:
case TOKEN_CONSTDEF:
case TOKEN_COLON:
case TOKEN_COMMA:
case TOKEN_CT_CASE:

View File

@@ -1238,7 +1238,7 @@ RETRY:;
inner = decl->strukt.members[0]->type->canonical;
break;
case DECL_ENUM:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
// Could be made to work.
return false;
default:
@@ -1656,7 +1656,7 @@ static bool rule_enum_to_value(CastContext *cc, bool is_explicit, bool is_silent
return cast_is_allowed(cc, is_explicit, is_silent);
}
ASSERT(enum_decl->decl_kind != DECL_CONST_ENUM);
ASSERT(enum_decl->decl_kind != DECL_CONSTDEF);
Type *inner = enum_decl->enums.type_info->type;
if (!type_is_integer_or_bool_kind(type_flatten(cc->to)))

View File

@@ -71,7 +71,7 @@ static inline bool sema_resolve_align_expr(SemaContext *context, Expr *expr, Ali
}
static inline bool sema_analyse_enum_param(SemaContext *context, Decl *param);
static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *erase_decl);
static inline bool sema_analyse_raw_enum(SemaContext *context, Decl *decl, bool *erase_decl);
static inline bool sema_analyse_constdef(SemaContext *context, Decl *decl, bool *erase_decl);
static bool sema_check_section(SemaContext *context, Attr *attr)
{
@@ -1636,11 +1636,11 @@ static inline void sema_print_enum_to_cenum_error(SemaContext *context, Decl *de
TypeInfo *type_info = decl->enums.type_info;
if (type_info->type == type_int)
{
SEMA_ERROR(arg, "Assigning a value requires the declaration of associated values for the enum. Did you perhaps want C-style enums? In that case use const enums, defined like 'enum %s : const { ... }'", decl->name);
SEMA_ERROR(arg, "Assigning a value requires the declaration of associated values for the enum. Did you perhaps want C-style enums? In that case use constdef, defined like 'constdef %s : { ... }'", decl->name);
}
else
{
SEMA_ERROR(arg, "Assigning a value requires the declaration of associated values for the enum. Did you perhaps want C-style enums? In that case use const enums, defined like 'enum %s : const %s { ... }'", decl->name, type_to_error_string(type_info->type));
SEMA_ERROR(arg, "Assigning a value requires the declaration of associated values for the enum. Did you perhaps want C-style enums? In that case use constdef, defined like 'constdef %s : %s { ... }'", decl->name, type_to_error_string(type_info->type));
}
}
static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *erase_decl)
@@ -1812,7 +1812,7 @@ static bool sema_analyse_const_enum_constant_val(SemaContext *context, Decl *dec
}
return true;
}
static inline bool sema_analyse_raw_enum(SemaContext *context, Decl *decl, bool *erase_decl)
static inline bool sema_analyse_constdef(SemaContext *context, Decl *decl, bool *erase_decl)
{
if (!sema_analyse_attributes(context, decl, decl->attributes, ATTR_ENUM, erase_decl)) return decl_poison(decl);
if (*erase_decl) return true;
@@ -1836,18 +1836,18 @@ static inline bool sema_analyse_raw_enum(SemaContext *context, Decl *decl, bool
SEMA_ERROR(decl->enums.type_info, "No type can be inferred from the optional result.");
return decl_poison(decl);
case STORAGE_VOID:
SEMA_ERROR(decl->enums.type_info, "An enum may not have a void type.");
SEMA_ERROR(decl->enums.type_info, "A constdef may not have a void type.");
return decl_poison(decl);
case STORAGE_COMPILE_TIME:
SEMA_ERROR(decl->enums.type_info, "An enum may not be %s.", type_invalid_storage_type_name(type));
SEMA_ERROR(decl->enums.type_info, "A constdef may not be %s.", type_invalid_storage_type_name(type));
return decl_poison(decl);
case STORAGE_UNKNOWN:
SEMA_ERROR(decl->enums.type_info, "An enum may not be %s, as it has an unknown size.",
SEMA_ERROR(decl->enums.type_info, "A constdef may not be %s, as it has an unknown size.",
type_quoted_error_string(type));
return decl_poison(decl);
}
DEBUG_LOG("* Raw enum type resolved to %s.", type->name);
DEBUG_LOG("* Constdef type resolved to %s.", type->name);
ASSERT_SPAN(decl, !decl->enums.parameters);
@@ -1865,7 +1865,7 @@ static inline bool sema_analyse_raw_enum(SemaContext *context, Decl *decl, bool
{
if (enums == 1)
{
RETURN_SEMA_ERROR(decl, "No enum values left in enum after @if resolution, there must be at least one.");
RETURN_SEMA_ERROR(decl, "No constdef values left in constdef after @if resolution, there must be at least one.");
}
vec_erase_at(enum_values, i);
enums--;
@@ -1873,12 +1873,12 @@ static inline bool sema_analyse_raw_enum(SemaContext *context, Decl *decl, bool
continue;
}
enum_value->type = decl->type;
DEBUG_LOG("* Checking enum constant %s.", enum_value->name);
DEBUG_LOG("* Checking constdef constant %s.", enum_value->name);
if (!enum_value->enum_constant.value)
{
if (!type_is_integer(flat))
{
RETURN_SEMA_ERROR(enum_value, "Enums with missing values must be an integer type.");
RETURN_SEMA_ERROR(enum_value, "Constdefs with missing values must be of integer type.");
}
if (i == 0)
{
@@ -5733,8 +5733,8 @@ bool sema_analyse_decl(SemaContext *context, Decl *decl)
case DECL_ENUM:
if (!sema_analyse_enum(context, decl, &erase_decl)) goto FAILED;
break;
case DECL_CONST_ENUM:
if (!sema_analyse_raw_enum(context, decl, &erase_decl)) goto FAILED;
case DECL_CONSTDEF:
if (!sema_analyse_constdef(context, decl, &erase_decl)) goto FAILED;
break;
case DECL_FAULT:
if (!sema_analyse_fault(context, decl, &erase_decl)) goto FAILED;

View File

@@ -999,8 +999,10 @@ static inline bool sema_cast_ident_rvalue(SemaContext *context, Expr *expr)
case DECL_UNION:
SEMA_ERROR(expr, "Expected union followed by {...} or '.'.");
return expr_poison(expr);
case DECL_CONSTDEF:
SEMA_ERROR(expr, "Expected constdef name followed by '.' and a constdef value.");
return expr_poison(expr);
case DECL_ENUM:
case DECL_CONST_ENUM:
SEMA_ERROR(expr, "Expected enum name followed by '.' and an enum value.");
return expr_poison(expr);
}
@@ -1187,7 +1189,14 @@ static inline bool sema_expr_analyse_enum_constant(SemaContext *context, Expr *e
if (enum_constant->resolve_status == RESOLVE_NOT_DONE)
{
SEMA_ERROR(expr, "Unable to properly resolve enum constant value, this can sometimes happen in recursive definitions.");
if (decl->decl_kind == DECL_ENUM)
{
SEMA_ERROR(expr, "Unable to properly resolve enum constant value, this can sometimes happen in recursive definitions.");
}
else
{
SEMA_ERROR(expr, "Unable to properly resolve constdef value, this can sometimes happen in recursive definitions.");
}
return expr_poison(expr), true;
}
expr->type = decl->type;
@@ -3502,7 +3511,7 @@ INLINE bool sema_expr_analyse_from_ordinal(SemaContext *context, Expr *expr, Exp
{
RETURN_SEMA_ERROR(key, "The ordinal should be an integer.");
}
bool is_const_enum = decl->decl_kind == DECL_CONST_ENUM;
bool is_const_enum = decl->decl_kind == DECL_CONSTDEF;
if (sema_cast_const(key))
{
Int to_convert = key->const_expr.ixx;
@@ -3532,7 +3541,7 @@ INLINE bool sema_expr_analyse_from_ordinal(SemaContext *context, Expr *expr, Exp
}
if (is_const_enum)
{
RETURN_SEMA_ERROR(key, ".from_ordinal on const enums is only valid with compile time constant arguments, maybe you can try using regular enums?");
RETURN_SEMA_ERROR(key, ".from_ordinal on constdefs is only valid with compile time constant arguments, maybe you want to use enums instead?");
}
expr->expr_kind = EXPR_ENUM_FROM_ORD;
expr->inner_expr = key;
@@ -5086,15 +5095,18 @@ static inline bool sema_expr_analyse_type_access(SemaContext *context, Expr *exp
switch (decl->decl_kind)
{
case DECL_ENUM:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
if (is_const)
{
if (!sema_expr_analyse_enum_constant(context, expr, name, decl))
{
if (missing_ref) goto MISSING_REF;
if (!decl_ok(decl)) return false;
if (decl->decl_kind != DECL_ENUM)
{
RETURN_SEMA_ERROR(expr, "'%s' has no value '%s'.", decl->name, name);
}
RETURN_SEMA_ERROR(expr, "'%s' has no enumeration value '%s'.", decl->name, name);
return false;
}
return expr_ok(expr);
}
@@ -10522,7 +10534,7 @@ static inline bool sema_expr_analyse_ct_nameof(SemaContext *context, Expr *expr,
case DECL_BITSTRUCT:
case DECL_TYPEDEF:
case DECL_ENUM:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_ENUM_CONSTANT:
case DECL_FNTYPE:
case DECL_FUNC:

View File

@@ -604,7 +604,7 @@ RETRY:
case DECL_TYPEDEF:
sema_trace_type_liveness(decl->distinct->type);
FALLTHROUGH;
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_BITSTRUCT:
case DECL_INTERFACE:
case DECL_UNION:

View File

@@ -243,7 +243,7 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in
type_info->type = decl->type;
type_info->resolve_status = RESOLVE_DONE;
return true;
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_TYPEDEF:
if (resolve_type_kind & RESOLVE_TYPE_NO_CHECK_DISTINCT)
{

View File

@@ -262,7 +262,7 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls)
case DECL_ALIAS:
case DECL_ATTRIBUTE:
case DECL_BITSTRUCT:
case DECL_CONST_ENUM:
case DECL_CONSTDEF:
case DECL_TYPEDEF:
case DECL_ENUM:
case DECL_INTERFACE:

View File

@@ -199,12 +199,12 @@ const char *token_type_to_string(TokenType type)
return "break";
case TOKEN_CASE:
return "case";
case TOKEN_CENUM:
return "cenum";
case TOKEN_CATCH:
return "catch";
case TOKEN_CONST:
return "const";
case TOKEN_CONSTDEF:
return "constdef";
case TOKEN_CONTINUE:
return "continue";
case TOKEN_DEFAULT:

View File

@@ -2131,7 +2131,7 @@ RETRY_DISTINCT:
return NULL;
case ALL_INTS:
{
// If Foo + 1, then we allow this if Foo is a distinct type or const enum that has
// If Foo + 1, then we allow this if Foo is a distinct type or constdef that has
// integer or float as the base type.
if (first && type_is_distinct_like(other) && type_underlying_is_numeric(other) && expr_is_const(first)) return other;
// See if we can flatten it.
@@ -2145,7 +2145,7 @@ RETRY_DISTINCT:
}
case ALL_FLOATS:
{
// If Foo + 1.0, then we allow this if Foo is a distinct type or const enum that has
// If Foo + 1.0, then we allow this if Foo is a distinct type or constdef that has
// float as the base type.
if (first && type_is_distinct_like(other) && type_underlying_is_numeric(other) && expr_is_const(first)) return other;
// See if we can flatten it.