Re: [scc-dev] Struct initialization with compatible type

From: Roberto E. Vargas Caballero <k0ga_at_shike2.net>
Date: Mon, 28 Apr 2025 11:06:06 +0200

Hi,

On Thu, Apr 24, 2025 at 11:49:01PM +0200, Xavier Del Campo Romero wrote:
> Hi,
>
> scc (commit d0ec99aa) fails to compile the following minimalistic example:
>
> $ cat struct.c
> struct a {
> int a;
> };
>
> int main()
> {
> struct a a;
> struct a aa = a;
>
> return 0;
> }
> $ scc struct.c
> struct.c:8: error: incorrect initializer

This test case was hitting a few problems in the initializer code. First, the
grammar allows things that are disallow using semantic rules, and it was not
done correctly. I added a flag in initialize to know if we come from an initializer
list or from a normal initializer (a bit hacky from my point of view). The
second problem came from the assumption in the code that a struct could be initialized
only with an initilizer list, but in fact it can be initialized with any expression
of the same type.

I pushed the changes to fix both problems.

Kind Regards,
Roberto Vargas
--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Mon 28 Apr 2025 - 11:06:06 CEST

This archive was generated by hypermail 2.3.0 : Mon 28 Apr 2025 - 11:10:01 CEST