summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-11 20:34:51 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-11 20:34:51 +0000
commit0a106a56316034efac09b71c8ba7327944f3c4d1 (patch)
treedc0fb0bf893653820d07bb3aa7aa71c77e01177d /gcc
parentc5d44e2fbe97b15dc79f213a19223f75c22bcf8e (diff)
downloadgcc-0a106a56316034efac09b71c8ba7327944f3c4d1.tar.gz
cp:
Revert 2000-12-01 Nathan Sidwell <nathan@codesourcery.com>, It is incorrect. * typeck.c (build_static_cast): Compare non-qualified types with pointer to member conversions. testsuite: * testsuite/g++.dg/overload/pmf1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50591 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/cp/typeck.c16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/overload/pmf1.C21
5 files changed, 50 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d2f15802dc7..513dd00cb5b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-11 Nathan Sidwell <nathan@codesourcery.com>
+
+ Revert 2000-12-01 Nathan Sidwell <nathan@codesourcery.com>,
+ It is incorrect.
+ * typeck.c (build_static_cast): Compare non-qualified types
+ with pointer to member conversions.
+
2002-03-11 Dan Nicolaescu <dann@ics.uci.edu>
Daniel Berlin <dan@dberlin.org>
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 29e0c72caea..31b5baaf3fe 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -795,9 +795,8 @@ standard_conversion (to, from, expr)
{
tree fbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (from));
tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to));
- tree binfo = lookup_base (tbase, fbase, ba_check, NULL);
- if (binfo && !binfo_from_vbase (binfo)
+ if (DERIVED_FROM_P (fbase, tbase)
&& (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (TREE_TYPE (from)),
TREE_TYPE (TREE_TYPE (to)))))
@@ -843,9 +842,8 @@ standard_conversion (to, from, expr)
tree tofn = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (to));
tree fbase = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fromfn)));
tree tbase = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (tofn)));
- tree binfo = lookup_base (tbase, fbase, ba_check, NULL);
- if (!binfo || binfo_from_vbase (binfo)
+ if (!DERIVED_FROM_P (fbase, tbase)
|| !same_type_p (TREE_TYPE (fromfn), TREE_TYPE (tofn))
|| !compparms (TREE_CHAIN (TYPE_ARG_TYPES (fromfn)),
TREE_CHAIN (TYPE_ARG_TYPES (tofn)))
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index e5f643c72d8..b14687b5027 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5078,6 +5078,22 @@ build_static_cast (type, expr)
&& kind != bk_via_virtual)
ok = 1;
}
+ else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
+ {
+ /* They're pointers to members. The pointed to objects must be
+ the same (ignoring CV qualifiers), and the containing classes
+ must be related non-virtually. */
+ base_kind kind;
+
+ if (same_type_p
+ (strip_all_pointer_quals (TREE_TYPE (TREE_TYPE (type))),
+ strip_all_pointer_quals (TREE_TYPE (TREE_TYPE (intype))))
+ && (lookup_base (TYPE_OFFSET_BASETYPE (TREE_TYPE (intype)),
+ TYPE_OFFSET_BASETYPE (TREE_TYPE (type)),
+ ba_ignore | ba_quiet, &kind))
+ && kind != bk_via_virtual)
+ ok = 1;
+ }
else if (TREE_CODE (intype) != BOOLEAN_TYPE
&& TREE_CODE (type) != ARRAY_TYPE
&& TREE_CODE (type) != FUNCTION_TYPE
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fc23908a4c3..354e9616129 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-03-11 Nathan Sidwell <nathan@codesourcery.com>
+
+ * testsuite/g++.dg/overload/pmf1.C: New test.
+
2002-03-11 Kazu Hirata <kazu@hxi.com>
* gcc.c-torture/execute/20020307-1.c: Use long.
diff --git a/gcc/testsuite/g++.dg/overload/pmf1.C b/gcc/testsuite/g++.dg/overload/pmf1.C
new file mode 100644
index 00000000000..772cb530529
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/pmf1.C
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+// Copyright (C) 2002 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 04 Mar 2002 <nathan@codesourcery.com>
+// Jason Merrill <jason@redhat.com>
+
+struct A { int i; };
+struct B: private A {};
+struct C {
+ C (int A::*);
+};
+
+int A::*aip = &A::i;
+
+void f (int B::*) {} // should choose this, even though it's ill-formed
+void f (C) {} // even though this would be well-formed
+
+int main ()
+{
+ f (aip); // { dg-error "`A' is an inaccessible base of `B'" "" }
+}