From f4886d807d0773e6b35538446b098be8f2c88d49 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 2 Dec 2015 16:41:02 +0000 Subject: [PATCH] re PR c++/68290 (g++.dg/concepts/auto1.C FAILs) PR c++/68290 * constraint.cc (make_constrained_auto): Move to... * pt.c (make_auto_1): Add set_canonical parameter and set TYPE_CANONICAL on the type only if it is true. (make_decltype_auto): Adjust call to make_auto_1. (make_auto): Likewise. (splice_late_return_type): Likewise. (make_constrained_auto): ...here. Call make_auto_1 instead of make_auto and pass false. Set TYPE_CANONICAL directly. From-SVN: r231189 --- gcc/cp/ChangeLog | 12 ++++++++++++ gcc/cp/constraint.cc | 26 -------------------------- gcc/cp/pt.c | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d2a7e99c63f..f5f97070fac 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2015-12-02 Eric Botcazou + + PR c++/68290 + * constraint.cc (make_constrained_auto): Move to... + * pt.c (make_auto_1): Add set_canonical parameter and set + TYPE_CANONICAL on the type only if it is true. + (make_decltype_auto): Adjust call to make_auto_1. + (make_auto): Likewise. + (splice_late_return_type): Likewise. + (make_constrained_auto): ...here. Call make_auto_1 instead of + make_auto and pass false. Set TYPE_CANONICAL directly. + 2015-12-02 Thomas Schwinge * parser.c (cp_parser_omp_clause_name) diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index c6eaf754606..71e3e0d6f1c 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1353,32 +1353,6 @@ finish_template_introduction (tree tmpl_decl, tree intro_list) } -/* Make a "constrained auto" type-specifier. This is an - auto type with constraints that must be associated after - deduction. The constraint is formed from the given - CONC and its optional sequence of arguments, which are - non-null if written as partial-concept-id. */ -tree -make_constrained_auto (tree con, tree args) -{ - tree type = make_auto(); - - /* Build the constraint. */ - tree tmpl = DECL_TI_TEMPLATE (con); - tree expr; - if (VAR_P (con)) - expr = build_concept_check (tmpl, type, args); - else - expr = build_concept_check (build_overload (tmpl, NULL_TREE), type, args); - - tree constr = make_predicate_constraint (expr); - PLACEHOLDER_TYPE_CONSTRAINTS (type) = constr; - - /* Attach the constraint to the type declaration. */ - tree decl = TYPE_NAME (type); - return decl; -} - /* Given the predicate constraint T from a constrained-type-specifier, extract its TMPL and ARGS. FIXME why do we need two different forms of constrained-type-specifier? */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d1d1e4e9a6c..8435ddc224a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23469,10 +23469,10 @@ make_args_non_dependent (vec *args) /* Returns a type which represents 'auto' or 'decltype(auto)'. We use a TEMPLATE_TYPE_PARM with a level one deeper than the actual template - parms. */ + parms. If set_canonical is true, we set TYPE_CANONICAL on it. */ static tree -make_auto_1 (tree name) +make_auto_1 (tree name, bool set_canonical) { tree au = cxx_make_type (TEMPLATE_TYPE_PARM); TYPE_NAME (au) = build_decl (input_location, @@ -23481,7 +23481,8 @@ make_auto_1 (tree name) TEMPLATE_TYPE_PARM_INDEX (au) = build_template_parm_index (0, processing_template_decl + 1, processing_template_decl + 1, TYPE_NAME (au), NULL_TREE); - TYPE_CANONICAL (au) = canonical_type_parameter (au); + if (set_canonical) + TYPE_CANONICAL (au) = canonical_type_parameter (au); DECL_ARTIFICIAL (TYPE_NAME (au)) = 1; SET_DECL_TEMPLATE_PARM_P (TYPE_NAME (au)); @@ -23491,13 +23492,43 @@ make_auto_1 (tree name) tree make_decltype_auto (void) { - return make_auto_1 (get_identifier ("decltype(auto)")); + return make_auto_1 (get_identifier ("decltype(auto)"), true); } tree make_auto (void) { - return make_auto_1 (get_identifier ("auto")); + return make_auto_1 (get_identifier ("auto"), true); +} + +/* Make a "constrained auto" type-specifier. This is an + auto type with constraints that must be associated after + deduction. The constraint is formed from the given + CONC and its optional sequence of arguments, which are + non-null if written as partial-concept-id. */ + +tree +make_constrained_auto (tree con, tree args) +{ + tree type = make_auto_1 (get_identifier ("auto"), false); + + /* Build the constraint. */ + tree tmpl = DECL_TI_TEMPLATE (con); + tree expr; + if (VAR_P (con)) + expr = build_concept_check (tmpl, type, args); + else + expr = build_concept_check (build_overload (tmpl, NULL_TREE), type, args); + + tree constr = make_predicate_constraint (expr); + PLACEHOLDER_TYPE_CONSTRAINTS (type) = constr; + + /* Our canonical type depends on the constraint. */ + TYPE_CANONICAL (type) = canonical_type_parameter (type); + + /* Attach the constraint to the type declaration. */ + tree decl = TYPE_NAME (type); + return decl; } /* Given type ARG, return std::initializer_list. */ @@ -23813,7 +23844,7 @@ splice_late_return_type (tree type, tree late_return_type) /* In an abbreviated function template we didn't know we were dealing with a function template when we saw the auto return type, so update it to have the correct level. */ - return make_auto_1 (TYPE_IDENTIFIER (type)); + return make_auto_1 (TYPE_IDENTIFIER (type), true); } return type; }