[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: compiler error: ninval: init node not constant
From: Anders Magnusson <ragge () ludd ! ltu ! se>
Date: 2007-09-29 15:08:51
Message-ID: 46FE6A83.6010605 () ludd ! ltu ! se
[Download RAW message or body]
Otto Moerbeek wrote:
> Hi,
>
> I think this check should be done in the machine independent code.
>
Think so to. Added.
-- Ragge
> [otto@lou:3]$ cat x.c
> int a;
> int n = a;
> [otto@lou:4]$ pcc x.c
> x.c, line 2: compiler error: ninval: init node not constant
> [otto@lou:5]$
>
> It's the same check as is being done in arch/x86/local.c. AFAIKS Sthat
> check should remain, sine there are other callers of ninval().
>
> -Otto
>
> Index: init.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/pcc/cc/ccom/init.c,v
> retrieving revision 1.7
> diff -u -p -r1.7 init.c
> --- init.c 29 Sep 2007 13:57:14 -0000 1.7
> +++ init.c 29 Sep 2007 14:54:48 -0000
> @@ -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;
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic