aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-04-24 03:50:31 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-04-24 03:50:31 +0000
commite2537f2c039f645cff41975b5a6ddcf26b7c4c79 (patch)
treeaef78361996e61e02ee5a14c7f9d6f1ab2a35d52 /gcc/cp/decl2.c
parentd24b23bb89dee07f183cd19a4d77c77a31f511e1 (diff)
downloadgcc-e2537f2c039f645cff41975b5a6ddcf26b7c4c79.zip
gcc-e2537f2c039f645cff41975b5a6ddcf26b7c4c79.tar.gz
gcc-e2537f2c039f645cff41975b5a6ddcf26b7c4c79.tar.bz2
re PR c++/26912 (friend const member function specialization fails to compile)
PR c++/26912 * cp-tree.h (build_this_parm): Declare. (grok_method_quals): Remove. (build_memfn_type): Declare. (build_artificial_parm): Declare. (do_friend): Remove quals parameter. * decl.c (build_this_parm): New function. (grokfndecl): Use it. Do not pass quals to grokclassfn. (grokdeclarator): Rename quals to memfn_quals. Avoid allocating unnecessary TYPE_DECLs. Correct qualification of member function types. Tidy. * method.c (implicitly_declare_fn): Use build_this_parm. * friend.c (do_friend): Remove quals parameter. * decl2.c (grok_method_quals): Remove. (build_memfn_type): New function. (build_artificial_parm): Give it external linkage. (grokclassfn): Remove quals parameter. Do not build "this" PARM_DECL here. PR c++/26912 * g++.dg/template/friend41.C: New test. From-SVN: r113213
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c55
1 files changed, 13 insertions, 42 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index ed26db2..fe5db71 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -103,33 +103,28 @@ tree static_ctors;
tree static_dtors;
-/* Incorporate `const' and `volatile' qualifiers for member functions.
- FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
- QUALS is a list of qualifiers. Returns any explicit
- top-level qualifiers of the method's this pointer, anything other than
- TYPE_UNQUALIFIED will be an extension. */
-
-int
-grok_method_quals (tree ctype, tree function, cp_cv_quals quals)
+
+/* Return a member function type (a METHOD_TYPE), given FNTYPE (a
+ FUNCTION_TYPE), CTYPE (class type), and QUALS (the cv-qualifiers
+ that apply to the function). */
+
+tree
+build_memfn_type (tree fntype, tree ctype, cp_cv_quals quals)
{
- tree fntype = TREE_TYPE (function);
- tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
- int type_quals = TYPE_UNQUALIFIED;
- int this_quals = TYPE_UNQUALIFIED;
+ tree raises;
+ int type_quals;
type_quals = quals & ~TYPE_QUAL_RESTRICT;
- this_quals = quals & TYPE_QUAL_RESTRICT;
-
ctype = cp_build_qualified_type (ctype, type_quals);
fntype = build_method_type_directly (ctype, TREE_TYPE (fntype),
(TREE_CODE (fntype) == METHOD_TYPE
? TREE_CHAIN (TYPE_ARG_TYPES (fntype))
: TYPE_ARG_TYPES (fntype)));
+ raises = TYPE_RAISES_EXCEPTIONS (fntype);
if (raises)
fntype = build_exception_variant (fntype, raises);
- TREE_TYPE (function) = fntype;
- return this_quals;
+ return fntype;
}
/* Build a PARM_DECL with NAME and TYPE, and set DECL_ARG_TYPE
@@ -149,7 +144,7 @@ cp_build_parm_decl (tree name, tree type)
/* Returns a PARM_DECL for a parameter of the indicated TYPE, with the
indicated NAME. */
-static tree
+tree
build_artificial_parm (tree name, tree type)
{
tree parm = cp_build_parm_decl (name, type);
@@ -257,11 +252,9 @@ maybe_retrofit_in_chrg (tree fn)
QUALS are the qualifiers for the this pointer. */
void
-grokclassfn (tree ctype, tree function, enum overload_flags flags,
- cp_cv_quals quals)
+grokclassfn (tree ctype, tree function, enum overload_flags flags)
{
tree fn_name = DECL_NAME (function);
- cp_cv_quals this_quals = TYPE_UNQUALIFIED;
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
@@ -274,28 +267,6 @@ grokclassfn (tree ctype, tree function, enum overload_flags flags,
DECL_NAME (function) = fn_name;
}
- if (quals)
- this_quals = grok_method_quals (ctype, function, quals);
-
- if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
- {
- /* Must add the class instance variable up front. */
- /* Right now we just make this a pointer. But later
- we may wish to make it special. */
- tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (function)));
- tree qual_type;
- tree parm;
-
- /* The `this' parameter is implicitly `const'; it cannot be
- assigned to. */
- this_quals |= TYPE_QUAL_CONST;
- qual_type = cp_build_qualified_type (type, this_quals);
- parm = build_artificial_parm (this_identifier, qual_type);
- cp_apply_type_quals_to_decl (this_quals, parm);
- TREE_CHAIN (parm) = DECL_ARGUMENTS (function);
- DECL_ARGUMENTS (function) = parm;
- }
-
DECL_CONTEXT (function) = ctype;
if (flags == DTOR_FLAG)