cp-tree.h (TREE_READONLY_DECL_P): Use DECL_P.

* cp-tree.h (TREE_READONLY_DECL_P): Use DECL_P.
	* init.c (decl_constant_value): Check TREE_READONLY_DECL_P.
	* call.c (convert_like_real): Don't test TREE_READONLY_DECL_P
	before calling decl_constant_value.
	* class.c (check_bitfield_decl): Likewise.
	* cvt.c (ocp_convert): Likewise.
	(convert): Likewise.
	* decl.c (compute_array_index_type): Likewise.
	(build_enumerator): Likewise.
	* decl2.c (check_cp_case_value): Likewise.
	* pt.c (convert_nontype_argument): Likewise.
	(tsubst): Likewise.
	* typeck.c (decay_conversion): Likewise.
	(build_compound_expr): Likewise.
	(build_reinterpret_cast): Likewise.
	(build_c_cast): Likewise.
	(convert_for_assignment): Likewise.

From-SVN: r33446
This commit is contained in:
Mark Mitchell 2000-04-26 15:43:50 +00:00 committed by Mark Mitchell
parent d4047e241e
commit fc611ce0f5
10 changed files with 42 additions and 33 deletions

View File

@ -1,3 +1,23 @@
2000-04-26 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (TREE_READONLY_DECL_P): Use DECL_P.
* init.c (decl_constant_value): Check TREE_READONLY_DECL_P.
* call.c (convert_like_real): Don't test TREE_READONLY_DECL_P
before calling decl_constant_value.
* class.c (check_bitfield_decl): Likewise.
* cvt.c (ocp_convert): Likewise.
(convert): Likewise.
* decl.c (compute_array_index_type): Likewise.
(build_enumerator): Likewise.
* decl2.c (check_cp_case_value): Likewise.
* pt.c (convert_nontype_argument): Likewise.
(tsubst): Likewise.
* typeck.c (decay_conversion): Likewise.
(build_compound_expr): Likewise.
(build_reinterpret_cast): Likewise.
(build_c_cast): Likewise.
(convert_for_assignment): Likewise.
2000-04-26 Jason Merrill <jason@casey.cygnus.com>
* decl.c (finish_function): Don't play games with DECL_INLINE.

View File

