aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-05-19 17:01:50 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-05-19 17:01:50 -0400
commit2872152c39fbc1c91da3fc07e8701fadb6b87f98 (patch)
treea224afc9e9939a2cfe3c63c93d01f4adfa3c5a9d /gcc/cp/decl.c
parent1961ffb8cd83ccb0f91ce9b3015bb3290f48b04b (diff)
downloadgcc-2872152c39fbc1c91da3fc07e8701fadb6b87f98.zip
gcc-2872152c39fbc1c91da3fc07e8701fadb6b87f98.tar.gz
gcc-2872152c39fbc1c91da3fc07e8701fadb6b87f98.tar.bz2
re PR c++/44193 (function types, cv-quals and typename)
PR c++/44193 * typeck.c (type_memfn_quals): New fn. (apply_memfn_quals): New fn. (cp_type_quals): Return TYPE_UNQUALIFIED for FUNCTION_TYPE. (cp_type_readonly): Use cp_type_quals. * cp-tree.h: Add declarations. * tree.c (cp_build_qualified_type_real): Don't set, but do preserve, quals on FUNCTION_TYPE. (strip_typedefs): Use apply_memfn_quals and type_memfn_quals. * decl.c (build_ptrmem_type): Likewise. (grokdeclarator): Likewise. (static_fn_type): Likewise. * decl2.c (change_return_type): Likewise. (cp_reconstruct_complex_type): Likewise. * pt.c (tsubst_function_type): Likewise. (unify): Likewise. (tsubst): Likewise. Drop special FUNCTION_TYPE substitution code. From-SVN: r159596
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0636aba..e57a753 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7265,8 +7265,7 @@ build_ptrmem_type (tree class_type, tree member_type)
{
if (TREE_CODE (member_type) == METHOD_TYPE)
{
- tree arg_types = TYPE_ARG_TYPES (member_type);
- cp_cv_quals quals = cp_type_quals (TREE_TYPE (TREE_VALUE (arg_types)));
+ cp_cv_quals quals = type_memfn_quals (member_type);
member_type = build_memfn_type (member_type, class_type, quals);
return build_ptrmemfunc_type (build_pointer_type (member_type));
}
@@ -8683,7 +8682,7 @@ grokdeclarator (const cp_declarator *declarator,
&& (TREE_CODE (type) == FUNCTION_TYPE
|| (memfn_quals && TREE_CODE (type) == METHOD_TYPE)))
{
- memfn_quals |= cp_type_quals (type);
+ memfn_quals |= type_memfn_quals (type);
type = build_memfn_type (type,
declarator->u.pointer.class_type,
memfn_quals);
@@ -8691,7 +8690,7 @@ grokdeclarator (const cp_declarator *declarator,
}
if (TREE_CODE (type) == FUNCTION_TYPE
- && cp_type_quals (type) != TYPE_UNQUALIFIED)
+ && type_memfn_quals (type) != TYPE_UNQUALIFIED)
error (declarator->kind == cdk_reference
? G_("cannot declare reference to qualified function type %qT")
: G_("cannot declare pointer to qualified function type %qT"),
@@ -8994,7 +8993,7 @@ grokdeclarator (const cp_declarator *declarator,
function type. */
if (memfn_quals && TREE_CODE (type) == FUNCTION_TYPE)
{
- type = cp_build_qualified_type (type, memfn_quals);
+ type = apply_memfn_quals (type, memfn_quals);
/* We have now dealt with these qualifiers. */
memfn_quals = TYPE_UNQUALIFIED;
@@ -9114,7 +9113,7 @@ grokdeclarator (const cp_declarator *declarator,
{
/* A cv-qualifier-seq shall only be part of the function type
for a non-static member function. [8.3.5/4 dcl.fct] */
- if (cp_type_quals (type) != TYPE_UNQUALIFIED
+ if (type_memfn_quals (type) != TYPE_UNQUALIFIED
&& (current_class_type == NULL_TREE || staticp) )
{
error (staticp
@@ -9127,7 +9126,7 @@ grokdeclarator (const cp_declarator *declarator,
/* The qualifiers on the function type become the qualifiers on
the non-static member function. */
- memfn_quals |= cp_type_quals (type);
+ memfn_quals |= type_memfn_quals (type);
type_quals = TYPE_UNQUALIFIED;
}
}
@@ -9195,7 +9194,7 @@ grokdeclarator (const cp_declarator *declarator,
type = build_memfn_type (type, ctype, memfn_quals);
/* Core issue #547: need to allow this in template type args. */
else if (template_type_arg && TREE_CODE (type) == FUNCTION_TYPE)
- type = cp_build_qualified_type (type, memfn_quals);
+ type = apply_memfn_quals (type, memfn_quals);
else
error ("invalid qualifiers on non-member function type");
}
@@ -12944,7 +12943,6 @@ static_fn_type (tree memfntype)
{
tree fntype;
tree args;
- int quals;
if (TYPE_PTRMEMFUNC_P (memfntype))
memfntype = TYPE_PTRMEMFUNC_FN_TYPE (memfntype);
@@ -12956,8 +12954,7 @@ static_fn_type (tree memfntype)
gcc_assert (TREE_CODE (memfntype) == METHOD_TYPE);
args = TYPE_ARG_TYPES (memfntype);
fntype = build_function_type (TREE_TYPE (memfntype), TREE_CHAIN (args));
- quals = cp_type_quals (TREE_TYPE (TREE_VALUE (args)));
- fntype = build_qualified_type (fntype, quals);
+ fntype = apply_memfn_quals (fntype, type_memfn_quals (memfntype));
fntype = (cp_build_type_attribute_variant
(fntype, TYPE_ATTRIBUTES (memfntype)));
fntype = (build_exception_variant