scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 9b8d4f081969cb22e1a127c690e943b8247e5594
parent a0cfc89f2d6edb0f059c14000adab63913efce29
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  3 Sep 2015 17:57:36 +0200

Fix promote()

Promote is called in different places to ensure that the integer type promotion
is done, but it may be called with no integer nodes, and convert() returns
NULL in this case, so a test is needed.

Diffstat:
Mcc1/expr.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -50,6 +50,7 @@ static Node * promote(Node *np) { Type *tp; + Node *new; unsigned r; tp = np->type; @@ -57,7 +58,9 @@ promote(Node *np) if (r > RANK_UINT || tp == inttype || tp == uinttype) return np; tp = (r == RANK_UINT) ? uinttype : inttype; - return convert(np, tp, 1); + if ((new = convert(np, tp, 1)) != NULL) + return new; + return np; } static void