Do default promotion on the expression of switch()es.
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Dec 2007 21:41:18 +0000 (21:41 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 11 Dec 2007 21:41:18 +0000 (21:41 +0000)
[r18683]

parser.c

index fb7ce4e..303bef6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4914,7 +4914,9 @@ static statement_t *parse_switch(void)
        statement->statement.source_position = token.source_position;
 
        expect('(');
-       statement->expression = parse_expression();
+       expression_t *const expr = parse_expression();
+       type_t       *const type = promote_integer(expr->base.datatype);
+       statement->expression = create_implicit_cast(expr, type);
        expect(')');
        statement->body = parse_statement();