* [PATCH] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]
@ 2024-04-15 8:04 Jakub Jelinek
2024-04-15 8:09 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-04-15 8:04 UTC (permalink / raw)
To: Richard Biener, Joseph S. Myers, Jason Merrill; +Cc: gcc-patches
Hi!
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.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
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.
--- gcc/attribs.cc.jj 2024-02-12 20:44:52.409074876 +0100
+++ gcc/attribs.cc 2024-04-12 18:29:52.000381917 +0200
@@ -468,7 +468,10 @@ diag_attr_exclusions (tree last_decl, tr
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
+ attrs[1] = NULL_TREE;
}
else
{
--- gcc/testsuite/g++.dg/ext/attrib68.C.jj 2024-04-12 18:31:38.100968098 +0200
+++ gcc/testsuite/g++.dg/ext/attrib68.C 2024-04-12 18:30:57.011515625 +0200
@@ -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'" }
+};
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]
2024-04-15 8:04 [PATCH] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] Jakub Jelinek
@ 2024-04-15 8:09 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-04-15 8:09 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Joseph S. Myers, Jason Merrill, gcc-patches
On Mon, 15 Apr 2024, Jakub Jelinek wrote:
> Hi!
>
> 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.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK, but can you add a comment?
Thanks,
Richard.
> 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.
>
> --- gcc/attribs.cc.jj 2024-02-12 20:44:52.409074876 +0100
> +++ gcc/attribs.cc 2024-04-12 18:29:52.000381917 +0200
> @@ -468,7 +468,10 @@ diag_attr_exclusions (tree last_decl, tr
> 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
> + attrs[1] = NULL_TREE;
> }
> else
> {
> --- gcc/testsuite/g++.dg/ext/attrib68.C.jj 2024-04-12 18:31:38.100968098 +0200
> +++ gcc/testsuite/g++.dg/ext/attrib68.C 2024-04-12 18:30:57.011515625 +0200
> @@ -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'" }
> +};
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-15 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15 8:04 [PATCH] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] Jakub Jelinek
2024-04-15 8:09 ` Richard Biener
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).