diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 37 | ||||
-rw-r--r-- | gcc/cp/call.c | 19 | ||||
-rw-r--r-- | gcc/cp/class.c | 10 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl.c | 10 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/init.c | 2 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 7 | ||||
-rw-r--r-- | gcc/cp/method.c | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 14 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 4 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 24 |
14 files changed, 86 insertions, 58 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6dd97bb..68d461e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,42 @@ 2010-05-19 Jason Merrill <jason@redhat.com> + * call.c (reference_binding): Use cp_build_qualified_type_real + and cp_type_quals consistently. + (add_function_candidate): Likewise. + (build_conditional_expr): Likewise. + (convert_like_real): Likewise. + (type_passed_as): Likewise. + * class.c (add_method): Likewise. + (same_signature_p): Likewise. + (layout_class_type): Likewise. + * decl.c (cxx_init_decl_processing): Likewise. + (cp_fname_init): Likewise. + (grokdeclarator): Likewise. + * decl2.c (cp_reconstruct_complex_type): Likewise. + * init.c (build_new_1): Likewise. + * method.c (do_build_copy_constructor): Likewise. + (implicitly_declare_fn): Likewise. + * pt.c (tsubst_aggr_type): Likewise. + (tsubst): Likewise. + * rtti.c (init_rtti_processing): Likewise. + (build_headof): Likewise. + (build_dynamic_cast_1): Likewise. + (tinfo_base_init): Likewise. + (emit_support_tinfos): Likewise. + * semantics.c (capture_decltype): Likewise. + * tree.c (cv_unqualified): Likewise. + * typeck.c (composite_pointer_type): Likewise. + (string_conv_p): Likewise. + + * mangle.c (write_CV_qualifiers_for_type): Tweak. + + * call.c (initialize_reference): Use CP_TYPE_CONST_P. + * decl.c (start_decl): Likewise. + * semantics.c (finish_compound_literal): Likewise. + * typeck.c (check_return_expr): Use CP_TYPE_VOLATILE_P. + (cp_type_readonly): Remove. + * cp-tree.h: Remove declaration. + * typeck.c (merge_types): Preserve memfn quals. * decl.c (grokdeclarator): Don't check quals on fn type. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 97a196b..3cb30a5 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1246,7 +1246,7 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) type, so that we can later do a const_cast to the desired type. */ if (related_p && c_cast_p && !at_least_as_qualified_p (to, tfrom)) - to = build_qualified_type (to, cp_type_quals (tfrom)); + to = cp_build_qualified_type (to, cp_type_quals (tfrom)); compatible_p = reference_compatible_p (to, tfrom); /* Directly bind reference when target expression's type is compatible with @@ -1617,9 +1617,8 @@ add_function_candidate (struct z_candidate **candidates, parameter, we can just change the parm type. */ if (ctype && is_this) { - parmtype - = build_qualified_type (ctype, - TYPE_QUALS (TREE_TYPE (parmtype))); + parmtype = cp_build_qualified_type + (ctype, cp_type_quals (TREE_TYPE (parmtype))); parmtype = build_pointer_type (parmtype); } @@ -3777,11 +3776,11 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3, the type of the other. */ if ((conv2 || conv3) && CLASS_TYPE_P (arg2_type) - && TYPE_QUALS (arg2_type) != TYPE_QUALS (arg3_type)) + && cp_type_quals (arg2_type) != cp_type_quals (arg3_type)) arg2_type = arg3_type = cp_build_qualified_type (arg2_type, - TYPE_QUALS (arg2_type) - | TYPE_QUALS (arg3_type)); + cp_type_quals (arg2_type) + | cp_type_quals (arg3_type)); } /* [expr.cond] @@ -4997,7 +4996,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, } /* Build up the array. */ elttype = cp_build_qualified_type - (elttype, TYPE_QUALS (elttype) | TYPE_QUAL_CONST); + (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST); array = build_array_of_n_type (elttype, len); array = finish_compound_literal (array, new_ctor); @@ -5378,7 +5377,7 @@ type_passed_as (tree type) { type = build_reference_type (type); /* There are no other pointers to this temporary. */ - type = build_qualified_type (type, TYPE_QUAL_RESTRICT); + type = cp_build_qualified_type (type, TYPE_QUAL_RESTRICT); } else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) @@ -7735,7 +7734,7 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup, { if (complain & tf_error) { - if (!(TYPE_QUALS (TREE_TYPE (type)) & TYPE_QUAL_CONST) + if (!CP_TYPE_CONST_P (TREE_TYPE (type)) && !TYPE_REF_IS_RVALUE (type) && !real_lvalue_p (expr)) error ("invalid initialization of non-const reference of " diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 88db80f..748e1b3 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1048,8 +1048,8 @@ add_method (tree type, tree method, tree using_decl) && ! DECL_STATIC_FUNCTION_P (method) && TREE_TYPE (TREE_VALUE (parms1)) != error_mark_node && TREE_TYPE (TREE_VALUE (parms2)) != error_mark_node - && (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1))) - != TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2))))) + && (cp_type_quals (TREE_TYPE (TREE_VALUE (parms1))) + != cp_type_quals (TREE_TYPE (TREE_VALUE (parms2))))) continue; /* For templates, the return type and template parameters @@ -1868,8 +1868,8 @@ same_signature_p (const_tree fndecl, const_tree base_fndecl) tree types, base_types; types = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); base_types = TYPE_ARG_TYPES (TREE_TYPE (base_fndecl)); - if ((TYPE_QUALS (TREE_TYPE (TREE_VALUE (base_types))) - == TYPE_QUALS (TREE_TYPE (TREE_VALUE (types)))) + if ((cp_type_quals (TREE_TYPE (TREE_VALUE (base_types))) + == cp_type_quals (TREE_TYPE (TREE_VALUE (types)))) && compparms (TREE_CHAIN (base_types), TREE_CHAIN (types))) return 1; } @@ -5102,7 +5102,7 @@ layout_class_type (tree t, tree *virtuals_p) TYPE_UNSIGNED (ftype)); TREE_TYPE (field) = cp_build_qualified_type (TREE_TYPE (field), - TYPE_QUALS (ftype)); + cp_type_quals (ftype)); } } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 6a0dd12..3e1b310 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5415,7 +5415,6 @@ extern tree build_ptrmemfunc (tree, tree, int, bool); extern int cp_type_quals (const_tree); extern int type_memfn_quals (const_tree); extern tree apply_memfn_quals (tree, cp_cv_quals); -extern bool cp_type_readonly (const_tree); extern bool cp_has_mutable_p (const_tree); extern bool at_least_as_qualified_p (const_tree, const_tree); extern void cp_apply_type_quals_to_decl (int, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d3cc02b..43a6bc3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3482,7 +3482,7 @@ cxx_init_decl_processing (void) vtbl_type_node = build_cplus_array_type (vtable_entry_type, NULL_TREE); layout_type (vtbl_type_node); - vtbl_type_node = build_qualified_type (vtbl_type_node, TYPE_QUAL_CONST); + vtbl_type_node = cp_build_qualified_type (vtbl_type_node, TYPE_QUAL_CONST); record_builtin_type (RID_MAX, NULL, vtbl_type_node); vtbl_ptr_type_node = build_pointer_type (vtable_entry_type); layout_type (vtbl_ptr_type_node); @@ -3580,7 +3580,7 @@ cp_fname_init (const char* name, tree *type_p) init = build_string (length + 1, name); } - type = build_qualified_type (char_type_node, TYPE_QUAL_CONST); + type = cp_build_qualified_type (char_type_node, TYPE_QUAL_CONST); type = build_cplus_array_type (type, domain); *type_p = type; @@ -4320,7 +4320,7 @@ start_decl (const cp_declarator *declarator, /* This is a const variable with implicit 'static'. Set DECL_THIS_STATIC so we can tell it from variables that are !TREE_PUBLIC because of the anonymous namespace. */ - gcc_assert (cp_type_readonly (TREE_TYPE (decl))); + gcc_assert (CP_TYPE_CONST_P (TREE_TYPE (decl))); DECL_THIS_STATIC (decl) = 1; } @@ -8078,8 +8078,8 @@ grokdeclarator (const cp_declarator *declarator, if (long_p && !longlong && TYPE_MAIN_VARIANT (type) == double_type_node) { long_p = false; - type = build_qualified_type (long_double_type_node, - cp_type_quals (type)); + type = cp_build_qualified_type (long_double_type_node, + cp_type_quals (type)); } /* Check all other uses of type modifiers. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 29971ce..25c1175 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1272,7 +1272,7 @@ cp_reconstruct_complex_type (tree type, tree bottom) if (TYPE_ATTRIBUTES (type)) outer = cp_build_type_attribute_variant (outer, TYPE_ATTRIBUTES (type)); - return cp_build_qualified_type (outer, TYPE_QUALS (type)); + return cp_build_qualified_type (outer, cp_type_quals (type)); } /* Like decl_attributes, but handle C++ complexity. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index e45d2b8..1fb5eb0 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2200,7 +2200,7 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, /* But we want to operate on a non-const version to start with, since we'll be modifying the elements. */ non_const_pointer_type = build_pointer_type - (cp_build_qualified_type (type, TYPE_QUALS (type) & ~TYPE_QUAL_CONST)); + (cp_build_qualified_type (type, cp_type_quals (type) & ~TYPE_QUAL_CONST)); data_addr = fold_convert (non_const_pointer_type, data_addr); /* Any further uses of alloc_node will want this type, too. */ diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5108950..707df8b 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1975,18 +1975,19 @@ write_CV_qualifiers_for_type (const tree type) Note that we do not use cp_type_quals below; given "const int[3]", the "const" is emitted with the "int", not with the array. */ + cp_cv_quals quals = TYPE_QUALS (type); - if (TYPE_QUALS (type) & TYPE_QUAL_RESTRICT) + if (quals & TYPE_QUAL_RESTRICT) { write_char ('r'); ++num_qualifiers; } - if (TYPE_QUALS (type) & TYPE_QUAL_VOLATILE) + if (quals & TYPE_QUAL_VOLATILE) { write_char ('V'); ++num_qualifiers; } - if (TYPE_QUALS (type) & TYPE_QUAL_CONST) + if (quals & TYPE_QUAL_CONST) { write_char ('K'); ++num_qualifiers; diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 5ed98bc..43b84dd 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -494,7 +494,7 @@ do_build_copy_constructor (tree fndecl) if (DECL_MUTABLE_P (field)) quals &= ~TYPE_QUAL_CONST; - quals |= TYPE_QUALS (expr_type); + quals |= cp_type_quals (expr_type); expr_type = cp_build_qualified_type (expr_type, quals); } @@ -934,7 +934,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p) if (const_p) { data.quals = TYPE_QUAL_CONST; - rhs_parm_type = build_qualified_type (type, TYPE_QUAL_CONST); + rhs_parm_type = cp_build_qualified_type (type, TYPE_QUAL_CONST); } else rhs_parm_type = type; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e7e43c0..85bf1fd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8760,7 +8760,7 @@ tsubst_aggr_type (tree t, { r = lookup_template_class (t, argvec, in_decl, context, entering_scope, complain); - r = cp_build_qualified_type_real (r, TYPE_QUALS (t), complain); + r = cp_build_qualified_type_real (r, cp_type_quals (t), complain); } cp_unevaluated_operand = saved_unevaluated_operand; @@ -10141,7 +10141,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) /*entering_scope=*/0, complain); return cp_build_qualified_type_real - (r, TYPE_QUALS (t), complain); + (r, cp_type_quals (t), complain); } else /* TEMPLATE_TEMPLATE_PARM or TEMPLATE_PARM_INDEX. */ @@ -10331,7 +10331,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) TYPE_REF_IS_RVALUE (t) && TYPE_REF_IS_RVALUE (type)); else r = cp_build_reference_type (type, TYPE_REF_IS_RVALUE (t)); - r = cp_build_qualified_type_real (r, TYPE_QUALS (t), complain); + r = cp_build_qualified_type_real (r, cp_type_quals (t), complain); if (r != error_mark_node) /* Will this ever be needed for TYPE_..._TO values? */ @@ -10380,7 +10380,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) } else return cp_build_qualified_type_real (build_ptrmem_type (r, type), - TYPE_QUALS (t), + cp_type_quals (t), complain); } case FUNCTION_TYPE: diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 4eb2ba7..9d300d7 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -155,7 +155,7 @@ init_rtti_processing (void) /*tag_scope=*/ts_current, false); pop_namespace (); const_type_info_type_node - = build_qualified_type (type_info_type, TYPE_QUAL_CONST); + = cp_build_qualified_type (type_info_type, TYPE_QUAL_CONST); type_info_ptr_type = build_pointer_type (const_type_info_type_node); unemitted_tinfo_decls = VEC_alloc (tree, gc, 124); @@ -192,8 +192,8 @@ build_headof (tree exp) tf_warning_or_error), index); - type = build_qualified_type (ptr_type_node, - cp_type_quals (TREE_TYPE (exp))); + type = cp_build_qualified_type (ptr_type_node, + cp_type_quals (TREE_TYPE (exp))); return build2 (POINTER_PLUS_EXPR, type, exp, convert_to_integer (sizetype, offset)); } @@ -726,7 +726,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) /*tag_scope=*/ts_current, false); tinfo_ptr = build_pointer_type - (build_qualified_type + (cp_build_qualified_type (tinfo_ptr, TYPE_QUAL_CONST)); name = "__dynamic_cast"; tmp = tree_cons @@ -871,7 +871,7 @@ tinfo_base_init (tinfo_s *ti, tree target) /* Generate the NTBS array variable. */ tree name_type = build_cplus_array_type - (build_qualified_type (char_type_node, TYPE_QUAL_CONST), + (cp_build_qualified_type (char_type_node, TYPE_QUAL_CONST), NULL_TREE); /* Determine the name of the variable -- and remember with which @@ -1495,8 +1495,8 @@ emit_support_tinfos (void) types[0] = bltn; types[1] = build_pointer_type (bltn); - types[2] = build_pointer_type (build_qualified_type (bltn, - TYPE_QUAL_CONST)); + types[2] = build_pointer_type (cp_build_qualified_type (bltn, + TYPE_QUAL_CONST)); for (i = 0; i < 3; ++i) { diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 47f3897c..173ef96 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2212,7 +2212,7 @@ finish_compound_literal (tree type, tree compound_literal) if (TREE_CODE (type) == ARRAY_TYPE) cp_complete_array_type (&type, compound_literal, false); compound_literal = digest_init (type, compound_literal); - if ((!at_function_scope_p () || cp_type_readonly (type)) + if ((!at_function_scope_p () || CP_TYPE_CONST_P (type)) && initializer_constant_valid_p (compound_literal, type)) { tree decl = create_temporary_var (type); @@ -5629,7 +5629,7 @@ capture_decltype (tree decl) if (TREE_CODE (type) != REFERENCE_TYPE) { if (!LAMBDA_EXPR_MUTABLE_P (lam)) - type = cp_build_qualified_type (type, (TYPE_QUALS (type) + type = cp_build_qualified_type (type, (cp_type_quals (type) |TYPE_QUAL_CONST)); type = build_reference_type (type); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e34a69c..d3bba4c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -940,7 +940,7 @@ cv_unqualified (tree type) if (type == error_mark_node) return type; - quals = TYPE_QUALS (type); + quals = cp_type_quals (type); quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE); return cp_build_qualified_type (type, quals); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a46b218..54ccbfe 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -633,10 +633,10 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2, if (DERIVED_FROM_P (class1, class2)) t2 = (build_pointer_type - (cp_build_qualified_type (class1, TYPE_QUALS (class2)))); + (cp_build_qualified_type (class1, cp_type_quals (class2)))); else if (DERIVED_FROM_P (class2, class1)) t1 = (build_pointer_type - (cp_build_qualified_type (class2, TYPE_QUALS (class1)))); + (cp_build_qualified_type (class2, cp_type_quals (class1)))); else { if (complain & tf_error) @@ -1250,7 +1250,10 @@ structural_comptypes (tree t1, tree t2, int strict) /* Qualifiers must match. For array types, we will check when we recur on the array element types. */ if (TREE_CODE (t1) != ARRAY_TYPE - && TYPE_QUALS (t1) != TYPE_QUALS (t2)) + && cp_type_quals (t1) != cp_type_quals (t2)) + return false; + if (TREE_CODE (t1) == FUNCTION_TYPE + && type_memfn_quals (t1) != type_memfn_quals (t2)) return false; if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2)) return false; @@ -2032,7 +2035,7 @@ string_conv_p (const_tree totype, const_tree exp, int warn) else { /* Is this a string constant which has decayed to 'const char *'? */ - t = build_pointer_type (build_qualified_type (t, TYPE_QUAL_CONST)); + t = build_pointer_type (cp_build_qualified_type (t, TYPE_QUAL_CONST)); if (!same_type_p (TREE_TYPE (exp), t)) return 0; STRIP_NOPS (exp); @@ -7642,7 +7645,7 @@ check_return_expr (tree retval, bool *no_warning) if ((cxx_dialect != cxx98) && named_return_value_okay_p /* The variable must not have the `volatile' qualifier. */ - && !(cp_type_quals (TREE_TYPE (retval)) & TYPE_QUAL_VOLATILE) + && !CP_TYPE_VOLATILE_P (TREE_TYPE (retval)) /* The return type must be a class type. */ && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl)))) flags = flags | LOOKUP_PREFER_RVALUE; @@ -7902,17 +7905,6 @@ apply_memfn_quals (tree type, cp_cv_quals memfn_quals) return build_qualified_type (type, memfn_quals); } -/* Returns nonzero if the TYPE is const from a C++ perspective: look inside - arrays. */ - -bool -cp_type_readonly (const_tree type) -{ - /* This CONST_CAST is okay because strip_array_types returns its - argument unmodified and we assign it to a const_tree. */ - return (cp_type_quals (type) & TYPE_QUAL_CONST) != 0; -} - /* Returns nonzero if TYPE is const or volatile. */ bool |