Commit edca5937 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

widl: Rename (error|warning)_loc_info to (error|warning)_at.

parent d8d87745
...@@ -406,29 +406,25 @@ struct expression_type ...@@ -406,29 +406,25 @@ struct expression_type
static void check_scalar_type(const struct expr_loc *expr_loc, static void check_scalar_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *type) const type_t *cont_type, const type_t *type)
{ {
if (!cont_type || (!is_integer_type(type) && !is_ptr(type) && if (!cont_type || (!is_integer_type( type ) && !is_ptr( type ) && !is_float_type( type )))
!is_float_type(type))) error_at( &expr_loc->v->where, "scalar type required in expression%s%s\n",
error_loc_info(&expr_loc->v->loc_info, "scalar type required in expression%s%s\n", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
} }
static void check_arithmetic_type(const struct expr_loc *expr_loc, static void check_arithmetic_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *type) const type_t *cont_type, const type_t *type)
{ {
if (!cont_type || (!is_integer_type(type) && !is_float_type(type))) if (!cont_type || (!is_integer_type( type ) && !is_float_type( type )))
error_loc_info(&expr_loc->v->loc_info, "arithmetic type required in expression%s%s\n", error_at( &expr_loc->v->where, "arithmetic type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
} }
static void check_integer_type(const struct expr_loc *expr_loc, static void check_integer_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *type) const type_t *cont_type, const type_t *type)
{ {
if (!cont_type || !is_integer_type(type)) if (!cont_type || !is_integer_type( type ))
error_loc_info(&expr_loc->v->loc_info, "integer type required in expression%s%s\n", error_at( &expr_loc->v->where, "integer type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
} }
static type_t *find_identifier(const char *identifier, const type_t *cont_type, int *found_in_cont_type) static type_t *find_identifier(const char *identifier, const type_t *cont_type, int *found_in_cont_type)
...@@ -547,11 +543,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -547,11 +543,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
result.is_temporary = FALSE; result.is_temporary = FALSE;
result.type = find_identifier(e->u.sval, cont_type, &found_in_cont_type); result.type = find_identifier(e->u.sval, cont_type, &found_in_cont_type);
if (!result.type) if (!result.type)
{ error_at( &expr_loc->v->where, "identifier %s cannot be resolved in expression%s%s\n", e->u.sval,
error_loc_info(&expr_loc->v->loc_info, "identifier %s cannot be resolved in expression%s%s\n", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
e->u.sval, expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
}
break; break;
} }
case EXPR_LOGNOT: case EXPR_LOGNOT:
...@@ -575,9 +568,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -575,9 +568,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
case EXPR_ADDRESSOF: case EXPR_ADDRESSOF:
result = resolve_expression(expr_loc, cont_type, e->ref); result = resolve_expression(expr_loc, cont_type, e->ref);
if (!result.is_variable) if (!result.is_variable)
error_loc_info(&expr_loc->v->loc_info, "address-of operator applied to non-variable type in expression%s%s\n", error_at( &expr_loc->v->where, "address-of operator applied to non-variable type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
result.is_variable = FALSE; result.is_variable = FALSE;
result.is_temporary = TRUE; result.is_temporary = TRUE;
result.type = type_new_pointer(result.type); result.type = type_new_pointer(result.type);
...@@ -590,9 +582,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -590,9 +582,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
&& type_array_is_decl_as_ptr(result.type)) && type_array_is_decl_as_ptr(result.type))
result.type = type_array_get_element_type(result.type); result.type = type_array_get_element_type(result.type);
else else
error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n", error_at( &expr_loc->v->where, "dereference operator applied to non-pointer type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
break; break;
case EXPR_CAST: case EXPR_CAST:
result = resolve_expression(expr_loc, cont_type, e->ref); result = resolve_expression(expr_loc, cont_type, e->ref);
...@@ -645,9 +636,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -645,9 +636,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
if (result.type && is_valid_member_operand(result.type)) if (result.type && is_valid_member_operand(result.type))
result = resolve_expression(expr_loc, result.type, e->u.ext); result = resolve_expression(expr_loc, result.type, e->u.ext);
else else
error_loc_info(&expr_loc->v->loc_info, "'.' or '->' operator applied to a type that isn't a structure, union or enumeration in expression%s%s\n", error_at( &expr_loc->v->where, "'.' or '->' operator applied to a type that isn't a structure, union or enumeration in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
break; break;
case EXPR_COND: case EXPR_COND:
{ {
...@@ -658,8 +648,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -658,8 +648,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
result_third = resolve_expression(expr_loc, cont_type, e->ext2); result_third = resolve_expression(expr_loc, cont_type, e->ext2);
check_scalar_type(expr_loc, cont_type, result_second.type); check_scalar_type(expr_loc, cont_type, result_second.type);
check_scalar_type(expr_loc, cont_type, result_third.type); check_scalar_type(expr_loc, cont_type, result_third.type);
if (!is_ptr(result_second.type) ^ !is_ptr(result_third.type)) if (!is_ptr( result_second.type ) ^ !is_ptr( result_third.type ))
error_loc_info(&expr_loc->v->loc_info, "type mismatch in ?: expression\n" ); error_at( &expr_loc->v->where, "type mismatch in ?: expression\n" );
/* FIXME: determine the correct return type */ /* FIXME: determine the correct return type */
result = result_second; result = result_second;
result.is_variable = FALSE; result.is_variable = FALSE;
...@@ -672,15 +662,15 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -672,15 +662,15 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
struct expression_type index_result; struct expression_type index_result;
result.type = type_array_get_element_type(result.type); result.type = type_array_get_element_type(result.type);
index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext); index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext);
if (!index_result.type || !is_integer_type(index_result.type)) if (!index_result.type || !is_integer_type( index_result.type ))
error_loc_info(&expr_loc->v->loc_info, "array subscript not of integral type in expression%s%s\n", error_at( &expr_loc->v->where, "array subscript not of integral type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
expr_loc->attr ? expr_loc->attr : "");
} }
else else
error_loc_info(&expr_loc->v->loc_info, "array subscript operator applied to non-array type in expression%s%s\n", {
expr_loc->attr ? " for attribute " : "", error_at( &expr_loc->v->where, "array subscript operator applied to non-array type in expression%s%s\n",
expr_loc->attr ? expr_loc->attr : ""); expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
}
break; break;
} }
return result; return result;
......
...@@ -1791,9 +1791,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator ...@@ -1791,9 +1791,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator
{ {
if (ptr_attr && ptr_attr != FC_UP && if (ptr_attr && ptr_attr != FC_UP &&
type_get_type(type_pointer_get_ref_type(ptr)) == TYPE_INTERFACE) type_get_type(type_pointer_get_ref_type(ptr)) == TYPE_INTERFACE)
warning_loc_info(&v->loc_info, warning_at( &v->where, "%s: pointer attribute applied to interface pointer type has no effect\n", v->name );
"%s: pointer attribute applied to interface "
"pointer type has no effect\n", v->name);
if (!ptr_attr && top) if (!ptr_attr && top)
{ {
/* FIXME: this is a horrible hack to cope with the issue that we /* FIXME: this is a horrible hack to cope with the issue that we
...@@ -1972,7 +1970,7 @@ var_t *make_var(char *name) ...@@ -1972,7 +1970,7 @@ var_t *make_var(char *name)
init_declspec(&v->declspec, NULL); init_declspec(&v->declspec, NULL);
v->attrs = NULL; v->attrs = NULL;
v->eval = NULL; v->eval = NULL;
init_loc_info(&v->loc_info); init_location( &v->where );
v->declonly = FALSE; v->declonly = FALSE;
return v; return v;
} }
...@@ -1984,7 +1982,7 @@ static var_t *copy_var(var_t *src, char *name, map_attrs_filter_t attr_filter) ...@@ -1984,7 +1982,7 @@ static var_t *copy_var(var_t *src, char *name, map_attrs_filter_t attr_filter)
v->declspec = src->declspec; v->declspec = src->declspec;
v->attrs = map_attrs(src->attrs, attr_filter); v->attrs = map_attrs(src->attrs, attr_filter);
v->eval = src->eval; v->eval = src->eval;
v->loc_info = src->loc_info; v->where = src->where;
return v; return v;
} }
...@@ -2195,10 +2193,9 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at ...@@ -2195,10 +2193,9 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
* FIXME: We may consider string separated type tables for each input * FIXME: We may consider string separated type tables for each input
* for cleaner solution. * for cleaner solution.
*/ */
if (cur && input_name == cur->loc_info.input_name) if (cur && input_name == cur->where.input_name)
error_loc("%s: redefinition error; original definition was at %s:%d\n", error_loc( "%s: redefinition error; original definition was at %s:%d\n",
cur->name, cur->loc_info.input_name, cur->name, cur->where.input_name, cur->where.line_number );
cur->loc_info.line_number);
name = declare_var(attrs, decl_spec, decl, 0); name = declare_var(attrs, decl_spec, decl, 0);
cur = type_new_alias(&name->declspec, name->name); cur = type_new_alias(&name->declspec, name->name);
...@@ -2486,7 +2483,7 @@ attr_list_t *append_attr(attr_list_t *list, attr_t *attr) ...@@ -2486,7 +2483,7 @@ attr_list_t *append_attr(attr_list_t *list, attr_t *attr)
LIST_FOR_EACH_ENTRY(attr_existing, list, attr_t, entry) LIST_FOR_EACH_ENTRY(attr_existing, list, attr_t, entry)
if (attr_existing->type == attr->type) if (attr_existing->type == attr->type)
{ {
parser_warning("duplicate attribute %s\n", get_attr_display_name(attr->type)); warning_loc( "duplicate attribute %s\n", get_attr_display_name(attr->type) );
/* use the last attribute, like MIDL does */ /* use the last attribute, like MIDL does */
list_remove(&attr_existing->entry); list_remove(&attr_existing->entry);
break; break;
...@@ -2779,8 +2776,7 @@ static void check_conformance_expr_list(const char *attr_name, const var_t *arg, ...@@ -2779,8 +2776,7 @@ static void check_conformance_expr_list(const char *attr_name, const var_t *arg,
{ {
const type_t *expr_type = expr_resolve_type(&expr_loc, container_type, dim); const type_t *expr_type = expr_resolve_type(&expr_loc, container_type, dim);
if (!is_allowed_conf_type(expr_type)) if (!is_allowed_conf_type(expr_type))
error_loc_info(&arg->loc_info, "expression must resolve to integral type <= 32bits for attribute %s\n", error_at( &arg->where, "expression must resolve to integral type <= 32bits for attribute %s\n", attr_name );
attr_name);
} }
} }
} }
...@@ -2822,9 +2818,7 @@ static void check_field_common(const type_t *container_type, ...@@ -2822,9 +2818,7 @@ static void check_field_common(const type_t *container_type,
if (is_attr(arg->attrs, ATTR_LENGTHIS) && if (is_attr(arg->attrs, ATTR_LENGTHIS) &&
(is_attr(arg->attrs, ATTR_STRING) || is_aliaschain_attr(arg->declspec.type, ATTR_STRING))) (is_attr(arg->attrs, ATTR_STRING) || is_aliaschain_attr(arg->declspec.type, ATTR_STRING)))
error_loc_info(&arg->loc_info, error_at( &arg->where, "string and length_is specified for argument %s are mutually exclusive attributes\n", arg->name );
"string and length_is specified for argument %s are mutually exclusive attributes\n",
arg->name);
if (is_attr(arg->attrs, ATTR_SIZEIS)) if (is_attr(arg->attrs, ATTR_SIZEIS))
{ {
...@@ -2847,7 +2841,7 @@ static void check_field_common(const type_t *container_type, ...@@ -2847,7 +2841,7 @@ static void check_field_common(const type_t *container_type,
expr_loc.attr = "iid_is"; expr_loc.attr = "iid_is";
expr_type = expr_resolve_type(&expr_loc, container_type, expr); expr_type = expr_resolve_type(&expr_loc, container_type, expr);
if (!expr_type || !is_ptr_guid_type(expr_type)) if (!expr_type || !is_ptr_guid_type(expr_type))
error_loc_info(&arg->loc_info, "expression must resolve to pointer to GUID type for attribute iid_is\n"); error_at( &arg->where, "expression must resolve to pointer to GUID type for attribute iid_is\n" );
} }
} }
if (is_attr(arg->attrs, ATTR_SWITCHIS)) if (is_attr(arg->attrs, ATTR_SWITCHIS))
...@@ -2861,8 +2855,7 @@ static void check_field_common(const type_t *container_type, ...@@ -2861,8 +2855,7 @@ static void check_field_common(const type_t *container_type,
expr_loc.attr = "switch_is"; expr_loc.attr = "switch_is";
expr_type = expr_resolve_type(&expr_loc, container_type, expr); expr_type = expr_resolve_type(&expr_loc, container_type, expr);
if (!expr_type || !is_allowed_conf_type(expr_type)) if (!expr_type || !is_allowed_conf_type(expr_type))
error_loc_info(&arg->loc_info, "expression must resolve to integral type <= 32bits for attribute %s\n", error_at( &arg->where, "expression must resolve to integral type <= 32bits for attribute %s\n", expr_loc.attr );
expr_loc.attr);
} }
} }
...@@ -2902,17 +2895,14 @@ static void check_field_common(const type_t *container_type, ...@@ -2902,17 +2895,14 @@ static void check_field_common(const type_t *container_type,
default: default:
break; break;
} }
error_loc_info(&arg->loc_info, "%s \'%s\' of %s \'%s\' %s\n", error_at( &arg->where, "%s \'%s\' of %s \'%s\' %s\n", var_type, arg->name, container_type_name, container_name, reason );
var_type, arg->name, container_type_name, container_name, reason);
break; break;
} }
case TGT_CTXT_HANDLE: case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER: case TGT_CTXT_HANDLE_POINTER:
if (type_get_type(container_type) != TYPE_FUNCTION) if (type_get_type(container_type) != TYPE_FUNCTION)
error_loc_info(&arg->loc_info, error_at( &arg->where, "%s \'%s\' of %s \'%s\' cannot be a context handle\n",
"%s \'%s\' of %s \'%s\' cannot be a context handle\n", var_type, arg->name, container_type_name, container_name );
var_type, arg->name, container_type_name,
container_name);
break; break;
case TGT_STRING: case TGT_STRING:
{ {
...@@ -2920,7 +2910,7 @@ static void check_field_common(const type_t *container_type, ...@@ -2920,7 +2910,7 @@ static void check_field_common(const type_t *container_type,
while (is_ptr(t)) while (is_ptr(t))
t = type_pointer_get_ref_type(t); t = type_pointer_get_ref_type(t);
if (is_aliaschain_attr(t, ATTR_RANGE)) if (is_aliaschain_attr(t, ATTR_RANGE))
warning_loc_info(&arg->loc_info, "%s: range not verified for a string of ranged types\n", arg->name); warning_at( &arg->where, "%s: range not verified for a string of ranged types\n", arg->name );
break; break;
} }
case TGT_POINTER: case TGT_POINTER:
...@@ -2934,9 +2924,7 @@ static void check_field_common(const type_t *container_type, ...@@ -2934,9 +2924,7 @@ static void check_field_common(const type_t *container_type,
case TGT_ENUM: case TGT_ENUM:
type = type_get_real_type(type); type = type_get_real_type(type);
if (!type_is_complete(type)) if (!type_is_complete(type))
{ error_at( &arg->where, "undefined type declaration \"enum %s\"\n", type->name );
error_loc_info(&arg->loc_info, "undefined type declaration \"enum %s\"\n", type->name);
}
case TGT_USER_TYPE: case TGT_USER_TYPE:
case TGT_IFACE_POINTER: case TGT_IFACE_POINTER:
case TGT_BASIC: case TGT_BASIC:
...@@ -2964,14 +2952,14 @@ static void check_remoting_fields(const var_t *var, type_t *type) ...@@ -2964,14 +2952,14 @@ static void check_remoting_fields(const var_t *var, type_t *type)
if (type_is_complete(type)) if (type_is_complete(type))
fields = type_struct_get_fields(type); fields = type_struct_get_fields(type);
else else
error_loc_info(&var->loc_info, "undefined type declaration \"struct %s\"\n", type->name); error_at( &var->where, "undefined type declaration \"struct %s\"\n", type->name );
} }
else if (type_get_type(type) == TYPE_UNION || type_get_type(type) == TYPE_ENCAPSULATED_UNION) else if (type_get_type(type) == TYPE_UNION || type_get_type(type) == TYPE_ENCAPSULATED_UNION)
{ {
if (type_is_complete(type)) if (type_is_complete(type))
fields = type_union_get_cases(type); fields = type_union_get_cases(type);
else else
error_loc_info(&var->loc_info, "undefined type declaration \"union %s\"\n", type->name); error_at( &var->where, "undefined type declaration \"union %s\"\n", type->name );
} }
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
...@@ -3003,10 +2991,10 @@ static void check_remoting_args(const var_t *func) ...@@ -3003,10 +2991,10 @@ static void check_remoting_args(const var_t *func)
case TGT_UNION: case TGT_UNION:
case TGT_CTXT_HANDLE: case TGT_CTXT_HANDLE:
case TGT_USER_TYPE: case TGT_USER_TYPE:
error_loc_info(&arg->loc_info, "out parameter \'%s\' of function \'%s\' is not a pointer\n", arg->name, funcname); error_at( &arg->where, "out parameter \'%s\' of function \'%s\' is not a pointer\n", arg->name, funcname );
break; break;
case TGT_IFACE_POINTER: case TGT_IFACE_POINTER:
error_loc_info(&arg->loc_info, "out interface pointer \'%s\' of function \'%s\' is not a double pointer\n", arg->name, funcname); error_at( &arg->where, "out interface pointer \'%s\' of function \'%s\' is not a double pointer\n", arg->name, funcname );
break; break;
case TGT_STRING: case TGT_STRING:
if (is_array(type)) if (is_array(type))
...@@ -3017,7 +3005,7 @@ static void check_remoting_args(const var_t *func) ...@@ -3017,7 +3005,7 @@ static void check_remoting_args(const var_t *func)
if (!type_array_has_conformance(type) && type_array_get_dim(type)) break; if (!type_array_has_conformance(type) && type_array_get_dim(type)) break;
} }
if (is_attr( arg->attrs, ATTR_IN )) break; if (is_attr( arg->attrs, ATTR_IN )) break;
error_loc_info(&arg->loc_info, "out parameter \'%s\' of function \'%s\' cannot be an unsized string\n", arg->name, funcname); error_at( &arg->where, "out parameter \'%s\' of function \'%s\' cannot be an unsized string\n", arg->name, funcname );
break; break;
case TGT_INVALID: case TGT_INVALID:
/* already error'd before we get here */ /* already error'd before we get here */
...@@ -3080,7 +3068,7 @@ static void check_functions(const type_t *iface, int is_inside_library) ...@@ -3080,7 +3068,7 @@ static void check_functions(const type_t *iface, int is_inside_library)
if (is_attr(func->attrs, ATTR_PROPGET) != is_attr(func_iter->attrs, ATTR_PROPGET)) continue; if (is_attr(func->attrs, ATTR_PROPGET) != is_attr(func_iter->attrs, ATTR_PROPGET)) continue;
if (is_attr(func->attrs, ATTR_PROPPUT) != is_attr(func_iter->attrs, ATTR_PROPPUT)) continue; if (is_attr(func->attrs, ATTR_PROPPUT) != is_attr(func_iter->attrs, ATTR_PROPPUT)) continue;
if (is_attr(func->attrs, ATTR_PROPPUTREF) != is_attr(func_iter->attrs, ATTR_PROPPUTREF)) continue; if (is_attr(func->attrs, ATTR_PROPPUTREF) != is_attr(func_iter->attrs, ATTR_PROPPUTREF)) continue;
error_loc_info(&func->loc_info, "duplicated function \'%s\'\n", func->name); error_at( &func->where, "duplicated function \'%s\'\n", func->name );
} }
} }
} }
...@@ -3401,11 +3389,11 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s ...@@ -3401,11 +3389,11 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
return list; return list;
} }
void init_loc_info(loc_info_t *i) void init_location( struct location *where )
{ {
i->input_name = input_name ? input_name : "stdin"; where->input_name = input_name ? input_name : "stdin";
i->line_number = line_number; where->line_number = line_number;
i->near_text = parser_text; where->near_text = parser_text;
} }
type_t *find_parameterized_type(type_t *type, typeref_list_t *params) type_t *find_parameterized_type(type_t *type, typeref_list_t *params)
......
...@@ -65,7 +65,7 @@ type_t *make_type(enum type_type type) ...@@ -65,7 +65,7 @@ type_t *make_type(enum type_type type)
t->tfswrite = FALSE; t->tfswrite = FALSE;
t->checked = FALSE; t->checked = FALSE;
t->typelib_idx = -1; t->typelib_idx = -1;
init_loc_info(&t->loc_info); init_location( &t->where );
return t; return t;
} }
...@@ -172,8 +172,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t ...@@ -172,8 +172,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t
else if (type->signature) n += strappend(buf, len, pos + n, "%s", type->signature); else if (type->signature) n += strappend(buf, len, pos + n, "%s", type->signature);
else else
{ {
if (!(uuid = get_attrp(type->attrs, ATTR_UUID))) if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
error_loc_info(&type->loc_info, "cannot compute type signature, no uuid found for type %s.\n", type->name); error_at( &type->where, "cannot compute type signature, no uuid found for type %s.\n", type->name );
n += strappend(buf, len, pos + n, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", n += strappend(buf, len, pos + n, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data1, uuid->Data2, uuid->Data3,
...@@ -241,7 +241,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t ...@@ -241,7 +241,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t
case TYPE_BASIC_WCHAR: case TYPE_BASIC_WCHAR:
case TYPE_BASIC_ERROR_STATUS_T: case TYPE_BASIC_ERROR_STATUS_T:
case TYPE_BASIC_HANDLE: case TYPE_BASIC_HANDLE:
error_loc_info(&type->loc_info, "unimplemented type signature for basic type %d.\n", type_basic_get_type(type)); error_at( &type->where, "unimplemented type signature for basic type %d.\n",
type_basic_get_type( type ) );
break; break;
} }
case TYPE_ENUM: case TYPE_ENUM:
...@@ -260,7 +261,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t ...@@ -260,7 +261,8 @@ static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t
case TYPE_BITFIELD: case TYPE_BITFIELD:
case TYPE_MODULE: case TYPE_MODULE:
case TYPE_APICONTRACT: case TYPE_APICONTRACT:
error_loc_info(&type->loc_info, "unimplemented type signature for type %s of type %d.\n", type->name, type->type_type); error_at( &type->where, "unimplemented type signature for type %s of type %d.\n",
type->name, type->type_type );
break; break;
case TYPE_PARAMETERIZED_TYPE: case TYPE_PARAMETERIZED_TYPE:
case TYPE_PARAMETER: case TYPE_PARAMETER:
...@@ -346,8 +348,8 @@ static char *format_parameterized_type_signature(type_t *type, typeref_list_t *p ...@@ -346,8 +348,8 @@ static char *format_parameterized_type_signature(type_t *type, typeref_list_t *p
typeref_t *ref; typeref_t *ref;
const struct uuid *uuid; const struct uuid *uuid;
if (!(uuid = get_attrp(type->attrs, ATTR_UUID))) if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
error_loc_info(&type->loc_info, "cannot compute type signature, no uuid found for type %s.\n", type->name); error_at( &type->where, "cannot compute type signature, no uuid found for type %s.\n", type->name );
pos += strappend(&buf, &len, pos, "pinterface({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", pos += strappend(&buf, &len, pos, "pinterface({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data1, uuid->Data2, uuid->Data3,
...@@ -476,7 +478,7 @@ type_t *type_new_alias(const decl_spec_t *t, const char *name) ...@@ -476,7 +478,7 @@ type_t *type_new_alias(const decl_spec_t *t, const char *name)
a->name = xstrdup(name); a->name = xstrdup(name);
a->attrs = NULL; a->attrs = NULL;
a->details.alias.aliasee = *t; a->details.alias.aliasee = *t;
init_loc_info(&a->loc_info); init_location( &a->where );
return a; return a;
} }
...@@ -722,17 +724,17 @@ static unsigned int compute_method_indexes(type_t *iface) ...@@ -722,17 +724,17 @@ static unsigned int compute_method_indexes(type_t *iface)
type_t *type_interface_declare(char *name, struct namespace *namespace) type_t *type_interface_declare(char *name, struct namespace *namespace)
{ {
type_t *type = get_type(TYPE_INTERFACE, name, namespace, 0); type_t *type = get_type(TYPE_INTERFACE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_INTERFACE) if (type_get_type_detect_alias( type ) != TYPE_INTERFACE)
error_loc("interface %s previously not declared an interface at %s:%d\n", error_loc( "interface %s previously not declared an interface at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
type_t *type_interface_define(type_t *iface, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires) type_t *type_interface_define(type_t *iface, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires)
{ {
if (iface->defined) if (iface->defined)
error_loc("interface %s already defined at %s:%d\n", error_loc( "interface %s already defined at %s:%d\n", iface->name,
iface->name, iface->loc_info.input_name, iface->loc_info.line_number); iface->where.input_name, iface->where.line_number );
if (iface == inherit) if (iface == inherit)
error_loc("interface %s can't inherit from itself\n", error_loc("interface %s can't inherit from itself\n",
iface->name); iface->name);
...@@ -753,17 +755,17 @@ type_t *type_interface_define(type_t *iface, attr_list_t *attrs, type_t *inherit ...@@ -753,17 +755,17 @@ type_t *type_interface_define(type_t *iface, attr_list_t *attrs, type_t *inherit
type_t *type_dispinterface_declare(char *name) type_t *type_dispinterface_declare(char *name)
{ {
type_t *type = get_type(TYPE_INTERFACE, name, NULL, 0); type_t *type = get_type(TYPE_INTERFACE, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_INTERFACE) if (type_get_type_detect_alias( type ) != TYPE_INTERFACE)
error_loc("dispinterface %s previously not declared a dispinterface at %s:%d\n", error_loc( "dispinterface %s previously not declared a dispinterface at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number); type->name, type->where.input_name, type->where.line_number );
return type; return type;
} }
type_t *type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t *props, var_list_t *methods) type_t *type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t *props, var_list_t *methods)
{ {
if (iface->defined) if (iface->defined)
error_loc("dispinterface %s already defined at %s:%d\n", error_loc( "dispinterface %s already defined at %s:%d\n", iface->name,
iface->name, iface->loc_info.input_name, iface->loc_info.line_number); iface->where.input_name, iface->where.line_number );
iface->attrs = check_dispiface_attrs(iface->name, attrs); iface->attrs = check_dispiface_attrs(iface->name, attrs);
iface->details.iface = xmalloc(sizeof(*iface->details.iface)); iface->details.iface = xmalloc(sizeof(*iface->details.iface));
iface->details.iface->disp_props = props; iface->details.iface->disp_props = props;
...@@ -782,8 +784,8 @@ type_t *type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t ...@@ -782,8 +784,8 @@ type_t *type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t
type_t *type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *attrs, type_t *iface) type_t *type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *attrs, type_t *iface)
{ {
if (dispiface->defined) if (dispiface->defined)
error_loc("dispinterface %s already defined at %s:%d\n", error_loc( "dispinterface %s already defined at %s:%d\n", dispiface->name,
dispiface->name, dispiface->loc_info.input_name, dispiface->loc_info.line_number); dispiface->where.input_name, dispiface->where.line_number );
dispiface->attrs = check_dispiface_attrs(dispiface->name, attrs); dispiface->attrs = check_dispiface_attrs(dispiface->name, attrs);
dispiface->details.iface = xmalloc(sizeof(*dispiface->details.iface)); dispiface->details.iface = xmalloc(sizeof(*dispiface->details.iface));
dispiface->details.iface->disp_props = NULL; dispiface->details.iface->disp_props = NULL;
...@@ -802,17 +804,17 @@ type_t *type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *att ...@@ -802,17 +804,17 @@ type_t *type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *att
type_t *type_module_declare(char *name) type_t *type_module_declare(char *name)
{ {
type_t *type = get_type(TYPE_MODULE, name, NULL, 0); type_t *type = get_type(TYPE_MODULE, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_MODULE) if (type_get_type_detect_alias( type ) != TYPE_MODULE)
error_loc("module %s previously not declared a module at %s:%d\n", error_loc( "module %s previously not declared a module at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
type_t *type_module_define(type_t* module, attr_list_t *attrs, statement_list_t *stmts) type_t *type_module_define(type_t* module, attr_list_t *attrs, statement_list_t *stmts)
{ {
if (module->defined) if (module->defined)
error_loc("module %s already defined at %s:%d\n", error_loc( "module %s already defined at %s:%d\n", module->name,
module->name, module->loc_info.input_name, module->loc_info.line_number); module->where.input_name, module->where.line_number );
module->attrs = check_module_attrs(module->name, attrs); module->attrs = check_module_attrs(module->name, attrs);
module->details.module = xmalloc(sizeof(*module->details.module)); module->details.module = xmalloc(sizeof(*module->details.module));
module->details.module->stmts = stmts; module->details.module->stmts = stmts;
...@@ -823,17 +825,17 @@ type_t *type_module_define(type_t* module, attr_list_t *attrs, statement_list_t ...@@ -823,17 +825,17 @@ type_t *type_module_define(type_t* module, attr_list_t *attrs, statement_list_t
type_t *type_coclass_declare(char *name) type_t *type_coclass_declare(char *name)
{ {
type_t *type = get_type(TYPE_COCLASS, name, NULL, 0); type_t *type = get_type(TYPE_COCLASS, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_COCLASS) if (type_get_type_detect_alias( type ) != TYPE_COCLASS)
error_loc("coclass %s previously not declared a coclass at %s:%d\n", error_loc( "coclass %s previously not declared a coclass at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t *ifaces) type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t *ifaces)
{ {
if (coclass->defined) if (coclass->defined)
error_loc("coclass %s already defined at %s:%d\n", error_loc( "coclass %s already defined at %s:%d\n", coclass->name,
coclass->name, coclass->loc_info.input_name, coclass->loc_info.line_number); coclass->where.input_name, coclass->where.line_number );
coclass->attrs = check_coclass_attrs(coclass->name, attrs); coclass->attrs = check_coclass_attrs(coclass->name, attrs);
coclass->details.coclass.ifaces = ifaces; coclass->details.coclass.ifaces = ifaces;
coclass->defined = TRUE; coclass->defined = TRUE;
...@@ -843,9 +845,9 @@ type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t ...@@ -843,9 +845,9 @@ type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t
type_t *type_runtimeclass_declare(char *name, struct namespace *namespace) type_t *type_runtimeclass_declare(char *name, struct namespace *namespace)
{ {
type_t *type = get_type(TYPE_RUNTIMECLASS, name, namespace, 0); type_t *type = get_type(TYPE_RUNTIMECLASS, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_RUNTIMECLASS) if (type_get_type_detect_alias( type ) != TYPE_RUNTIMECLASS)
error_loc("runtimeclass %s previously not declared a runtimeclass at %s:%d\n", error_loc( "runtimeclass %s previously not declared a runtimeclass at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
...@@ -855,8 +857,8 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typer ...@@ -855,8 +857,8 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typer
typeref_list_t *requires; typeref_list_t *requires;
if (runtimeclass->defined) if (runtimeclass->defined)
error_loc("runtimeclass %s already defined at %s:%d\n", error_loc( "runtimeclass %s already defined at %s:%d\n", runtimeclass->name,
runtimeclass->name, runtimeclass->loc_info.input_name, runtimeclass->loc_info.line_number); runtimeclass->where.input_name, runtimeclass->where.line_number );
runtimeclass->attrs = check_runtimeclass_attrs(runtimeclass->name, attrs); runtimeclass->attrs = check_runtimeclass_attrs(runtimeclass->name, attrs);
runtimeclass->details.runtimeclass.ifaces = ifaces; runtimeclass->details.runtimeclass.ifaces = ifaces;
runtimeclass->defined = TRUE; runtimeclass->defined = TRUE;
...@@ -891,17 +893,17 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typer ...@@ -891,17 +893,17 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typer
type_t *type_apicontract_declare(char *name, struct namespace *namespace) type_t *type_apicontract_declare(char *name, struct namespace *namespace)
{ {
type_t *type = get_type(TYPE_APICONTRACT, name, namespace, 0); type_t *type = get_type(TYPE_APICONTRACT, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_APICONTRACT) if (type_get_type_detect_alias( type ) != TYPE_APICONTRACT)
error_loc("apicontract %s previously not declared a apicontract at %s:%d\n", error_loc( "apicontract %s previously not declared a apicontract at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs) type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs)
{ {
if (apicontract->defined) if (apicontract->defined)
error_loc("apicontract %s already defined at %s:%d\n", error_loc( "apicontract %s already defined at %s:%d\n", apicontract->name,
apicontract->name, apicontract->loc_info.input_name, apicontract->loc_info.line_number); apicontract->where.input_name, apicontract->where.line_number );
apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs); apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs);
apicontract->defined = TRUE; apicontract->defined = TRUE;
return apicontract; return apicontract;
...@@ -922,9 +924,9 @@ static void compute_delegate_iface_names(type_t *delegate, type_t *type, typeref ...@@ -922,9 +924,9 @@ static void compute_delegate_iface_names(type_t *delegate, type_t *type, typeref
type_t *type_delegate_declare(char *name, struct namespace *namespace) type_t *type_delegate_declare(char *name, struct namespace *namespace)
{ {
type_t *type = get_type(TYPE_DELEGATE, name, namespace, 0); type_t *type = get_type(TYPE_DELEGATE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_DELEGATE) if (type_get_type_detect_alias( type ) != TYPE_DELEGATE)
error_loc("delegate %s previously not declared a delegate at %s:%d\n", error_loc( "delegate %s previously not declared a delegate at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
return type; return type;
} }
...@@ -933,8 +935,8 @@ type_t *type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_lis ...@@ -933,8 +935,8 @@ type_t *type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_lis
type_t *iface; type_t *iface;
if (delegate->defined) if (delegate->defined)
error_loc("delegate %s already defined at %s:%d\n", error_loc( "delegate %s already defined at %s:%d\n", delegate->name,
delegate->name, delegate->loc_info.input_name, delegate->loc_info.line_number); delegate->where.input_name, delegate->where.line_number );
delegate->attrs = check_interface_attrs(delegate->name, attrs); delegate->attrs = check_interface_attrs(delegate->name, attrs);
...@@ -962,9 +964,9 @@ type_t *type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_lis ...@@ -962,9 +964,9 @@ type_t *type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_lis
type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, typeref_list_t *params) type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, typeref_list_t *params)
{ {
type_t *type = get_type(TYPE_PARAMETERIZED_TYPE, name, namespace, 0); type_t *type = get_type(TYPE_PARAMETERIZED_TYPE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE) if (type_get_type_detect_alias( type ) != TYPE_PARAMETERIZED_TYPE)
error_loc("pinterface %s previously not declared a pinterface at %s:%d\n", error_loc( "pinterface %s previously not declared a pinterface at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
type->details.parameterized.type = make_type(TYPE_INTERFACE); type->details.parameterized.type = make_type(TYPE_INTERFACE);
type->details.parameterized.params = params; type->details.parameterized.params = params;
return type; return type;
...@@ -974,8 +976,8 @@ type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, ty ...@@ -974,8 +976,8 @@ type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, ty
{ {
type_t *iface; type_t *iface;
if (type->defined) if (type->defined)
error_loc("pinterface %s already defined at %s:%d\n", error_loc( "pinterface %s already defined at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
/* The parameterized type UUID is actually a PIID that is then used as a seed to generate /* The parameterized type UUID is actually a PIID that is then used as a seed to generate
* a new type GUID with the rules described in: * a new type GUID with the rules described in:
...@@ -1003,9 +1005,9 @@ type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, ty ...@@ -1003,9 +1005,9 @@ type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, ty
type_t *type_parameterized_delegate_declare(char *name, struct namespace *namespace, typeref_list_t *params) type_t *type_parameterized_delegate_declare(char *name, struct namespace *namespace, typeref_list_t *params)
{ {
type_t *type = get_type(TYPE_PARAMETERIZED_TYPE, name, namespace, 0); type_t *type = get_type(TYPE_PARAMETERIZED_TYPE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE) if (type_get_type_detect_alias( type ) != TYPE_PARAMETERIZED_TYPE)
error_loc("pdelegate %s previously not declared a pdelegate at %s:%d\n", error_loc( "pdelegate %s previously not declared a pdelegate at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
type->details.parameterized.type = make_type(TYPE_DELEGATE); type->details.parameterized.type = make_type(TYPE_DELEGATE);
type->details.parameterized.params = params; type->details.parameterized.params = params;
return type; return type;
...@@ -1016,8 +1018,8 @@ type_t *type_parameterized_delegate_define(type_t *type, attr_list_t *attrs, sta ...@@ -1016,8 +1018,8 @@ type_t *type_parameterized_delegate_define(type_t *type, attr_list_t *attrs, sta
type_t *iface, *delegate; type_t *iface, *delegate;
if (type->defined) if (type->defined)
error_loc("pdelegate %s already defined at %s:%d\n", error_loc( "pdelegate %s already defined at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
type->attrs = check_interface_attrs(type->name, attrs); type->attrs = check_interface_attrs(type->name, attrs);
...@@ -1097,7 +1099,8 @@ static var_list_t *replace_type_parameters_in_var_list(var_list_t *var_list, typ ...@@ -1097,7 +1099,8 @@ static var_list_t *replace_type_parameters_in_var_list(var_list_t *var_list, typ
return new_var_list; return new_var_list;
} }
static statement_t *replace_type_parameters_in_statement(statement_t *stmt, typeref_list_t *orig, typeref_list_t *repl, loc_info_t *loc) static statement_t *replace_type_parameters_in_statement( statement_t *stmt, typeref_list_t *orig,
typeref_list_t *repl, struct location *where )
{ {
statement_t *new_stmt = xmalloc(sizeof(*new_stmt)); statement_t *new_stmt = xmalloc(sizeof(*new_stmt));
*new_stmt = *stmt; *new_stmt = *stmt;
...@@ -1121,14 +1124,15 @@ static statement_t *replace_type_parameters_in_statement(statement_t *stmt, type ...@@ -1121,14 +1124,15 @@ static statement_t *replace_type_parameters_in_statement(statement_t *stmt, type
case STMT_IMPORTLIB: case STMT_IMPORTLIB:
case STMT_PRAGMA: case STMT_PRAGMA:
case STMT_CPPQUOTE: case STMT_CPPQUOTE:
error_loc_info(loc, "unimplemented parameterized type replacement for statement type %d.\n", stmt->type); error_at( where, "unimplemented parameterized type replacement for statement type %d.\n", stmt->type );
break; break;
} }
return new_stmt; return new_stmt;
} }
static statement_list_t *replace_type_parameters_in_statement_list(statement_list_t *stmt_list, typeref_list_t *orig, typeref_list_t *repl, loc_info_t *loc) static statement_list_t *replace_type_parameters_in_statement_list( statement_list_t *stmt_list, typeref_list_t *orig,
typeref_list_t *repl, struct location *where )
{ {
statement_list_t *new_stmt_list; statement_list_t *new_stmt_list;
statement_t *stmt, *new_stmt; statement_t *stmt, *new_stmt;
...@@ -1140,7 +1144,7 @@ static statement_list_t *replace_type_parameters_in_statement_list(statement_lis ...@@ -1140,7 +1144,7 @@ static statement_list_t *replace_type_parameters_in_statement_list(statement_lis
LIST_FOR_EACH_ENTRY(stmt, stmt_list, statement_t, entry) LIST_FOR_EACH_ENTRY(stmt, stmt_list, statement_t, entry)
{ {
new_stmt = replace_type_parameters_in_statement(stmt, orig, repl, loc); new_stmt = replace_type_parameters_in_statement( stmt, orig, repl, where );
list_add_tail(new_stmt_list, &new_stmt->entry); list_add_tail(new_stmt_list, &new_stmt->entry);
} }
...@@ -1205,7 +1209,8 @@ static type_t *replace_type_parameters_in_type(type_t *type, typeref_list_t *ori ...@@ -1205,7 +1209,8 @@ static type_t *replace_type_parameters_in_type(type_t *type, typeref_list_t *ori
case TYPE_MODULE: case TYPE_MODULE:
case TYPE_COCLASS: case TYPE_COCLASS:
case TYPE_APICONTRACT: case TYPE_APICONTRACT:
error_loc_info(&type->loc_info, "unimplemented parameterized type replacement for type %s of type %d.\n", type->name, type->type_type); error_at( &type->where, "unimplemented parameterized type replacement for type %s of type %d.\n",
type->name, type->type_type );
break; break;
} }
...@@ -1217,7 +1222,8 @@ static void type_parameterized_interface_specialize(type_t *tmpl, type_t *iface, ...@@ -1217,7 +1222,8 @@ static void type_parameterized_interface_specialize(type_t *tmpl, type_t *iface,
iface->details.iface = xmalloc(sizeof(*iface->details.iface)); iface->details.iface = xmalloc(sizeof(*iface->details.iface));
iface->details.iface->disp_methods = NULL; iface->details.iface->disp_methods = NULL;
iface->details.iface->disp_props = NULL; iface->details.iface->disp_props = NULL;
iface->details.iface->stmts = replace_type_parameters_in_statement_list(tmpl->details.iface->stmts, orig, repl, &tmpl->loc_info); iface->details.iface->stmts = replace_type_parameters_in_statement_list( tmpl->details.iface->stmts,
orig, repl, &tmpl->where );
iface->details.iface->inherit = replace_type_parameters_in_type(tmpl->details.iface->inherit, orig, repl); iface->details.iface->inherit = replace_type_parameters_in_type(tmpl->details.iface->inherit, orig, repl);
iface->details.iface->disp_inherit = NULL; iface->details.iface->disp_inherit = NULL;
iface->details.iface->async_iface = NULL; iface->details.iface->async_iface = NULL;
...@@ -1298,8 +1304,8 @@ type_t *type_parameterized_type_specialize_define(type_t *type) ...@@ -1298,8 +1304,8 @@ type_t *type_parameterized_type_specialize_define(type_t *type)
if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE || if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE ||
type_get_type_detect_alias(tmpl) != TYPE_PARAMETERIZED_TYPE) type_get_type_detect_alias(tmpl) != TYPE_PARAMETERIZED_TYPE)
error_loc("cannot define non-parameterized type %s, declared at %s:%d\n", error_loc( "cannot define non-parameterized type %s, declared at %s:%d\n", type->name,
type->name, type->loc_info.input_name, type->loc_info.line_number); type->where.input_name, type->where.line_number );
if (type_get_type_detect_alias(tmpl->details.parameterized.type) == TYPE_INTERFACE && if (type_get_type_detect_alias(tmpl->details.parameterized.type) == TYPE_INTERFACE &&
type_get_type_detect_alias(iface) == TYPE_INTERFACE) type_get_type_detect_alias(iface) == TYPE_INTERFACE)
...@@ -1309,7 +1315,7 @@ type_t *type_parameterized_type_specialize_define(type_t *type) ...@@ -1309,7 +1315,7 @@ type_t *type_parameterized_type_specialize_define(type_t *type)
type_parameterized_delegate_specialize(tmpl->details.parameterized.type, iface, orig, repl); type_parameterized_delegate_specialize(tmpl->details.parameterized.type, iface, orig, repl);
else else
error_loc("pinterface/pdelegate %s previously not declared a pinterface/pdelegate at %s:%d\n", error_loc("pinterface/pdelegate %s previously not declared a pinterface/pdelegate at %s:%d\n",
iface->name, iface->loc_info.input_name, iface->loc_info.line_number); iface->name, iface->where.input_name, iface->where.line_number);
iface->impl_name = format_parameterized_type_impl_name(type, repl, ""); iface->impl_name = format_parameterized_type_impl_name(type, repl, "");
iface->signature = format_parameterized_type_signature(type, repl); iface->signature = format_parameterized_type_signature(type, repl);
......
...@@ -392,7 +392,7 @@ static inline type_t *type_runtimeclass_get_default_iface(const type_t *type, in ...@@ -392,7 +392,7 @@ static inline type_t *type_runtimeclass_get_default_iface(const type_t *type, in
return ref->type; return ref->type;
if (!check) return NULL; if (!check) return NULL;
error_loc_info(&type->loc_info, "runtimeclass %s needs a default interface\n", type->name); error_at( &type->where, "runtimeclass %s needs a default interface\n", type->name );
} }
static inline type_t *type_delegate_get_iface(const type_t *type) static inline type_t *type_delegate_get_iface(const type_t *type)
......
...@@ -46,58 +46,39 @@ static void make_print(char *str) ...@@ -46,58 +46,39 @@ static void make_print(char *str)
} }
} }
static void generic_msg(const loc_info_t *loc_info, const char *s, const char *t, va_list ap) static void generic_msg( const struct location *where, const char *s, const char *t, va_list ap )
{ {
fprintf(stderr, "%s:%d: %s: ", loc_info->input_name, loc_info->line_number, t); fprintf( stderr, "%s:%d: %s: ", where->input_name, where->line_number, t );
vfprintf(stderr, s, ap); vfprintf( stderr, s, ap );
if (want_near_indication) if (want_near_indication)
{ {
char *cpy; char *cpy;
if(loc_info->near_text) if (where->near_text)
{ {
cpy = xstrdup(loc_info->near_text); cpy = xstrdup( where->near_text );
make_print(cpy); make_print( cpy );
fprintf(stderr, " near '%s'", cpy); fprintf( stderr, " near '%s'", cpy );
free(cpy); free( cpy );
} }
} }
} }
void error_loc(const char *s, ...)
{
loc_info_t cur_loc = CURRENT_LOCATION;
va_list ap;
va_start(ap, s);
generic_msg(&cur_loc, s, "error", ap);
va_end(ap);
exit(1);
}
/* yyerror: yacc assumes this is not newline terminated. */ /* yyerror: yacc assumes this is not newline terminated. */
void parser_error(const char *s) void parser_error(const char *s)
{ {
error_loc("%s\n", s); error_loc("%s\n", s);
} }
void error_loc_info(const loc_info_t *loc_info, const char *s, ...) void error_at( const struct location *where, const char *s, ... )
{ {
struct location cur_loc = CURRENT_LOCATION;
va_list ap; va_list ap;
va_start(ap, s); va_start( ap, s );
generic_msg(loc_info, s, "error", ap); generic_msg( where ? where : &cur_loc, s, "error", ap );
va_end(ap); va_end( ap );
exit(1); exit( 1 );
}
int parser_warning(const char *s, ...)
{
loc_info_t cur_loc = CURRENT_LOCATION;
va_list ap;
va_start(ap, s);
generic_msg(&cur_loc, s, "warning", ap);
va_end(ap);
return 0;
} }
void error(const char *s, ...) void error(const char *s, ...)
...@@ -119,12 +100,13 @@ void warning(const char *s, ...) ...@@ -119,12 +100,13 @@ void warning(const char *s, ...)
va_end(ap); va_end(ap);
} }
void warning_loc_info(const loc_info_t *loc_info, const char *s, ...) void warning_at( const struct location *where, const char *s, ... )
{ {
struct location cur_loc = CURRENT_LOCATION;
va_list ap; va_list ap;
va_start(ap, s); va_start( ap, s );
generic_msg(loc_info, s, "warning", ap); generic_msg( where ? where : &cur_loc, s, "warning", ap );
va_end(ap); va_end( ap );
} }
void chat(const char *s, ...) void chat(const char *s, ...)
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
#include "widltypes.h" #include "widltypes.h"
void parser_error(const char *s) __attribute__((noreturn)); void parser_error(const char *s) __attribute__((noreturn));
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn)); void error(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
void error_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3))) __attribute__((noreturn)); void error_at( const struct location *, const char *s, ... ) __attribute__((format( printf, 2, 3 ))) __attribute__((noreturn));
#define error_loc( ... ) error_at( NULL, ## __VA_ARGS__ )
void warning(const char *s, ...) __attribute__((format (printf, 1, 2))); void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3))); void warning_at( const struct location *, const char *s, ... ) __attribute__((format( printf, 2, 3 )));
#define warning_loc( ... ) warning_at( NULL, ## __VA_ARGS__ )
void chat(const char *s, ...) __attribute__((format (printf, 1, 2))); void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
size_t strappend(char **buf, size_t *len, size_t pos, const char* fmt, ...) __attribute__((__format__ (__printf__, 4, 5 ))); size_t strappend(char **buf, size_t *len, size_t pos, const char* fmt, ...) __attribute__((__format__ (__printf__, 4, 5 )));
......
...@@ -37,7 +37,6 @@ struct uuid ...@@ -37,7 +37,6 @@ struct uuid
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
typedef struct _loc_info_t loc_info_t;
typedef struct _attr_t attr_t; typedef struct _attr_t attr_t;
typedef struct _attr_custdata_t attr_custdata_t; typedef struct _attr_custdata_t attr_custdata_t;
typedef struct _expr_t expr_t; typedef struct _expr_t expr_t;
...@@ -311,7 +310,7 @@ enum type_basic_type ...@@ -311,7 +310,7 @@ enum type_basic_type
#define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
#define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
struct _loc_info_t struct location
{ {
const char *input_name; const char *input_name;
int line_number; int line_number;
...@@ -513,7 +512,7 @@ struct _type_t { ...@@ -513,7 +512,7 @@ struct _type_t {
unsigned int typestring_offset; unsigned int typestring_offset;
unsigned int ptrdesc; /* used for complex structs */ unsigned int ptrdesc; /* used for complex structs */
int typelib_idx; int typelib_idx;
loc_info_t loc_info; struct location where;
unsigned int ignore : 1; unsigned int ignore : 1;
unsigned int defined : 1; unsigned int defined : 1;
unsigned int written : 1; unsigned int written : 1;
...@@ -533,7 +532,7 @@ struct _var_t { ...@@ -533,7 +532,7 @@ struct _var_t {
/* fields specific to functions */ /* fields specific to functions */
unsigned int procstring_offset, func_idx; unsigned int procstring_offset, func_idx;
struct _loc_info_t loc_info; struct location where;
unsigned int declonly : 1; unsigned int declonly : 1;
...@@ -654,7 +653,7 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in ...@@ -654,7 +653,7 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in
var_t *make_var(char *name); var_t *make_var(char *name);
var_list_t *append_var(var_list_t *list, var_t *var); var_list_t *append_var(var_list_t *list, var_t *var);
void init_loc_info(loc_info_t *); void init_location( struct location * );
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix, char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
const char *abi_prefix); const char *abi_prefix);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment