Commit 32e02ee0 by Jason Merrill Committed by Jason Merrill

typeck.c (get_delta_difference): Give hard error for conversion from virtual base.

	* typeck.c (get_delta_difference): Give hard error for conversion
	from virtual base.
	* cp-tree.h: Tweak formatting.

From-SVN: r18229
parent 75cf27d4
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.
......
......@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */
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;
......@@ -80,7 +80,7 @@ struct tree_binding
/* 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) \
......
......@@ -6304,24 +6304,8 @@ get_delta_difference (from, to, force)
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);
if (binfo == 0 || binfo == error_mark_node || TREE_VIA_VIRTUAL (binfo))
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");
}
delta = BINFO_OFFSET (binfo);
delta = cp_convert (ptrdiff_type_node, delta);
......@@ -6329,10 +6313,21 @@ get_delta_difference (from, to, force)
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);
}
......
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