Remove stale (since r21011) comment.
[cparser] / parser.c
index 8b277e2..fa85c3c 100644 (file)
--- 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;
@@ -7372,13 +7381,13 @@ static expression_t *parse_conditional_expression(unsigned precedence,
                                        "pointer/integer type mismatch in conditional expression ('%T' and '%T')", true_type, false_type);
                        result_type = pointer_type;
                } else {
-                       type_error_incompatible("while parsing conditional",
-                                       &expression->base.source_position, true_type, false_type);
+                       if (is_type_valid(other_type)) {
+                               type_error_incompatible("while parsing conditional",
+                                               &expression->base.source_position, true_type, false_type);
+                       }
                        result_type = type_error_type;
                }
        } else {
-               /* TODO: one pointer to void*, other some pointer */
-
                if (is_type_valid(true_type) && is_type_valid(false_type)) {
                        type_error_incompatible("while parsing conditional",
                                                &conditional->base.source_position, true_type,
@@ -7476,7 +7485,10 @@ static bool is_lvalue(const expression_t *expression)
                return true;
 
        default:
-               return false;
+               /* Claim it is an lvalue, if the type is invalid.  There was a parse
+                * error before, which maybe prevented properly recognizing it as
+                * lvalue. */
+               return !is_type_valid(skip_typeref(expression->base.type));
        }
 }
 
@@ -7646,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);
@@ -8778,7 +8790,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(expression->base.type)) {
+               if (is_type_valid(skip_typeref(expression->base.type))) {
                        errorf(pos, "case label does not reduce to an integer constant");
                }
                statement->case_label.is_bad = true;
@@ -8797,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;
@@ -9139,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);