+bool psi_impl_func_validate(struct psi_data *data, struct psi_impl_func *func,
+ struct psi_validate_scope *scope)
+{
+ int def = 0;
+ size_t i = 0;
+ struct psi_impl_arg *iarg;
+
+ while (psi_plist_get(func->args, i++, &iarg)) {
+ if (iarg->def) {
+ def = 1;
+ if (!psi_impl_def_val_validate(data, iarg->def, iarg->type, scope)) {
+ return 0;
+ }
+ } else if (def) {
+ data->error(data, func->token, PSI_WARNING,
+ "Non-optional argument %zu '$%s' of implementation '%s'"
+ " follows optional argument",
+ i + 1,
+ iarg->var->name, func->name);
+ return false;
+ }
+ }
+
+ return true;
+}