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;
......
......@@ -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)
if (where->near_text)
{
cpy = xstrdup(loc_info->near_text);
make_print(cpy);
fprintf(stderr, " near '%s'", cpy);
free(cpy);
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, ... )
{
struct location cur_loc = CURRENT_LOCATION;
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;
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, ... )
{
struct location cur_loc = CURRENT_LOCATION;
va_list ap;
va_start(ap, s);
generic_msg(loc_info, s, "warning", ap);
va_end(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