From patchwork Mon Mar 5 16:10:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 881560 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-474285-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EMK14fFS"; 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 3zw4dP5t8Gz9s3G for ; Tue, 6 Mar 2018 03:10: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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=B7ePLbyAEDwobXD1hRRG7ihR6B73NZti5e2znXkCENf/cxdNgL S07U/1E9p/W0I4ZIKcrjwTZoeIlwSRABdAjcQiSV0Q+7fDAzFgE93p67Aoe7MTZE Uljtc/swUBU0HXefXaCa7uYKHa6yi3qkE4BjMbbRtToNWspY1xxL5YgVs= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=mF/Dbx/YjiTK/+iYc7yruXR9Djs=; b=EMK14fFSZMy2wPR8dd9J /4CAtQ0SxRi3jGYIcKmybnZeO8bl0OzKmCUDFRLpH8Ms4ZdO6EunE8uDdosHHdou BDyCRoTUxHMUS0YK1OIqB69bPJ8gXIUkWM2vkMCYvttPT536TM1lTWljPXs1kQJM soQQilzD4jFwkZ2DitrIdbw= Received: (qmail 99588 invoked by alias); 5 Mar 2018 16:10: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 99541 invoked by uid 89); 5 Mar 2018 16:10:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yb0-f181.google.com Received: from mail-yb0-f181.google.com (HELO mail-yb0-f181.google.com) (209.85.213.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Mar 2018 16:10:37 +0000 Received: by mail-yb0-f181.google.com with SMTP id e135-v6so5936318ybb.3 for ; Mon, 05 Mar 2018 08:10:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=Wd0km0EKKqmSXGvKoI8uXbxAVMK8q46MCSLkiqoUKSM=; b=YQxQJr0oGtlQI5UHghtzWx0367kEJcm1+KrFmDFFnRmamQ7HJJB8+hl872LQeYsCkc cNgEfuzmoPVIwSefau6e8/METZcmyu568IlXFekeKrkGYAyqpsgBnqnfiTil3Pm7Xnwt 4AyzbzZY4a+a7soTKMF1QQD9xH/Wb+vjIzmXC08AAWPybtPSAMxgNgt8/t75vLnM9dlB 1l+OQp9gNoVNMd7kk+AYLRoXW7OG7RZ0HJxj2qIw84UW4DHBz4I4jgVmwRNGS27e/sQL HO3WMJD81jYFyWZT44G/YEooG7s6USokfv1/0VdDMcRJNL24ed134xTQM5gOEViNa/D+ Foaw== X-Gm-Message-State: AElRT7HUqREJgM8gYutVQdzaLJIKJEhR6eFKVsadeufMs9MqWfih3c/N EhaLEYcde/f8ok3sA30YGglZsQ== X-Google-Smtp-Source: AG47ELtXV9WCU4k904JcGOzeyTRgaexKQGLjkyLtxpyYSYdUoJeaDBubWqWsNn5p9BL+5VD3hbTxmw== X-Received: by 2002:a25:30d5:: with SMTP id w204-v6mr1150803ybw.459.1520266235770; Mon, 05 Mar 2018 08:10:35 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::1:7aef]) by smtp.googlemail.com with ESMTPSA id l15sm1433782ywk.44.2018.03.05.08.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:10:34 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/84694] ICE on template friend decl Message-ID: Date: Mon, 5 Mar 2018 11:10:33 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 This fixes an ICE with a friend decl. Although the reported source is invalid, we can turn it into valid, but useless, source. ISTM that we should be generating a raw identifier_node here, but finding the TEMPLATE_DECL at parse time. But that's a change for another day. This restores the previous non-crashing behaviour. nathan 2018-03-05 Nathan Sidwell PR c++/84694 * friend.c (do_friend): Restore check for identifier_p inside TEMPLATE_ID_EXPR. PR c++/84694 * g++.dg/template/pr84694.C: New. Index: cp/friend.c =================================================================== --- cp/friend.c (revision 258244) +++ cp/friend.c (working copy) @@ -495,7 +495,8 @@ do_friend (tree ctype, tree declarator, if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR) { declarator = TREE_OPERAND (declarator, 0); - declarator = OVL_NAME (declarator); + if (!identifier_p (declarator)) + declarator = OVL_NAME (declarator); } if (ctype) Index: testsuite/g++.dg/template/pr84694.C =================================================================== --- testsuite/g++.dg/template/pr84694.C (revision 0) +++ testsuite/g++.dg/template/pr84694.C (working copy) @@ -0,0 +1,6 @@ +// PR c++84694 ICE on friend decl +template +struct a { + template void b(); + friend void b<0>(); // ICEd with useless friend decl +};