From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34156 invoked by alias); 26 Feb 2018 09:45:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 34134 invoked by uid 89); 26 Feb 2018 09:44:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Feb 2018 09:44:57 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 536FC2DA9B6 for ; Mon, 26 Feb 2018 09:44:56 +0000 (UTC) Received: from redhat.com (ovpn-204-51.brq.redhat.com [10.40.204.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D737960BE6; Mon, 26 Feb 2018 09:44:54 +0000 (UTC) Date: Mon, 26 Feb 2018 09:45:00 -0000 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH to fix ICE with suggestions (PR c++/84537) Message-ID: <20180226094449.GG2995@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-02/txt/msg01393.txt.bz2 Here error_mark_node leaks all the way to edit_distance_traits::get_string which crashed, so let's not try to give a suggestion for an error node in the first place. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-02-26 Marek Polacek PR c++/84537 * name-lookup.c (suggest_alternative_in_explicit_scope): Return false if name is error node. * g++.dg/parse/error60.C: New test. diff --git gcc/cp/name-lookup.c gcc/cp/name-lookup.c index 9117e0b30eb..0f00328e96e 100644 --- gcc/cp/name-lookup.c +++ gcc/cp/name-lookup.c @@ -5541,6 +5541,10 @@ bool suggest_alternative_in_explicit_scope (location_t location, tree name, tree scope) { + /* Something went very wrong; don't suggest anything. */ + if (name == error_mark_node) + return false; + /* Resolve any namespace aliases. */ scope = ORIGINAL_NAMESPACE (scope); diff --git gcc/testsuite/g++.dg/parse/error60.C gcc/testsuite/g++.dg/parse/error60.C index e69de29bb2d..38f4e34c59d 100644 --- gcc/testsuite/g++.dg/parse/error60.C +++ gcc/testsuite/g++.dg/parse/error60.C @@ -0,0 +1,9 @@ +// PR c++/84537 +// { dg-do compile } + +namespace N +{ + template struct A {}; +} + +N::template A<> a; // { dg-error "" } Marek