From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id E66CD385042A; Mon, 16 May 2022 21:34:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E66CD385042A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-515] attribs: fix typedefs in generic code [PR105492] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: 2402dc6b982c4dacac2360830f0edc123c588110 X-Git-Newrev: ed12749a3c9d9569a2c23df2e0db2136dcd3512d Message-Id: <20220516213405.E66CD385042A@sourceware.org> Date: Mon, 16 May 2022 21:34:05 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 21:34:06 -0000 https://gcc.gnu.org/g:ed12749a3c9d9569a2c23df2e0db2136dcd3512d commit r13-515-ged12749a3c9d9569a2c23df2e0db2136dcd3512d Author: Jason Merrill Date: Thu May 5 11:03:44 2022 -0400 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. Diff: --- gcc/attribs.cc | 15 +++++++++++++++ gcc/c-family/c-attribs.cc | 10 ---------- 2 files changed, 15 insertions(+), 10 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) { diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index e50e79e0cd1..4dc68dbe82a 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -2215,16 +2215,6 @@ handle_mode_attribute (tree *node, tree name, tree args, TYPE_QUALS (type)); if (TYPE_USER_ALIGN (type)) *node = build_aligned_type (*node, TYPE_ALIGN (type)); - - tree decl = node[2]; - if (decl && TYPE_NAME (type) == decl) - { - /* Set up the typedef all over again. */ - DECL_ORIGINAL_TYPE (decl) = NULL_TREE; - TREE_TYPE (decl) = *node; - set_underlying_type (decl); - *node = TREE_TYPE (decl); - } } return NULL_TREE;