From patchwork Wed Jan 29 09:31:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1230759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518470-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.a=rsa-sha1 header.s=default header.b=Va/QEoNw; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2019-08-05 header.b=kfwWGm/p; 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 486ytL5MBjz9sNT for ; Wed, 29 Jan 2020 20:31:53 +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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=l7LQ2E3bAZ/4qOLjp18CoE8nu0v2CznNogY3vhkxV/G9vrGHqT /A171dSyjGNyroy4zWh8M8VO3zf/MOy529mVTIZfgPthh6USQkQ1hfYTui21hZGj mAcY/zIR6Ru4QBQvND79sPH6QJ0yzd7CeISgHiKIfGS55Y1LKQ1O207uc= 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=+MLZaBaBJkCzXIwg4LyMkGs7Fec=; b=Va/QEoNwoAjhrb2nzS/A 3v1tfPdRVHtrMmJMUUnXmgSr+hEW2fspcxqQdvKIZeqAt3CUdKt6e10kAWk49o3d 0ayZaIjzNWpHUdoa0WRU7SqJCqyv2zr1VC4kxbvIsk37iJ2XcCT2PCJOukGf7DUn kwI60JeJNO8QCCtCeweb01c= Received: (qmail 69263 invoked by alias); 29 Jan 2020 09:31:45 -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 69248 invoked by uid 89); 29 Jan 2020 09:31:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*r:8.13.8 X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Jan 2020 09:31:41 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00T9UgL2007800; Wed, 29 Jan 2020 09:31:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=6kcRg8cpfkjjrW6m1spid+Kq8gbOEPhrBzssKwjihcs=; b=kfwWGm/pAWCdfLbEktFBox5FpMO4Nbc0y8nGO2g8giwoQcd2ECB2PPJKXWdmaonNfKsM 0sa2EOBhJnFsfrEjCTtI5kW548y0mPTfPfMB1F7Ve5qAW8DhDImTl33uaeEA9VZBy15d 44p99I2Z+IFkULO+MgSOptFYfQxxN8OUDpy+TFN/+p7DN2K2ue3SxsG986tqn2EsCSe8 mkJMXL+/OymGecd2KNFd5bQoqNp3D7TxuBJMj0tqhVRQG8FKxRJqp7WJfitURGxZiGxP d/6vtl3t78vr+mpg8o4NQtyWWccgTySUHbMHiWK91U5jOu/BcnorSoHUCBdNrM07KXhe QA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2xrdmqkpmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jan 2020 09:31:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00T9O60M102422; Wed, 29 Jan 2020 09:31:38 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2xth5jrfr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jan 2020 09:31:38 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 00T9VbjG017374; Wed, 29 Jan 2020 09:31:37 GMT Received: from [192.168.1.4] (/87.13.210.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Jan 2020 01:31:36 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 90915 [9/10 Regression] ICE in has_attribute, at c-family/c-attribs.c:4221 Message-ID: Date: Wed, 29 Jan 2020 10:31:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this regression we issue a diagnostic about an incomplete type (only a warning by default) and then we crash when we try to query has_attribute on a member of the type because in such cases the member remains an IDENTIFIER_NODE which of course doesn't have a TREE_TYPE neither a DECL_ATTRIBUTES... Simply recognizing IDENTIFIER_NODEs and returning false works fine, not sure if we want to do something more sophisticated. Tested x86_64-linux. Thanks, Paolo. //////////////////////// Fix "PR c++/90915 ICE in has_attribute, at c-family/c-attribs.c:4221" A rather simple ICE where we didn't properly recover upon diagnosing an incomplete type. Tested x86_64-linux. /c-family PR c++/90915 * c-attribs.c (has_attribute): Handle correctly IDENTIFIER_NODEs. /testsuite PR c++/90915 * g++.dg/ext/builtin-has-attribute-1.C: New. diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index dc9579c5c60..97590a19c0f 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -4759,6 +4759,10 @@ has_attribute (location_t atloc, tree t, tree attr, tree (*convert)(tree)) expr = NULL_TREE; done = true; } + else if (TREE_CODE (expr) == IDENTIFIER_NODE) + /* Can happen during error-recovery when querying a member of + an incomplete type (c++/90915). */ + return false; else if (DECL_P (expr)) { /* Set TYPE to the DECL's type to process it on the next diff --git a/gcc/testsuite/g++.dg/ext/builtin-has-attribute-1.C b/gcc/testsuite/g++.dg/ext/builtin-has-attribute-1.C new file mode 100644 index 00000000000..3d81a078159 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin-has-attribute-1.C @@ -0,0 +1,7 @@ +// { dg-do compile { target c++11 } } + +struct S; +template struct T +{ + static_assert (!__builtin_has_attribute (((S *) 0) -> a, packed), ""); // { dg-error "invalid use of incomplete type" } +};