From 7d066bd55675e55cdb7317ae664128c5c78b689b Mon Sep 17 00:00:00 2001 From: asutton Date: Wed, 22 Apr 2015 13:59:04 +0000 Subject: [PATCH] 2015-04-22 Andrew Sutton Compare constrained partial specializations structurally. * gcc/pt.c (process_partial_specialization): Don't use a canonical type for constrained partial template specializations. Compare structurally to avoid ICE's when specializations resolve differently. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/c++-concepts@222323 138bc75d-0d04-0410-961f-82ee72b054a4 --- ChangeLog.concepts | 8 ++++++++ gcc/cp/pt.c | 36 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ChangeLog.concepts b/ChangeLog.concepts index 4c1ec8fb026..8aa835ecd03 100644 --- a/ChangeLog.concepts +++ b/ChangeLog.concepts @@ -1,3 +1,11 @@ +2015-04-22 Andrew Sutton + + Compare constrained partial specializations structurally. + * gcc/pt.c (process_partial_specialization): Don't use a + canonical type for constrained partial template specializations. + Compare structurally to avoid ICE's when specializations resolve + differently. + 2015-04-20 Andrew Sutton PR65681 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d3e64f30e7a..5547a6c0499 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4420,25 +4420,25 @@ process_partial_specialization (tree decl) return error_mark_node; } - // When defining a constrained partial specialization, DECL's type - // will have been assigned to the canonical type of the primary. - // That is: - // - // template - // struct S; // Has canonical type S - // - // template - // requires C - // struct S; // binds to the primary template. - // - // However, the the constraints differ, so we should be constructing - // a new type. We do this by making the DECL's type its own - // canonical type. - // - // TODO: Do we need to compare the current requirements to make - // sure this isn't a redeclaration? + /* When defining a constrained partial specialization, DECL's type + will have been assigned to the canonical type of the primary. + That is: + + template + struct S; // Has canonical type S + + template + struct S; // Binds to the primary template. + + However, the constraints differ, so we should be constructing + a new type instead of simply referring to the old one. We + do this by erasing the canonical type of the partial + specialization and always comparing these types structurally. + + TODO: Do we need to compare the current requirements to make + sure this isn't a redeclaration? */ if (TEMPLATE_PARM_CONSTRAINTS (current_template_parms)) - TYPE_CANONICAL (type) = type; + SET_TYPE_STRUCTURAL_EQUALITY (type); inner_parms = INNERMOST_TEMPLATE_PARMS (current_template_parms); ntparms = TREE_VEC_LENGTH (inner_parms); -- 2.11.4.GIT