diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2005-05-27 15:50:26 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2005-05-27 15:50:26 +0000 |
commit | f879d298f449561a9033da4498b61340e79b2f49 (patch) | |
tree | 0ebc16f1f4cae8cf11f1d1c8abcf8b03f1b4c458 | |
parent | d2763ab5f180a4e22cc7d05c84a3728e89ced2b1 (diff) | |
download | gcc-f879d298f449561a9033da4498b61340e79b2f49.zip gcc-f879d298f449561a9033da4498b61340e79b2f49.tar.gz gcc-f879d298f449561a9033da4498b61340e79b2f49.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 55 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/inherit/ptrmem3.C | 17 |
4 files changed, 52 insertions, 27 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6f29005..5d70567 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8bd1012..92bbc1e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c424bf5..1a6bdc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/g++.dg/inherit/ptrmem3.C b/gcc/testsuite/g++.dg/inherit/ptrmem3.C new file mode 100644 index 0000000..0c06c65 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/ptrmem3.C @@ -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; +}; |