From 510306ed8a97c9eb3f113d9181b60ccdf0b91d79 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 16 Feb 2016 13:24:13 +0100 Subject: [PATCH 1/1] more validations --- src/context_validate.c | 4 +- tests/parser/validate001.phpt | 98 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 tests/parser/validate001.phpt 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=== -- 2.30.2