Introduce C2X _Static_assert syntax

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Introduce C2X _Static_assert syntax

uso ewin
Hello, as I was working on fixing _Static_assert bug,
I've saw that it was fairly easy to add C2x _Static_assert
syntax support to tinycc.

the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x

The only difference with current _Static_assert is
that we can omit the literal string.

Is the code okay ?

Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)

I won't push this if I don't have a go from peoples here
because C2x isn't standard yet.

Matthias,

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Introduce C2X _Static_assert syntax

Christian Jullien-3
Hi Matthias,

I'm not an official maintainer but, IMHO, you should also add -std=xxx option that corresponds to the C version of the new features you want to introduce.
I added c11 few months ago:
  -std=c99    Conform to the ISO 1999 C standard (default).
  -std=c11    Conform to the ISO 2011 C standard.

And gcc supports many other versions. A least, we should add:

  -std=c18                    Conform to the ISO 2017 C standard (published in 2018).
  -std=c2x                    Conform to the ISO 202X C standard draft (experimental and incomplete support).


And set __STDC__ and __STDC_VERSION__ accordingly. Currently, gcc set __STDC_VERSION__ to 202000 when you pass -std=c2x

This way, you can pass -std=c2x to the test suite and change
#elif defined test_static_assert_c2x
By
#elif __STDC_VERSION >= 201710L

Otherwise, as far I can tell, your patch looks good to me.

M2c

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of uso ewin
Sent: Saturday, February 29, 2020 00:50
To: [hidden email]
Subject: [Tinycc-devel] Introduce C2X _Static_assert syntax

Hello, as I was working on fixing _Static_assert bug,
I've saw that it was fairly easy to add C2x _Static_assert
syntax support to tinycc.

the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x

The only difference with current _Static_assert is
that we can omit the literal string.

Is the code okay ?

Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)

I won't push this if I don't have a go from peoples here
because C2x isn't standard yet.

Matthias,

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Introduce C2X _Static_assert syntax

Michael Matz-4
In reply to this post by uso ewin
Hello,

On Sat, 29 Feb 2020, uso ewin wrote:

> Hello, as I was working on fixing _Static_assert bug,
> I've saw that it was fairly easy to add C2x _Static_assert
> syntax support to tinycc.
>
> the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x
>
> The only difference with current _Static_assert is
> that we can omit the literal string.
>
> Is the code okay ?
>
> Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)

Fine with me at least.  I'd say also without testing for anything like
-std=c2x, your call.

I have a mild preference for using parse_mult_str no matter if the
condition is true or false, obviating the need for an extra loop to skip
the STR tokens.  Remember that you need to cstr_free the string in that
case (which you can avoid right now only because tcc_error doesn't
return).


Ciao,
Michael.

>
> I won't push this if I don't have a go from peoples here
> because C2x isn't standard yet.
>
> Matthias,
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Introduce C2X _Static_assert syntax

uso ewin
On Tue, Mar 3, 2020 at 7:47 PM Michael Matz <[hidden email]> wrote:

>
> Hello,
>
> On Sat, 29 Feb 2020, uso ewin wrote:
>
> > Hello, as I was working on fixing _Static_assert bug,
> > I've saw that it was fairly easy to add C2x _Static_assert
> > syntax support to tinycc.
> >
> > the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x
> >
> > The only difference with current _Static_assert is
> > that we can omit the literal string.
> >
> > Is the code okay ?
> >
> > Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)
>
> Fine with me at least.  I'd say also without testing for anything like
> -std=c2x, your call.
>
Ok, then I wont add -std=c2x now, mainly because gcc seems to accept c2x
_Static_assert syntax even without the argument, (like it does for _Generic)
I could add -std=c2x that only add the define, but if that's all this do,
maybe wait for features that require it ?

> I have a mild preference for using parse_mult_str no matter if the
> condition is true or false, obviating the need for an extra loop to skip
> the STR tokens.  Remember that you need to cstr_free the string in that
> case (which you can avoid right now only because tcc_error doesn't
> return).
>
Thanks for the feedback, I've update my branch (force push)
following your recommendations.
>
> Ciao,
> Michael.
>

