From patchwork Mon Nov 11 20:14:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1193110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513000-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="weZ+aLW2"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="QqtEx32N"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Bhv42WwFz9s4Y for ; Tue, 12 Nov 2019 07:15:10 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=jZI RrsnREwV1cgolndK8n+Rzfsuhmhl//eQbsVZ7dWf62lTZbryvQbeodvYhm4HDpyg G03xr12YG249vAOS+iNPR5Ko67ctiXLVS9E9IZjL7Ew8HLLV2HKNvrafQoF9vfAQ qHi6YDErCcxTZ8DLeBiDE1WTyPWJPuzytjtEs4iM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=faanrHl/h 3Q38lSP+9lUHLkW9E0=; b=weZ+aLW2hvqP0NzcORR9cGCRhnZxvByqWfEUg1/R1 r8trCbLN/aYSNCQXxY4CRoo7o2N0itilWF0+OdYeNk6Y9MaSNHDvlpj3xFguhYUo WeldHaHxquM0x8ZVV9SVE8f8bv9wwz/vY/6kIFFtmwP5JZfpGmKr/Mfa8Wj1OPts 54= Received: (qmail 113724 invoked by alias); 11 Nov 2019 20:15:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113700 invoked by uid 89); 11 Nov 2019 20:15:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=decl_context, HX-Languages-Length:1797, DECL_CONTEXT X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Nov 2019 20:15:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573503298; 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: content-transfer-encoding:content-transfer-encoding; bh=1oyvB9QCZ2/ZV7lq5Q58nBGmAvPCc49wF2Owvr/cyng=; b=QqtEx32N1ksTRiFePUWGO27w09yFIfbZAEk+nPn1jDLouAekg3lms5j1bI6NOsos2WMFzQ 8Gql8uAqKZyobZnZXmOPPYKN7dnBuMj7eqknVn0cKpBQFNmJnEo7p5W58wONAuFAzdx2// dSjwkswDu8c5JQ78/09yS85l0BNvHmc= 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-426-lSA5-g8dNDWGFTk01NuMSQ-1; Mon, 11 Nov 2019 15:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8068118B5F68 for ; Mon, 11 Nov 2019 20:14:54 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B6C51B42C; Mon, 11 Nov 2019 20:14:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xABKEpcE026617; Mon, 11 Nov 2019 21:14:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xABKEo7v026616; Mon, 11 Nov 2019 21:14:50 +0100 Date: Mon, 11 Nov 2019 21:14:50 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix deleted fn handling (PR c++/92447) Message-ID: <20191111201450.GA4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! The finish_function change to goto cleanup; on DECL_DELETED_FN added in the spaceship commit broke the following testcase. The problem is that during start_preparsed_function push_nested_class pushes a scope, but as ctype is kept NULL when goto cleanup; crosses the setting of ctype to something else, pop_nested_class isn't called anymore and callers get upset they are in current_binding_level of sk_class instead of what they expected. Fixed thusly, bootstrapped/regtested on powerpc64le-linux, ok for trunk? 2019-11-11 Jakub Jelinek PR c++/92447 * decl.c (finish_function): Move ctype initialization before DECL_DELETED_FN handling. * g++.dg/cpp0x/pr92447.C: New test. Jakub --- gcc/cp/decl.c.jj 2019-11-07 09:50:51.000000000 +0100 +++ gcc/cp/decl.c 2019-11-11 15:29:17.610112820 +0100 @@ -16803,6 +16803,10 @@ finish_function (bool inline_p) } } + /* Remember that we were in class scope. */ + if (current_class_name) + ctype = current_class_type; + if (DECL_DELETED_FN (fndecl)) { DECL_INITIAL (fndecl) = error_mark_node; @@ -16861,10 +16865,6 @@ finish_function (bool inline_p) current_function_return_value = NULL_TREE; } - /* Remember that we were in class scope. */ - if (current_class_name) - ctype = current_class_type; - /* Must mark the RESULT_DECL as being in this function. */ DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl; --- gcc/testsuite/g++.dg/cpp0x/pr92447.C.jj 2019-11-11 15:31:28.208138229 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr92447.C 2019-11-11 15:30:29.314028624 +0100 @@ -0,0 +1,14 @@ +// PR c++/92447 +// { dg-do compile { target c++11 } } + +template +void +foo () +{ + struct S { S &operator=(S &&x) = default; const T s{}; }; +} + +void bar () +{ + foo(); +}