UNSET_FLAG(v, late);
}
+static inline bool _late_array(const Array_Sub array) {
+ return array && !array->exp;
+}
+
+ANN static inline bool late_array(const Type_Decl *td, const Var_Decl var) {
+ return _late_array(td->array) || _late_array(var->array);
+}
+
ANN static m_bool emit_decl(const Emitter emit, const Exp_Decl *decl) {
const m_bool global = GET_FLAG(decl->td, global);
const uint var = exp_getvar(exp_self(decl));
CHECK_BB(op_emit(emit, &opi));
}
set_late(emit->gwion, decl, list->self);
- if (GET_FLAG(array_base(v->type), abstract) && !GET_FLAG(decl->td, late) &&
- GET_FLAG(v, late)) {
- env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use late"),
- v->type->name);
+ if ((GET_FLAG(array_base(v->type), abstract) && !GET_FLAG(decl->td, late) &&
+ GET_FLAG(v, late)) || late_array(decl->td, list->self)) {
+ env_warn(emit->env, decl->td->pos, _("Type '%s' is abstract, use {+G}late{0} instead of {G+}%s{0}"),
+ v->type->name, !GET_FLAG(decl->td, const) ? "var" : "const");
}
} while ((list = list->next));
return GW_OK;
#endif
}
+ANN static void _env_warn(const Env env, const loc_t pos, const m_str fmt,
+ va_list arg) {
+#ifndef __FUZZING__
+ va_list tmpa;
+ va_copy(tmpa, arg);
+ const int size = vsnprintf(NULL, 0, fmt, tmpa);
+ va_end(tmpa);
+ char c[size + 1];
+ vsprintf(c, fmt, arg);
+ gwerr_warn(c, NULL, NULL, env->name, pos);
+ env_error_footer(env);
+#endif
+}
+
ANN void env_warn(const Env env, const loc_t pos, const m_str fmt, ...) {
#ifndef __FUZZING__
va_list arg;
va_start(arg, fmt);
- env_xxx(env, pos, fmt, arg);
+ _env_warn(env, pos, fmt, arg);
va_end(arg);
#endif
}