From patchwork Fri Feb 22 19:13:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 222675 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]) by ozlabs.org (Postfix) with SMTP id E9A7A2C02A7 for ; Sat, 23 Feb 2013 09:23:42 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1362176623; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=QHKCHNG WJ24gI50OR69PyImhfds=; b=NopJmjqDEVzUp6Mty6UZfEy5StqFUhq5OHoYmoM zsiGijNwENBK8LL1kwbjjpHeZ3vO0V+s/dL3SB2t9geTY9a+BamXdqRc/P04ttge 7OrSAiQ8t5yTt3yRYP9N7KjzGOFn8paK7BAWLJ4Y7uxeXEVb/eRXP1lS9A0z9CP6 8QFM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=IPOfjAHEWCIpu/ikArYUPnYuJc4A7ADKJyPl3der8KBvg/wYyVJ+TunELCXvhj G6JlerYJcuyt1hJH60/Y2xo+bCjc50T2/3Gc12Xz04dNchK2KXfu0nXodopMssC8 UWAxEH/Wg6aFRuWAMy4RToCd94PVpRysQsTa0WICCdWhQ=; Received: (qmail 825 invoked by alias); 22 Feb 2013 22:23:38 -0000 Received: (qmail 813 invoked by uid 22791); 22 Feb 2013 22:23:37 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_03_06, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Feb 2013 22:23:31 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1MMNUhd002484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Feb 2013 17:23:30 -0500 Received: from [10.3.113.106] (ovpn-113-106.phx2.redhat.com [10.3.113.106]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1MMNTQT029317 for ; Fri, 22 Feb 2013 17:23:30 -0500 Message-ID: <5127C364.6050804@redhat.com> Date: Fri, 22 Feb 2013 14:13:40 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:20.0) Gecko/20100101 Thunderbird/20.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/40405 (ICE with invalid template) 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 Another place in push_template_decl_real already uses this technique to avoid crashing in import_export_decl. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit f9e38d8e08b8602fe0264fd381d97bff495acc32 Author: Jason Merrill Date: Fri Feb 22 12:52:04 2013 -0500 PR c++/40405 * pt.c (push_template_decl_real): Set DECL_INTERFACE_KNOWN if we got the wrong number of template parms. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a39d114..5ff0821 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4782,6 +4782,8 @@ push_template_decl_real (tree decl, bool is_friend) error ("got %d template parameters for %q#T", TREE_VEC_LENGTH (a), current); error (" but %d required", TREE_VEC_LENGTH (t)); + /* Avoid crash in import_export_decl. */ + DECL_INTERFACE_KNOWN (decl) = 1; return error_mark_node; } diff --git a/gcc/testsuite/g++.dg/template/error49.C b/gcc/testsuite/g++.dg/template/error49.C new file mode 100644 index 0000000..57789a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error49.C @@ -0,0 +1,10 @@ +// PR c++/40405 + +template struct A +{ + static int i; +}; + +template int A<0,0>::i = 0; // { dg-error "" } + +int j = A<0,0>::i;