Commit 12f71313 by Nathan Sidwell Committed by Nathan Sidwell

[C++ PATCH] class member ordering

https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01426.html
	* name-lookup.c (member_name_cmp): Use DECL_UID for final
	ordering.

From-SVN: r253048
parent 9ed32e27
2017-09-20 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (member_name_cmp): Use DECL_UID for final
ordering.
2017-09-20 Jakub Jelinek <jakub@redhat.com> 2017-09-20 Jakub Jelinek <jakub@redhat.com>
P0409R2 - allow lambda capture [=, this] P0409R2 - allow lambda capture [=, this]
......
...@@ -1434,29 +1434,38 @@ member_name_cmp (const void *a_p, const void *b_p) ...@@ -1434,29 +1434,38 @@ member_name_cmp (const void *a_p, const void *b_p)
b = OVL_FUNCTION (b); b = OVL_FUNCTION (b);
/* We're in STAT_HACK or USING_DECL territory (or possibly error-land). */ /* We're in STAT_HACK or USING_DECL territory (or possibly error-land). */
if (TREE_CODE (a) == TREE_CODE (b)) if (TREE_CODE (a) != TREE_CODE (b))
/* We can get two TYPE_DECLs or two USING_DECLs. Place in source {
order. */ /* If one of them is a TYPE_DECL, it loses. */
return DECL_SOURCE_LOCATION (a) < DECL_SOURCE_LOCATION (b) ? -1 : +1; if (TREE_CODE (a) == TYPE_DECL)
return +1;
/* If one of them is a TYPE_DECL, it loses. */ else if (TREE_CODE (b) == TYPE_DECL)
if (TREE_CODE (a) == TYPE_DECL) return -1;
return +1;
else if (TREE_CODE (b) == TYPE_DECL) /* If one of them is a USING_DECL, it loses. */
return -1; if (TREE_CODE (a) == USING_DECL)
return +1;
/* If one of them is a USING_DECL, it loses. */ else if (TREE_CODE (b) == USING_DECL)
if (TREE_CODE (a) == USING_DECL) return -1;
return +1;
else if (TREE_CODE (b) == USING_DECL) /* There are no other cases with different kinds of decls, as
return -1; duplicate detection should have kicked in earlier. However,
some erroneous cases get though. */
/* There are no other cases, as duplicate detection should have gcc_assert (errorcount);
kicked in earlier. However, some erroneous cases get though. }
Order by source location. We should really prevent this
happening. */ /* Using source location would be the best thing here, but we can
gcc_assert (errorcount); get identically-located decls in the following circumstances:
return DECL_SOURCE_LOCATION (a) < DECL_SOURCE_LOCATION (b) ? -1 : +1;
1) duplicate artificial type-decls for the same type.
2) pack expansions of using-decls.
We should not be doing #1, but in either case it doesn't matter
how we order these. Use UID as a proxy for source ordering, so
that identically-located decls still have a well-defined stable
ordering. */
return DECL_UID (a) < DECL_UID (b) ? -1 : +1;
} }
static struct { static struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment