mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-04 14:10:20 +08:00
Kill remnants of this is variable.
cp: Kill remnants of this is variable. * cp-tree.h (flag_this_is_variable): Remove. * decl2.c (flag_this_is_variable): Remove. * class.c (fixed_type_or_null): Add cdtor parm. Adjust. (build_vbase_path): The path is non-static, even in a cdtor. (resolves_to_fixed_type_p): Add additional return value. * search.c (init_vbase_pointers): Adjust. * tree.c (lvalue_p_1): Adjust. * typeck.c (mark_addressable): Adjust. From-SVN: r39676
This commit is contained in:
parent
c7c0ae3d7f
commit
394fd77650
@ -1,3 +1,15 @@
|
||||
2001-02-14 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
Kill remnants of this is variable.
|
||||
* cp-tree.h (flag_this_is_variable): Remove.
|
||||
* decl2.c (flag_this_is_variable): Remove.
|
||||
* class.c (fixed_type_or_null): Add cdtor parm. Adjust.
|
||||
(build_vbase_path): The path is non-static, even in a cdtor.
|
||||
(resolves_to_fixed_type_p): Add additional return value.
|
||||
* search.c (init_vbase_pointers): Adjust.
|
||||
* tree.c (lvalue_p_1): Adjust.
|
||||
* typeck.c (mark_addressable): Adjust.
|
||||
|
||||
2001-02-14 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* pt.c (unify): Don't check cv quals of array types.
|
||||
|
@ -131,7 +131,7 @@ static void maybe_warn_about_overly_private_class PARAMS ((tree));
|
||||
static int field_decl_cmp PARAMS ((const tree *, const tree *));
|
||||
static int method_name_cmp PARAMS ((const tree *, const tree *));
|
||||
static tree add_implicitly_declared_members PARAMS ((tree, int, int, int));
|
||||
static tree fixed_type_or_null PARAMS ((tree, int *));
|
||||
static tree fixed_type_or_null PARAMS ((tree, int *, int *));
|
||||
static tree resolve_address_of_overloaded_function PARAMS ((tree, tree, int,
|
||||
int, int, tree));
|
||||
static void build_vtable_entry_ref PARAMS ((tree, tree, tree));
|
||||
@ -381,6 +381,9 @@ build_vbase_path (code, type, expr, path, nonnull)
|
||||
convert back to the type we want. Until that is done, we only optimize
|
||||
if the complete type is the same type as expr has. */
|
||||
fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);
|
||||
if (fixed_type_p < 0)
|
||||
/* Virtual base layout is not fixed, even in ctors and dtors. */
|
||||
fixed_type_p = 0;
|
||||
|
||||
if (!fixed_type_p && TREE_SIDE_EFFECTS (expr))
|
||||
expr = save_expr (expr);
|
||||
@ -5370,9 +5373,10 @@ finish_struct (t, attributes)
|
||||
before this function is called. */
|
||||
|
||||
static tree
|
||||
fixed_type_or_null (instance, nonnull)
|
||||
fixed_type_or_null (instance, nonnull, cdtorp)
|
||||
tree instance;
|
||||
int *nonnull;
|
||||
int *cdtorp;
|
||||
{
|
||||
switch (TREE_CODE (instance))
|
||||
{
|
||||
@ -5400,31 +5404,31 @@ fixed_type_or_null (instance, nonnull)
|
||||
*nonnull = 1;
|
||||
return TREE_TYPE (instance);
|
||||
}
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
|
||||
|
||||
case RTL_EXPR:
|
||||
return NULL_TREE;
|
||||
|
||||
case PLUS_EXPR:
|
||||
case MINUS_EXPR:
|
||||
if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR)
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
|
||||
if (TREE_CODE (TREE_OPERAND (instance, 1)) == INTEGER_CST)
|
||||
/* Propagate nonnull. */
|
||||
fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
|
||||
if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR)
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
|
||||
fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
|
||||
return NULL_TREE;
|
||||
|
||||
case NOP_EXPR:
|
||||
case CONVERT_EXPR:
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
|
||||
|
||||
case ADDR_EXPR:
|
||||
if (nonnull)
|
||||
*nonnull = 1;
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
|
||||
|
||||
case COMPONENT_REF:
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 1), nonnull);
|
||||
return fixed_type_or_null (TREE_OPERAND (instance, 1), nonnull, cdtorp);
|
||||
|
||||
case VAR_DECL:
|
||||
case FIELD_DECL:
|
||||
@ -5444,21 +5448,25 @@ fixed_type_or_null (instance, nonnull)
|
||||
*nonnull = 1;
|
||||
return TREE_TYPE (instance);
|
||||
}
|
||||
else if (nonnull)
|
||||
{
|
||||
if (instance == current_class_ptr
|
||||
&& flag_this_is_variable <= 0)
|
||||
{
|
||||
/* Normally, 'this' must be non-null. */
|
||||
if (flag_this_is_variable == 0)
|
||||
*nonnull = 1;
|
||||
|
||||
/* <0 means we're in a constructor and we know our type. */
|
||||
if (flag_this_is_variable < 0)
|
||||
return TREE_TYPE (TREE_TYPE (instance));
|
||||
}
|
||||
else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
|
||||
/* Reference variables should be references to objects. */
|
||||
else if (instance == current_class_ptr)
|
||||
{
|
||||
if (nonnull)
|
||||
*nonnull = 1;
|
||||
|
||||
/* if we're in a ctor or dtor, we know our type. */
|
||||
if (DECL_LANG_SPECIFIC (current_function_decl)
|
||||
&& (DECL_CONSTRUCTOR_P (current_function_decl)
|
||||
|| DECL_DESTRUCTOR_P (current_function_decl)))
|
||||
{
|
||||
if (cdtorp)
|
||||
*cdtorp = 1;
|
||||
return TREE_TYPE (TREE_TYPE (instance));
|
||||
}
|
||||
}
|
||||
else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
|
||||
{
|
||||
/* Reference variables should be references to objects. */
|
||||
if (nonnull)
|
||||
*nonnull = 1;
|
||||
}
|
||||
return NULL_TREE;
|
||||
@ -5470,7 +5478,9 @@ fixed_type_or_null (instance, nonnull)
|
||||
|
||||
/* Return non-zero if the dynamic type of INSTANCE is known, and equivalent
|
||||
to the static type. We also handle the case where INSTANCE is really
|
||||
a pointer.
|
||||
a pointer. Return negative if this is a ctor/dtor. There the dynamic type
|
||||
is known, but this might not be the most derived base of the original object,
|
||||
and hence virtual bases may not be layed out according to this type.
|
||||
|
||||
Used to determine whether the virtual function table is needed
|
||||
or not.
|
||||
@ -5485,12 +5495,16 @@ resolves_to_fixed_type_p (instance, nonnull)
|
||||
int *nonnull;
|
||||
{
|
||||
tree t = TREE_TYPE (instance);
|
||||
tree fixed = fixed_type_or_null (instance, nonnull);
|
||||
int cdtorp = 0;
|
||||
|
||||
tree fixed = fixed_type_or_null (instance, nonnull, &cdtorp);
|
||||
if (fixed == NULL_TREE)
|
||||
return 0;
|
||||
if (POINTER_TYPE_P (t))
|
||||
t = TREE_TYPE (t);
|
||||
return same_type_ignoring_top_level_qualifiers_p (t, fixed);
|
||||
if (!same_type_ignoring_top_level_qualifiers_p (t, fixed))
|
||||
return 0;
|
||||
return cdtorp ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3420,10 +3420,6 @@ extern varray_type local_classes;
|
||||
|
||||
/* Things for handling inline functions. */
|
||||
|
||||
/* Negative values means we know `this' to be of static type. */
|
||||
|
||||
extern int flag_this_is_variable;
|
||||
|
||||
/* Nonzero means do emit exported implementations of functions even if
|
||||
they can be inlined. */
|
||||
|
||||
|
@ -346,11 +346,6 @@ int flag_labels_ok;
|
||||
int flag_ms_extensions;
|
||||
|
||||
/* C++ specific flags. */
|
||||
/* Zero means that `this' is a *const. This gives nice behavior in the
|
||||
2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior.
|
||||
-2 means we're constructing an object and it has fixed type. */
|
||||
|
||||
int flag_this_is_variable;
|
||||
|
||||
/* Nonzero means we should attempt to elide constructors when possible. */
|
||||
|
||||
|
@ -2388,9 +2388,7 @@ init_vbase_pointers (type, decl_ptr)
|
||||
if (TYPE_USES_VIRTUAL_BASECLASSES (type))
|
||||
{
|
||||
struct vbase_info vi;
|
||||
int old_flag = flag_this_is_variable;
|
||||
tree binfo = TYPE_BINFO (type);
|
||||
flag_this_is_variable = -2;
|
||||
|
||||
/* Find all the virtual base classes, marking them for later
|
||||
initialization. */
|
||||
@ -2408,7 +2406,6 @@ init_vbase_pointers (type, decl_ptr)
|
||||
marked_vtable_pathp,
|
||||
NULL);
|
||||
|
||||
flag_this_is_variable = old_flag;
|
||||
return vi.inits;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues)
|
||||
if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
|
||||
return clk_ordinary;
|
||||
|
||||
if (ref == current_class_ptr && flag_this_is_variable <= 0)
|
||||
if (ref == current_class_ptr)
|
||||
return clk_none;
|
||||
|
||||
switch (TREE_CODE (ref))
|
||||
|
@ -4886,8 +4886,7 @@ mark_addressable (exp)
|
||||
case PARM_DECL:
|
||||
if (x == current_class_ptr)
|
||||
{
|
||||
if (! flag_this_is_variable)
|
||||
error ("cannot take the address of `this', which is an ravlue expression");
|
||||
error ("cannot take the address of `this', which is an rvalue expression");
|
||||
TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user