From: Michael Wallner Date: Tue, 16 Feb 2016 12:24:13 +0000 (+0100) Subject: more validations X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=510306ed8a97c9eb3f113d9181b60ccdf0b91d79;p=m6w6%2Fext-psi more validations --- diff --git a/src/context_validate.c b/src/context_validate.c index 897ae65..a5d3604 100644 --- a/src/context_validate.c +++ b/src/context_validate.c @@ -181,7 +181,7 @@ static inline int validate_decl_typedef(PSI_Data *data, decl_arg *def) { } data->error(data, def->token, PSI_WARNING, "Type '%s' cannot be aliased to %s'%s'", - def->type->name, pre, def->var->name); + def->var->name, pre, def->type->name); return 0; } if (def->type->type == PSI_T_VOID) { @@ -393,7 +393,7 @@ static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { if (!s->size && !s->args->count) { data->error(data, s->token, PSI_WARNING, - "Cannot compute size of empty struct %s", + "Cannot compute size of empty struct '%s'", s->name); return 0; } diff --git a/tests/parser/validate001.phpt b/tests/parser/validate001.phpt new file mode 100644 index 0000000..f9869a8 --- /dev/null +++ b/tests/parser/validate001.phpt @@ -0,0 +1,98 @@ +--TEST-- +validate types +--SKIPIF-- + +--FILE-- +===TEST=== + +===DONE=== +--CLEAN-- + +--EXPECTF-- +===TEST=== + +Warning: PSI syntax error: Unexpected token ';' in %s001.psi on line 1 + +Warning: PSI syntax error: Unexpected token 'int' in %s001.psi on line 1 + +Warning: Type 'bar' cannot be aliased to struct 'foo' in %s001.psi on line 1 + +Warning: Cannot compute size of empty struct 'a' in %s001.psi on line 1 + +Warning: Unknown variable 'X' in numeric expression in %s001.psi on line 4 + +Warning: PSI syntax error: Unexpected token '(' in %s001.psi on line 1 +===DONE===