--- orig/declarations.c Fri Sep 19 02:33:28 2003 +++ p/declarations.c Tue Oct 7 19:02:02 2003 @@ -2054,7 +2058,7 @@ tree object_type, name, parameters, resultvar, resulttype; int check_forward, structor; { - tree r; + tree old, r; int is_procedure = resulttype == void_type_node; if (object_type && TREE_CODE (object_type) == IDENTIFIER_NODE) { @@ -2070,18 +2074,20 @@ object_type = error_mark_node; } } + old = lookup_name_current_level (name); if (!resulttype) { /* Only allowed when function has already been declared with a directive. */ - tree decl = lookup_name_current_level (name); - if (!check_forward || !decl || TREE_CODE (decl) != FUNCTION_DECL) + if (!check_forward || !old || TREE_CODE (old) != FUNCTION_DECL) { error ("type of function `%s' undefined", IDENTIFIER_NAME (name)); resulttype = error_mark_node; } else - resulttype = TREE_TYPE (TREE_TYPE (decl)); + resulttype = TREE_TYPE (TREE_TYPE (old)); } + else if (old && resulttype != void_type_node && !structor) + chk_dialect ("result types in forward declared functions are", U_B_D_M_PASCAL); /* If user did not specify a result variable for a function, we create one. */ if (is_procedure) assert (!resultvar); @@ -2261,10 +2268,8 @@ tree arg2; if (DECL_EXTERNAL (old)) is_extern = 1; - if (arguments) + if (PASCAL_METHOD_HEADING (foobar) ? TREE_CHAIN (arguments) : arguments) chk_dialect ("parameters in forward declared routines are", U_B_D_M_PASCAL); - if (type != void_type_node) - chk_dialect ("result types in forward declared functions are", U_B_D_M_PASCAL); if (directive) error ("attributes in forward declared routines are not allowed");