ref: 7a524f1e58b5c1f8066273703f6d950154a5ae67
parent: aeec9a7683a27012c530e72e1e4ab07a9d9ba07d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Apr 23 01:12:57 EDT 2015
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.
--- a/sys/src/cmd/cc/dcl.c
+++ b/sys/src/cmd/cc/dcl.c
@@ -381,11 +381,12 @@
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;
}
--
⑨