From patchwork Fri Sep 13 10:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1985141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MGao3tFl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X4qxy0rhSz1y1y for ; Fri, 13 Sep 2024 20:17:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CDD43858C35 for ; Fri, 13 Sep 2024 10:17:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id D73DB3858D28 for ; Fri, 13 Sep 2024 10:17:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D73DB3858D28 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 D73DB3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726222655; cv=none; b=wVQeOJI9fZ7lKIfWP2myjSrtVwrUEkotGsrigM1luXDmu82nSQ4Ykxw5Fn3LUnplqDiTVFTBTR1JuSCQ32Ipam9nc6tjER6T2B7nDh+3LJWoo3WA89Sl4Jsk7a2z84QDn4NZof0/riKYkpLB4GmELmhwA/cBk8y9+Cxhd54qvaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726222655; c=relaxed/simple; bh=sLK7bhkbmbgqb3oTTNHKgIfzqS4q+BeMvjfpU6RbPYc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=J23iSFNUL5L0RCMRag/ucgcKP/uP9Wg8H2P5V3u/I6mMDzZe/pn9+kz4XjzZk/zPsc7qGU7wGVCJzKt/HfQBaLSbggQLjauzMBSc+2JWqyBHg/UaK6a5Zn3GApSOyrv/CKnsWnnuiD7LjZ32F5GaMtcfH2jXPLh8e+hE7FjYPK4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726222653; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=RnqhQEFH2n/XGkCJGy38foKqXdUurUGIkcykIj7E6co=; b=MGao3tFlP500GCnW7LqSyBKKwjo6YPfgiaRyMepvj/gXyGLmUu6xuNQdVLqXQABl0ZEBQZ zK79kGIBMZctsGGJE6CYH/ovFQN3Wq+sPmR/T+OTB31DKJ/JKe9K9vf+SV9hZDLAt3ybOj FoV+1ieb4KJLKT4eXVscJhPhI8cWrnY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-Y2JOyz9-PSO-ilLSCU6tmg-1; Fri, 13 Sep 2024 06:17:31 -0400 X-MC-Unique: Y2JOyz9-PSO-ilLSCU6tmg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1E2B1956048 for ; Fri, 13 Sep 2024 10:17:30 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.29]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BC2E31956086; Fri, 13 Sep 2024 10:17:28 +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 48DAHPtI2983025 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 13 Sep 2024 12:17:25 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 48DAHPID2983024; Fri, 13 Sep 2024 12:17:25 +0200 Date: Fri, 13 Sep 2024 12:17:25 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Don't emit deprecated/unavailable attribute diagnostics when creating cdtor thunks [PR116678] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Another spot where we mark_used a function (in this case ctor or dtor) even when it is just artificially used inside of thunks (emitted on mingw with -Os for the testcase). Bootstrapped/regtested on x86_64-linux and i686-linux and tested with a cross compiler to x86_64-mingw on the testcase, ok for trunk? 2024-09-13 Jakub Jelinek PR c++/116678 * optimize.cc: Include decl.h. (maybe_thunk_body): Temporarily change deprecated_state to UNAVAILABLE_DEPRECATED_SUPPRESS. * g++.dg/warn/deprecated-20.C: New test. Jakub --- gcc/cp/optimize.cc.jj 2024-05-21 10:19:34.484528180 +0200 +++ gcc/cp/optimize.cc 2024-09-12 13:56:30.710186354 +0200 @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. #include "coretypes.h" #include "target.h" #include "cp-tree.h" +#include "decl.h" #include "stringpool.h" #include "cgraph.h" #include "debug.h" @@ -287,6 +288,11 @@ maybe_thunk_body (tree fn, bool force) if (ctor_omit_inherited_parms (fns[0])) return 0; + /* Don't diagnose deprecated or unavailable cdtors just because they + have thunks emitted for them. */ + auto du = make_temp_override (deprecated_state, + UNAVAILABLE_DEPRECATED_SUPPRESS); + DECL_ABSTRACT_P (fn) = false; if (!DECL_WEAK (fn)) { --- gcc/testsuite/g++.dg/warn/deprecated-20.C.jj 2024-09-12 13:54:58.850422325 +0200 +++ gcc/testsuite/g++.dg/warn/deprecated-20.C 2024-09-12 13:55:27.510036714 +0200 @@ -0,0 +1,16 @@ +// PR c++/116678 +// { dg-do compile } +// { dg-options "-Os -pedantic" } + +struct S +{ + [[deprecated]] S () { s = 1; } // { dg-bogus "'S::S\\\(\\\)' is deprecated" } + S (int x) { s = x; } // { dg-warning "C\\\+\\\+11 attributes only available with" "" { target c++98_only } .-1 } + ~S () {} + int s; +}; + +int +main () +{ +}