re PR c++/21455 (type 'X' is not a base type for type 'X' in pointer to member conversion)
cp: PR c++/21455 * typeck.c (get_delta_difference): Cope with incomplete but equal classes. Reorder if. testsuite: PR c++/21455 * g++.dg/inherit/ptrmem3.C: New. From-SVN: r100258
This commit is contained in:
parent
d2763ab5f1
commit
f879d298f4
@ -1,5 +1,9 @@
|
||||
2005-05-27 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/21455
|
||||
* typeck.c (get_delta_difference): Cope with incomplete but equal
|
||||
classes. Reorder if.
|
||||
|
||||
PR c++/21681
|
||||
* parser.c (cp_parser_late_parsing_for_member): Disable access
|
||||
checking for template functions.
|
||||
|
@ -5523,7 +5523,6 @@ get_delta_difference (tree from, tree to,
|
||||
bool c_cast_p)
|
||||
{
|
||||
tree binfo;
|
||||
tree virt_binfo;
|
||||
base_kind kind;
|
||||
tree result;
|
||||
|
||||
@ -5532,36 +5531,14 @@ get_delta_difference (tree from, tree to,
|
||||
binfo = lookup_base (to, from, c_cast_p ? ba_unique : ba_check, &kind);
|
||||
if (kind == bk_inaccessible || kind == bk_ambig)
|
||||
error (" in pointer to member function conversion");
|
||||
else if (!binfo)
|
||||
else if (binfo)
|
||||
{
|
||||
if (!allow_inverse_p)
|
||||
{
|
||||
error_not_base_type (from, to);
|
||||
error (" in pointer to member conversion");
|
||||
}
|
||||
else
|
||||
{
|
||||
binfo = lookup_base (from, to, c_cast_p ? ba_unique : ba_check,
|
||||
&kind);
|
||||
if (binfo)
|
||||
{
|
||||
virt_binfo = binfo_from_vbase (binfo);
|
||||
if (virt_binfo)
|
||||
/* This is a reinterpret cast, we choose to do nothing. */
|
||||
warning (0, "pointer to member cast via virtual base %qT",
|
||||
BINFO_TYPE (virt_binfo));
|
||||
else
|
||||
result = size_diffop (size_zero_node, BINFO_OFFSET (binfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
virt_binfo = binfo_from_vbase (binfo);
|
||||
if (!virt_binfo)
|
||||
if (kind != bk_via_virtual)
|
||||
result = BINFO_OFFSET (binfo);
|
||||
else
|
||||
{
|
||||
tree virt_binfo = binfo_from_vbase (binfo);
|
||||
|
||||
/* This is a reinterpret cast, we choose to do nothing. */
|
||||
if (allow_inverse_p)
|
||||
warning (0, "pointer to member cast via virtual base %qT",
|
||||
@ -5571,6 +5548,30 @@ get_delta_difference (tree from, tree to,
|
||||
BINFO_TYPE (virt_binfo));
|
||||
}
|
||||
}
|
||||
else if (same_type_ignoring_top_level_qualifiers_p (from, to))
|
||||
/* Pointer to member of incomplete class is permitted*/;
|
||||
else if (!allow_inverse_p)
|
||||
{
|
||||
error_not_base_type (from, to);
|
||||
error (" in pointer to member conversion");
|
||||
}
|
||||
else
|
||||
{
|
||||
binfo = lookup_base (from, to, c_cast_p ? ba_unique : ba_check, &kind);
|
||||
if (binfo)
|
||||
{
|
||||
if (kind != bk_via_virtual)
|
||||
result = size_diffop (size_zero_node, BINFO_OFFSET (binfo));
|
||||
else
|
||||
{
|
||||
/* This is a reinterpret cast, we choose to do nothing. */
|
||||
tree virt_binfo = binfo_from_vbase (binfo);
|
||||
|
||||
warning (0, "pointer to member cast via virtual base %qT",
|
||||
BINFO_TYPE (virt_binfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fold_if_not_in_template (convert_to_integer (ptrdiff_type_node,
|
||||
result));
|
||||
|
@ -1,5 +1,8 @@
|
||||
2005-05-27 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/21455
|
||||
* g++.dg/inherit/ptrmem3.C: New.
|
||||
|
||||
PR c++/21681
|
||||
* g++.dg/parse/template16.C: New.
|
||||
|
||||
|
17
gcc/testsuite/g++.dg/inherit/ptrmem3.C
Normal file
17
gcc/testsuite/g++.dg/inherit/ptrmem3.C
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
// Contributed by Nathan Sidwell 27 May 2005 <nathan@codesourcery.com>
|
||||
|
||||
// Origin:Andrew Pinski pinskia@gcc.gnu.org
|
||||
// PR 21455 bogus error with pointer to member of incomplete
|
||||
|
||||
class XMLFile;
|
||||
|
||||
typedef bool (XMLFile::*ParserFunctionPtr)();
|
||||
|
||||
struct ParserElement
|
||||
{
|
||||
ParserFunctionPtr getPreFunc() const { return preFunc; }
|
||||
ParserFunctionPtr getPostFunc() const { return postFunc; }
|
||||
ParserFunctionPtr preFunc;
|
||||
ParserFunctionPtr postFunc;
|
||||
};
|
Loading…
Reference in New Issue
Block a user