c-decl.c (build_compound_literal): Use TYPE_READONLY.

* c-decl.c (build_compound_literal): Use TYPE_READONLY.
	* emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise.
	* objc/objc-act.c (adorn_decl, gen_declspecs): Likewise.
	* c-typeck.c (decl_constant_value): Don't access DECL_INITIAL of a
	PARM_DECL.
	* calls.c (flags_from_decl_or_type): Use TYPE_READONLY and do so only
	for a type.
	* print-tree.c (print_node): Properly handle side-effects, readonly,
	and constant flags.
	* tree.c (build1_stat, build_expr_wfl): Only look at TREE_SIDE_EFFECTS
	and TREE_CONSTANT if not a type.
	* tree.h (IS_NON_TYPE_CODE_CLASS): New macro.
	(IS_EXPR_CODE_CLASS): Write 'E', not 'e'.
	(NON_TYPE_CHECK): New macro.
	(TREE_SIDE_EFFECT, TREE_READONLY, TREE_CONSTANT: Add check.

	* cp/init.c (decl_constant_value): Don't look at DECL_INITIAL
	of PARM_DECL.
	* cp/tree.c (bot_manip, build_min): Don't look at TREE_CONSTANT
	or TREE_SIDE_EFFECTS of a type.

	* ada/decl.c (gnat_to_gnu_entity): Use TYPE_READONLY.
	* ada/utils.c (create_field_decl): Likewise.
	* ada/utils2.c (build_unary_op, gnat_build_constructor): Likewise.

From-SVN: r80430
This commit is contained in:
Richard Kenner 2004-04-05 12:25:26 +00:00 committed by Richard Kenner
parent 5ffc47306c
commit 4f976745b7
16 changed files with 97 additions and 44 deletions

View File

@ -1,3 +1,21 @@
2004-04-05 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* c-decl.c (build_compound_literal): Use TYPE_READONLY.
* emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise.
* objc/objc-act.c (adorn_decl, gen_declspecs): Likewise.
* c-typeck.c (decl_constant_value): Don't access DECL_INITIAL of a
PARM_DECL.
* calls.c (flags_from_decl_or_type): Use TYPE_READONLY and do so only
for a type.
* print-tree.c (print_node): Properly handle side-effects, readonly,
and constant flags.
* tree.c (build1_stat, build_expr_wfl): Only look at TREE_SIDE_EFFECTS
and TREE_CONSTANT if not a type.
* tree.h (IS_NON_TYPE_CODE_CLASS): New macro.
(IS_EXPR_CODE_CLASS): Write 'E', not 'e'.
(NON_TYPE_CHECK): New macro.
(TREE_SIDE_EFFECT, TREE_READONLY, TREE_CONSTANT: Add check.
2004-04-05 Eric Botcazou <ebotcazou@libertysurf.fr>
* config/sparc/sol2-bi.h (PREFERRED_DEBUGGING_TYPE): Set

View File

@ -1,3 +1,9 @@
2004-04-05 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* decl.c (gnat_to_gnu_entity): Use TYPE_READONLY.
* utils.c (create_field_decl): Likewise.
* utils2.c (build_unary_op, gnat_build_constructor): Likewise.
2004-04-02 Arnaud Charlet <charlet@act-europe.fr>
* gnat-style.texi, gnat_rm.texi, gnat_ugn.texi: Remove RCS tags.

View File

@ -1443,7 +1443,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
= create_concat_name (gnat_entity, "XUB");
TYPE_NAME (gnu_fat_type) = create_concat_name (gnat_entity, "XUP");
TYPE_IS_FAT_POINTER_P (gnu_fat_type) = 1;
TREE_READONLY (gnu_template_type) = 1;
TYPE_READONLY (gnu_template_type) = 1;
/* Make a node for the array. If we are not defining the array
suppress expanding incomplete types and save the node as the type
@ -1553,7 +1553,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Install all the fields into the template. */
finish_record_type (gnu_template_type, gnu_template_fields, 0, 0);
TREE_READONLY (gnu_template_type) = 1;
TYPE_READONLY (gnu_template_type) = 1;
/* Now make the array of arrays and update the pointer to the array
in the fat pointer. Note that it is the first field. */

View File

@ -1403,7 +1403,7 @@ create_field_decl (tree field_name,
tree field_decl = build_decl (FIELD_DECL, field_name, field_type);
DECL_CONTEXT (field_decl) = record_type;
TREE_READONLY (field_decl) = TREE_READONLY (field_type);
TREE_READONLY (field_decl) = TYPE_READONLY (field_type);
/* If FIELD_TYPE is BLKmode, we must ensure this is aligned to at least a
byte boundary since GCC cannot handle less-aligned BLKmode bitfields. */

View File

@ -1234,7 +1234,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
else
{
result = fold (build1 (op_code, TREE_TYPE (type), operand));
TREE_READONLY (result) = TREE_READONLY (TREE_TYPE (type));
TREE_READONLY (result) = TYPE_READONLY (TREE_TYPE (type));
}
side_effects
@ -1521,7 +1521,7 @@ gnat_build_constructor (tree type, tree list)
TREE_CONSTANT (result) = allconstant;
TREE_STATIC (result) = allconstant;
TREE_SIDE_EFFECTS (result) = side_effects;
TREE_READONLY (result) = TREE_READONLY (type);
TREE_READONLY (result) = TYPE_READONLY (type);
return result;
}

View File

@ -3089,7 +3089,7 @@ build_compound_literal (tree type, tree init)
DECL_CONTEXT (decl) = current_function_decl;
TREE_USED (decl) = 1;
TREE_TYPE (decl) = type;
TREE_READONLY (decl) = TREE_READONLY (type);
TREE_READONLY (decl) = TYPE_READONLY (type);
store_init_value (decl, init);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))

