aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-10-21 21:23:42 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-10-21 21:23:42 +0000
commit08e17d9d1121f0ce5869ddf1283db2449a4bc458 (patch)
treef2b7fac0767818e1f51fd05dc1e3af743cc2df4b /gcc/cp/class.c
parent8265f931175625977cb6ad5191a2ae286f71002e (diff)
downloadgcc-08e17d9d1121f0ce5869ddf1283db2449a4bc458.zip
gcc-08e17d9d1121f0ce5869ddf1283db2449a4bc458.tar.gz
gcc-08e17d9d1121f0ce5869ddf1283db2449a4bc458.tar.bz2
re PR c++/18073 (mmintrin.h rejected by C++ frontend)
PR c++/18073 PR c++/10841 * cp-tree.h (convert_to_base): Change prototype. (build_ptrmemfunc): Likewise. (convert_ptrmem): New function. * call.c (struct conversion): Adjust documentation for base_p. (standard_conversion): Set base_p for ck_pmem conversions as appropriate. (convert_like_real): Use convert_to_base for ck_pmem and ck_ptr conversions. * class.c (convert_to_base): Handle both pointers and objects. Add nonnull parameter. (build_vfield_ref): Adjust call to convert_to_base. * cvt.c (cp_convert_to_pointer): Adjust call to build_ptrmemfunc. (convert_force): Likewise. * typeck.c (build_unary_op): Likewise. (convert_ptrmem): New function. (build_static_cast_1): Use it. (build_reinterpret_cast): Allow conversions to vector types. (get_delta_difference): Add c_cast_p parameter. (build_ptrmemfunc): Likewise. Adjust calls to get_delta_difference. PR c++/10841 * g++.dg/conversion/cast1.C: New test. * g++.dg/overload/pmf1.C: Adjust error marker. From-SVN: r89403
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a0a2ed4..15ca26a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -426,22 +426,34 @@ build_simple_base_path (tree expr, tree binfo)
gcc_unreachable ();
}
-/* Convert OBJECT to the base TYPE. If CHECK_ACCESS is true, an error
- message is emitted if TYPE is inaccessible. OBJECT is assumed to
- be non-NULL. */
+/* Convert OBJECT to the base TYPE. OBJECT is an expression whose
+ type is a class type or a pointer to a class type. In the former
+ case, TYPE is also a class type; in the latter it is another
+ pointer type. If CHECK_ACCESS is true, an error message is emitted
+ if TYPE is inaccessible. If OBJECT has pointer type, the value is
+ assumed to be non-NULL. */
tree
-convert_to_base (tree object, tree type, bool check_access)
+convert_to_base (tree object, tree type, bool check_access, bool nonnull)
{
tree binfo;
+ tree object_type;
- binfo = lookup_base (TREE_TYPE (object), type,
+ if (TYPE_PTR_P (TREE_TYPE (object)))
+ {
+ object_type = TREE_TYPE (TREE_TYPE (object));
+ type = TREE_TYPE (type);
+ }
+ else
+ object_type = TREE_TYPE (object);
+
+ binfo = lookup_base (object_type, type,
check_access ? ba_check : ba_unique,
NULL);
if (!binfo || binfo == error_mark_node)
return error_mark_node;
- return build_base_path (PLUS_EXPR, object, binfo, /*nonnull=*/1);
+ return build_base_path (PLUS_EXPR, object, binfo, nonnull);
}
/* EXPR is an expression with unqualified class type. BASE is a base
@@ -485,7 +497,8 @@ build_vfield_ref (tree datum, tree type)
/* First, convert to the requested type. */
if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (datum), type))
- datum = convert_to_base (datum, type, /*check_access=*/false);
+ datum = convert_to_base (datum, type, /*check_access=*/false,
+ /*nonnull=*/true);
/* Second, the requested type may not be the owner of its own vptr.
If not, convert to the base class that owns it. We cannot use