git: 9front

Download patch

ref: 81ee69b2b87b4041adfb682c3b493ec79ed7ea24
parent: 4e76c07a496a12fba5ac89bceaca26e941ae58ac
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Apr 16 10:32:42 EDT 2015

cc: catch non constant pointer initializers

char	FOO[] = "abc";	/* ok */
char	*BAR = FOO;		/* ok */
char	*BAZ = BAR;		/* wrong */

--- a/sys/src/cmd/cc/dcl.c
+++ b/sys/src/cmd/cc/dcl.c
@@ -381,8 +381,14 @@
 				diag(a, "initialization of incompatible pointers: %s\n%T and %T",
 					s->name, t, a->type);
 			}
-			if(a->op == OADDR)
+			if(a->op == OADDR) {
 				a = a->left;
+				goto gext;
+			}
+			if(a->type->etype == TIND) {
+				diag(a, "initializer is not a constant: %s", s->name);
+				return Z;
+			}
 			goto gext;
 		}
 
--