From patchwork Fri Jan 20 12:19:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 137022 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 7F527B6EF1 for ; Fri, 20 Jan 2012 23:21:41 +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=1327666902; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=CXgFTVb+1g48CYX5TNpyxrtEorg=; b=ZGJT9oqMCiL+T7w 3IehvSZBjWB5c6pAE/uBPJ96p2uSXUoAZosGwnrKcvxBb8pDtS2wS7p1b/pUHBhg im5hVvYXF452JCwIF8NldVB8MqSiuzw39dhgbLUhrbfd1AU6+3+2IW3hRjOI8DCc 4gp6CDKgflr8Z/88JW74DwHoQy64= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZHP+jIhJ6u9Owr6iMErQgrnxoUDGEwFN6XAy9Jb47o83oCMF5tJKuQcmWyROS7 pxWo6DBg7jqVHCockXdk4DHKJFkf609M3Uj7403sBwCT5TvX3qr1yzHzCcgwnvV7 1oIaQ7J3QebmlXYTHK5kE40JFv6AO05Z5FYQs719BanmU=; Received: (qmail 15790 invoked by alias); 20 Jan 2012 12:21:32 -0000 Received: (qmail 15770 invoked by uid 22791); 20 Jan 2012 12:21:29 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 Jan 2012 12:21:16 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id q0KCLEbk005068 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Jan 2012 12:21:15 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q0KCLDZc001041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Jan 2012 12:21:14 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q0KCLDT3000925; Fri, 20 Jan 2012 06:21:13 -0600 Received: from [192.168.1.4] (/79.51.12.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 20 Jan 2012 04:21:13 -0800 Message-ID: <4F195BE0.8040204@oracle.com> Date: Fri, 20 Jan 2012 13:19:44 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111219 Thunderbird/9.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 51402 X-IsSubscribed: yes 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 Hi, a small diagnostic regression, pretty easy to fix: checking the value returned by tsubst avoids crashing later in the template_class_depth loop. Tested x86_64-linux. Thanks, Paolo. //////////////////////// /cp 2012-01-20 Paolo Carlini PR c++/51402 * pt.c (lookup_template_class_1): Check context returned by tsubst for error_mark_node. /testsuite 2012-01-20 Paolo Carlini PR c++/51402 * g++.dg/template/crash110.C: New. Index: testsuite/g++.dg/template/crash110.C =================================================================== --- testsuite/g++.dg/template/crash110.C (revision 0) +++ testsuite/g++.dg/template/crash110.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/51402 + +template struct A // { dg-error "not a valid type" } +{ + template struct B {}; + template struct B {}; +}; Index: cp/pt.c =================================================================== --- cp/pt.c (revision 183335) +++ cp/pt.c (working copy) @@ -1,6 +1,6 @@ /* Handle parameterized types (templates) for GNU C++. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 + 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Rewritten by Jason Merrill (jason@cygnus.com). @@ -7466,6 +7466,9 @@ lookup_template_class_1 (tree d1, tree arglist, tr context = tsubst (DECL_CONTEXT (gen_tmpl), arglist, complain, in_decl); + if (context == error_mark_node) + return error_mark_node; + if (!context) context = global_namespace;