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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A7109398744E for ; Wed, 11 Nov 2020 04:16:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A7109398744E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-Y8ghqY0oNR-RWs4enuHZnw-1; Tue, 10 Nov 2020 23:16:09 -0500 X-MC-Unique: Y8ghqY0oNR-RWs4enuHZnw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CEE01074659; Wed, 11 Nov 2020 04:16:08 +0000 (UTC) Received: from localhost.localdomain (ovpn-114-181.phx2.redhat.com [10.3.114.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56F685B4D0; Wed, 11 Nov 2020 04:16:07 +0000 (UTC) Subject: Re: [PATCH] Objective-C++ : Allow prefix attrs on linkage specs. To: Iain Sandoe , GCC Patches References: From: Jeff Law Message-ID: Date: Tue, 10 Nov 2020 21:16:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Nov 2020 04:16:13 -0000 On 11/7/20 8:11 AM, Iain Sandoe wrote: > Hi, > > For Objective-C++/C, we cater for the possibility that a class interface > (@interface) might be preceded by prefix attributes. In the case of > Objective-C++, the reference implementation (a.k.a. clang) also allows > (and combines) prefix attributes that precede a linkage specification > (but only on a single decl). > > Some discussion with Nathan here: > https://gcc.gnu.org/pipermail/gcc/2020-October/234057.html > > The upshot is that clang’s behaviour is inconsistent (I can file a bug, > I guess) - but since what is “well-formed” for Objective-C is defined in > reality by what clang accepts - there is a body of code out there that > depends on the behaviour (some variant of Hyrum’s law, or corollary > to it, perhaps?). > > Inability to parse code including these patterns is blocking progress > in modernising GNU Objective-C.. so I need to find a way forward. > > The compromise made here is to accept the sequence when parsing > for Objective-C++, and to warn** that the attributes are discarded otherwise. > > This seems to me to be an improvement in diagnostics for regular C++ > (since it now says something pertinent to the actual problem and does > the 'same as usual' when encountering an unhandled attribute). > > Tested across the Darwin patch, and on x86_64-linux-gnu, > OK for master? > thanks > Iain > > ** trivially, that could be an error instead - but it seems we usually warn > for unrecognised attributes. > > —— commit message > > For Objective-C++, this combines prefix attributes from before and > after top level linkage specs. The "reference implementation" for > Objective-C++ allows this, and system headers depend on it. > > e.g. > > __attribute__((__deprecated__)) > extern "C" __attribute__((__visibility__("default"))) > @interface MyClass > ... > @end > > Would consider the list of prefix attributes to the interface for > MyClass to include both the visibility and deprecated ones. > > When we are compiling regular C++, this emits a warning and discards > any prefix attributes before a linkage spec. > > gcc/cp/ChangeLog: > > * parser.c (cp_parser_declaration): Unless we are compiling for > Ojective-C++, warn about and discard any attributes that prefix > a linkage specification. Absolutely willing to trust your judgment on ObjC++.  So, OK jeff