From e6d4ff7f90c253f00702462105613afb4581a3f2 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 2 Apr 2004 11:48:56 +0000 Subject: cp: PR c++/14007 * pt.c (check_cv_quals_for_unify): Correct logic for disallowed cv-qualifier unification. * tree.c (cp_build_qualified_type_real): Renable DR295 logic. testsuite: PR c++/14007 * g++.dg/template/unify5.C: New. * g++.dg/template/unify6.C: New. * g++.dg/template/qualttp20.C: Adjust. * g++.old-deja/g++.jason/report.C: Adjust. * g++.old-deja/g++.other/qual1.C: Adjust. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@80351 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/pt.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'gcc/cp/pt.c') diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b096017430e..fd38b0a381c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9543,7 +9543,7 @@ template_decl_level (tree decl) /* Decide whether ARG can be unified with PARM, considering only the cv-qualifiers of each type, given STRICT as documented for unify. - Returns nonzero iff the unification is OK on that basis.*/ + Returns nonzero iff the unification is OK on that basis. */ static int check_cv_quals_for_unify (int strict, tree arg, tree parm) @@ -9553,15 +9553,22 @@ check_cv_quals_for_unify (int strict, tree arg, tree parm) if (TREE_CODE (parm) == TEMPLATE_TYPE_PARM) { - /* If the cvr quals of parm will not unify with ARG, they'll be - ignored in instantiation, so we have to do the same here. */ - if (TREE_CODE (arg) == REFERENCE_TYPE) - parm_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); - if (!POINTER_TYPE_P (arg) && - TREE_CODE (arg) != TEMPLATE_TYPE_PARM) - parm_quals &= ~TYPE_QUAL_RESTRICT; + /* Although a CVR qualifier is ignored when being applied to a + substituted template parameter ([8.3.2]/1 for example), that + does not apply during deduction [14.8.2.4]/1, (even though + that is not explicitly mentioned, [14.8.2.4]/9 indicates + this). */ + if ((TREE_CODE (arg) == REFERENCE_TYPE + || TREE_CODE (arg) == FUNCTION_TYPE + || TREE_CODE (arg) == METHOD_TYPE) + && (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))) + return 0; + + if ((!POINTER_TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_TYPE_PARM) + && (parm_quals & TYPE_QUAL_RESTRICT)) + return 0; } - + if (!(strict & (UNIFY_ALLOW_MORE_CV_QUAL | UNIFY_ALLOW_OUTER_MORE_CV_QUAL)) && (arg_quals & parm_quals) != parm_quals) return 0; -- cgit v1.2.3