From patchwork Thu Apr 5 00:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 895231 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-475897-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Vn1ZnCn7"; 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 40GkjC14xVz9s0x for ; Thu, 5 Apr 2018 10:48:44 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Zp2MHyWc1luMSyGh5X8k8yZNCmIdK7x26mRwN0/uHs5FO9UYhu ewU+Zok+/WU9BbHIaSmUP4S3iIK8zgcIPw7NzxJ+7eL28bggqa87WPX5pQAXVyjM 3goAtPkNU+fl7rtGHyCOwWwW1wwDg5UQbq14kxnhQyDf+0jfzFcEvQN1U= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=OuQVR6oXfFtjLExdZGMxqeZdSDs=; b=Vn1ZnCn7Xr+g6TK7/LYj NCqyPc5BCx+UGzH94onNOyC62q2yAXPqKC7fqHShxEFCLq84yYGAAYtfIEdlqRnR FsPmHiZRtP5pAz/9pv6vdoKnt3enGUij/mr1QQlGRO//Hq8XHADtknydCIPe0M0X BI+0ttE3OkaRk5mciPgnkYo= Received: (qmail 83812 invoked by alias); 5 Apr 2018 00:48:36 -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 83696 invoked by uid 89); 5 Apr 2018 00:48:20 -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, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Apr 2018 00:48:19 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w350gjd2046625; Thu, 5 Apr 2018 00:48:08 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2h59gag09d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Apr 2018 00:48:08 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w350m7qc009353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Apr 2018 00:48:07 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w350m64h025437; Thu, 5 Apr 2018 00:48:06 GMT Received: from [192.168.1.4] (/79.53.236.120) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Apr 2018 17:48:05 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 84792 ("[6/7/8 Regression] ICE with broken typedef of a struct") Message-ID: <535f57c0-d193-adfc-a3b9-6a0407e0d731@oracle.com> Date: Thu, 5 Apr 2018 02:48:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8853 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804040235 X-IsSubscribed: yes Hi, I'm really happy to report that these 5 ugly lines are causing an actual bug. Seriously, not considering the formatting, the problem is that we really want to keep 'type' in sync, because we are using it below before returning. Note that we don't regress location-wise because either explicitly or implicitly we pass input_location anyway. Finishing testing on x86_64-linux. Thanks, Paolo. //////////////////// /cp 2018-04-04 Paolo Carlini PR c++/84792 * decl.c (grokdeclarator): Fix diagnostic about typedef name used as nested-name-specifier, keep type and TREE_TYPE (decl) in sync. /testsuite 2018-04-04 Paolo Carlini PR c++/84792 * g++.dg/other/pr84792-1.C: New. * g++.dg/other/pr84792-2.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 259104) +++ cp/decl.c (working copy) @@ -11746,15 +11746,16 @@ grokdeclarator (const cp_declarator *declarator, if (reqs) error_at (location_of (reqs), "requires-clause on typedef"); + if (id_declarator && declarator->u.id.qualifying_scope) + { + error ("typedef name may not be a nested-name-specifier"); + type = error_mark_node; + } + if (decl_context == FIELD) decl = build_lang_decl (TYPE_DECL, unqualified_id, type); else decl = build_decl (input_location, TYPE_DECL, unqualified_id, type); - if (id_declarator && declarator->u.id.qualifying_scope) { - error_at (DECL_SOURCE_LOCATION (decl), - "typedef name may not be a nested-name-specifier"); - TREE_TYPE (decl) = error_mark_node; - } if (decl_context != FIELD) { Index: testsuite/g++.dg/other/pr84792-1.C =================================================================== --- testsuite/g++.dg/other/pr84792-1.C (nonexistent) +++ testsuite/g++.dg/other/pr84792-1.C (working copy) @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + virtual void foo() {} +} A::B; // { dg-error "typedef" } Index: testsuite/g++.dg/other/pr84792-2.C =================================================================== --- testsuite/g++.dg/other/pr84792-2.C (nonexistent) +++ testsuite/g++.dg/other/pr84792-2.C (working copy) @@ -0,0 +1,6 @@ +struct A {}; + +typedef struct +{ + void foo() {} +} A::B; // { dg-error "typedef" }