From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A2CC3385E02D for ; Tue, 5 Dec 2023 15:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2CC3385E02D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A2CC3385E02D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701788586; cv=none; b=SQX46PwPN07qopeafyNqJuvXKLnksUlxfLtDofsUJoBvOJXxeB8Nzbqkho+sHBt8U657knbbfaN919gV24fXO4nyCVimFzN7XLczahK+xPpGeDDeDNNkZO/eCUAXY+GtbQ9g539evrj67F91vA0ZCO9aY9C2FIISvbWqrny4n9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701788586; c=relaxed/simple; bh=NiY7p0/7hSLWfg2paIR5ga9eWSJuWn/4A6t1IBGeRnk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=nkSG7H11egPz9UkWRpGi/MZKvZIgy0e6zArI3br6tWsiheAs8dweVRgewm6eBqKC5hkyQFze/KmHF/edNINMOPzi9GMZG4xVPWTolAJANzQsOESixyNJin2I7urn/DH0VKQK2KnNZG3sFTom8aGjM8rU8r3k0BVDhWeR3NtqvGM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701788579; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=W9edElYTz8Z7wqqlN9CDUGWLNLGsw/hJefnClnkcGNo=; b=b0Z7vCZKLis/LpUJx0Qh5zpesrjXg36NpEYnrsclYYtudiKBwIQlbWqpeb98AFkRRRp2Zd QEKtUtEOX8aM2N4YiKcMYKwWKaPw+/E6Nrwy3VP9rISshYkP9/17oHA2xNr0Hl3VJ/o+gt KQFY7Tcf2jaBbmtwzgG8W2vVyHO+uJ8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-j1ElZBhwPMytm5YoR11S9g-1; Tue, 05 Dec 2023 10:02:24 -0500 X-MC-Unique: j1ElZBhwPMytm5YoR11S9g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 524A480C17E; Tue, 5 Dec 2023 15:02:24 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B93751E3; Tue, 5 Dec 2023 15:02:23 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3B5F2KuT1801949 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 5 Dec 2023 16:02:20 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3B5F2JeR1800959; Tue, 5 Dec 2023 16:02:19 +0100 Date: Tue, 5 Dec 2023 16:02:18 +0100 From: Jakub Jelinek To: Roger Sayle , 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++).) Message-ID: Reply-To: Jakub Jelinek References: <006601da263f$d455aa30$7d00fe90$@nextmovesoftware.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 t (table, 3); > >> > >> or equivalently > >> > >> array_slice t = array_slice(table, 3); > >> > >> or equivalently > >> > >> array_slice t = array_slice(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