View File

@ -1003,8 +1003,10 @@ tree
decl_constant_value (tree decl)
{
if (/* Don't change a variable array bound or initial value to a constant
in a place where a variable is invalid. */
in a place where a variable is invalid. Note that DECL_INITIAL
isn't valid for a PARM_DECL. */
current_function_decl != 0
&& TREE_CODE (decl) != PARM_DECL
&& ! TREE_THIS_VOLATILE (decl)
&& TREE_READONLY (decl)
&& DECL_INITIAL (decl) != 0

View File

@ -726,10 +726,9 @@ flags_from_decl_or_type (tree exp)
flags |= ECF_NOTHROW;
if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
flags |= ECF_LIBCALL_BLOCK;
flags |= ECF_LIBCALL_BLOCK | ECF_CONST;
}
if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
else if (TYPE_P (exp) && TYPE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
flags |= ECF_CONST;
if (TREE_THIS_VOLATILE (exp))

View File

@ -1,3 +1,10 @@
2004-04-05 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* init.c (decl_constant_value): Don't look at DECL_INITIAL
of PARM_DECL.
* tree.c (bot_manip, build_min): Don't look at TREE_CONSTANT
or TREE_SIDE_EFFECTS of a type.
2004-04-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/14007

View File

@ -1623,6 +1623,7 @@ decl_constant_value (tree decl)
/* And so are variables with a 'const' type -- unless they
are also 'volatile'. */
|| CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)))
&& TREE_CODE (decl) != PARM_DECL
&& DECL_INITIAL (decl)
&& DECL_INITIAL (decl) != error_mark_node
/* This is invalid if initial value is not constant.

View File

@ -1186,7 +1186,7 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
splay_tree target_remap = ((splay_tree) data);
tree t = *tp;
if (TREE_CONSTANT (t))
if (!TYPE_P (t) && TREE_CONSTANT (t))
{
/* There can't be any TARGET_EXPRs or their slot variables below
this point. We used to check !TREE_SIDE_EFFECTS, but then we
@ -1327,7 +1327,7 @@ build_min (enum tree_code code, tree tt, ...)
{
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
if (x && TREE_SIDE_EFFECTS (x))
if (x && !TYPE_P (x) && TREE_SIDE_EFFECTS (x))
TREE_SIDE_EFFECTS (t) = 1;
}

View File

@ -1504,7 +1504,7 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
RTX_UNCHANGING_P (ref)
|= ((lang_hooks.honor_readonly
&& (TYPE_READONLY (type) || TREE_READONLY (t)))
&& (TYPE_READONLY (type) || (t != type && TREE_READONLY (t))))
|| (! TYPE_P (t) && TREE_CONSTANT (t)));
MEM_POINTER (ref) = POINTER_TYPE_P (type);

View File

@ -8099,9 +8099,9 @@ adorn_decl (tree decl, char *str)
else if (code == POINTER_TYPE)
{
strcpy (tmpbuf, "*");
if (TREE_READONLY (decl) || TYPE_VOLATILE (decl))
if (TYPE_READONLY (decl) || TYPE_VOLATILE (decl))
{
if (TREE_READONLY (decl))
if (TYPE_READONLY (decl))
strcat (tmpbuf, " const");
if (TYPE_VOLATILE (decl))
strcat (tmpbuf, " volatile");
@ -8305,7 +8305,7 @@ gen_declspecs (tree declspecs, char *buf, int raw)
else
{
/* Type qualifiers. */
if (TREE_READONLY (declspecs))
if (TYPE_READONLY (declspecs))
strcat (buf, "const ");
if (TYPE_VOLATILE (declspecs))
strcat (buf, "volatile ");

