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.
This commit is contained in:
parent
7f0728b7f4
commit
c1ff805e23
|
@ -381,11 +381,12 @@ init1(Sym *s, Type *t, long o, int exflag)
|
||||||
diag(a, "initialization of incompatible pointers: %s\n%T and %T",
|
diag(a, "initialization of incompatible pointers: %s\n%T and %T",
|
||||||
s->name, t, a->type);
|
s->name, t, a->type);
|
||||||
}
|
}
|
||||||
if(a->op == OADDR) {
|
switch(a->op) {
|
||||||
|
case OADDR:
|
||||||
a = a->left;
|
a = a->left;
|
||||||
goto gext;
|
break;
|
||||||
}
|
case ONAME:
|
||||||
if(a->type->etype == TIND) {
|
case OIND:
|
||||||
diag(a, "initializer is not a constant: %s", s->name);
|
diag(a, "initializer is not a constant: %s", s->name);
|
||||||
return Z;
|
return Z;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue