public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8633] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] Date: Sun, 21 Apr 2024 04:09:27 +0000 (GMT) [thread overview] Message-ID: <20240421040927.4AB0D3858C60@sourceware.org> (raw) https://gcc.gnu.org/g:2c85e8def0efd4b0d9d312a1f0cbbee332b4e0d1 commit r13-8633-g2c85e8def0efd4b0d9d312a1f0cbbee332b4e0d1 Author: Jakub Jelinek <jakub@redhat.com> Date: Mon Apr 15 10:25:22 2024 +0200 attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] The enumerator still doesn't have TREE_TYPE set but diag_attr_exclusions assumes that all decls must have types. I think it is better in something as unimportant as diag_attr_exclusions to be more robust, if there is no type, it can just diagnose exclusions on the DECL_ATTRIBUTES, like for types it only diagnoses it on TYPE_ATTRIBUTES. 2024-04-15 Jakub Jelinek <jakub@redhat.com> PR c++/114634 * attribs.cc (diag_attr_exclusions): Set attrs[1] to NULL_TREE for decls with NULL TREE_TYPE. * g++.dg/ext/attrib68.C: New test. (cherry picked from commit 7ec54f5fdfec298812a749699874db4d6a7246bb) Diff: --- gcc/attribs.cc | 7 ++++++- gcc/testsuite/g++.dg/ext/attrib68.C | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/attribs.cc b/gcc/attribs.cc index 080b95928eb..24818c76f70 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -480,7 +480,12 @@ diag_attr_exclusions (tree last_decl, tree node, tree attrname, if (DECL_P (node)) { attrs[0] = DECL_ATTRIBUTES (node); - attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node)); + if (TREE_TYPE (node)) + attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node)); + else + /* TREE_TYPE can be NULL e.g. while processing attributes on + enumerators. */ + attrs[1] = NULL_TREE; } else { diff --git a/gcc/testsuite/g++.dg/ext/attrib68.C b/gcc/testsuite/g++.dg/ext/attrib68.C new file mode 100644 index 00000000000..be3b1108491 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib68.C @@ -0,0 +1,8 @@ +// PR c++/114634 +// { dg-do compile } + +template <int N> +struct A +{ + enum { e __attribute__ ((aligned (16))) }; // { dg-error "alignment may not be specified for 'e'" } +};
reply other threads:[~2024-04-21 4:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240421040927.4AB0D3858C60@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).