Commit 999cc24c by Nathan Sidwell Committed by Nathan Sidwell

Revert 2000-12-01 Nathan Sidwell <nathan@codesourcery.com>, It is incorrect.

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.

From-SVN: r50591
parent 61eece67
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> 2002-03-11 Dan Nicolaescu <dann@ics.uci.edu>
Daniel Berlin <dan@dberlin.org> Daniel Berlin <dan@dberlin.org>
......
...@@ -795,9 +795,8 @@ standard_conversion (to, from, expr) ...@@ -795,9 +795,8 @@ standard_conversion (to, from, expr)
{ {
tree fbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (from)); tree fbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (from));
tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to)); 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 && (same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (TREE_TYPE (from)), (TREE_TYPE (TREE_TYPE (from)),
TREE_TYPE (TREE_TYPE (to))))) TREE_TYPE (TREE_TYPE (to)))))
...@@ -843,9 +842,8 @@ standard_conversion (to, from, expr) ...@@ -843,9 +842,8 @@ standard_conversion (to, from, expr)
tree tofn = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (to)); tree tofn = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (to));
tree fbase = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fromfn))); tree fbase = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fromfn)));
tree tbase = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (tofn))); 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)) || !same_type_p (TREE_TYPE (fromfn), TREE_TYPE (tofn))
|| !compparms (TREE_CHAIN (TYPE_ARG_TYPES (fromfn)), || !compparms (TREE_CHAIN (TYPE_ARG_TYPES (fromfn)),
TREE_CHAIN (TYPE_ARG_TYPES (tofn))) TREE_CHAIN (TYPE_ARG_TYPES (tofn)))
......
...@@ -5078,6 +5078,22 @@ build_static_cast (type, expr) ...@@ -5078,6 +5078,22 @@ build_static_cast (type, expr)
&& kind != bk_via_virtual) && kind != bk_via_virtual)
ok = 1; 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 else if (TREE_CODE (intype) != BOOLEAN_TYPE
&& TREE_CODE (type) != ARRAY_TYPE && TREE_CODE (type) != ARRAY_TYPE
&& TREE_CODE (type) != FUNCTION_TYPE && TREE_CODE (type) != FUNCTION_TYPE
......
2002-03-11 Nathan Sidwell <nathan@codesourcery.com>
* testsuite/g++.dg/overload/pmf1.C: New test.
2002-03-11 Kazu Hirata <kazu@hxi.com> 2002-03-11 Kazu Hirata <kazu@hxi.com>
* gcc.c-torture/execute/20020307-1.c: Use long. * gcc.c-torture/execute/20020307-1.c: Use long.
......
// { 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'" "" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment