From: Jakub Jelinek Date: Wed, 22 Nov 2017 22:35:52 +0000 (+0100) Subject: re PR c++/82401 (error: qsort comparator non-negative on sorted output: 1 in insert_l... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c19e703de27d0fd94bdf3e3941a4f5b7b72f4e4;p=gcc.git re PR c++/82401 (error: qsort comparator non-negative on sorted output: 1 in insert_late_enum_def_bindings on an invalid code) PR c++/82401 * name-lookup.c (member_name_cmp): Return 0 if a == b. * g++.dg/cpp0x/pr82401.C: New test. From-SVN: r255084 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f97187eaf1c..59e890f6efd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-11-22 Jakub Jelinek + + PR c++/82401 + * name-lookup.c (member_name_cmp): Return 0 if a == b. + 2017-11-22 David Malcolm PR c++/62170 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 7c363b0f935..9f65c4d7992 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1469,7 +1469,10 @@ member_name_cmp (const void *a_p, const void *b_p) 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; + if (DECL_UID (a) != DECL_UID (b)) + return DECL_UID (a) < DECL_UID (b) ? -1 : +1; + gcc_assert (a == b); + return 0; } static struct { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 36867c5990f..726773bee0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-22 Jakub Jelinek + + PR c++/82401 + * g++.dg/cpp0x/pr82401.C: New test. + 2017-11-22 David Malcolm PR tree-optimization/82588 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr82401.C b/gcc/testsuite/g++.dg/cpp0x/pr82401.C new file mode 100644 index 00000000000..52d40e04282 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr82401.C @@ -0,0 +1,16 @@ +// PR c++/82401 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template struct A +{ + enum E : T; + void h (); +}; +template enum A::E : T { e1, e2 }; +template <> enum A::E : long long {}; +template struct C +{ + enum class E : T; +}; +C::E c3 = C::E::e1; // { dg-error "is not a member of" }