public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Roger Sayle <roger@nextmovesoftware.com>,
	gcc-patches@gcc.gnu.org, richard.sandiford@arm.com
Subject: Re: [PATCH] Restore build with GCC 4.8 to GCC 5 (was Re: [PATCH] Workaround array_slice constructor portability issues (with older g++).)
Date: Tue, 5 Dec 2023 16:02:18 +0100	[thread overview]
Message-ID: <ZW87eiwXEwWLcELM@tucnak> (raw)
In-Reply-To: <mptleaa6r6u.fsf_-_@arm.com>

On Mon, Dec 04, 2023 at 01:19:21PM +0000, Richard Sandiford wrote:
> >> (that takes a size) explicitly, rather than rely on template resolution.
> >> In the example above this looks like:
> >>
> >> array_slice<int> t (table, 3);
> >>
> >> or equivalently
> >>
> >> array_slice<int> t = array_slice<int>(table, 3);
> >>
> >> or equivalently
> >>
> >> array_slice<int> t = array_slice<int>(table, ARRAY_SIZE (table));
> >
> > Taking c-decl.cc as an arbitrary example, it seems to be enough to change:
> >
> > const scoped_attribute_specs std_attribute_table =
> > {
> >   nullptr, std_attributes
> > };
> >
> > to:
> >
> > const scoped_attribute_specs std_attribute_table =
> > {
> >   nullptr, { std_attributes }
> > };
> >
> > which seems less ugly than the explicit constructors.
> >
> > But if we're going to do this, we should do it across the board,
> > not just for x86.
> 
> Here's an attempt to do that.  Tested so far by building
> aarch64-linux-gnu (which has target attributes) and frv-elf
> (which doesn't) with GCC 4.8.
> 
> OK if further testing passes?
> 
> Richard
> 
> ---
> 
> GCC 5 and earlier applied array-to-pointer decay too early,
> which affected the new attribute namespace code.  A reduced
> example of the construct that the attribute code uses is:
> 
>     struct S { template<__SIZE_TYPE__ N> S(int (&)[N]); };
>     struct T { int a; S b; };
>     int a[] = { 1 };
>     T t = { 1, a };
> 
> This was fixed by f85e1317f8ea933f5c615680353bd646f480f7d3
> (PR 16333 et al).
> 
> This patch tries to add a minimally-invasive workaround.
> 
> gcc/ada/
> 	* gcc-interface/utils.cc (gnat_internal_attribute_table): Add extra
> 	braces to work around PR 16333 in older compilers.
> 
> gcc/
> 	* attribs.cc (handle_ignored_attributes_option): Add extra
> 	braces to work around PR 16333 in older compilers.
> 	* config/arm/arm.cc (arm_gnu_attribute_table): Likewise.
> 	* config/i386/i386-options.cc (ix86_gnu_attribute_table): Likewise.
> 	* config/ia64/ia64.cc (ia64_gnu_attribute_table): Likewise.
> 	* config/rs6000/rs6000.cc (rs6000_gnu_attribute_table): Likewise.
> 	* target-def.h (TARGET_GNU_ATTRIBUTES): Likewise.
> 	* genhooks.cc (emit_init_macros): Likewise, when emitting the
> 	instantiation of TARGET_ATTRIBUTE_TABLE.
> 	* langhooks-def.h (LANG_HOOKS_INITIALIZER): Likewise, when
> 	instantiating LANG_HOOKS_ATTRIBUTE_TABLE.
> 	(LANG_HOOKS_ATTRIBUTE_TABLE): Define to be empty by default.
> 	* target.def (attribute_table): Likewise.
> 
> gcc/c-family/
> 	* c-attribs.cc (c_common_gnu_attribute_table): Add extra
> 	braces to work around PR 16333 in older compilers.
> 
> gcc/c/
> 	* c-decl.cc (std_attribute_table): Add extra braces to work
> 	around PR 16333 in older compilers.
> 
> gcc/cp/
> 	* tree.cc (cxx_gnu_attribute_table): Add extra braces to work
> 	around PR 16333 in older compilers.
> 
> gcc/d/
> 	* d-attribs.cc (d_langhook_common_attribute_table): Add extra braces
> 	to work around PR 16333 in older compilers.
> 	(d_langhook_gnu_attribute_table): Likewise.
> 
> gcc/fortran/
> 	* f95-lang.cc (gfc_gnu_attribute_table): Add extra braces to work
> 	around PR 16333 in older compilers.
> 
> gcc/jit/
> 	* dummy-frontend.cc (jit_gnu_attribute_table): Add extra braces
> 	to work around PR 16333 in older compilers.
> 	(jit_format_attribute_table): Likewise.
> 
> gcc/lto/
> 	* lto-lang.cc (lto_gnu_attribute_table): Add extra braces to work
> 	around PR 16333 in older compilers.
> 	(lto_format_attribute_table): Likewise.

LGTM.

	Jakub


      reply	other threads:[~2023-12-05 15:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-03 23:24 [PATCH] Workaround array_slice constructor portability issues (with older g++) Roger Sayle
2023-12-04 10:41 ` Richard Sandiford
2023-12-04 13:19   ` [PATCH] Restore build with GCC 4.8 to GCC 5 (was Re: [PATCH] Workaround array_slice constructor portability issues (with older g++).) Richard Sandiford
2023-12-05 15:02     ` Jakub Jelinek [this message]

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=ZW87eiwXEwWLcELM@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    --cc=roger@nextmovesoftware.com \
    /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).