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
static void check_scalar_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *type)
{
if (!cont_type || (!is_integer_type(type) && !is_ptr(type) &&
!is_float_type(type)))
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 : "");
if (!cont_type || (!is_integer_type( type ) && !is_ptr( type ) && !is_float_type( type )))
error_at( &expr_loc->v->where, "scalar type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
}
static void check_arithmetic_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *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",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
if (!cont_type || (!is_integer_type( type ) && !is_float_type( type )))
error_at( &expr_loc->v->where, "arithmetic type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
}
static void check_integer_type(const struct expr_loc *expr_loc,
const type_t *cont_type, const type_t *type)
{
if (!cont_type || !is_integer_type(type))
error_loc_info(&expr_loc->v->loc_info, "integer type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
if (!cont_type || !is_integer_type( type ))
error_at( &expr_loc->v->where, "integer type required in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
}
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
result.is_temporary = FALSE;
result.type = find_identifier(e->u.sval, cont_type, &found_in_cont_type);
if (!result.type)
{
error_loc_info(&expr_loc->v->loc_info, "identifier %s cannot be resolved in expression%s%s\n",
e->u.sval, expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
}
error_at( &expr_loc->v->where, "identifier %s cannot be resolved in expression%s%s\n", e->u.sval,
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
break;
}
case EXPR_LOGNOT:
......@@ -575,9 +568,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
case EXPR_ADDRESSOF:
result = resolve_expression(expr_loc, cont_type, e->ref);
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",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
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 ? expr_loc->attr : "" );
result.is_variable = FALSE;
result.is_temporary = TRUE;
result.type = type_new_pointer(result.type);
......@@ -590,9 +582,8 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
&& type_array_is_decl_as_ptr(result.type))
result.type = type_array_get_element_type(result.type);
else
error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
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 ? expr_loc->attr : "" );
break;
case EXPR_CAST:
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
if (result.type && is_valid_member_operand(result.type))
result = resolve_expression(expr_loc, result.type, e->u.ext);
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",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
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 ? expr_loc->attr : "" );
break;
case EXPR_COND:
{
......@@ -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);
check_scalar_type(expr_loc, cont_type, result_second.type);
check_scalar_type(expr_loc, cont_type, 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" );
if (!is_ptr( result_second.type ) ^ !is_ptr( result_third.type ))
error_at( &expr_loc->v->where, "type mismatch in ?: expression\n" );
/* FIXME: determine the correct return type */
result = result_second;
result.is_variable = FALSE;
......@@ -672,15 +662,15 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
struct expression_type index_result;
result.type = type_array_get_element_type(result.type);
index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext);
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",
expr_loc->attr ? " for attribute " : "",
expr_loc->attr ? expr_loc->attr : "");
if (!index_result.type || !is_integer_type( index_result.type ))
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 ? expr_loc->attr : "" );
}
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 " : "",
expr_loc->attr ? expr_loc->attr : "");
{
error_at( &expr_loc->v->where, "array subscript operator applied to non-array type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "", expr_loc->attr ? expr_loc->attr : "" );
}
break;
}
return result;
......
......@@ -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 &&
type_get_type(type_pointer_get_ref_type(ptr)) == TYPE_INTERFACE)
warning_loc_info(&v->loc_info,
"%s: pointer attribute applied to interface "
"pointer type has no effect\n", v->name);
warning_at( &v->where, "%s: pointer attribute applied to interface pointer type has no effect\n", v->name );
if (!ptr_attr && top)
{
/* FIXME: this is a horrible hack to cope with the issue that we
......@@ -1972,7 +1970,7 @@ var_t *make_var(char *name)
init_declspec(&v->declspec, NULL);
v->attrs = NULL;
v->eval = NULL;
init_loc_info(&v->loc_info);
init_location( &v->where );
v->declonly = FALSE;
return v;
}
......@@ -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->attrs = map_attrs(src->attrs, attr_filter);
v->eval = src->eval;
v->loc_info = src->loc_info;
v->where = src->where;
return v;
}
......@@ -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
* for cleaner solution.
*/
if (cur && input_name == cur->loc_info.input_name)
error_loc("%s: redefinition error; original definition was at %s:%d\n",
cur->name, cur->loc_info.input_name,
cur->loc_info.line_number);
if (cur && input_name == cur->where.input_name)
error_loc( "%s: redefinition error; original definition was at %s:%d\n",
cur->name, cur->where.input_name, cur->where.line_number );
name = declare_var(attrs, decl_spec, decl, 0);
cur = type_new_alias(&name->declspec, name->name);
......@@ -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)
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 */
list_remove(&attr_existing->entry);
break;
......@@ -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);
if (!is_allowed_conf_type(expr_type))
error_loc_info(&arg->loc_info, "expression must resolve to integral type <= 32bits for attribute %s\n",
attr_name);
error_at( &arg->where, "expression must resolve to integral type <= 32bits for attribute %s\n", attr_name );
}
}
}
......@@ -2822,9 +2818,7 @@ static void check_field_common(const type_t *container_type,
if (is_attr(arg->attrs, ATTR_LENGTHIS) &&
(is_attr(arg->attrs, ATTR_STRING) || is_aliaschain_attr(arg->declspec.type, ATTR_STRING)))
error_loc_info(&arg->loc_info,
"string and length_is specified for argument %s are mutually exclusive attributes\n",
arg->name);
error_at( &arg->where, "string and length_is specified for argument %s are mutually exclusive attributes\n", arg->name );
if (is_attr(arg->attrs, ATTR_SIZEIS))
{
......@@ -2847,7 +2841,7 @@ static void check_field_common(const type_t *container_type,
expr_loc.attr = "iid_is";
expr_type = expr_resolve_type(&expr_loc, container_type, expr);
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))
......@@ -2861,8 +2855,7 @@ static void check_field_common(const type_t *container_type,
expr_loc.attr = "switch_is";
expr_type = expr_resolve_type(&expr_loc, container_type, expr);
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",
expr_loc.attr);
error_at( &arg->where, "expression must resolve to integral type <= 32bits for attribute %s\n", expr_loc.attr );
}
}
......@@ -2902,17 +2895,14 @@ static void check_field_common(const type_t *container_type,
default:
break;
}
error_loc_info(&arg->loc_info, "%s \'%s\' of %s \'%s\' %s\n",
var_type, arg->name, container_type_name, container_name, reason);
error_at( &arg->where, "%s \'%s\' of %s \'%s\' %s\n", var_type, arg->name, container_type_name, container_name, reason );
break;
}
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
if (type_get_type(container_type) != TYPE_FUNCTION)
error_loc_info(&arg->loc_info,
"%s \'%s\' of %s \'%s\' cannot be a context handle\n",
var_type, arg->name, container_type_name,
container_name);
error_at( &arg->where, "%s \'%s\' of %s \'%s\' cannot be a context handle\n",
var_type, arg->name, container_type_name, container_name );
break;
case TGT_STRING:
{
......@@ -2920,7 +2910,7 @@ static void check_field_common(const type_t *container_type,
while (is_ptr(t))
t = type_pointer_get_ref_type(t);
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;
}
case TGT_POINTER:
......@@ -2934,9 +2924,7 @@ static void check_field_common(const type_t *container_type,
case TGT_ENUM:
type = type_get_real_type(type);
if (!type_is_complete(type))
{
error_loc_info(&arg->loc_info, "undefined type declaration \"enum %s\"\n", type->name);
}
error_at( &arg->where, "undefined type declaration \"enum %s\"\n", type->name );
case TGT_USER_TYPE:
case TGT_IFACE_POINTER:
case TGT_BASIC:
......@@ -2964,14 +2952,14 @@ static void check_remoting_fields(const var_t *var, type_t *type)
if (type_is_complete(type))
fields = type_struct_get_fields(type);
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)
{
if (type_is_complete(type))
fields = type_union_get_cases(type);
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 )
......@@ -3003,10 +2991,10 @@ static void check_remoting_args(const var_t *func)
case TGT_UNION:
case TGT_CTXT_HANDLE:
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;
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;
case TGT_STRING:
if (is_array(type))
......@@ -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 (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;
case TGT_INVALID:
/* already error'd before we get here */
......@@ -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_PROPPUT) != is_attr(func_iter->attrs, ATTR_PROPPUT)) 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
return list;
}
void init_loc_info(loc_info_t *i)
void init_location( struct location *where )
{
i->input_name = input_name ? input_name : "stdin";
i->line_number = line_number;
i->near_text = parser_text;
where->input_name = input_name ? input_name : "stdin";
where->line_number = line_number;
where->near_text = parser_text;
}
type_t *find_parameterized_type(type_t *type, typeref_list_t *params)
......
......@@ -65,7 +65,7 @@ type_t *make_type(enum type_type type)
t->tfswrite = FALSE;
t->checked = FALSE;
t->typelib_idx = -1;
init_loc_info(&t->loc_info);
init_location( &t->where );
return 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 (!(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);
if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
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}",
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
case TYPE_BASIC_WCHAR:
case TYPE_BASIC_ERROR_STATUS_T:
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;
}
case TYPE_ENUM:
......@@ -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_MODULE:
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;
case TYPE_PARAMETERIZED_TYPE:
case TYPE_PARAMETER:
......@@ -346,8 +348,8 @@ static char *format_parameterized_type_signature(type_t *type, typeref_list_t *p
typeref_t *ref;
const struct uuid *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);
if (!(uuid = get_attrp( type->attrs, ATTR_UUID )))
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}",
uuid->Data1, uuid->Data2, uuid->Data3,
......@@ -476,7 +478,7 @@ type_t *type_new_alias(const decl_spec_t *t, const char *name)
a->name = xstrdup(name);
a->attrs = NULL;
a->details.alias.aliasee = *t;
init_loc_info(&a->loc_info);
init_location( &a->where );
return a;
}
......@@ -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 = get_type(TYPE_INTERFACE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_INTERFACE)
error_loc("interface %s previously not declared an interface at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_INTERFACE)
error_loc( "interface %s previously not declared an interface at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
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)
{
if (iface->defined)
error_loc("interface %s already defined at %s:%d\n",
iface->name, iface->loc_info.input_name, iface->loc_info.line_number);
error_loc( "interface %s already defined at %s:%d\n", iface->name,
iface->where.input_name, iface->where.line_number );
if (iface == inherit)
error_loc("interface %s can't inherit from itself\n",
iface->name);
......@@ -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 = get_type(TYPE_INTERFACE, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_INTERFACE)
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);
if (type_get_type_detect_alias( type ) != TYPE_INTERFACE)
error_loc( "dispinterface %s previously not declared a dispinterface at %s:%d\n",
type->name, type->where.input_name, type->where.line_number );
return type;
}
type_t *type_dispinterface_define(type_t *iface, attr_list_t *attrs, var_list_t *props, var_list_t *methods)
{
if (iface->defined)
error_loc("dispinterface %s already defined at %s:%d\n",
iface->name, iface->loc_info.input_name, iface->loc_info.line_number);
error_loc( "dispinterface %s already defined at %s:%d\n", iface->name,
iface->where.input_name, iface->where.line_number );
iface->attrs = check_dispiface_attrs(iface->name, attrs);
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
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
type_t *type_dispinterface_define_from_iface(type_t *dispiface, attr_list_t *attrs, type_t *iface)
{
if (dispiface->defined)
error_loc("dispinterface %s already defined at %s:%d\n",
dispiface->name, dispiface->loc_info.input_name, dispiface->loc_info.line_number);
error_loc( "dispinterface %s already defined at %s:%d\n", dispiface->name,
dispiface->where.input_name, dispiface->where.line_number );
dispiface->attrs = check_dispiface_attrs(dispiface->name, attrs);
dispiface->details.iface = xmalloc(sizeof(*dispiface->details.iface));
dispiface->details.iface->disp_props = NULL;
......@@ -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 = get_type(TYPE_MODULE, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_MODULE)
error_loc("module %s previously not declared a module at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_MODULE)
error_loc( "module %s previously not declared a module at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
return type;
}
type_t *type_module_define(type_t* module, attr_list_t *attrs, statement_list_t *stmts)
{
if (module->defined)
error_loc("module %s already defined at %s:%d\n",
module->name, module->loc_info.input_name, module->loc_info.line_number);
error_loc( "module %s already defined at %s:%d\n", module->name,
module->where.input_name, module->where.line_number );
module->attrs = check_module_attrs(module->name, attrs);
module->details.module = xmalloc(sizeof(*module->details.module));
module->details.module->stmts = stmts;
......@@ -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 = get_type(TYPE_COCLASS, name, NULL, 0);
if (type_get_type_detect_alias(type) != TYPE_COCLASS)
error_loc("coclass %s previously not declared a coclass at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_COCLASS)
error_loc( "coclass %s previously not declared a coclass at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
return type;
}
type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t *ifaces)
{
if (coclass->defined)
error_loc("coclass %s already defined at %s:%d\n",
coclass->name, coclass->loc_info.input_name, coclass->loc_info.line_number);
error_loc( "coclass %s already defined at %s:%d\n", coclass->name,
coclass->where.input_name, coclass->where.line_number );
coclass->attrs = check_coclass_attrs(coclass->name, attrs);
coclass->details.coclass.ifaces = ifaces;
coclass->defined = TRUE;
......@@ -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 = get_type(TYPE_RUNTIMECLASS, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_RUNTIMECLASS)
error_loc("runtimeclass %s previously not declared a runtimeclass at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_RUNTIMECLASS)
error_loc( "runtimeclass %s previously not declared a runtimeclass at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
return type;
}
......@@ -855,8 +857,8 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typer
typeref_list_t *requires;
if (runtimeclass->defined)
error_loc("runtimeclass %s already defined at %s:%d\n",
runtimeclass->name, runtimeclass->loc_info.input_name, runtimeclass->loc_info.line_number);
error_loc( "runtimeclass %s already defined at %s:%d\n", runtimeclass->name,
runtimeclass->where.input_name, runtimeclass->where.line_number );
runtimeclass->attrs = check_runtimeclass_attrs(runtimeclass->name, attrs);
runtimeclass->details.runtimeclass.ifaces = ifaces;
runtimeclass->defined = TRUE;
......@@ -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 = get_type(TYPE_APICONTRACT, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_APICONTRACT)
error_loc("apicontract %s previously not declared a apicontract at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_APICONTRACT)
error_loc( "apicontract %s previously not declared a apicontract at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
return type;
}
type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs)
{
if (apicontract->defined)
error_loc("apicontract %s already defined at %s:%d\n",
apicontract->name, apicontract->loc_info.input_name, apicontract->loc_info.line_number);
error_loc( "apicontract %s already defined at %s:%d\n", apicontract->name,
apicontract->where.input_name, apicontract->where.line_number );
apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs);
apicontract->defined = TRUE;
return apicontract;
......@@ -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 = get_type(TYPE_DELEGATE, name, namespace, 0);
if (type_get_type_detect_alias(type) != TYPE_DELEGATE)
error_loc("delegate %s previously not declared a delegate at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_DELEGATE)
error_loc( "delegate %s previously not declared a delegate at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
return type;
}
......@@ -933,8 +935,8 @@ type_t *type_delegate_define(type_t *delegate, attr_list_t *attrs, statement_lis
type_t *iface;
if (delegate->defined)
error_loc("delegate %s already defined at %s:%d\n",
delegate->name, delegate->loc_info.input_name, delegate->loc_info.line_number);
error_loc( "delegate %s already defined at %s:%d\n", delegate->name,
delegate->where.input_name, delegate->where.line_number );
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
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);
if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE)
error_loc("pinterface %s previously not declared a pinterface at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_PARAMETERIZED_TYPE)
error_loc( "pinterface %s previously not declared a pinterface at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
type->details.parameterized.type = make_type(TYPE_INTERFACE);
type->details.parameterized.params = params;
return type;
......@@ -974,8 +976,8 @@ type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, ty
{
type_t *iface;
if (type->defined)
error_loc("pinterface %s already defined at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
error_loc( "pinterface %s already defined at %s:%d\n", type->name,
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
* 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
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);
if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE)
error_loc("pdelegate %s previously not declared a pdelegate at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
if (type_get_type_detect_alias( type ) != TYPE_PARAMETERIZED_TYPE)
error_loc( "pdelegate %s previously not declared a pdelegate at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
type->details.parameterized.type = make_type(TYPE_DELEGATE);
type->details.parameterized.params = params;
return type;
......@@ -1016,8 +1018,8 @@ type_t *type_parameterized_delegate_define(type_t *type, attr_list_t *attrs, sta
type_t *iface, *delegate;
if (type->defined)
error_loc("pdelegate %s already defined at %s:%d\n",
type->name, type->loc_info.input_name, type->loc_info.line_number);
error_loc( "pdelegate %s already defined at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
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
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));
*new_stmt = *stmt;
......@@ -1121,14 +1124,15 @@ static statement_t *replace_type_parameters_in_statement(statement_t *stmt, type
case STMT_IMPORTLIB:
case STMT_PRAGMA:
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;
}
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_t *stmt, *new_stmt;
......@@ -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)
{
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);
}
......@@ -1205,7 +1209,8 @@ static type_t *replace_type_parameters_in_type(type_t *type, typeref_list_t *ori
case TYPE_MODULE:
case TYPE_COCLASS:
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;
}
......@@ -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->disp_methods = 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->disp_inherit = NULL;
iface->details.iface->async_iface = NULL;
......@@ -1298,8 +1304,8 @@ type_t *type_parameterized_type_specialize_define(type_t *type)
if (type_get_type_detect_alias(type) != 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",
type->name, type->loc_info.input_name, type->loc_info.line_number);
error_loc( "cannot define non-parameterized type %s, declared at %s:%d\n", type->name,
type->where.input_name, type->where.line_number );
if (type_get_type_detect_alias(tmpl->details.parameterized.type) == TYPE_INTERFACE &&
type_get_type_detect_alias(iface) == TYPE_INTERFACE)
......@@ -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);
else
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->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
return ref->type;
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)
......
......@@ -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);
vfprintf(stderr, s, ap);
fprintf( stderr, "%s:%d: %s: ", where->input_name, where->line_number, t );
vfprintf( stderr, s, ap );
if (want_near_indication)
{
char *cpy;
if(loc_info->near_text)
{
cpy = xstrdup(loc_info->near_text);
make_print(cpy);
fprintf(stderr, " near '%s'", cpy);
free(cpy);
}
if (want_near_indication)
{
char *cpy;
if (where->near_text)
{
cpy = xstrdup( where->near_text );
make_print( cpy );
fprintf( stderr, " near '%s'", 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. */
void parser_error(const char *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, ... )
{
va_list ap;
va_start(ap, s);
generic_msg(loc_info, s, "error", ap);
va_end(ap);
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;
struct location cur_loc = CURRENT_LOCATION;
va_list ap;
va_start( ap, s );
generic_msg( where ? where : &cur_loc, s, "error", ap );
va_end( ap );
exit( 1 );
}
void error(const char *s, ...)
......@@ -119,12 +100,13 @@ void warning(const char *s, ...)
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, ... )
{
va_list ap;
va_start(ap, s);
generic_msg(loc_info, s, "warning", ap);
va_end(ap);
struct location cur_loc = CURRENT_LOCATION;
va_list ap;
va_start( ap, s );
generic_msg( where ? where : &cur_loc, s, "warning", ap );
va_end( ap );
}
void chat(const char *s, ...)
......
......@@ -24,12 +24,12 @@
#include "widltypes.h"
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_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_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)));
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
#define TRUE 1
#define FALSE 0
typedef struct _loc_info_t loc_info_t;
typedef struct _attr_t attr_t;
typedef struct _attr_custdata_t attr_custdata_t;
typedef struct _expr_t expr_t;
......@@ -311,7 +310,7 @@ enum type_basic_type
#define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
#define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
struct _loc_info_t
struct location
{
const char *input_name;
int line_number;
......@@ -513,7 +512,7 @@ struct _type_t {
unsigned int typestring_offset;
unsigned int ptrdesc; /* used for complex structs */
int typelib_idx;
loc_info_t loc_info;
struct location where;
unsigned int ignore : 1;
unsigned int defined : 1;
unsigned int written : 1;
......@@ -533,7 +532,7 @@ struct _var_t {
/* fields specific to functions */
unsigned int procstring_offset, func_idx;
struct _loc_info_t loc_info;
struct location where;
unsigned int declonly : 1;
......@@ -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_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,
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