diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-04-26 15:43:50 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-04-26 15:43:50 +0000 |
commit | fc611ce0f5aa284bd88116eab9c781a9e95e0e79 (patch) | |
tree | e677c2a2cecce758e9be195b1143cdb72174210c /gcc/cp | |
parent | d4047e241e8c3f88b53f8c14bd8dc77d82d8efbb (diff) | |
download | gcc-fc611ce0f5aa284bd88116eab9c781a9e95e0e79.zip gcc-fc611ce0f5aa284bd88116eab9c781a9e95e0e79.tar.gz gcc-fc611ce0f5aa284bd88116eab9c781a9e95e0e79.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 20 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 8 | ||||
-rw-r--r-- | gcc/cp/init.c | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 19 |
10 files changed, 42 insertions, 33 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0cfe024..f835725 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d8dda3e..8cbdd30 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b5d3f3e..5a95bc5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5c4f5ac..a36803e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 376cdaa..5a2964f 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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)); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cd6fd49..78c4167 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) { diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 61685dd..dd89057 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fc2bcfb..373b7c0 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bfad70f..2379a2c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index da5e954..39b47a0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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] |