From aabdb83166b53a13956071f0e01f841a184340f7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 6 Dec 2015 23:34:51 -0500 Subject: [PATCH] Fix memclass5.C, memfriend10.C, var-templ19.C with -std=c++1z. * constraint.cc (strictly_subsumes): New. * cp-tree.h: Declare it. * pt.c (process_partial_specialization): Use it instead of subsumes_constraints. (maybe_new_partial_specialization): Do compare null constraints. * search.c (lookup_member): Handle currently_open_class returning null. From-SVN: r231350 --- gcc/cp/ChangeLog | 9 ++++++++- gcc/cp/constraint.cc | 9 +++++++++ gcc/cp/cp-tree.h | 1 + gcc/cp/pt.c | 8 +++++--- gcc/cp/search.c | 3 ++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c04ea0133b..310cdba837b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,4 +1,11 @@ -2015-12-05 Jason Merrill +2015-12-06 Jason Merrill + + * constraint.cc (strictly_subsumes): New. + * cp-tree.h: Declare it. + * pt.c (process_partial_specialization): Use it instead of + subsumes_constraints. + (maybe_new_partial_specialization): Do compare null constraints. + * search.c (lookup_member): Handle currently_open_class returning null. PR c++/68597, fix auto9.C and auto-neg1.C with -std=c++1z. * decl.c (check_tag_decl): Use ds_type_spec in auto diagnostic. diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 71e3e0d6f1c..89da6ecbf79 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2314,6 +2314,15 @@ subsumes_constraints (tree a, tree b) return subsumes (a, b); } +/* Returns true when the the constraints in A subsume those in B, but + the constraints in B do not subsume the constraints in A. */ + +bool +strictly_subsumes (tree a, tree b) +{ + return subsumes (a, b) && !subsumes (b, a); +} + /* Determines which of the declarations, A or B, is more constrained. That is, which declaration's constraints subsume but are not subsumed by the other's? diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6ddab8a57cf..1b2563d00ee 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6866,6 +6866,7 @@ extern bool constraints_satisfied_p (tree, tree); extern bool equivalent_constraints (tree, tree); extern bool equivalently_constrained (tree, tree); extern bool subsumes_constraints (tree, tree); +extern bool strictly_subsumes (tree, tree); extern int more_constrained (tree, tree); extern void diagnose_constraints (location_t, tree, tree); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6e50fcd1ee9..22dcee281ba 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -860,9 +860,11 @@ maybe_new_partial_specialization (tree type) tree type_constr = current_template_constraints (); if (type == TREE_TYPE (tmpl)) - if (tree main_constr = get_constraints (tmpl)) + { + tree main_constr = get_constraints (tmpl); if (equivalent_constraints (type_constr, main_constr)) return NULL_TREE; + } // Also, if there's a pre-existing specialization with matching // constraints, then this also isn't new. @@ -4508,8 +4510,8 @@ process_partial_specialization (tree decl) = TI_ARGS (get_template_info (DECL_TEMPLATE_RESULT (maintmpl))); if (comp_template_args (inner_args, INNERMOST_TEMPLATE_ARGS (main_args)) && (!flag_concepts - || !subsumes_constraints (current_template_constraints (), - get_constraints (maintmpl)))) + || !strictly_subsumes (current_template_constraints (), + get_constraints (maintmpl)))) { if (!flag_concepts) error ("partial specialization %q+D does not specialize " diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0c11a8318cb..05a45c3fbfb 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1271,7 +1271,8 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, /* Make sure we're looking for a member of the current instantiation in the right partial specialization. */ if (flag_concepts && dependent_type_p (type)) - type = currently_open_class (type); + if (tree t = currently_open_class (type)) + type = t; if (!basetype_path) basetype_path = TYPE_BINFO (type); -- 2.30.2