aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-05-24 23:55:20 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-05-24 23:55:20 +0000
commit00c15f8deb694cc46e54dd5bf4fd6a4d60d22a83 (patch)
tree753e8900721afec2662f593a026b5f30821b97fb
parent1dcf683ec2188907189a0815e28c7a8377c52b5c (diff)
downloadgcc-00c15f8deb694cc46e54dd5bf4fd6a4d60d22a83.zip
gcc-00c15f8deb694cc46e54dd5bf4fd6a4d60d22a83.tar.gz
gcc-00c15f8deb694cc46e54dd5bf4fd6a4d60d22a83.tar.bz2
call.c (maybe_handle_implicit_object): Handle QUAL_CONVs.
1998-05-24 Mark Mitchell <mark@markmitchell.com> * call.c (maybe_handle_implicit_object): Handle QUAL_CONVs. Make sure the type of the REF_BIND is a reference type. (maybe_handle_ref_bind, compare_ics): Rename reference_type* to ref_to_type* for clarity. From-SVN: r20037
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c32
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/overload6.C18
3 files changed, 41 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e0cfc11..0bf7d8a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
1998-05-24 Mark Mitchell <mark@markmitchell.com>
+ * call.c (maybe_handle_implicit_object): Handle QUAL_CONVs. Make
+ sure the type of the REF_BIND is a reference type.
+ (maybe_handle_ref_bind, compare_ics): Rename reference_type to
+ target_type for clarity.
+
* parse.y (xcond): Move call to condition_conversion ...
* semantics.c (finish_for_cond): Here.
* parse.c: Regenerated.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f0bf7d8..01bb53f 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3739,23 +3739,27 @@ maybe_handle_implicit_object (ics)
member and cv is the cv-qualification on the member
function declaration. */
tree t = *ics;
+ if (TREE_CODE (t) == QUAL_CONV)
+ t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == PTR_CONV)
t = TREE_OPERAND (t, 0);
t = build1 (IDENTITY_CONV, TREE_TYPE (TREE_TYPE (t)), NULL_TREE);
- t = build_conv (REF_BIND, TREE_TYPE (*ics), t);
+ t = build_conv (REF_BIND,
+ build_reference_type (TREE_TYPE (TREE_TYPE (*ics))),
+ t);
ICS_STD_RANK (t) = ICS_STD_RANK (*ics);
*ics = t;
}
}
-/* If ICS is a REF_BIND, modify it appropriately, set ORIG_TO_TYPE
+/* If ICS is a REF_BIND, modify it appropriately, set TARGET_TYPE
to the type the reference originally referred to, and return 1.
Otherwise, return 0. */
static int
-maybe_handle_ref_bind (ics, reference_type)
+maybe_handle_ref_bind (ics, target_type)
tree* ics;
- tree* reference_type;
+ tree* target_type;
{
if (TREE_CODE (*ics) == REF_BIND)
{
@@ -3788,11 +3792,11 @@ maybe_handle_ref_bind (ics, reference_type)
tree old_ics = *ics;
- *reference_type = TREE_TYPE (TREE_TYPE (*ics));
+ *target_type = TREE_TYPE (TREE_TYPE (*ics));
*ics = TREE_OPERAND (*ics, 0);
if (TREE_CODE (*ics) == IDENTITY_CONV
- && is_properly_derived_from (TREE_TYPE (*ics), *reference_type))
- *ics = build_conv (BASE_CONV, *reference_type, *ics);
+ && is_properly_derived_from (TREE_TYPE (*ics), *target_type))
+ *ics = build_conv (BASE_CONV, *target_type, *ics);
ICS_USER_FLAG (*ics) = ICS_USER_FLAG (old_ics);
ICS_BAD_FLAG (*ics) = ICS_BAD_FLAG (old_ics);
@@ -3823,20 +3827,20 @@ compare_ics (ics1, ics2)
tree deref_to_type2;
/* REF_BINDING is non-zero if the result of the conversion sequence
- is a reference type. In that case REFERENCE_TYPE is the
- reference type. */
+ is a reference type. In that case TARGET_TYPE is the
+ type referred to by the reference. */
int ref_binding1;
int ref_binding2;
- tree reference_type1;
- tree reference_type2;
+ tree target_type1;
+ tree target_type2;
/* Handle implicit object parameters. */
maybe_handle_implicit_object (&ics1);
maybe_handle_implicit_object (&ics2);
/* Handle reference parameters. */
- ref_binding1 = maybe_handle_ref_bind (&ics1, &reference_type1);
- ref_binding2 = maybe_handle_ref_bind (&ics2, &reference_type2);
+ ref_binding1 = maybe_handle_ref_bind (&ics1, &target_type1);
+ ref_binding2 = maybe_handle_ref_bind (&ics2, &target_type2);
/* [over.ics.rank]
@@ -4132,7 +4136,7 @@ compare_ics (ics1, ics2)
if (ref_binding1 && ref_binding2
&& comptypes (TYPE_MAIN_VARIANT (to_type1),
TYPE_MAIN_VARIANT (to_type2), 1))
- return comp_cv_qualification (reference_type2, reference_type1);
+ return comp_cv_qualification (target_type2, target_type1);
/* Neither conversion sequence is better than the other. */
return 0;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload6.C b/gcc/testsuite/g++.old-deja/g++.other/overload6.C
new file mode 100644
index 0000000..fae26c3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/overload6.C
@@ -0,0 +1,18 @@
+extern "C" void abort();
+
+struct S1
+{
+ int f() { return 0; }
+ int f() const { return 1; }
+};
+
+struct S2 : public S1
+{
+};
+
+int main()
+{
+ S2 s2;
+ if (s2.f() != 0)
+ abort ();
+}