From 0fe4aa8169cefd5408eb33b4ed5f15ba660c0d76 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 29 Nov 2007 21:26:41 +0000 Subject: [PATCH] declaration with unspecified parameters can follow declaration with specified parameters [r18571] --- parser.c | 19 +++++++++++++------ parsetest/cp_error001.c | 9 +++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 parsetest/cp_error001.c diff --git a/parser.c b/parser.c index a7b334b..9b52ea7 100644 --- a/parser.c +++ b/parser.c @@ -517,19 +517,26 @@ static bool is_compatible_declaration(declaration_t *declaration, return true; } + /* shortcur, same types are always compatible */ + if(declaration->type == previous->type) + return true; + if (declaration->type->type == TYPE_FUNCTION && - previous->type->type == TYPE_FUNCTION && - previous->type->function.unspecified_parameters) { + previous->type->type == TYPE_FUNCTION) { function_type_t* const prev_func = &previous->type->function; function_type_t* const decl_func = &declaration->type->function; - if (prev_func->unspecified_parameters && - prev_func->result_type == decl_func->result_type) { + + /* 1 of the 2 declarations might have unspecified parameters */ + if(decl_func->unspecified_parameters) { + return true; + } else if(prev_func->unspecified_parameters) { declaration->type = previous->type; return true; } } - /* TODO: not correct yet */ - return declaration->type == previous->type; + + /* TODO: not correct/complete yet */ + return false; } static declaration_t *get_declaration(symbol_t *symbol, namespace_t namespc) diff --git a/parsetest/cp_error001.c b/parsetest/cp_error001.c new file mode 100644 index 0000000..6973841 --- /dev/null +++ b/parsetest/cp_error001.c @@ -0,0 +1,9 @@ +void bi_windup(void); + +void bi_windup() { +} + +int main(void) +{ + return 0; +} -- 2.20.1