diff options
| author | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-09-02 15:56:36 +0100 |
| commit | 220485a2d2cd180e7ff2a15bab66c867c06b05d7 (patch) | |
| tree | 4b3df1aae33e7b2af9375b1f8e11d8c2b2b88a15 /src/check_decl.cpp | |
| parent | eb274cf31600814b2f808c80d43376b0e9e959f1 (diff) | |
`typeid` as keyword (ready to implement polymorphic name parameters)
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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); } } |