Commit 394fd776 by Nathan Sidwell Committed by Nathan Sidwell

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
parent c7c0ae3d
2001-02-14 Nathan Sidwell <nathan@codesourcery.com> 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. * pt.c (unify): Don't check cv quals of array types.
2001-02-14 Nathan Sidwell <nathan@codesourcery.com> 2001-02-14 Nathan Sidwell <nathan@codesourcery.com>
......
...@@ -131,7 +131,7 @@ static void maybe_warn_about_overly_private_class PARAMS ((tree)); ...@@ -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 field_decl_cmp PARAMS ((const tree *, const tree *));
static int method_name_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 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, static tree resolve_address_of_overloaded_function PARAMS ((tree, tree, int,
int, int, tree)); int, int, tree));
static void build_vtable_entry_ref PARAMS ((tree, tree, tree)); static void build_vtable_entry_ref PARAMS ((tree, tree, tree));
...@@ -381,6 +381,9 @@ build_vbase_path (code, type, expr, path, nonnull) ...@@ -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 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. */ if the complete type is the same type as expr has. */
fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull); 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)) if (!fixed_type_p && TREE_SIDE_EFFECTS (expr))
expr = save_expr (expr); expr = save_expr (expr);
...@@ -5370,9 +5373,10 @@ finish_struct (t, attributes) ...@@ -5370,9 +5373,10 @@ finish_struct (t, attributes)
before this function is called. */ before this function is called. */
static tree static tree
fixed_type_or_null (instance, nonnull) fixed_type_or_null (instance, nonnull, cdtorp)
tree instance; tree instance;
int *nonnull; int *nonnull;
int *cdtorp;
{ {
switch (TREE_CODE (instance)) switch (TREE_CODE (instance))
{ {
...@@ -5400,31 +5404,31 @@ fixed_type_or_null (instance, nonnull) ...@@ -5400,31 +5404,31 @@ fixed_type_or_null (instance, nonnull)
*nonnull = 1; *nonnull = 1;
return TREE_TYPE (instance); 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: case RTL_EXPR:
return NULL_TREE; return NULL_TREE;
case PLUS_EXPR: case PLUS_EXPR:
case MINUS_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) if (TREE_CODE (TREE_OPERAND (instance, 1)) == INTEGER_CST)
/* Propagate nonnull. */ /* Propagate nonnull. */
fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull); fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR)
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull);
return NULL_TREE; return NULL_TREE;
case NOP_EXPR: case NOP_EXPR:
case CONVERT_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: case ADDR_EXPR:
if (nonnull) if (nonnull)
*nonnull = 1; *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: 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 VAR_DECL:
case FIELD_DECL: case FIELD_DECL:
...@@ -5444,21 +5448,25 @@ fixed_type_or_null (instance, nonnull) ...@@ -5444,21 +5448,25 @@ fixed_type_or_null (instance, nonnull)
*nonnull = 1; *nonnull = 1;
return TREE_TYPE (instance); return TREE_TYPE (instance);
} }
else if (nonnull) else if (instance == current_class_ptr)
{ {
if (instance == current_class_ptr if (nonnull)
&& flag_this_is_variable <= 0) *nonnull = 1;
{
/* Normally, 'this' must be non-null. */ /* if we're in a ctor or dtor, we know our type. */
if (flag_this_is_variable == 0) if (DECL_LANG_SPECIFIC (current_function_decl)
*nonnull = 1; && (DECL_CONSTRUCTOR_P (current_function_decl)
|| DECL_DESTRUCTOR_P (current_function_decl)))
/* <0 means we're in a constructor and we know our type. */ {
if (flag_this_is_variable < 0) if (cdtorp)
return TREE_TYPE (TREE_TYPE (instance)); *cdtorp = 1;
} return TREE_TYPE (TREE_TYPE (instance));
else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE) }
/* Reference variables should be references to objects. */ }
else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
{
/* Reference variables should be references to objects. */
if (nonnull)
*nonnull = 1; *nonnull = 1;
} }
return NULL_TREE; return NULL_TREE;
...@@ -5470,7 +5478,9 @@ fixed_type_or_null (instance, nonnull) ...@@ -5470,7 +5478,9 @@ fixed_type_or_null (instance, nonnull)
/* Return non-zero if the dynamic type of INSTANCE is known, and equivalent /* 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 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 Used to determine whether the virtual function table is needed
or not. or not.
...@@ -5485,12 +5495,16 @@ resolves_to_fixed_type_p (instance, nonnull) ...@@ -5485,12 +5495,16 @@ resolves_to_fixed_type_p (instance, nonnull)
int *nonnull; int *nonnull;
{ {
tree t = TREE_TYPE (instance); 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) if (fixed == NULL_TREE)
return 0; return 0;
if (POINTER_TYPE_P (t)) if (POINTER_TYPE_P (t))
t = TREE_TYPE (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; ...@@ -3420,10 +3420,6 @@ extern varray_type local_classes;
/* Things for handling inline functions. */ /* 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 /* Nonzero means do emit exported implementations of functions even if
they can be inlined. */ they can be inlined. */
......
...@@ -346,11 +346,6 @@ int flag_labels_ok; ...@@ -346,11 +346,6 @@ int flag_labels_ok;
int flag_ms_extensions; int flag_ms_extensions;
/* C++ specific flags. */ /* 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. */ /* Nonzero means we should attempt to elide constructors when possible. */
......
...@@ -2388,9 +2388,7 @@ init_vbase_pointers (type, decl_ptr) ...@@ -2388,9 +2388,7 @@ init_vbase_pointers (type, decl_ptr)
if (TYPE_USES_VIRTUAL_BASECLASSES (type)) if (TYPE_USES_VIRTUAL_BASECLASSES (type))
{ {
struct vbase_info vi; struct vbase_info vi;
int old_flag = flag_this_is_variable;
tree binfo = TYPE_BINFO (type); tree binfo = TYPE_BINFO (type);
flag_this_is_variable = -2;
/* Find all the virtual base classes, marking them for later /* Find all the virtual base classes, marking them for later
initialization. */ initialization. */
...@@ -2408,7 +2406,6 @@ init_vbase_pointers (type, decl_ptr) ...@@ -2408,7 +2406,6 @@ init_vbase_pointers (type, decl_ptr)
marked_vtable_pathp, marked_vtable_pathp,
NULL); NULL);
flag_this_is_variable = old_flag;
return vi.inits; return vi.inits;
} }
......
...@@ -65,7 +65,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues) ...@@ -65,7 +65,7 @@ lvalue_p_1 (ref, treat_class_rvalues_as_lvalues)
if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE) if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
return clk_ordinary; return clk_ordinary;
if (ref == current_class_ptr && flag_this_is_variable <= 0) if (ref == current_class_ptr)
return clk_none; return clk_none;
switch (TREE_CODE (ref)) switch (TREE_CODE (ref))
......
...@@ -4886,8 +4886,7 @@ mark_addressable (exp) ...@@ -4886,8 +4886,7 @@ mark_addressable (exp)
case PARM_DECL: case PARM_DECL:
if (x == current_class_ptr) if (x == current_class_ptr)
{ {
if (! flag_this_is_variable) error ("cannot take the address of `this', which is an rvalue expression");
error ("cannot take the address of `this', which is an ravlue expression");
TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */ TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */
return 1; return 1;
} }
......
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