From 3e05be8eb8b14729b63ee541d11b3deb19b38710 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 29 Oct 2017 18:09:05 +0000 Subject: `@(default_calling_convention = ...)` for `foreign` blocks --- src/check_decl.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 1361ac31c..bc8d35a40 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -467,6 +467,10 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) { if (d != nullptr && d->attributes.count > 0) { + StringSet set = {}; + string_set_init(&set, heap_allocator()); + defer (string_set_destroy(&set)); + for_array(i, d->attributes) { AstNode *attr = d->attributes[i]; if (attr->kind != AstNode_Attribute) continue; @@ -500,14 +504,17 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) { } } + if (string_set_exists(&set, name)) { + error(elem, "Previous declaration of `%.*s`", LIT(name)); + } else { + string_set_add(&set, name); + } + if (name == "link_name") { - if (link_name.len > 0) { - error(elem, "Previous declaration of `link_name`"); - } if (ev.kind == ExactValue_String) { link_name = ev.value_string; } else { - error(elem, "Expected a string value for `link_name`"); + error(elem, "Expected a string value for `%.*s`", LIT(name)); } } else { error(elem, "Unknown attribute element name `%.*s`", LIT(name)); -- cgit v1.2.3