public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Remove conditional STATIC_ASSERT.
Date: Thu, 5 May 2022 14:29:31 +0200	[thread overview]
Message-ID: <CAFiYyc1d2RYtgVb0B9Bjf3vOqimBaSsdSSvQSzqPuWHmRCPFRQ@mail.gmail.com> (raw)
In-Reply-To: <60e9783e-d324-2d12-5744-68a3b2e5c96a@suse.cz>

On Thu, May 5, 2022 at 2:20 PM Martin Liška <mliska@suse.cz> wrote:
>
> As we require a c++11 compliant compiler, the #if __cplusplus >= 201103L
> conditional build is always true.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

Can we then use static_assert (...) instead and remove the
macro?  Do we have C compiled code left (I think we might,
otherwise we'd not have __cplusplus guards in system.h),
in which case the #if should change to #ifdef __cplusplus?

Thanks,
Richard.

> Thanks,
> Martin
>
> gcc/ChangeLog:
>
>         * basic-block.h (STATIC_ASSERT): Use normal STATIC_ASSERT.
>         * system.h (STATIC_ASSERT): Define always as static_assert.
> ---
>  gcc/basic-block.h | 5 +----
>  gcc/system.h      | 9 +--------
>  2 files changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/basic-block.h b/gcc/basic-block.h
> index e3fff1f6975..21a9b24dbf9 100644
> --- a/gcc/basic-block.h
> +++ b/gcc/basic-block.h
> @@ -158,10 +158,7 @@ struct GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb"))) basic_block_d
>  /* This ensures that struct gimple_bb_info is smaller than
>     struct rtl_bb_info, so that inlining the former into basic_block_def
>     is the better choice.  */
> -typedef int __assert_gimple_bb_smaller_rtl_bb
> -              [(int) sizeof (struct rtl_bb_info)
> -               - (int) sizeof (struct gimple_bb_info)];
> -
> +STATIC_ASSERT (sizeof (rtl_bb_info) >= sizeof (gimple_bb_info));
>
>  #define BB_FREQ_MAX 10000
>
> diff --git a/gcc/system.h b/gcc/system.h
> index 1688b763ef5..48145951337 100644
> --- a/gcc/system.h
> +++ b/gcc/system.h
> @@ -801,14 +801,7 @@ extern void fancy_abort (const char *, int, const char *)
>
>  #define STATIC_CONSTANT_P(X) (__builtin_constant_p (X) && (X))
>
> -/* static_assert (COND, MESSAGE) is available in C++11 onwards.  */
> -#if __cplusplus >= 201103L
> -#define STATIC_ASSERT(X) \
> -  static_assert ((X), #X)
> -#else
> -#define STATIC_ASSERT(X) \
> -  typedef int assertion1[(X) ? 1 : -1] ATTRIBUTE_UNUSED
> -#endif
> +#define STATIC_ASSERT(X) static_assert ((X), #X)
>
>  /* Provide a fake boolean type.  We make no attempt to use the
>     C99 _Bool, as it may not be available in the bootstrap compiler,
> --
> 2.36.0
>

  reply	other threads:[~2022-05-05 12:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05 12:18 Martin Liška
2022-05-05 12:29 ` Richard Biener [this message]
2022-05-05 12:41   ` Martin Liška
2022-05-05 12:51     ` Pedro Alves
2022-05-05 12:56       ` Martin Liška
2022-05-05 13:08     ` Richard Biener
2022-05-09  8:45       ` Martin Liška
2022-05-09 12:05         ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc1d2RYtgVb0B9Bjf3vOqimBaSsdSSvQSzqPuWHmRCPFRQ@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).