From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E76BC3858C50 for ; Tue, 4 Oct 2022 17:37:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E76BC3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.95,158,1661846400"; d="scan'208";a="84182357" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 04 Oct 2022 09:37:47 -0800 IronPort-SDR: s2HfGjqZIKnB9jlvZboHJEDzX5jCiSB03qlu5aaPEc2vN5+B6lf7QVoURmIsRxsjc2auDAnp8X ziqmddN5tk4IvQiaWq/vfivZfq4yG+zhDPraIDxKy96yrbf2aN3dZZlN+eJWtkSLkunfM3Itaq PVKplh1j5wVwblz8vyCEtfAFaQnutmHhCrfGGFLgKjUdyi2TFRnZKd89eNnR470+GP6TQVLDxW luvsBUsCUXHfRvbW9w2HBd3PM+feFV5OgGUXMu1ZnC5K6g7+r2hA72NKo8Le2YYb/Qq3Y9h51B n58= Date: Tue, 4 Oct 2022 17:37:42 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Qing Zhao CC: , , , , Subject: Re: [GCC13][Patch][V5][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array In-Reply-To: <20221004152154.1665626-2-qing.zhao@oracle.com> Message-ID: References: <20221004152154.1665626-1-qing.zhao@oracle.com> <20221004152154.1665626-2-qing.zhao@oracle.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3110.9 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 4 Oct 2022, Qing Zhao via Gcc-patches wrote: > + { "strict_flex_array", 1, 1, false, false, false, false, > + handle_strict_flex_array_attribute, NULL }, You're not requiring that the attribute be applied to a declaration here. > +static tree > +handle_strict_flex_array_attribute (tree *node, tree name, > + tree args, int ARG_UNUSED (flags), > + bool *no_add_attrs) > +{ > + tree decl = *node; > + tree argval = TREE_VALUE (args); > + > + /* This attribute only applies to field decls of a structure. */ > + if (TREE_CODE (decl) != FIELD_DECL) > + { > + error_at (DECL_SOURCE_LOCATION (decl), > + "%qE attribute may not be specified for %q+D", name, decl); But here you're using DECL_SOURCE_LOCATION on what might be a type, not a DECL. So if you have a test such as int [[gnu::strict_flex_array(1)]] x; that applies the attribute to a type, you get an ICE: t.c:1:1: internal compiler error: tree check: expected tree that contains 'decl minimal' structure, have 'integer_type' in handle_strict_flex_array_attribute, at c-family/c-attribs.cc:2526 1 | int [[gnu::strict_flex_array(1)]] x; | ^~~ -- Joseph S. Myers joseph@codesourcery.com