From patchwork Wed May 7 08:58:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 346445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 11032140109 for ; Wed, 7 May 2014 19:00:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=sm4qpsWByoC8q3NXA3yT2xeBuk9dgISQLTDUiG3J5PB 8QesCnynw611KUeUAyEpu9Evln0TE1bpkDtZPeWPjPCzb/v2hZPOQ6AsIjUgH13z bRj0VTN9AAJfZZ5PbD5nDOluOwyWQnOg5hPsocydDAfoBzenIE8eIIGcdoiDdSRI = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=NTZgaXJZ6hRYEXiTwa4DPwBVBPA=; b=uvCTmUgjfMYFgPdY5 2N3MGc0O7ZVQ11MX8cJ8UdjHRP62Lg4Ri2WCogDnBW2XasKgqtQ07QfHnB4zn6ND U0Iw6RlA40ubV92ZBKhzxXew99FVfGdLTSFB3iNJoOa/OBFBwaihUUZUXRMF/Bzv J9J6SrQI2UG2PHLqVKytrLx1Fk= Received: (qmail 21204 invoked by alias); 7 May 2014 09:00:40 -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 21194 invoked by uid 89); 7 May 2014 09:00:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 07 May 2014 09:00:38 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4790Z1A022078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 May 2014 09:00:36 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4790YqD026849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 7 May 2014 09:00:35 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4790YcS003814; Wed, 7 May 2014 09:00:34 GMT Received: from [192.168.1.4] (/79.35.208.86) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 May 2014 02:00:33 -0700 Message-ID: <5369F5BD.6030804@oracle.com> Date: Wed, 07 May 2014 10:58:37 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 61080 X-IsSubscribed: yes Hi, thus I prepared this simple patch. Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2014-05-07 Paolo Carlini PR c++/61080 * pt.c (instantiate_decl): Avoid generating the body of a deleted function. /testsuite 2014-05-07 Paolo Carlini PR c++/61080 * g++.dg/cpp0x/deleted7.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 210140) +++ cp/pt.c (working copy) @@ -19542,6 +19542,7 @@ instantiate_decl (tree d, int defer_ok, int saved_unevaluated_operand = cp_unevaluated_operand; int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings; bool external_p; + bool deleted_p; tree fn_context; bool nested; @@ -19623,11 +19624,17 @@ instantiate_decl (tree d, int defer_ok, args = gen_args; if (TREE_CODE (d) == FUNCTION_DECL) - pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE - || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern) - || DECL_DELETED_FN (code_pattern)); + { + deleted_p = DECL_DELETED_FN (code_pattern); + pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE + || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern) + || deleted_p); + } else - pattern_defined = ! DECL_IN_AGGR_P (code_pattern); + { + deleted_p = false; + pattern_defined = ! DECL_IN_AGGR_P (code_pattern); + } /* We may be in the middle of deferred access check. Disable it now. */ push_deferring_access_checks (dk_no_deferred); @@ -19671,7 +19678,10 @@ instantiate_decl (tree d, int defer_ok, elsewhere, we don't want to instantiate the entire data member, but we do want to instantiate the initializer so that we can substitute that elsewhere. */ - || (external_p && VAR_P (d))) + || (external_p && VAR_P (d)) + /* Handle here a deleted function too, avoid generating + its body (c++/61080). */ + || deleted_p) { /* The definition of the static data member is now required so we must substitute the initializer. */ @@ -19867,17 +19877,14 @@ instantiate_decl (tree d, int defer_ok, tf_warning_or_error, tmpl, /*integral_constant_expression_p=*/false); - if (DECL_STRUCT_FUNCTION (code_pattern)) - { - /* Set the current input_location to the end of the function - so that finish_function knows where we are. */ - input_location - = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus; + /* Set the current input_location to the end of the function + so that finish_function knows where we are. */ + input_location + = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus; - /* Remember if we saw an infinite loop in the template. */ - current_function_infinite_loop - = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop; - } + /* Remember if we saw an infinite loop in the template. */ + current_function_infinite_loop + = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop; } /* We don't need the local specializations any more. */ Index: testsuite/g++.dg/cpp0x/deleted7.C =================================================================== --- testsuite/g++.dg/cpp0x/deleted7.C (revision 0) +++ testsuite/g++.dg/cpp0x/deleted7.C (working copy) @@ -0,0 +1,36 @@ +// PR c++/61080 +// { dg-do compile { target c++11 } } +// { dg-options "-Wreturn-type" } + +struct AAA +{ + int a1, a2, a3; + void *p; +}; + +template +class WeakMapPtr +{ + public: + WeakMapPtr() : ptr(nullptr) {}; + bool init(AAA *cx); + private: + void *ptr; + WeakMapPtr(const WeakMapPtr &wmp) = delete; + WeakMapPtr &operator=(const WeakMapPtr &wmp) = delete; +}; + +template +bool WeakMapPtr::init(AAA *cx) +{ + ptr = cx->p; + return true; +} + +struct JSObject +{ + int blah; + float meh; +}; + +template class WeakMapPtr;