From patchwork Thu Feb 23 14:02:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 731547 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 3vTbXT2Gtkz9s7D for ; Fri, 24 Feb 2017 01:02:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="l9GmUbJz"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=QRs7TaYCntPkB4ZicfghV3TODjjlu+AZZnEtv5YlvbyzZydGCX 2By9OTSKFhTlAN8OMBYIhhAdaI5USKdVGGZs2h6Do8cjyCFHgxhf+7HB8c82tLZQ jnxliMeXhFxe72/nE+jzmVv4vCRy2N4HbSjfUHFoAXgEXZ2NADYXi8Bw0= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=HKkzxDtV5bj263JhZrec6Nwf6Qo=; b=l9GmUbJzV0HPONbcQKdb eZU2s+AvqJ42sNDA2oF6S6qDfiDQDBGp0UijznVUTTZBQjAxARtk/g5hT6Ff/BhC gU+UYN66krQMMo9k37GOLlkWO1zYBBijYnHcRsdfJa7fqrYQ9gbzYAbau+1Qfm8f rFHQn/mnHMZc1dyyckD3300= Received: (qmail 29610 invoked by alias); 23 Feb 2017 14:02:21 -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 29586 invoked by uid 89); 23 Feb 2017 14:02:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sensible, H*r:ip*192.168.1.4, H*RU:192.168.1.4, Hx-spam-relays-external:192.168.1.4 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 ESMTP; Thu, 23 Feb 2017 14:02:18 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1NE2Ghc021091 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Feb 2017 14:02:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v1NE2FCT011128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Feb 2017 14:02:15 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v1NE2D6n029500; Thu, 23 Feb 2017 14:02:14 GMT Received: from [192.168.1.4] (/79.35.208.47) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Feb 2017 06:02:13 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 79361 Message-ID: <5817d25c-aa16-ff6a-e720-d34df14f9521@oracle.com> Date: Thu, 23 Feb 2017 15:02:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this error recovery regression, we ICE after (a lot after) a sensible diagnostic, when lower_function_body encounters an error_mark_node. I worked quite a bit on the issue, and, all in all, I propose to simply check the return value of duplicate_decls as called by register_specialization and bail out. In principle it may make sense to continue and, for example, also emit diagnostic about '= default' making sense only for special member functions - returning spec instead of error_mark_node would achieve that without regressions for the second testcase - but I'm not sure we want to do this kind of change right here right now together with fixing the ICE, because we do *not* emit additional diagnostic in the non-template case, eg for: void foo(int) {} void foo(int) = default; Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2017-02-23 Paolo Carlini PR c++/79361 * pt.c (register_specialization): Check duplicate_decls return value for error_mark_node and pass it back. /testsuite 2017-02-23 Paolo Carlini PR c++/79361 * g++.dg/cpp0x/pr79361-1.C: New. * g++.dg/cpp0x/pr79361-2.C: Likewise. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 245655) +++ cp/pt.c (working copy) @@ -1599,7 +1599,12 @@ register_specialization (tree spec, tree tmpl, tre } else if (DECL_TEMPLATE_SPECIALIZATION (fn)) { - if (!duplicate_decls (spec, fn, is_friend) && DECL_INITIAL (spec)) + tree dd = duplicate_decls (spec, fn, is_friend); + if (dd == error_mark_node) + /* We've already complained in duplicate_decls. */ + return error_mark_node; + + if (dd == NULL_TREE && DECL_INITIAL (spec)) /* Dup decl failed, but this is a new definition. Set the line number so any errors match this new definition. */ Index: testsuite/g++.dg/cpp0x/pr79361-1.C =================================================================== --- testsuite/g++.dg/cpp0x/pr79361-1.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr79361-1.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/79361 +// { dg-do compile { target c++11 } } + +template void foo(T); + +template<> void foo(int) {} // { dg-message "declared" } +template<> void foo(int) = delete; // { dg-error "redefinition" } Index: testsuite/g++.dg/cpp0x/pr79361-2.C =================================================================== --- testsuite/g++.dg/cpp0x/pr79361-2.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr79361-2.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/79361 +// { dg-do compile { target c++11 } } + +template void foo(T); + +template<> void foo(int) {} // { dg-message "declared" } +template<> void foo(int) = default; // { dg-error "redefinition" }