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 2EFC2383F84F for ; Tue, 9 Mar 2021 09:52:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2EFC2383F84F 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-485-W5dWqS80OqG08a_zFcA83Q-1; Tue, 09 Mar 2021 04:52:04 -0500 X-MC-Unique: W5dWqS80OqG08a_zFcA83Q-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 1DB1926865; Tue, 9 Mar 2021 09:52:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-238.ams2.redhat.com [10.36.113.238]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD1F019814; Tue, 9 Mar 2021 09:52:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1299q0h61835873 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 9 Mar 2021 10:52:00 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1299pw1D1835872; Tue, 9 Mar 2021 10:51:58 +0100 Date: Tue, 9 Mar 2021 10:51:58 +0100 From: Jakub Jelinek To: Nathan Sidwell , Iain Sandoe Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Fix coroutines on targetm.cxx.cdtor_return_this targets [PR99459] Message-ID: <20210309095158.GL745611@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 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=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, 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: Tue, 09 Mar 2021 09:52:10 -0000 Hi! The r11-7528 build_co_await changes broke coroutines on arm*-linux-gnuabi, 2780 ^FAIL.*coroutines/ in total. The problem is that arm is targetm.cxx.cdtor_return_this target where both ctors and dtors in the ABI return this pointer rather than void, and build_new_method_call_1 does: else if (call != error_mark_node && DECL_DESTRUCTOR_P (cand->fn) && !VOID_TYPE_P (TREE_TYPE (call))) /* An explicit call of the form "x->~X()" has type "void". However, on platforms where destructors return "this" (i.e., those where targetm.cxx.cdtor_returns_this is true), such calls will appear to have a return value of pointer type to the low-level call machinery. We do not want to change the low-level machinery, since we want to be able to optimize "delete f()" on such platforms as "operator delete(~X(f()))" (rather than generating "t = f(), ~X(t), operator delete (t)"). */ call = build_nop (void_type_node, call); The new code in build_co_await relies on build_special_member_call returned expression being a CALL_EXPR, but due to the build_nop in there it is a NOP_EXPR around the CALL_EXPR. It can't be stripped with STRIP_NOPS because void has different mode from the pointer mode. Bootstrapped/regtested on armv7hl-linux-gnueabi and x86_64-linux, ok for trunk? 2021-03-09 Jakub Jelinek PR c++/99459 * coroutines.cc (build_co_await): Look through NOP_EXPRs in build_special_member_call return value to find the CALL_EXPR. --- gcc/cp/coroutines.cc.jj 2021-03-05 21:51:48.671185716 +0100 +++ gcc/cp/coroutines.cc 2021-03-08 10:53:13.187959339 +0100 @@ -868,6 +868,8 @@ build_co_await (location_t loc, tree a, = build_special_member_call (a, complete_dtor_identifier, NULL, a_type, LOOKUP_NORMAL, tf_none); + if (dummy && CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) : NULL_TREE; if (dummy && coro_diagnose_throwing_fn (dummy)) @@ -1031,6 +1033,8 @@ build_co_await (location_t loc, tree a, = build_special_member_call (e_proxy, complete_dtor_identifier, NULL, o_type, LOOKUP_NORMAL, tf_none); + if (dummy && CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) : NULL_TREE; if (dummy && coro_diagnose_throwing_fn (dummy)) Jakub