aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-01-19 09:19:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-01-19 09:19:33 +0000
commit08c2df0f4f04b0f799842f66b68d17dce626fe02 (patch)
tree7866b0a2dd5a3c3597bc91f87af4213a7e468b4a /gcc/cp/pt.c
parent7c6a32d25bba2da41f3eea80f1d96a439f3c6b6d (diff)
downloadgcc-08c2df0f4f04b0f799842f66b68d17dce626fe02.zip
gcc-08c2df0f4f04b0f799842f66b68d17dce626fe02.tar.gz
gcc-08c2df0f4f04b0f799842f66b68d17dce626fe02.tar.bz2
pt.c (copy_default_args_to_explicit_spec): Preserve object's CV quals.
cp: * pt.c (copy_default_args_to_explicit_spec): Preserve object's CV quals. Reorganize. testsuite: * g++.old-deja/g++.pt/spec34.C: New test. From-SVN: r39127
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 747df21..33c3f26 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1207,6 +1207,8 @@ copy_default_args_to_explicit_spec (decl)
tree old_type;
tree new_type;
tree t;
+ tree object_type = NULL_TREE;
+ tree in_charge = NULL_TREE;
/* See if there's anything we need to do. */
tmpl = DECL_TI_TEMPLATE (decl);
@@ -1220,40 +1222,43 @@ copy_default_args_to_explicit_spec (decl)
old_type = TREE_TYPE (decl);
spec_types = TYPE_ARG_TYPES (old_type);
- /* DECL may contain more parameters than TMPL due to the extra
- in-charge parameter in constructors and destructors. */
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl))
{
+ /* Remove the this pointer, but remember the object's type for
+ CV quals. */
+ object_type = TREE_TYPE (TREE_VALUE (spec_types));
spec_types = TREE_CHAIN (spec_types);
tmpl_types = TREE_CHAIN (tmpl_types);
+
if (DECL_HAS_IN_CHARGE_PARM_P (decl))
- spec_types = TREE_CHAIN (spec_types);
+ {
+ /* DECL may contain more parameters than TMPL due to the extra
+ in-charge parameter in constructors and destructors. */
+ in_charge = spec_types;
+ spec_types = TREE_CHAIN (spec_types);
+ }
}
/* Compute the merged default arguments. */
new_spec_types =
copy_default_args_to_explicit_spec_1 (spec_types, tmpl_types);
- /* Put the extra parameters back together -- but note that
- build_cplus_method_type will automatically add the `this'
- pointer. */
- if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
- && DECL_HAS_IN_CHARGE_PARM_P (decl))
+ /* Compute the new FUNCTION_TYPE. */
+ if (object_type)
{
- tree t = TREE_CHAIN (TYPE_ARG_TYPES (old_type));
- new_spec_types = hash_tree_cons (TREE_PURPOSE (t),
- TREE_VALUE (t),
- new_spec_types);
+ if (in_charge)
+ /* Put the in-charge parameter back. */
+ new_spec_types = hash_tree_cons (TREE_PURPOSE (in_charge),
+ TREE_VALUE (in_charge),
+ new_spec_types);
+
+ new_type = build_cplus_method_type (object_type,
+ TREE_TYPE (old_type),
+ new_spec_types);
}
-
- /* Compute the new FUNCTION_TYPE. */
- if (TREE_CODE (old_type) == METHOD_TYPE)
- new_type = build_cplus_method_type (TYPE_METHOD_BASETYPE (old_type),
- TREE_TYPE (old_type),
- new_spec_types);
else
new_type = build_function_type (TREE_TYPE (old_type),
- new_spec_types);
+ new_spec_types);
new_type = build_type_attribute_variant (new_type,
TYPE_ATTRIBUTES (old_type));
new_type = build_exception_variant (new_type,
@@ -1500,7 +1505,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
else if (TREE_CODE (TREE_OPERAND (declarator, 0)) == LOOKUP_EXPR)
{
/* A friend declaration. We can't do much, because we don't
- know what this resolves to, yet. */
+ know what this resolves to, yet. */
my_friendly_assert (is_friend != 0, 0);
my_friendly_assert (!explicit_instantiation, 0);
SET_DECL_IMPLICIT_INSTANTIATION (decl);
@@ -1641,7 +1646,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
return tmpl;
}
- /* If we though that the DECL was a member function, but it
+ /* If we thought that the DECL was a member function, but it
turns out to be specializing a static member function,
make DECL a static member function as well. */
if (DECL_STATIC_FUNCTION_P (tmpl)