@ -3720,7 +3720,7 @@ convert_like_real (convs, expr, fn, argnum, inner)
/* Convert a non-array constant variable to its underlying value, unless we
are about to bind it to a reference, in which case we need to
leave it as an lvalue. */
if (TREE_READONLY_DECL_P (expr) && TREE_CODE (convs) != REF_BIND
if (TREE_CODE (convs) != REF_BIND
&& TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
expr = decl_constant_value (expr);

View File

@ -3061,7 +3061,7 @@ check_bitfield_decl (field)
/* detect invalid field size. */
if (TREE_CODE (w) == CONST_DECL)
w = DECL_INITIAL (w);
else if (TREE_READONLY_DECL_P (w))
else
w = decl_constant_value (w);
if (TREE_CODE (w) != INTEGER_CST)

View File

@ -1922,7 +1922,7 @@ struct lang_decl
/* Non-zero if NODE is a _DECL with TREE_READONLY set. */
#define TREE_READONLY_DECL_P(NODE) \
(TREE_READONLY (NODE) && TREE_CODE_CLASS (TREE_CODE (NODE)) == 'd')
(TREE_READONLY (NODE) && DECL_P (NODE))
/* Non-zero iff DECL is memory-based. The DECL_RTL of
certain const variables might be a CONST_INT, or a REG

View File

@ -673,8 +673,7 @@ ocp_convert (type, expr, convtype, flags)
complete_type (type);
complete_type (TREE_TYPE (expr));
if (TREE_READONLY_DECL_P (e))
e = decl_constant_value (e);
e = decl_constant_value (e);
if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP)
/* Some internal structures (vtable_entry_type, sigtbl_ptr_type)
@ -1003,8 +1002,7 @@ convert (type, expr)
if (POINTER_TYPE_P (type) && POINTER_TYPE_P (intype))
{
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}

View File

@ -9124,8 +9124,7 @@ compute_array_index_type (name, size)
STRIP_TYPE_NOPS (size);
/* It might be a const variable or enumeration constant. */
if (TREE_READONLY_DECL_P (size))
size = decl_constant_value (size);
size = decl_constant_value (size);
/* If this involves a template parameter, it will be a constant at
instantiation time, but we don't know what the value is yet.
@ -13019,8 +13018,7 @@ build_enumerator (name, value, enumtype)
/* Validate and default VALUE. */
if (value != NULL_TREE)
{
if (TREE_READONLY_DECL_P (value))
value = decl_constant_value (value);
value = decl_constant_value (value);
if (TREE_CODE (value) == INTEGER_CST)
{

View File

@ -4143,12 +4143,8 @@ check_cp_case_value (value)
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
STRIP_TYPE_NOPS (value);
if (TREE_READONLY_DECL_P (value))
{
value = decl_constant_value (value);
STRIP_TYPE_NOPS (value);
}
value = decl_constant_value (value);
STRIP_TYPE_NOPS (value);
value = fold (value);
if (TREE_CODE (value) != INTEGER_CST

View File

@ -1779,13 +1779,15 @@ resolve_offset_ref (exp)
return NULL_TREE;
}
/* Return either DECL or its known constant value (if it has one). */
/* If DECL is a `const' declaration, and its value is a known
constant, then return that value. */
tree
decl_constant_value (decl)
tree decl;
{
if (! TREE_THIS_VOLATILE (decl)
if (TREE_READONLY_DECL_P (decl)
&& ! TREE_THIS_VOLATILE (decl)
&& DECL_INITIAL (decl)
&& DECL_INITIAL (decl) != error_mark_node
/* This is invalid if initial value is not constant.

View File

@ -2701,7 +2701,7 @@ convert_nontype_argument (type, expr)
enumerators. Simplify things by folding them to their values,
unless we're about to bind the declaration to a reference
parameter. */
if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr)
if (INTEGRAL_TYPE_P (expr_type)
&& TREE_CODE (type) != REFERENCE_TYPE)
expr = decl_constant_value (expr);
@ -6200,7 +6200,7 @@ tsubst (t, args, complain, in_decl)
/* See if we can reduce this expression to something simpler. */
max = maybe_fold_nontype_arg (max);
if (!processing_template_decl && TREE_READONLY_DECL_P (max))
if (!processing_template_decl)
max = decl_constant_value (max);
if (processing_template_decl

View File

@ -1710,7 +1710,7 @@ decay_conversion (exp)
don't do this for arrays, though; we want the address of the
first element of the array, not the address of the first element
of its initializing constant. */
else if (TREE_READONLY_DECL_P (exp) && code != ARRAY_TYPE)
else if (code != ARRAY_TYPE)
{
exp = decl_constant_value (exp);
type = TREE_TYPE (exp);
@ -5084,8 +5084,7 @@ build_compound_expr (list)
register tree rest;
tree first;
if (TREE_READONLY_DECL_P (TREE_VALUE (list)))
TREE_VALUE (list) = decl_constant_value (TREE_VALUE (list));
TREE_VALUE (list) = decl_constant_value (TREE_VALUE (list));
if (TREE_CHAIN (list) == 0)
{
@ -5272,8 +5271,7 @@ build_reinterpret_cast (type, expr)
else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
{
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}
else if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
@ -5283,16 +5281,14 @@ build_reinterpret_cast (type, expr)
cp_pedwarn ("reinterpret_cast from `%T' to `%T' casts away const (or volatile)",
intype, type);
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}
else if ((TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype))
|| (TYPE_PTRFN_P (intype) && TYPE_PTROBV_P (type)))
{
pedwarn ("ISO C++ forbids casting between pointer-to-function and pointer-to-object");
if (TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
expr = decl_constant_value (expr);
return fold (build1 (NOP_EXPR, type, expr));
}
else
@ -5498,8 +5494,7 @@ build_c_cast (type, expr)
{
tree ovalue;
if (TREE_READONLY_DECL_P (value))
value = decl_constant_value (value);
value = decl_constant_value (value);
ovalue = value;
value = convert_force (type, value, CONV_C_CAST);
@ -6493,7 +6488,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
/* Simplify the RHS if possible. */
if (TREE_CODE (rhs) == CONST_DECL)
rhs = DECL_INITIAL (rhs);
else if (TREE_READONLY_DECL_P (rhs) && coder != ARRAY_TYPE)
else if (coder != ARRAY_TYPE)
rhs = decl_constant_value (rhs);
/* [expr.ass]