X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=parser.c;h=7526065599502eeb87fdaf3131edecdb4729a808;hb=f9b99f31447f156dd8f835ab26573da2722d81a0;hp=16541f0809fb442029ec7f00cdc3b74572131b38;hpb=27f4ce3da8d78ff0e70afde834793e0ebd81a42a;p=cparser diff --git a/parser.c b/parser.c index 16541f0..7526065 100644 --- a/parser.c +++ b/parser.c @@ -141,7 +141,7 @@ static struct obstack temp_obst; #define PUSH_PARENT(stmt) \ statement_t *const prev_parent = current_parent; \ - current_parent = (stmt); + ((void)(current_parent = (stmt))) #define POP_PARENT ((void)(current_parent = prev_parent)) static source_position_t null_position = { NULL, 0 }; @@ -842,10 +842,14 @@ static void stack_pop_to(stack_entry_t **stack_ptr, size_t new_top) break; } - /* Because of scopes and appending other namespaces to the end of - * the list, this must hold. */ - assert((old_declaration != NULL ? old_declaration->symbol_next : NULL) == iter->symbol_next); - *anchor = old_declaration; + /* Not all declarations adhere scopes (e.g. jump labels), so this + * correction is necessary */ + if (old_declaration != NULL) { + old_declaration->symbol_next = iter->symbol_next; + *anchor = old_declaration; + } else { + *anchor = iter->symbol_next; + } } ARR_SHRINKLEN(*stack_ptr, (int) new_top); @@ -1987,6 +1991,11 @@ static initializer_t *initializer_from_expression(type_t *orig_type, &expression->base.source_position); initializer_t *const result = allocate_initializer_zero(INITIALIZER_VALUE); +#if 0 + if (type->kind == TYPE_BITFIELD) { + type = type->bitfield.base_type; + } +#endif result->value.value = create_implicit_cast(expression, type); return result; @@ -7649,7 +7658,7 @@ static void semantic_take_addr(unary_expression_t *expression) value->base.type = revert_automatic_type_conversion(value); type_t *orig_type = value->base.type; - if (!is_type_valid(orig_type)) + if (!is_type_valid(skip_typeref(orig_type))) return; set_address_taken(value, false); @@ -8800,7 +8809,7 @@ static statement_t *parse_case_statement(void) /* This check does not prevent the error message in all cases of an * prior error while parsing the expression. At least it catches the * common case of a mistyped enum entry. */ - if (is_type_valid(end_range->base.type)) { + if (is_type_valid(skip_typeref(end_range->base.type))) { errorf(pos, "case range does not reduce to an integer constant"); } statement->case_label.is_bad = true; @@ -9142,7 +9151,7 @@ static statement_t *parse_do(void) eat(T_do); - PUSH_PARENT(statement) + PUSH_PARENT(statement); add_anchor_token(T_while); statement->do_while.body = parse_loop_body(statement);