aboutsummaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-02-01 09:08:21 -0700
committerMartin Sebor <msebor@redhat.com>2021-02-01 09:09:52 -0700
commit0718336a5284dd5b40fd6691a94d6be93a80f279 (patch)
treeb873cfd81012cb3152afe090d344c4cb7f9aa89b /gcc/attribs.c
parent90c9b2c17688f7be434415e90c5a655a6ecfaa9e (diff)
downloadgcc-0718336a5284dd5b40fd6691a94d6be93a80f279.zip
gcc-0718336a5284dd5b40fd6691a94d6be93a80f279.tar.gz
gcc-0718336a5284dd5b40fd6691a94d6be93a80f279.tar.bz2
Reset front end trees before they make it into the middle end (PR middle-end/97172).
gcc/ChangeLog: PR middle-end/97172 * attribs.c (attr_access::free_lang_data): Define new function. * attribs.h (attr_access::free_lang_data): Declare new function. gcc/c/ChangeLog: PR middle-end/97172 * c-decl.c (free_attr_access_data): New function. (c_parse_final_cleanups): Call free_attr_access_data. gcc/testsuite/ChangeLog: PR middle-end/97172 * gcc.dg/pr97172.c: New test.
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 94991fb..81322d4 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -2238,6 +2238,38 @@ attr_access::vla_bounds (unsigned *nunspec) const
return list_length (size);
}
+/* Reset front end-specific attribute access data from ATTRS.
+ Called from the free_lang_data pass. */
+
+/* static */ void
+attr_access::free_lang_data (tree attrs)
+{
+ for (tree acs = attrs; (acs = lookup_attribute ("access", acs));
+ acs = TREE_CHAIN (acs))
+ {
+ tree vblist = TREE_VALUE (acs);
+ vblist = TREE_CHAIN (vblist);
+ if (!vblist)
+ continue;
+
+ vblist = TREE_VALUE (vblist);
+ if (!vblist)
+ continue;
+
+ for (vblist = TREE_VALUE (vblist); vblist; vblist = TREE_CHAIN (vblist))
+ {
+ tree *pvbnd = &TREE_VALUE (vblist);
+ if (!*pvbnd || DECL_P (*pvbnd))
+ continue;
+
+ /* VLA bounds that are expressions as opposed to DECLs are
+ only used in the front end. Reset them to keep front end
+ trees leaking into the middle end (see pr97172) and to
+ free up memory. */
+ *pvbnd = NULL_TREE;
+ }
+ }
+}
/* Defined in attr_access. */
constexpr char attr_access::mode_chars[];