From patchwork Tue Dec 13 21:24:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 131193 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 4F1651007D3 for ; Wed, 14 Dec 2011 08:24:33 +1100 (EST) Received: (qmail 22594 invoked by alias); 13 Dec 2011 21:24:32 -0000 Received: (qmail 22583 invoked by uid 22791); 13 Dec 2011 21:24:31 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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; Tue, 13 Dec 2011 21:24:18 +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 pBDLOIgP003353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Dec 2011 16:24:18 -0500 Received: from localhost (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBDLOHHd006335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Dec 2011 16:24:18 -0500 Received: by localhost (Postfix, from userid 500) id 9A88829C13A; Tue, 13 Dec 2011 22:24:16 +0100 (CET) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH] PR c++/51477 - ICE with invalid NSDMI X-URL: http://www.redhat.com Date: Tue, 13 Dec 2011 22:24:16 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 Hello, In the example of this patch, during the implicit declaration of the destructor, walk_field_subobs calls locate_fn_flags on the field invalid field 'x', to locate its destructor. That function pokes the BINFO of that field, which is NULL, and passes it along to lookup_fnfields. And we ICE because of that NULL base type. Just preventing lookup_member from crashing because of a NULL (or otherwise invalid) base type fixes the issue. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ PR c++/51477 * search.c (lookup_member): Get out early on invalid base type. gcc/testsuite/ PR c++/51477 * g++.dg/cpp0x/nsdmi6.C: New test. --- gcc/cp/search.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/nsdmi6.C | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi6.C diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 3894c68..0ceb5bc 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1171,7 +1171,9 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, const char *errstr = 0; - if (name == error_mark_node) + if (name == error_mark_node + || xbasetype == NULL_TREE + || xbasetype == error_mark_node) return NULL_TREE; gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C new file mode 100644 index 0000000..bb455e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi6.C @@ -0,0 +1,8 @@ +// Origin PR c++/51477 +// { dg-options "-std=c++11" } + +struct A +{ + typedef int int T; // { dg-error "two or more data types in declaration" } + struct T x[1] = { 0 }; // { dg-error "invalid|forward" } +};