On 09/12/2017 12:06 PM, Joseph Myers wrote:
On Tue, 12 Sep 2017, Nathan Sidwell wrote:
This patch removes that checking, and also asserts that when we see
identically named decls, exactly one is a TYPE_DECL.
When do you get TYPE_DECLs here, for C? I wouldn't expect them to be
possible.
oh, of course (C is so primitive!). This patch survives a bootstrap, ok?
nathan
--
Nathan Sidwell
2017-09-12 Nathan Sidwell <nat...@acm.org>
* c-decl.c (field_decl_cmp): Don't handle NULL or equal names.
Index: c-decl.c
===================================================================
--- c-decl.c (revision 252023)
+++ c-decl.c (working copy)
@@ -7845,19 +7845,11 @@ warn_cxx_compat_finish_struct (tree fiel
static int
field_decl_cmp (const void *x_p, const void *y_p)
{
- const tree *const x = (const tree *) x_p;
- const tree *const y = (const tree *) y_p;
+ const tree x = *(const tree *) x_p;
+ const tree y = *(const tree *) y_p;
- if (DECL_NAME (*x) == DECL_NAME (*y))
- /* A nontype is "greater" than a type. */
- return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL);
- if (DECL_NAME (*x) == NULL_TREE)
- return -1;
- if (DECL_NAME (*y) == NULL_TREE)
- return 1;
- if (DECL_NAME (*x) < DECL_NAME (*y))
- return -1;
- return 1;
+ gcc_checking_assert (DECL_NAME (x) != DECL_NAME (y));
+ return DECL_NAME (x) < DECL_NAME (y) ? -1 : +1;
}
/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.