I'll wait 3,4 days to see if there is feedback, if no I'll push on mob

Matthias,

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Introduce C2X _Static_assert syntax

uso ewin
I got no answer so I've push

I hope I didn't break anything

Matthias,

On Thu, Mar 5, 2020 at 10:01 AM uso ewin <[hidden email]> wrote:

>
> On Tue, Mar 3, 2020 at 7:47 PM Michael Matz <[hidden email]> wrote:
> >
> > Hello,
> >
> > On Sat, 29 Feb 2020, uso ewin wrote:
> >
> > > Hello, as I was working on fixing _Static_assert bug,
> > > I've saw that it was fairly easy to add C2x _Static_assert
> > > syntax support to tinycc.
> > >
> > > the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x
> > >
> > > The only difference with current _Static_assert is
> > > that we can omit the literal string.
> > >
> > > Is the code okay ?
> > >
> > > Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)
> >
> > Fine with me at least.  I'd say also without testing for anything like
> > -std=c2x, your call.
> >
> Ok, then I wont add -std=c2x now, mainly because gcc seems to accept c2x
> _Static_assert syntax even without the argument, (like it does for _Generic)
> I could add -std=c2x that only add the define, but if that's all this do,
> maybe wait for features that require it ?
>
> > I have a mild preference for using parse_mult_str no matter if the
> > condition is true or false, obviating the need for an extra loop to skip
> > the STR tokens.  Remember that you need to cstr_free the string in that
> > case (which you can avoid right now only because tcc_error doesn't
> > return).
> >
> Thanks for the feedback, I've update my branch (force push)
> following your recommendations.
> >
> > Ciao,
> > Michael.
> >
>
> I'll wait 3,4 days to see if there is feedback, if no I'll push on mob
>
> Matthias,

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Introduce C2X _Static_assert syntax

Christian Jullien-3
Matthias, this unfortunately the "right" process :((

Nothing is broken on Windows 32/64, Linux arm/aarch64 and Linux x86_64.

Thanks for your contribution.

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of uso ewin
Sent: Sunday, March 08, 2020 23:53
To: [hidden email]
Subject: Re: [Tinycc-devel] Introduce C2X _Static_assert syntax

I got no answer so I've push

I hope I didn't break anything

Matthias,

On Thu, Mar 5, 2020 at 10:01 AM uso ewin <[hidden email]> wrote:

>
> On Tue, Mar 3, 2020 at 7:47 PM Michael Matz <[hidden email]> wrote:
> >
> > Hello,
> >
> > On Sat, 29 Feb 2020, uso ewin wrote:
> >
> > > Hello, as I was working on fixing _Static_assert bug,
> > > I've saw that it was fairly easy to add C2x _Static_assert
> > > syntax support to tinycc.
> > >
> > > the code is here: https://github.com/cosmo-ray/tcc/commits/static_assert_c2x
> > >
> > > The only difference with current _Static_assert is
> > > that we can omit the literal string.
> > >
> > > Is the code okay ?
> > >
> > > Are you ok to introduce C2x feature to tinycc ? (gcc allow this too)
> >
> > Fine with me at least.  I'd say also without testing for anything like
> > -std=c2x, your call.
> >
> Ok, then I wont add -std=c2x now, mainly because gcc seems to accept c2x
> _Static_assert syntax even without the argument, (like it does for _Generic)
> I could add -std=c2x that only add the define, but if that's all this do,
> maybe wait for features that require it ?
>
> > I have a mild preference for using parse_mult_str no matter if the
> > condition is true or false, obviating the need for an extra loop to skip
> > the STR tokens.  Remember that you need to cstr_free the string in that
> > case (which you can avoid right now only because tcc_error doesn't
> > return).
> >
> Thanks for the feedback, I've update my branch (force push)
> following your recommendations.
> >
> > Ciao,
> > Michael.
> >
>
> I'll wait 3,4 days to see if there is feedback, if no I'll push on mob
>
> Matthias,

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel