summaryrefslogtreecommitdiff
path: root/gcc/attribs.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-05-05 11:03:44 -0400
committerJason Merrill <jason@redhat.com>2022-05-16 17:32:46 -0400
commited12749a3c9d9569a2c23df2e0db2136dcd3512d (patch)
tree59dcadc8531bd38bb052c0ffdd4e5c0b40210f73 /gcc/attribs.cc
parent2402dc6b982c4dacac2360830f0edc123c588110 (diff)
downloadgcc-ed12749a3c9d9569a2c23df2e0db2136dcd3512d.tar.gz
attribs: fix typedefs in generic code [PR105492]
In my patch for PR100545 I added an assert to check for broken typedefs in set_underlying_type, and it found one in this case: rs6000_handle_altivec_attribute had the same problem as handle_mode_attribute. So let's move the fixup into decl_attributes. PR c/105492 gcc/ChangeLog: * attribs.cc (decl_attributes): Fix broken typedefs here. gcc/c-family/ChangeLog: * c-attribs.cc (handle_mode_attribute): Don't fix broken typedefs here.
Diffstat (limited to 'gcc/attribs.cc')
-rw-r--r--gcc/attribs.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/attribs.cc b/gcc/attribs.cc
index 6d4a30dc412..fb89616ff29 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -872,6 +872,21 @@ decl_attributes (tree *node, tree attributes, int flags,
tree ret = (spec->handler) (cur_and_last_decl, name, args,
flags|cxx11_flag, &no_add_attrs);
+ /* Fix up typedefs clobbered by attribute handlers. */
+ if (TREE_CODE (*node) == TYPE_DECL
+ && anode == &TREE_TYPE (*node)
+ && DECL_ORIGINAL_TYPE (*node)
+ && TYPE_NAME (*anode) == *node
+ && TYPE_NAME (cur_and_last_decl[0]) != *node)
+ {
+ tree t = cur_and_last_decl[0];
+ DECL_ORIGINAL_TYPE (*node) = t;
+ tree tt = build_variant_type_copy (t);
+ cur_and_last_decl[0] = tt;
+ TREE_TYPE (*node) = tt;
+ TYPE_NAME (tt) = *node;
+ }
+
*anode = cur_and_last_decl[0];
if (ret == error_mark_node)
{