From c1ff805e236a818eb530ac68236c506448377419 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 23 Apr 2015 05:12:57 +0200 Subject: cc: fix non constant pointer initializer for other compilers than 8c/6c i made a mistake here as this change breaks the arm and mips compilers which lack an optimiation in xcom() that folds constant pointer arithmetic into the offset. on arm, the a node is a complex expression with op OADD of type TIND but the test rejected the (valid) pointer arithmetic. instead, we now test for the operations which cannot be constant instead of using the type as a proxy. --- sys/src/cmd/cc/dcl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sys/src/cmd/cc') diff --git a/sys/src/cmd/cc/dcl.c b/sys/src/cmd/cc/dcl.c index 7b2ae464f..1a7f38e1a 100644 --- a/sys/src/cmd/cc/dcl.c +++ b/sys/src/cmd/cc/dcl.c @@ -381,11 +381,12 @@ init1(Sym *s, Type *t, long o, int exflag) diag(a, "initialization of incompatible pointers: %s\n%T and %T", s->name, t, a->type); } - if(a->op == OADDR) { + switch(a->op) { + case OADDR: a = a->left; - goto gext; - } - if(a->type->etype == TIND) { + break; + case ONAME: + case OIND: diag(a, "initializer is not a constant: %s", s->name); return Z; } -- cgit v1.2.3