From 220485a2d2cd180e7ff2a15bab66c867c06b05d7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 2 Sep 2018 15:56:36 +0100 Subject: `typeid` as keyword (ready to implement polymorphic name parameters) --- src/check_decl.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index efcbbe1d6..9b571867f 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -232,12 +232,11 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def) GB_ASSERT(e->type == nullptr); DeclInfo *decl = decl_info_of_entity(e); - if (decl != nullptr && total_attribute_count(decl) > 0) { - error(decl->attributes[0], "Attributes are not allowed on type declarations"); + if (decl != nullptr) { + check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr); } - bool is_distinct = is_type_distinct(type_expr); Ast *te = remove_type_alias_clutter(type_expr); e->type = t_invalid; @@ -254,6 +253,11 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def) check_type_path_pop(ctx); named->Named.base = base_type(bt); + + if (is_distinct && is_type_typeid(e->type)) { + error(type_expr, "'distinct' cannot be applied to 'typeid'"); + is_distinct = false; + } if (!is_distinct) { e->type = bt; named->Named.base = bt; @@ -393,8 +397,8 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, DeclInfo *decl = decl_info_of_entity(e); - if (decl != nullptr && total_attribute_count(decl) > 0) { - error(decl->attributes[0], "Attributes are not allowed on constant value declarations"); + if (decl != nullptr) { + check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr); } } -- cgit v1.2.3