From patchwork Mon Mar 5 14:47:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 881530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474277-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Utrmg6tn"; dkim-atps=neutral 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 3zw2nf5F5Xz9sZ3 for ; Tue, 6 Mar 2018 01:47:49 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=TD1IqzF4bZdssdvK1wxBu+jzv/zcajbDXCUEtw3AhZaFLgXA+CRxT pNM1MZn68lJJ8fCNOY9IYxdE8wz3skHz8mgif6chBJtxl1OobEqLdGJL/r28+QLS Fv2n/UI05AEta7t8P+mjUIymIa1muZxMPiml1RD+C7/XyrYBLuEfgc= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=eytTbXyS2LBM4CTNm1K7XeKumfs=; b=Utrmg6tn96YsZ5M1gsWS PkR734TmpeTA4KanlmOKTA0YuEncLCxaqn/CgtUkITkKUpgesGS0IcNRzPhwlvQm 58dsYCdQXfCtGcq1nwa+F7rhhFV7whW2kX1bjlLc3Y3pGVS4D/ZCrmwzDQVaPzDo yuk3gizSa2qfT7pwNY5rSmc= Received: (qmail 20942 invoked by alias); 5 Mar 2018 14:47:42 -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 20309 invoked by uid 89); 5 Mar 2018 14:47:41 -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, 05 Mar 2018 14:47:40 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B73C4E919; Mon, 5 Mar 2018 14:47:39 +0000 (UTC) Received: from redhat.com (unknown [10.40.205.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7571D605DC; Mon, 5 Mar 2018 14:47:38 +0000 (UTC) Date: Mon, 5 Mar 2018 15:47:35 +0100 From: Marek Polacek To: Jason Merrill , Nathan Sidwell , GCC Patches Subject: C++ PATCH for c++/84707, ICE with nested anonymous namespace Message-ID: <20180305144735.GT16833@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Since Nathan's r253489 we seem to not use anon_identifier anymore; rather, the DECL_NAME is simply NULL. This crashed in duplicate_decls on this invalid code because UDLIT_OPER_P was blithely used on a possibly null tree. Other spots in this function check this, too. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-03-05 Marek Polacek PR c++/84707 * decl.c (duplicate_decls): Check DECL_NAME before accessing UDLIT_OPER_P. * g++.dg/cpp0x/inline-ns10.C: New test. Marek diff --git gcc/cp/decl.c gcc/cp/decl.c index 1866e8f3574..b2e19a6549d 100644 --- gcc/cp/decl.c +++ gcc/cp/decl.c @@ -1410,7 +1410,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) || TREE_TYPE (olddecl) == error_mark_node) return error_mark_node; - if (UDLIT_OPER_P (DECL_NAME (newdecl)) + if (DECL_NAME (newdecl) + && DECL_NAME (olddecl) + && UDLIT_OPER_P (DECL_NAME (newdecl)) && UDLIT_OPER_P (DECL_NAME (olddecl))) { if (TREE_CODE (newdecl) == TEMPLATE_DECL diff --git gcc/testsuite/g++.dg/cpp0x/inline-ns10.C gcc/testsuite/g++.dg/cpp0x/inline-ns10.C index e69de29bb2d..3ab425f7be4 100644 --- gcc/testsuite/g++.dg/cpp0x/inline-ns10.C +++ gcc/testsuite/g++.dg/cpp0x/inline-ns10.C @@ -0,0 +1,8 @@ +// PR c++/84707 +// { dg-do compile { target c++11 } } + +inline namespace { + namespace {} +} + +namespace {} // { dg-error "conflicts" }