+ switch ((entity_kind_tag_t) kind) {
+ case ENTITY_FUNCTION: return "function";
+ case ENTITY_VARIABLE: return "variable";
+ case ENTITY_COMPOUND_MEMBER: return "compound type member";
+ case ENTITY_STRUCT: return "struct";
+ case ENTITY_UNION: return "union";
+ case ENTITY_ENUM: return "enum";
+ case ENTITY_ENUM_VALUE: return "enum value";
+ case ENTITY_LABEL: return "label";
+ case ENTITY_LOCAL_LABEL: return "local label";
+ case ENTITY_TYPEDEF: return "typedef";
+ case ENTITY_NAMESPACE: return "namespace";
+ case ENTITY_INVALID: break;
+ }
+
+ panic("Invalid entity kind encountered in get_entity_kind_name");
+}
+
+static void error_redefined_as_different_kind(const source_position_t *pos,
+ const entity_t *old, entity_kind_t new_kind)
+{
+ errorf(pos, "redeclaration of %s '%Y' as %s (declared %P)",
+ get_entity_kind_name(old->kind), old->base.symbol,
+ get_entity_kind_name(new_kind), &old->base.source_position);
+}
+
+/**
+ * record entities for the NAMESPACE_NORMAL, and produce error messages/warnings
+ * for various problems that occur for multiple definitions
+ */
+static entity_t *record_entity(entity_t *entity, const bool is_definition)
+{
+ const symbol_t *const symbol = entity->base.symbol;
+ const namespace_tag_t namespc = (namespace_tag_t)entity->base.namespc;
+ const source_position_t *pos = &entity->base.source_position;