format checking for error and warning + needed fixes

try to give name of object when calling non-function
This commit is contained in:
Bill Currie 2001-07-03 20:53:49 +00:00
parent ccc00b0608
commit 1edf1e0b39
3 changed files with 10 additions and 6 deletions

View file

@ -62,5 +62,5 @@ expr_t *function_expr (expr_t *e1, expr_t *e2);
def_t *emit_statement (opcode_t *op, def_t *var_a, def_t *var_b, def_t *var_c);
void emit_expr (expr_t *e);
expr_t *error (expr_t *e, const char *fmt, ...);
void warning (expr_t *e, const char *fmt, ...);
expr_t *error (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));
void warning (expr_t *e, const char *fmt, ...) __attribute__((format(printf, 2,3)));

View file

@ -631,7 +631,11 @@ function_expr (expr_t *e1, expr_t *e2)
t1 = get_type (e1);
if (t1 != ev_func) {
return error (e1, "called object is not a function %d", t1);
if (e1->type == ex_def)
return error (e1, "Called object \"%s\" is not a function",
e1->e.def->name);
else
return error (e1, "Called object is not a function");
}
ftype = e1->type == ex_def

View file

@ -10,7 +10,7 @@ extern int pr_source_line;
void
yyerror (const char *s)
{
error (0, "%s %s\n", strings + s_file, pr_source_line, yytext, s);
error (0, "%s %s\n", yytext, s);
}
int yylex (void);
@ -212,7 +212,7 @@ opt_initializer
| '=' '#' const
{
if (current_type->type != ev_func) {
error (0, "%s is not a function");
error (0, "%s is not a function", current_def->name);
} else {
if ($3->type != ex_int && $3->type != ex_float) {
error (0, "invalid constant for = #");
@ -408,7 +408,7 @@ expr
$$->type = ex_def;
$$->e.def = PR_GetDef (NULL, $1, pr_scope, false);
if (!$$->e.def) {
error (0, "%s undeclared", $1);
error (0, "Undeclared variable \"%s\".", $1);
$$->e.def = &def_float;
}
}