From: Qing Zhao <qing.zhao@oracle.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"msebor@gmail.com" <msebor@gmail.com>,
"jakub@redhat.com" <jakub@redhat.com>,
"rguenther@suse.de" <rguenther@suse.de>,
"keescook@chromium.org" <keescook@chromium.org>
Subject: Re: [GCC13][Patch][V5][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array
Date: Wed, 5 Oct 2022 14:04:08 +0000 [thread overview]
Message-ID: <23922B67-785E-4A10-9086-0E1F4A95BB92@oracle.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2210041735270.850856@digraph.polyomino.org.uk>
> On Oct 4, 2022, at 1:37 PM, Joseph Myers <joseph@codesourcery.com> wrote:
>
> 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.
Okay, so, you mean I need to require the attribute to be applied to a declaration as following:
{ "strict_flex_array", 1, 1, true, false, false, false,
handle_strict_flex_array_attribute, NULL },
?
Then when the attribute is attached to the type of the decl, the ICE will not happen? (Yes, I tried, and the ICE was replaced with the following warning:
/home/opc/Install/lates/bin/gcc t.c
t.c:1:1: warning: ‘strict_flex_array’ attribute does not apply to types [-Wattributes]
1 | int [[gnu::strict_flex_array(1)]] x;
| ^~~
Thanks, I will update the patch with this.
Let me know if you have more comments.
Qing
>
>> +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
next prev parent reply other threads:[~2022-10-05 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 15:21 [PATCH 0/2] [GCC13][Patch][V5][PATCH 0/2] Add a new option -fstrict-flex-arrays[=n] and attribute strict_flex_array(n) and use it in PR101836 Qing Zhao
2022-10-04 15:21 ` [GCC13][Patch][V5][PATCH 1/2] Add a new option -fstrict-flex-arrays[=n] and new attribute strict_flex_array Qing Zhao
2022-10-04 17:37 ` Joseph Myers
2022-10-05 14:04 ` Qing Zhao [this message]
2022-10-04 15:21 ` [GCC13][Patch][V5][PATCH 2/2] Use array_at_struct_end_p in __builtin_object_size [PR101836] Qing Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23922B67-785E-4A10-9086-0E1F4A95BB92@oracle.com \
--to=qing.zhao@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
--cc=keescook@chromium.org \
--cc=msebor@gmail.com \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).