if (c_parser_next_token_is (parser, CPP_NAME))
{
c_token *comp_tok = c_parser_peek_token (parser);
- /* Ignore the counted_by attribute for reference inside
- offsetof since the information is not useful at all. */
offsetof_ref
= build_component_ref (loc, offsetof_ref, comp_tok->value,
- comp_tok->location, UNKNOWN_LOCATION,
- false);
+ comp_tok->location, UNKNOWN_LOCATION);
c_parser_consume_token (parser);
while (c_parser_next_token_is (parser, CPP_DOT)
|| c_parser_next_token_is (parser,
break;
}
c_token *comp_tok = c_parser_peek_token (parser);
- /* Ignore the counted_by attribute for reference inside
- offsetof since the information is not useful. */
offsetof_ref
= build_component_ref (loc, offsetof_ref,
comp_tok->value,
comp_tok->location,
- UNKNOWN_LOCATION,
- false);
+ UNKNOWN_LOCATION);
c_parser_consume_token (parser);
}
else
/* If the array ref is inside TYPEOF or ALIGNOF, the call to
.ACCESS_WITH_SIZE was not generated by the routine
build_component_ref by default, we should generate it here. */
- if ((in_typeof || in_alignof) && TREE_CODE (ref) == COMPONENT_REF)
- ref = handle_counted_by_for_component_ref (loc, ref, false);
+ if (TREE_CODE (ref) == COMPONENT_REF)
+ ref = handle_counted_by_for_component_ref (loc, ref);
if (has_counted_by_object (ref))
expr.value = get_counted_by_ref (ref);
extern tree composite_type (tree, tree);
extern tree lookup_field (const_tree, tree);
extern tree build_component_ref (location_t, tree, tree, location_t,
- location_t, bool = true);
-extern tree handle_counted_by_for_component_ref (location_t, tree, bool);
+ location_t);
+extern tree handle_counted_by_for_component_ref (location_t, tree);
extern tree build_array_ref (location_t, tree, tree);
extern tree build_omp_array_section (location_t, tree, tree, tree);
extern tree build_external_ref (location_t, tree, bool, tree *);
default_function_array_read_conversion (location_t loc, struct c_expr exp)
{
mark_exp_read (exp.value);
- /* We only generate a call to .ACCESS_WITH_SIZE for a pointer field when
- it is a read. */
+ /* We only generate a call to .ACCESS_WITH_SIZE when it is a read. */
if (TREE_CODE (exp.value) == COMPONENT_REF
&& handle_counted_by_p (exp.value))
- exp.value = handle_counted_by_for_component_ref (loc, exp.value, true);
+ exp.value = handle_counted_by_for_component_ref (loc, exp.value);
return default_function_array_conversion (loc, exp);
}
bool force_non_npc = false;
if (read_p)
mark_exp_read (exp.value);
- /* We only generate a call to .ACCESS_WITH_SIZE for a pointer field when
- it is a read. */
+ /* We only generate a call to .ACCESS_WITH_SIZE when it is a read. */
if (read_p && TREE_CODE (exp.value) == COMPONENT_REF
&& handle_counted_by_p (exp.value))
- exp.value = handle_counted_by_for_component_ref (loc, exp.value, true);
+ exp.value = handle_counted_by_for_component_ref (loc, exp.value);
if (convert_p)
exp = default_function_array_conversion (loc, exp);
tree promoted_type;
mark_exp_read (exp);
- /* We only generate a call to .ACCESS_WITH_SIZE for a pointer field when
- it is a read. */
+ /* We only generate a call to .ACCESS_WITH_SIZE when it is a read. */
if (TREE_CODE (exp) == COMPONENT_REF
&& handle_counted_by_p (exp))
- exp = handle_counted_by_for_component_ref (EXPR_LOCATION (exp), exp, true);
+ exp = handle_counted_by_for_component_ref (EXPR_LOCATION (exp), exp);
/* Functions and arrays have been converted during parsing. */
gcc_assert (code != FUNCTION_TYPE);
/* For the COMPONENT_REF ref, check whether it has a counted_by attribute,
if so, wrap this COMPONENT_REF with the corresponding CALL to the
function .ACCESS_WITH_SIZE.
- Otherwise, return the ref itself.
- FOR_POINTER is true when this is for pointer field. */
+ Otherwise, return the ref itself. */
tree
-handle_counted_by_for_component_ref (location_t loc, tree ref,
- bool for_pointer)
+handle_counted_by_for_component_ref (location_t loc, tree ref)
{
gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
tree datum = TREE_OPERAND (ref, 0);
|| TREE_CODE (TREE_TYPE (ref)) == POINTER_TYPE))
return ref;
- bool is_fam = c_flexible_array_member_type_p (TREE_TYPE (ref));
-
- if (!(is_fam ^ for_pointer))
- return ref;
-
tree counted_by_ref = build_counted_by_ref (datum, subdatum,
&counted_by_type);
if (counted_by_ref)
tree
build_component_ref (location_t loc, tree datum, tree component,
- location_t component_loc, location_t arrow_loc,
- bool handle_counted_by)
+ location_t component_loc, location_t arrow_loc)
{
tree type = TREE_TYPE (datum);
enum tree_code code = TREE_CODE (type);
int quals;
tree subtype;
bool use_datum_quals;
- /* Do not handle counted_by when in typeof and alignof operator. */
- handle_counted_by = handle_counted_by && !in_typeof && !in_alignof;
if (TREE_TYPE (subdatum) == error_mark_node)
return error_mark_node;
SET_EXPR_LOCATION (ref, loc);
check_counted_by_attribute (loc, ref);
- if (handle_counted_by)
- ref = handle_counted_by_for_component_ref (loc, ref, false);
if (TREE_READONLY (subdatum)
|| (use_datum_quals && TREE_READONLY (datum)))
bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
+ /* We only generate a call to .ACCESS_WITH_SIZE when it is a read. */
+ if (TREE_CODE (array) == COMPONENT_REF
+ && handle_counted_by_p (array))
+ array = handle_counted_by_for_component_ref (loc, array);
+
if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
{
tree rval, type;