mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-15 07:40:29 +08:00
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
This commit is contained in:
parent
75cf27d4c9
commit
32e02ee0c0
@ -1,3 +1,10 @@
|
||||
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;
|
||||
@ -58,8 +58,8 @@ typedef struct
|
||||
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)
|
||||
@ -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);
|
||||
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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user