summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/cc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-09-29 15:19:14 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-09-29 15:19:14 +0000
commita99402a30cb18c71b3ee1e4447b53e95f24a3948 (patch)
treefec5996110282b1a9790732526c4e487b01ea454 /usr.bin/pcc/cc
parent480f53ea5cd00520a87c15a17d9a407aae570dce (diff)
check if initializer element is a constant in MI code. ok ragge@
Diffstat (limited to 'usr.bin/pcc/cc')
-rw-r--r--usr.bin/pcc/cc/ccom/init.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/pcc/cc/ccom/init.c b/usr.bin/pcc/cc/ccom/init.c
index f8dc543b14c..3813cf8369c 100644
--- a/usr.bin/pcc/cc/ccom/init.c
+++ b/usr.bin/pcc/cc/ccom/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.7 2007/09/29 13:57:14 otto Exp $ */
+/* $OpenBSD: init.c,v 1.8 2007/09/29 15:19:13 otto Exp $ */
/*
* Copyright (c) 2004, 2007 Anders Magnusson (ragge@ludd.ltu.se).
@@ -944,7 +944,10 @@ simpleinit(struct symtab *sp, NODE *p)
spname = sp;
p = optim(buildtree(ASSIGN, buildtree(NAME, NIL, NIL), p));
setscl(sp);
- ninval(0, p->n_right->n_sue->suesize, p->n_right);
+ if (p->n_right->n_op != ICON && p->n_right->n_op != FCON)
+ uerror("initializer element is not a constant");
+ else
+ ninval(0, p->n_right->n_sue->suesize, p->n_right);
tfree(p);
break;