public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-802] c-family: fix attribute constructor ICE [PR90658]
@ 2022-05-27 15:56 Marek Polacek
0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-05-27 15:56 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ca4b95069ca7dbf0be3a5aae053631e7a1b20103
commit r13-802-gca4b95069ca7dbf0be3a5aae053631e7a1b20103
Author: Marek Polacek <polacek@redhat.com>
Date: Thu May 26 18:59:44 2022 -0400
c-family: fix attribute constructor ICE [PR90658]
Here the C compiler crashes because a FUNCTION_DECL got into
get_priority -> default_conversion, and the C FE's version of d_c
specifically asserts that it doesn't get a FUNCTION_DECL. All uses
of default_conversion in c-attribs.cc are guarded by != IDENTIFIER_NODE
&& != FUNCTION_DECL, but get_priority was only checking IDENTIFIER_NODE.
PR c/90658
gcc/c-family/ChangeLog:
* c-attribs.cc (get_priority): Check FUNCTION_DECL.
gcc/testsuite/ChangeLog:
* c-c++-common/attr-cdtor-1.c: New test.
Diff:
---
gcc/c-family/c-attribs.cc | 2 +-
gcc/testsuite/c-c++-common/attr-cdtor-1.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 4dc68dbe82a..c8d96723f4c 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -1895,7 +1895,7 @@ get_priority (tree args, bool is_destructor)
}
arg = TREE_VALUE (args);
- if (TREE_CODE (arg) == IDENTIFIER_NODE)
+ if (TREE_CODE (arg) == IDENTIFIER_NODE || TREE_CODE (arg) == FUNCTION_DECL)
goto invalid;
if (arg == error_mark_node)
return DEFAULT_INIT_PRIORITY;
diff --git a/gcc/testsuite/c-c++-common/attr-cdtor-1.c b/gcc/testsuite/c-c++-common/attr-cdtor-1.c
new file mode 100644
index 00000000000..ea61336c404
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-cdtor-1.c
@@ -0,0 +1,6 @@
+/* PR c/90658 */
+/* { dg-do compile } */
+
+void f ();
+void g1 () __attribute__ ((constructor(f))); /* { dg-error "priorities must be integers" } */
+void g2 () __attribute__ ((destructor(f))); /* { dg-error "priorities must be integers" } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-27 15:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 15:56 [gcc r13-802] c-family: fix attribute constructor ICE [PR90658] Marek Polacek
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).