From patchwork Wed May 11 17:51:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1629679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QP+M6qUf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kz2bK4Wksz9sG2 for ; Thu, 12 May 2022 03:54:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A19373851C24 for ; Wed, 11 May 2022 17:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A19373851C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652291642; bh=8pZptm3DW7fB1A+2wP+1QEBjJeL4dSz6zYrJ4siQZHg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QP+M6qUf70IlSpQoXVCz7rQy2isFpF88+K8Nucmoq1NRocbOUiQcxMPaYOsc85RPp qT3uN8de+9TwqmFlPFWCoxV6q223go7gKzsVV/Vn7iX+9bj50vIHyaShPpxVfI9uoD XMGFCFyYqNI2ZMMHCvHED72nPbb5hNWxOiL1ZA7o= 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 ESMTPS id B6D7A3857409 for ; Wed, 11 May 2022 17:52:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6D7A3857409 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-249-QHlrdHBfOdaNIGovdCI4Fw-1; Wed, 11 May 2022 13:52:04 -0400 X-MC-Unique: QHlrdHBfOdaNIGovdCI4Fw-1 Received: by mail-qk1-f198.google.com with SMTP id y140-20020a376492000000b0069f7e985c95so2351788qkb.15 for ; Wed, 11 May 2022 10:52:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=8pZptm3DW7fB1A+2wP+1QEBjJeL4dSz6zYrJ4siQZHg=; b=v8l6KYIkDofsohoDDzSoHo0czPRVbZdeaVxMTt5wzsm6kVOm35tGwCC8RpWhQADMq1 m1k7bvQC0j2ocquEF33qNLL8M/u45GzF6NSULE96sstwsmyM/dV3gzCBHdGYyxYH9AaC 1gsf2Oiz1NCFCRxN4DDYID4HS6BflKUgydzPWp0Eci7GVw6aQp5vnM/W7KzpLRm6Zo4l XsY67RL6mDgAhwfmKMbRwNNgMchORvmQS6ONrxT/nR4aX2+41Kyxwo+1KxmpYs7CX5DB v1WSe+TUEBPvdFHKGf68pB6LaX05qGAg+hLJhi9ATiDI/Xv1x4eor+Mgk3tsqSJtMkhq 9NLQ== X-Gm-Message-State: AOAM531ld7R+VYDAyeM6KDv+TFXnuWnE7LrmvV2i2Y9BwXsfo44zp38U bah7I35gG/PO8einETyrznchG39dk43g/ZHMHaxWXMenpsGgwoUhtmQN0265GwL8BqzzSGo/IhW GqfQFUoT91FjF3bxLLuqQ3hcyMKT9uGu4mUqeHXLWLW4jzvpMmGzDh+vzkmYhRgHDGg== X-Received: by 2002:a05:6214:1d08:b0:45a:a692:3bb2 with SMTP id e8-20020a0562141d0800b0045aa6923bb2mr23491884qvd.24.1652291522913; Wed, 11 May 2022 10:52:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjVpsER42VKKrZ/f5lj58iwDP4bxog7K9a/PAO6bFxSRWsukIE2epIcI63y2/YdSau8za94g== X-Received: by 2002:a05:6214:1d08:b0:45a:a692:3bb2 with SMTP id e8-20020a0562141d0800b0045aa6923bb2mr23491850qvd.24.1652291522513; Wed, 11 May 2022 10:52:02 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id g24-20020a05620a13d800b0069fe1fc72e7sm1620736qkl.90.2022.05.11.10.51.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 10:51:58 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: fix arm-eabi bootstrap [PR105567] Date: Wed, 11 May 2022 13:51:53 -0400 Message-Id: <20220511175153.3460763-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Since my r13-112, in the template we were changing 'return' to 'return this' on cdtor_returns_this targets, and then getting confused by that when instantiating. So only make that change at instantiation time. Tested x86_64-pc-linux-gnu and arm-eabi sim, applying to trunk. PR bootstrap/105567 gcc/cp/ChangeLog: * typeck.cc (check_return_expr): Don't mess with ctor return value while parsing a template. gcc/testsuite/ChangeLog: * g++.dg/template/ctor10.C: New test. --- gcc/cp/typeck.cc | 4 ++-- gcc/testsuite/g++.dg/template/ctor10.C | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/ctor10.C base-commit: 0acdbe29f66017fc5cca40dcbd72a0dd41491d07 diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 57e55ed48d1..6ecdd97697d 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -10448,7 +10448,7 @@ check_return_expr (tree retval, bool *no_warning) if (retval) error_at (loc, "returning a value from a destructor"); - if (targetm.cxx.cdtor_returns_this ()) + if (targetm.cxx.cdtor_returns_this () && !processing_template_decl) retval = current_class_ptr; else return NULL_TREE; @@ -10463,7 +10463,7 @@ check_return_expr (tree retval, bool *no_warning) /* You can't return a value from a constructor. */ error_at (loc, "returning a value from a constructor"); - if (targetm.cxx.cdtor_returns_this ()) + if (targetm.cxx.cdtor_returns_this () && !processing_template_decl) retval = current_class_ptr; else return NULL_TREE; diff --git a/gcc/testsuite/g++.dg/template/ctor10.C b/gcc/testsuite/g++.dg/template/ctor10.C new file mode 100644 index 00000000000..cf10fc5b19a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ctor10.C @@ -0,0 +1,10 @@ +// PR bootstrap/105567 +// This was breaking with cdtor_returns_this. + +template +struct A +{ + A() { return; } +}; + +A a;