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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159599
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
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
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);
}
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]
}
/* 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);
{
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)
{
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 "
&& ! 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
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;
}
TYPE_UNSIGNED (ftype));
TREE_TYPE (field)
= cp_build_qualified_type (TREE_TYPE (field),
- TYPE_QUALS (ftype));
+ cp_type_quals (ftype));
}
}
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);
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);
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;
/* 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;
}
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. */
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. */
/* 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. */
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;
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);
}
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;
{
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;
/*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. */
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? */
}
else
return cp_build_qualified_type_real (build_ptrmem_type (r, type),
- TYPE_QUALS (t),
+ cp_type_quals (t),
complain);
}
case FUNCTION_TYPE:
/*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);
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));
}
/*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
/* 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
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)
{
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);
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);
}
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);
}
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)
/* 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;
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);
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;
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