From patchwork Fri May 2 10:33:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 344919 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 03694140124 for ; Fri, 2 May 2014 20:35:39 +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=hP2KYgL3lHIsQ32khYENHAXwheUflID5yOud6ASo7SS vt7+B3i915LMPvNNJJjySSaTCp35FGPGF/wwUAOLcxboIUupNISNNMdYtFptrocJ K2qIWTSYUiPRMEJXAA4VjJyUFXCkBdvuH6NFjyh0CjCZ+arAdnQCvpFL148zSvhg = 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=5DxZKzZ7Cudmd2l7m7wgVlyIWzI=; b=RUQmPjkCPUMxbdjGG DQwE85Avx3yoSMIj7tXfZ2bSR/QLTvs8NzcuelawGhGeH2KwbYfEOoT2/le0sPEh QuDX/SLU83TtpgWOtJPjqwxOP5FFA8TVO7Vb3zXMHRkri9MObzflLlLptg8UXg48 xwLFVeHT5CHvR97BQhYkmezJsE= Received: (qmail 28950 invoked by alias); 2 May 2014 10:35:33 -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 28932 invoked by uid 89); 2 May 2014 10:35:32 -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; Fri, 02 May 2014 10:35:27 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s42AZOtd015802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 May 2014 10:35:25 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s42AZOak025083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 May 2014 10:35:24 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s42AZIrN024935; Fri, 2 May 2014 10:35:23 GMT Received: from [192.168.1.4] (/95.252.77.121) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 May 2014 03:35:18 -0700 Message-ID: <53637479.9080402@oracle.com> Date: Fri, 02 May 2014 12:33:29 +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/RFC] PR 58582 X-IsSubscribed: yes Hi, this relatively old bug report is about an ICE during error recovery and some time ago I figured out that the below simple tweak to grokfndecl worked for it (we notice that duplicate_decls returned error_mark_node). Today, however, while formatting the original testcases, I noticed something slightly more interesting: at variance with both current clang and icc, we reject the below deleted6.C, thus we reject explicit instantiations of deleted template functions (without explaining that the function is deleted in the error message and still accepting the code with -fpermissive (?)). Thus the below tweak to instantiate_decl. Without it, 58582 is still fixed of course, only the testcases need a little adjusting. Tested x86_64-linux. Thanks, Paolo. ////////////////////// Index: cp/decl.c =================================================================== --- cp/decl.c (revision 210004) +++ cp/decl.c (working copy) @@ -7822,6 +7822,8 @@ grokfndecl (tree ctype, decl, ctype); return NULL_TREE; } + if (ok == error_mark_node) + return NULL_TREE; return old_decl; } } Index: cp/pt.c =================================================================== --- cp/pt.c (revision 210004) +++ cp/pt.c (working copy) @@ -19698,7 +19699,8 @@ instantiate_decl (tree d, int defer_ok, if (at_eof && !pattern_defined && DECL_EXPLICIT_INSTANTIATION (d) - && DECL_NOT_REALLY_EXTERN (d)) + && DECL_NOT_REALLY_EXTERN (d) + && (TREE_CODE (d) != FUNCTION_DECL || !DECL_DELETED_FN (d))) /* [temp.explicit] The definition of a non-exported function template, a Index: testsuite/g++.dg/cpp0x/deleted4.C =================================================================== --- testsuite/g++.dg/cpp0x/deleted4.C (revision 0) +++ testsuite/g++.dg/cpp0x/deleted4.C (working copy) @@ -0,0 +1,11 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template void foo() = delete; +}; + +template void A::foo() { int i; } // { dg-error "redefinition" } + +template void A::foo<0>(); Index: testsuite/g++.dg/cpp0x/deleted5.C =================================================================== --- testsuite/g++.dg/cpp0x/deleted5.C (revision 0) +++ testsuite/g++.dg/cpp0x/deleted5.C (working copy) @@ -0,0 +1,11 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template void foo() = delete; +}; + +template void A::foo() {} // { dg-error "redefinition" } + +template void A::foo<0>(); Index: testsuite/g++.dg/cpp0x/deleted6.C =================================================================== --- testsuite/g++.dg/cpp0x/deleted6.C (revision 0) +++ testsuite/g++.dg/cpp0x/deleted6.C (working copy) @@ -0,0 +1,9 @@ +// PR c++/58582 +// { dg-do compile { target c++11 } } + +struct A +{ + template void foo() = delete; +}; + +template void A::foo<0>();