Commit 3a11c665 by Jason Merrill Committed by Jason Merrill

typeck.c (cp_build_array_ref): Factor out from...

	* typeck.c (cp_build_array_ref): Factor out from...
	(build_array_ref): ...here.  Drop complain parm.
	(build_new_op): Adjust.
	* class.c (build_vtbl_ref_1): Adjust.
	* decl2.c (grok_array_decl): Adjust.
	* cp-tree.h: Adjust prototypes.

From-SVN: r159377
parent a2e66caf
2010-05-13 Jason Merrill <jason@redhat.com>
* typeck.c (cp_build_array_ref): Factor out from...
(build_array_ref): ...here. Drop complain parm.
(build_new_op): Adjust.
* class.c (build_vtbl_ref_1): Adjust.
* decl2.c (grok_array_decl): Adjust.
* cp-tree.h: Adjust prototypes.
2010-05-13 Jan Hubicka <jh@suse.cz> 2010-05-13 Jan Hubicka <jh@suse.cz>
* decl.c (cp_finish_decl): Do not worry about used attribute. * decl.c (cp_finish_decl): Do not worry about used attribute.
......
...@@ -4517,7 +4517,7 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3, ...@@ -4517,7 +4517,7 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3,
return cp_build_unary_op (code, arg1, candidates != 0, complain); return cp_build_unary_op (code, arg1, candidates != 0, complain);
case ARRAY_REF: case ARRAY_REF:
return build_array_ref (input_location, arg1, arg2, complain); return cp_build_array_ref (input_location, arg1, arg2, complain);
case MEMBER_REF: case MEMBER_REF:
return build_m_component_ref (cp_build_indirect_ref (arg1, RO_NULL, return build_m_component_ref (cp_build_indirect_ref (arg1, RO_NULL,
......
...@@ -629,7 +629,7 @@ build_vtbl_ref_1 (tree instance, tree idx) ...@@ -629,7 +629,7 @@ build_vtbl_ref_1 (tree instance, tree idx)
if (!vtbl) if (!vtbl)
vtbl = build_vfield_ref (instance, basetype); vtbl = build_vfield_ref (instance, basetype);
aref = build_array_ref (input_location, vtbl, idx, tf_warning_or_error); aref = build_array_ref (input_location, vtbl, idx);
TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx); TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx);
return aref; return aref;
......
...@@ -5365,7 +5365,8 @@ extern tree build_x_indirect_ref (tree, ref_operator, ...@@ -5365,7 +5365,8 @@ extern tree build_x_indirect_ref (tree, ref_operator,
tsubst_flags_t); tsubst_flags_t);
extern tree cp_build_indirect_ref (tree, ref_operator, extern tree cp_build_indirect_ref (tree, ref_operator,
tsubst_flags_t); tsubst_flags_t);
extern tree build_array_ref (location_t, tree, tree, extern tree build_array_ref (location_t, tree, tree);
extern tree cp_build_array_ref (location_t, tree, tree,
tsubst_flags_t); tsubst_flags_t);
extern tree get_member_function_from_ptrfunc (tree *, tree); extern tree get_member_function_from_ptrfunc (tree *, tree);
extern tree cp_build_function_call (tree, tree, tsubst_flags_t); extern tree cp_build_function_call (tree, tree, tsubst_flags_t);
......
...@@ -399,8 +399,7 @@ grok_array_decl (tree array_expr, tree index_exp) ...@@ -399,8 +399,7 @@ grok_array_decl (tree array_expr, tree index_exp)
if (array_expr == error_mark_node || index_exp == error_mark_node) if (array_expr == error_mark_node || index_exp == error_mark_node)
error ("ambiguous conversion for array subscript"); error ("ambiguous conversion for array subscript");
expr = build_array_ref (input_location, array_expr, index_exp, expr = build_array_ref (input_location, array_expr, index_exp);
tf_warning_or_error);
} }
if (processing_template_decl && expr != error_mark_node) if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (ARRAY_REF, expr, orig_array_expr, orig_index_exp, return build_min_non_dep (ARRAY_REF, expr, orig_array_expr, orig_index_exp,
......
...@@ -2860,8 +2860,8 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring, ...@@ -2860,8 +2860,8 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring,
LOC is the location to use in building the array reference. */ LOC is the location to use in building the array reference. */
tree tree
build_array_ref (location_t loc, tree array, tree idx, cp_build_array_ref (location_t loc, tree array, tree idx,
tsubst_flags_t complain) tsubst_flags_t complain)
{ {
tree ret; tree ret;
...@@ -2882,8 +2882,8 @@ build_array_ref (location_t loc, tree array, tree idx, ...@@ -2882,8 +2882,8 @@ build_array_ref (location_t loc, tree array, tree idx,
{ {
case COMPOUND_EXPR: case COMPOUND_EXPR:
{ {
tree value = build_array_ref (loc, TREE_OPERAND (array, 1), idx, tree value = cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx,
complain); complain);
ret = build2 (COMPOUND_EXPR, TREE_TYPE (value), ret = build2 (COMPOUND_EXPR, TREE_TYPE (value),
TREE_OPERAND (array, 0), value); TREE_OPERAND (array, 0), value);
SET_EXPR_LOCATION (ret, loc); SET_EXPR_LOCATION (ret, loc);
...@@ -2893,8 +2893,10 @@ build_array_ref (location_t loc, tree array, tree idx, ...@@ -2893,8 +2893,10 @@ build_array_ref (location_t loc, tree array, tree idx,
case COND_EXPR: case COND_EXPR:
ret = build_conditional_expr ret = build_conditional_expr
(TREE_OPERAND (array, 0), (TREE_OPERAND (array, 0),
build_array_ref (loc, TREE_OPERAND (array, 1), idx, complain), cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx,
build_array_ref (loc, TREE_OPERAND (array, 2), idx, complain), complain),
cp_build_array_ref (loc, TREE_OPERAND (array, 2), idx,
complain),
tf_warning_or_error); tf_warning_or_error);
protected_set_expr_location (ret, loc); protected_set_expr_location (ret, loc);
return ret; return ret;
...@@ -3020,6 +3022,14 @@ build_array_ref (location_t loc, tree array, tree idx, ...@@ -3020,6 +3022,14 @@ build_array_ref (location_t loc, tree array, tree idx,
return ret; return ret;
} }
} }
/* Entry point for Obj-C++. */
tree
build_array_ref (location_t loc, tree array, tree idx)
{
return cp_build_array_ref (loc, array, idx, tf_warning_or_error);
}
/* Resolve a pointer to member function. INSTANCE is the object /* Resolve a pointer to member function. INSTANCE is the object
instance to use, if the member points to a virtual member. instance to use, if the member points to a virtual member.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment