mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Assertion when has_tagof is accidentally called on fn type #1343
This commit is contained in:
@@ -2939,6 +2939,7 @@ static inline StorageType type_storage_type(Type *type)
|
||||
case TYPE_MEMBER:
|
||||
case TYPE_UNTYPED_LIST:
|
||||
case TYPE_TYPEINFO:
|
||||
case TYPE_FUNC_RAW:
|
||||
return STORAGE_COMPILE_TIME;
|
||||
case TYPE_OPTIONAL:
|
||||
type = type->optional;
|
||||
|
||||
@@ -4280,7 +4280,11 @@ static bool sema_expr_rewrite_to_type_property(SemaContext *context, Expr *expr,
|
||||
case TYPE_PROPERTY_TAGOF:
|
||||
case TYPE_PROPERTY_HAS_TAGOF:
|
||||
expr->expr_kind = EXPR_TAGOF;
|
||||
expr->tag_of_expr = (ExprTagOf) { .type = type->decl, .property = property };
|
||||
expr->tag_of_expr = (ExprTagOf) {
|
||||
.type = type->type_kind == TYPE_FUNC_PTR
|
||||
? type->pointer->function.decl
|
||||
: type->decl,
|
||||
.property = property };
|
||||
return true;
|
||||
case TYPE_PROPERTY_NONE:
|
||||
return false;
|
||||
|
||||
@@ -305,7 +305,8 @@ INLINE bool sema_resolve_typeof(SemaContext *context, TypeInfo *type_info)
|
||||
Expr *expr = type_info->unresolved_type_expr;
|
||||
if (!sema_analyse_expr_lvalue_fold_const(context, expr)) return false;
|
||||
Type *expr_type = expr->type;
|
||||
switch (type_storage_type(expr->type))
|
||||
if (expr_type->type_kind == TYPE_FUNC_RAW) expr_type = type_get_func_ptr(expr_type);
|
||||
switch (type_storage_type(expr_type))
|
||||
{
|
||||
case STORAGE_NORMAL:
|
||||
case STORAGE_VOID:
|
||||
|
||||
Reference in New Issue
Block a user