View File

@ -245,11 +245,12 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
indent_to (file, indent + 3);
}
if (TREE_SIDE_EFFECTS (node))
if (!TYPE_P (node) && TREE_SIDE_EFFECTS (node))
fputs (" side-effects", file);
if (TREE_READONLY (node))
if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
fputs (" readonly", file);
if (TREE_CONSTANT (node))
if (!TYPE_P (node) && TREE_CONSTANT (node))
fputs (" constant", file);
if (TREE_ADDRESSABLE (node))
fputs (" addressable", file);

View File

@ -2402,7 +2402,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
TREE_TYPE (t) = type;
TREE_COMPLEXITY (t) = 0;
TREE_OPERAND (t, 0) = node;
if (node && first_rtl_op (code) != 0)
if (node && !TYPE_P (node) && first_rtl_op (code) != 0)
{
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
TREE_READONLY (t) = TREE_READONLY (node);
@ -2456,7 +2456,8 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
break;
default:
if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node))
if (TREE_CODE_CLASS (code) == '1' && node && !TYPE_P (node)
&& TREE_CONSTANT (node))
TREE_CONSTANT (t) = 1;
break;
}
@ -2467,7 +2468,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
#define PROCESS_ARG(N) \
do { \
TREE_OPERAND (t, N) = arg##N; \
if (arg##N && fro > N) \
if (arg##N &&!TYPE_P (arg##N) && fro > N) \
{ \
if (TREE_SIDE_EFFECTS (arg##N)) \
side_effects = 1; \
@ -2742,7 +2743,8 @@ build_expr_wfl (tree node, const char *file, int line, int col)
}
EXPR_WFL_FILENAME_NODE (wfl) = last_filenode;
if (node)
if (node && !TYPE_P (node))
{
TREE_SIDE_EFFECTS (wfl) = TREE_SIDE_EFFECTS (node);
TREE_TYPE (wfl) = TREE_TYPE (node);

View File

@ -54,6 +54,10 @@ enum tree_code {
extern const char tree_code_type[];
#define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)]
/* Returns nonzero iff CLASS is not the tree code of a type. */
#define IS_NON_TYPE_CODE_CLASS(CLASS) (strchr ("xbcdr<12se", (CLASS)) != 0)
/* Returns nonzero iff CLASS is the tree-code class of an
expression. */
@ -159,15 +163,16 @@ struct tree_common GTY(())
unsigned readonly_flag : 1;
unsigned unsigned_flag : 1;
unsigned asm_written_flag: 1;
unsigned unused_0 : 1;
unsigned used_flag : 1;
unsigned nothrow_flag : 1;
unsigned static_flag : 1;
unsigned public_flag : 1;
unsigned private_flag : 1;
unsigned protected_flag : 1;
unsigned deprecated_flag : 1;
unsigned unused_0 : 1;
unsigned unused_1 : 1;
unsigned lang_flag_0 : 1;
@ -240,6 +245,8 @@ struct tree_common GTY(())
TREE_SIDE_EFFECTS in
all expressions
all decls
all constants
volatile_flag:
@ -259,6 +266,8 @@ struct tree_common GTY(())
TREE_CONSTANT in
all expressions
all decls
all constants
unsigned_flag:
@ -365,7 +374,16 @@ struct tree_common GTY(())
({ const tree __t = (T); \
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
if (!IS_EXPR_CODE_CLASS (__c)) \
tree_class_check_failed (__t, 'e', __FILE__, __LINE__, \
tree_class_check_failed (__t, 'E', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
/* These checks have to be special cased. */
#define NON_TYPE_CHECK(T) __extension__ \
({ const tree __t = (T); \
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
if (!IS_NON_TYPE_CODE_CLASS (__c)) \
tree_class_check_failed (__t, 'T', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
@ -448,6 +466,7 @@ extern void tree_operand_check_failed (int, enum tree_code,
#define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
#define TREE_CLASS_CHECK(T, CODE) (T)
#define EXPR_CHECK(T) (T)
#define NON_TYPE_CHECK(T) (T)
#define TREE_VEC_ELT_CHECK(T, I) ((T)->vec.a[I])
#define TREE_OPERAND_CHECK(T, I) ((T)->exp.operands[I])
#define TREE_OPERAND_CHECK_CODE(T, CODE, I) ((T)->exp.operands[I])
@ -677,12 +696,13 @@ extern void tree_operand_check_failed (int, enum tree_code,
for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
/* In any expression, nonzero means it has side effects or reevaluation
of the whole expression could produce a different value.
This is set if any subexpression is a function call, a side effect
or a reference to a volatile variable.
In a ..._DECL, this is set only if the declaration said `volatile'. */
#define TREE_SIDE_EFFECTS(NODE) ((NODE)->common.side_effects_flag)
/* In any expression, decl, or constant, nonzero means it has side effects or
reevaluation of the whole expression could produce a different value.
This is set if any subexpression is a function call, a side effect or a
reference to a volatile variable. In a ..._DECL, this is set only if the
declaration said `volatile'. This will never be set for a constant. */
#define TREE_SIDE_EFFECTS(NODE) \
(NON_TYPE_CHECK (NODE)->common.side_effects_flag)
/* Nonzero means this expression is volatile in the C sense:
its address should be of type `volatile WHATEVER *'.
@ -697,20 +717,15 @@ extern void tree_operand_check_failed (int, enum tree_code,
#define TREE_THIS_VOLATILE(NODE) ((NODE)->common.volatile_flag)
/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
nonzero means it may not be the lhs of an assignment.
In a ..._TYPE node, means this type is const-qualified
(but the macro TYPE_READONLY should be used instead of this macro
when the node is a type). */
#define TREE_READONLY(NODE) ((NODE)->common.readonly_flag)
nonzero means it may not be the lhs of an assignment. */
#define TREE_READONLY(NODE) (NON_TYPE_CHECK (NODE)->common.readonly_flag)
/* Nonzero if NODE is a _DECL with TREE_READONLY set. */
#define TREE_READONLY_DECL_P(NODE) (TREE_READONLY (NODE) && DECL_P (NODE))
#define TREE_READONLY_DECL_P(NODE) (DECL_P (NODE) && TREE_READONLY (NODE))
/* Value of expression is constant.
Always appears in all ..._CST nodes.
May also appear in an arithmetic expression, an ADDR_EXPR or a CONSTRUCTOR
if the value is constant. */
#define TREE_CONSTANT(NODE) ((NODE)->common.constant_flag)
/* Value of expression is constant. Always on in all ..._CST nodes. May
also appear in an expression or decl where the value is constant. */
#define TREE_CONSTANT(NODE) (NON_TYPE_CHECK (NODE)->common.constant_flag)
/* In a decl (most significantly a FIELD_DECL), means an unsigned field. */
#define DECL_UNSIGNED(NODE) (DECL_CHECK (NODE)->common.unsigned_flag)
@ -1446,7 +1461,9 @@ struct tree_type GTY(())
For a VAR_DECL, holds the initial value.
For a PARM_DECL, not used--default
values for parameters are encoded in the type of the function,
not in the PARM_DECL slot. */
not in the PARM_DECL slot.
??? Need to figure out some way to check this isn't a PARM_DECL. */
#define DECL_INITIAL(NODE) (DECL_CHECK (NODE)->decl.initial)
/* For a PARM_DECL, records the data type used to pass the argument,
which may be different from the type seen in the program. */