+Wed Feb 25 09:51:29 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * typeck.c (get_delta_difference): Give hard error for conversion
+ from virtual base.
+
+ * cp-tree.h: Tweak formatting.
+
Wed Feb 25 00:35:33 1998 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (push_namespace): Handle redeclaration error.
struct lang_identifier
{
struct tree_identifier ignore;
- tree global_value, local_value;
+ tree namespace_bindings, local_value;
tree class_value;
tree class_template_info;
struct lang_id2 *x;
tree decl;
} template_parm_index;
-#define BINDING_SCOPE(NODE) (((struct tree_binding*)NODE)->scope)
-#define BINDING_VALUE(NODE) (((struct tree_binding*)NODE)->value)
+#define BINDING_SCOPE(NODE) (((struct tree_binding*)NODE)->scope)
+#define BINDING_VALUE(NODE) (((struct tree_binding*)NODE)->value)
#define NAMESPACE_BINDING(ID,NS) BINDING_VALUE (binding_for_name (ID, NS))
#define IDENTIFIER_GLOBAL_VALUE(NODE) \
NAMESPACE_BINDING (NODE, global_namespace)
/* Macros for access to language-specific slots in an identifier. */
#define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \
- (((struct lang_identifier *)(NODE))->global_value)
+ (((struct lang_identifier *)(NODE))->namespace_bindings)
#define IDENTIFIER_CLASS_VALUE(NODE) \
(((struct lang_identifier *)(NODE))->class_value)
#define IDENTIFIER_LOCAL_VALUE(NODE) \
return delta;
}
binfo = get_binfo (to, from, 1);
- if (binfo == error_mark_node)
- {
- if (!force)
- error (" in pointer to member conversion");
- return delta;
- }
- if (binfo == 0)
- {
- if (!force)
- cp_error ("cannot convert pointer to member of type %T to unrelated pointer to member of type %T", from, to);
- return delta;
- }
- if (TREE_VIA_VIRTUAL (binfo))
- {
- binfo = binfo_member (BINFO_TYPE (binfo),
- CLASSTYPE_VBASECLASSES (from));
- warning ("pointer to member conversion to virtual base class will only work if you are very careful");
- }
+ if (binfo == 0 || binfo == error_mark_node || TREE_VIA_VIRTUAL (binfo))
+ return delta;
delta = BINFO_OFFSET (binfo);
delta = cp_convert (ptrdiff_type_node, delta);
integer_zero_node,
delta, 1);
}
+
if (TREE_VIA_VIRTUAL (binfo))
{
- warning ("pointer to member conversion from virtual base class will only work if you are very careful");
+ if (force)
+ {
+ cp_warning ("pointer to member cast from virtual base `%T'",
+ BINFO_TYPE (binfo));
+ warning (" will only work if you are very careful");
+ }
+ else
+ cp_error ("pointer to member conversion from virtual base `%T'",
+ BINFO_TYPE (binfo));
+ return delta;
}
+
return BINFO_OFFSET (binfo);
}