fix for error44
authorMatthias Braun <matze@braunis.de>
Thu, 7 Aug 2008 12:35:18 +0000 (12:35 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 7 Aug 2008 12:35:18 +0000 (12:35 +0000)
[r21044]

diagnostic.c
parser.c

index 3e83b0b..4a9122c 100644 (file)
@@ -94,7 +94,10 @@ static void diagnosticvf(const char *const fmt, va_list ap)
 
                                case 'Y': {
                                        const symbol_t *const symbol = va_arg(ap, const symbol_t*);
-                                       fputs(symbol->string, stderr);
+                                       if (symbol == NULL)
+                                               fputs("(null)", stderr);
+                                       else
+                                               fputs(symbol->string, stderr);
                                        break;
                                }
 
index e460f49..8e89ce8 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3425,8 +3425,6 @@ static declaration_t *parse_parameter(void)
 
        declaration_t *declaration = parse_declarator(&specifiers, /*may_be_abstract=*/true);
 
-       semantic_parameter(declaration);
-
        return declaration;
 }
 
@@ -3451,10 +3449,6 @@ static declaration_t *parse_parameters(function_type_t *type)
                type->unspecified_parameters = 1;
                goto parameters_finished;
        }
-       if(token.type == T_void && look_ahead(1)->type == ')') {
-               next_token();
-               goto parameters_finished;
-       }
 
        declaration_t        *declaration;
        declaration_t        *last_declaration = NULL;
@@ -3473,6 +3467,14 @@ static declaration_t *parse_parameters(function_type_t *type)
                DECLARATION_START
                        declaration = parse_parameter();
 
+                       /* func(void) is not a parameter */
+                       if (last_parameter == NULL
+                                       && token.type == ')'
+                                       && skip_typeref(declaration->type) == type_void) {
+                               goto parameters_finished;
+                       }
+                       semantic_parameter(declaration);
+
                        parameter       = obstack_alloc(type_obst, sizeof(parameter[0]));
                        memset(parameter, 0, sizeof(parameter[0]));
                        parameter->type = declaration->type;