+2016-05-12 Marek Polacek <polacek@redhat.com>
+
+ PR c/70756
+ * langhooks-def.h (lhd_incomplete_type_error): Adjust declaration.
+ * langhooks.c (lhd_incomplete_type_error): Add location parameter.
+ * langhooks.h (incomplete_type_error): Likewise.
+ * tree.c (size_in_bytes_loc): Renamed from size_in_bytes. Add location
+ parameter, pass it down to incomplete_type_error.
+ * tree.h (size_in_bytes): New inline overload.
+ (size_in_bytes_loc): Renamed from size_in_bytes.
+
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71059
+2016-05-12 Marek Polacek <polacek@redhat.com>
+
+ PR c/70756
+ * c-common.c (pointer_int_sum): Call size_in_bytes_loc instead of
+ size_in_bytes and pass LOC to it.
+
2016-05-11 Mikhail Maltsev <maltsevm@gmail.com>
PR c/43651
size_exp = integer_one_node;
}
else
- size_exp = size_in_bytes (TREE_TYPE (result_type));
+ size_exp = size_in_bytes_loc (loc, TREE_TYPE (result_type));
/* We are manipulating pointer values, so we don't need to warn
about relying on undefined signed overflow. We disable the
+2016-05-12 Marek Polacek <polacek@redhat.com>
+
+ PR c/70756
+ * c-decl.c (build_compound_literal): Pass LOC down to
+ c_incomplete_type_error.
+ * c-tree.h (require_complete_type): Adjust declaration.
+ (c_incomplete_type_error): Likewise.
+ * c-typeck.c (require_complete_type): Add location parameter, pass it
+ down to c_incomplete_type_error.
+ (c_incomplete_type_error): Add location parameter, pass it down to
+ error_at.
+ (build_component_ref): Pass location down to c_incomplete_type_error.
+ (default_conversion): Pass location down to require_complete_type.
+ (build_array_ref): Likewise.
+ (build_function_call_vec): Likewise.
+ (convert_arguments): Likewise.
+ (build_unary_op): Likewise.
+ (build_c_cast): Likewise.
+ (build_modify_expr): Likewise.
+ (convert_for_assignment): Likewise.
+ (c_finish_omp_clauses): Likewise.
+
2016-05-11 Mikhail Maltsev <maltsevm@gmail.com>
PR c/43651
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
{
- c_incomplete_type_error (NULL_TREE, type);
+ c_incomplete_type_error (loc, NULL_TREE, type);
return error_mark_node;
}
extern struct c_switch *c_switch_stack;
extern tree c_objc_common_truthvalue_conversion (location_t, tree);
-extern tree require_complete_type (tree);
+extern tree require_complete_type (location_t, tree);
extern int same_translation_unit_p (const_tree, const_tree);
extern int comptypes (tree, tree);
extern int comptypes_check_different_types (tree, tree, bool *);
extern bool c_vla_type_p (const_tree);
extern bool c_mark_addressable (tree);
-extern void c_incomplete_type_error (const_tree, const_tree);
+extern void c_incomplete_type_error (location_t, const_tree, const_tree);
extern tree c_type_promotes_to (tree);
extern struct c_expr default_function_array_conversion (location_t,
struct c_expr);
static const struct tagged_tu_seen_cache * tagged_tu_seen_base;
static void free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *);
-/* Do `exp = require_complete_type (exp);' to make sure exp
- does not have an incomplete type. (That includes void types.) */
+/* Do `exp = require_complete_type (loc, exp);' to make sure exp
+ does not have an incomplete type. (That includes void types.)
+ LOC is the location of the use. */
tree
-require_complete_type (tree value)
+require_complete_type (location_t loc, tree value)
{
tree type = TREE_TYPE (value);
if (COMPLETE_TYPE_P (type))
return value;
- c_incomplete_type_error (value, type);
+ c_incomplete_type_error (loc, value, type);
return error_mark_node;
}
/* Print an error message for invalid use of an incomplete type.
VALUE is the expression that was used (or 0 if that isn't known)
- and TYPE is the type that was invalid. */
+ and TYPE is the type that was invalid. LOC is the location for
+ the error. */
void
-c_incomplete_type_error (const_tree value, const_tree type)
+c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
{
/* Avoid duplicate error message. */
if (TREE_CODE (type) == ERROR_MARK)
return;
if (value != 0 && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
- error ("%qD has an incomplete type %qT", value, type);
+ error_at (loc, "%qD has an incomplete type %qT", value, type);
else
{
retry:
break;
case VOID_TYPE:
- error ("invalid use of void expression");
+ error_at (loc, "invalid use of void expression");
return;
case ARRAY_TYPE:
{
if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
{
- error ("invalid use of flexible array member");
+ error_at (loc, "invalid use of flexible array member");
return;
}
type = TREE_TYPE (type);
goto retry;
}
- error ("invalid use of array with unspecified bounds");
+ error_at (loc, "invalid use of array with unspecified bounds");
return;
default:
}
if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
- error ("invalid use of undefined type %qT", type);
+ error_at (loc, "invalid use of undefined type %qT", type);
else
/* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */
- error ("invalid use of incomplete typedef %qT", type);
+ error_at (loc, "invalid use of incomplete typedef %qT", type);
}
}
return error_mark_node;
}
- exp = require_complete_type (exp);
+ exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
if (exp == error_mark_node)
return error_mark_node;
{
if (!COMPLETE_TYPE_P (type))
{
- c_incomplete_type_error (NULL_TREE, type);
+ c_incomplete_type_error (loc, NULL_TREE, type);
return error_mark_node;
}
in an inline function.
Hope it doesn't break something else. */
| TREE_THIS_VOLATILE (array));
- ret = require_complete_type (rval);
+ ret = require_complete_type (loc, rval);
protected_set_expr_location (ret, loc);
if (non_lvalue)
ret = non_lvalue_loc (loc, ret);
"function with qualified void return type called");
return result;
}
- return require_complete_type (result);
+ return require_complete_type (loc, result);
}
/* Like build_function_call_vec, but call also resolve_overloaded_builtin. */
val = c_fully_fold (val, false, NULL);
STRIP_TYPE_NOPS (val);
- val = require_complete_type (val);
+ val = require_complete_type (ploc, val);
if (type != 0)
{
arg = remove_c_maybe_const_expr (arg);
if (code != ADDR_EXPR)
- arg = require_complete_type (arg);
+ arg = require_complete_type (location, arg);
typecode = TREE_CODE (TREE_TYPE (arg));
if (typecode == ERROR_MARK)
if (!VOID_TYPE_P (type))
{
- value = require_complete_type (value);
+ value = require_complete_type (loc, value);
if (value == error_mark_node)
return error_mark_node;
}
bool is_atomic_op;
/* Types that aren't fully specified cannot be used in assignments. */
- lhs = require_complete_type (lhs);
+ lhs = require_complete_type (location, lhs);
/* Avoid duplicate error messages from operands that had errors. */
if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
error_at (location, "void value not ignored as it ought to be");
return error_mark_node;
}
- rhs = require_complete_type (rhs);
+ rhs = require_complete_type (location, rhs);
if (rhs == error_mark_node)
return error_mark_node;
t = OMP_CLAUSE_DECL (c);
}
- t = require_complete_type (t);
+ t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
if (t == error_mark_node)
{
remove = true;
if (need_complete)
{
- t = require_complete_type (t);
+ t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
if (t == error_mark_node)
remove = true;
}
+2016-05-12 Marek Polacek <polacek@redhat.com>
+
+ PR c/70756
+ * call.c (build_new_op_1): Pass LOC to cp_build_modify_expr.
+ * cp-tree.h (cp_build_modify_expr): Update declaration.
+ (cxx_incomplete_type_error, cxx_incomplete_type_diagnostic): New inline
+ overloads.
+ * cp-ubsan.c (cp_ubsan_dfs_initialize_vtbl_ptrs): Pass INPUT_LOCATION to
+ cp_build_modify_expr.
+ * decl2.c (set_guard): Likewise.
+ (handle_tls_init): Likewise.
+ * init.c (perform_member_init): Likewise.
+ (expand_virtual_init): Likewise.
+ (build_new_1): Likewise.
+ (build_vec_delete_1): Likewise.
+ (get_temp_regvar): Likewise.
+ (build_vec_init): Likewise.
+ * method.c (do_build_copy_assign): Likewise.
+ (assignable_expr): Likewise.
+ * semantics.c (finish_omp_for): Likewise.
+ * typeck.c (cp_build_binary_op): Pass LOCATION to pointer_diff and
+ cp_pointer_int_sum.
+ (cp_pointer_int_sum): Add location parameter. Pass it down to
+ pointer_int_sum.
+ (pointer_diff): Add location parameter. Use it.
+ (build_modify_expr): Pass location down to cp_build_modify_expr.
+ (cp_build_modify_expr): Add location parameter. Use it.
+ (build_x_modify_expr): Pass location down to cp_build_modify_expr.
+ * typeck2.c (cxx_incomplete_type_diagnostic,
+ cxx_incomplete_type_error): Add location parameter.
+
2016-05-11 Marek Polacek <polacek@redhat.com>
PR c++/71024
switch (code)
{
case MODIFY_EXPR:
- return cp_build_modify_expr (arg1, code2, arg2, complain);
+ return cp_build_modify_expr (loc, arg1, code2, arg2, complain);
case INDIRECT_REF:
return cp_build_indirect_ref (arg1, RO_UNARY_STAR, complain);
extern cp_expr build_x_modify_expr (location_t, tree,
enum tree_code, tree,
tsubst_flags_t);
-extern tree cp_build_modify_expr (tree, enum tree_code, tree,
+extern tree cp_build_modify_expr (location_t, tree,
+ enum tree_code, tree,
tsubst_flags_t);
extern tree convert_for_initialization (tree, tree, tree, int,
impl_conv_rhs, tree, int,
/* in typeck2.c */
extern void require_complete_eh_spec_types (tree, tree);
-extern void cxx_incomplete_type_diagnostic (const_tree, const_tree, diagnostic_t);
-#undef cxx_incomplete_type_error
-extern void cxx_incomplete_type_error (const_tree, const_tree);
-#define cxx_incomplete_type_error(V,T) \
- (cxx_incomplete_type_diagnostic ((V), (T), DK_ERROR))
+extern void cxx_incomplete_type_diagnostic (location_t, const_tree,
+ const_tree, diagnostic_t);
+inline void
+cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
+ diagnostic_t diag_kind)
+{
+ cxx_incomplete_type_diagnostic (EXPR_LOC_OR_LOC (value, input_location),
+ value, type, diag_kind);
+}
+
+extern void cxx_incomplete_type_error (location_t, const_tree,
+ const_tree);
+inline void
+cxx_incomplete_type_error (const_tree value, const_tree type)
+{
+ cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+}
+
extern void cxx_incomplete_type_inform (const_tree);
extern tree error_not_base_type (tree, tree);
extern tree binfo_or_else (tree, tree);
/* Assign NULL to the vptr. */
tree vtbl = build_zero_cst (TREE_TYPE (vtbl_ptr));
- tree stmt = cp_build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl,
- tf_warning_or_error);
+ tree stmt = cp_build_modify_expr (input_location, vtbl_ptr, NOP_EXPR,
+ vtbl, tf_warning_or_error);
if (vptr_via_virtual_p (binfo))
/* If this vptr comes from a virtual base of the complete object, only
clear it if we're in charge of virtual bases. */
guard_init = integer_one_node;
if (!same_type_p (TREE_TYPE (guard_init), TREE_TYPE (guard)))
guard_init = fold_convert (TREE_TYPE (guard), guard_init);
- return cp_build_modify_expr (guard, NOP_EXPR, guard_init,
+ return cp_build_modify_expr (input_location, guard, NOP_EXPR, guard_init,
tf_warning_or_error);
}
tree cond = cp_build_unary_op (TRUTH_NOT_EXPR, guard, false,
tf_warning_or_error);
finish_if_stmt_cond (cond, if_stmt);
- finish_expr_stmt (cp_build_modify_expr (guard, NOP_EXPR, boolean_true_node,
+ finish_expr_stmt (cp_build_modify_expr (loc, guard, NOP_EXPR,
+ boolean_true_node,
tf_warning_or_error));
for (; vars; vars = TREE_CHAIN (vars))
{
tf_warning_or_error);
if (init)
- finish_expr_stmt (cp_build_modify_expr (decl, INIT_EXPR, init,
+ finish_expr_stmt (cp_build_modify_expr (input_location, decl,
+ INIT_EXPR, init,
tf_warning_or_error));
}
/* Assign the vtable to the vptr. */
vtbl = convert_force (TREE_TYPE (vtbl_ptr), vtbl, 0, tf_warning_or_error);
- finish_expr_stmt (cp_build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl,
- tf_warning_or_error));
+ finish_expr_stmt (cp_build_modify_expr (input_location, vtbl_ptr, NOP_EXPR,
+ vtbl, tf_warning_or_error));
}
/* If an exception is thrown in a constructor, those base classes already
ie = build_x_compound_expr_from_vec (*init, "new initializer",
complain);
- init_expr = cp_build_modify_expr (init_expr, INIT_EXPR, ie,
- complain);
+ init_expr = cp_build_modify_expr (input_location, init_expr,
+ INIT_EXPR, ie, complain);
}
stable = stabilize_init (init_expr, &init_preeval_expr);
}
tbase = create_temporary_var (ptype);
tbase_init
- = cp_build_modify_expr (tbase, NOP_EXPR,
+ = cp_build_modify_expr (input_location, tbase, NOP_EXPR,
fold_build_pointer_plus_loc (input_location,
fold_convert (ptype,
base),
fold_convert (ptype, base)));
tmp = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, size_exp);
tmp = fold_build_pointer_plus (tbase, tmp);
- tmp = cp_build_modify_expr (tbase, NOP_EXPR, tmp, complain);
+ tmp = cp_build_modify_expr (input_location, tbase, NOP_EXPR, tmp, complain);
if (tmp == error_mark_node)
return error_mark_node;
body = build_compound_expr (input_location, body, tmp);
decl = create_temporary_var (type);
add_decl_expr (decl);
- finish_expr_stmt (cp_build_modify_expr (decl, INIT_EXPR, init,
- tf_warning_or_error));
+ finish_expr_stmt (cp_build_modify_expr (input_location, decl, INIT_EXPR,
+ init, tf_warning_or_error));
return decl;
}
else if (MAYBE_CLASS_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
one_init = build_aggr_init (baseref, elt, 0, complain);
else
- one_init = cp_build_modify_expr (baseref, NOP_EXPR,
- elt, complain);
+ one_init = cp_build_modify_expr (input_location, baseref,
+ NOP_EXPR, elt, complain);
if (one_init == error_mark_node)
errors = true;
if (try_const)
from = NULL_TREE;
if (from_array == 2)
- elt_init = cp_build_modify_expr (to, NOP_EXPR, from,
- complain);
+ elt_init = cp_build_modify_expr (input_location, to, NOP_EXPR,
+ from, complain);
else if (type_build_ctor_call (type))
elt_init = build_aggr_init (to, from, 0, complain);
else if (from)
- elt_init = cp_build_modify_expr (to, NOP_EXPR, from,
+ elt_init = cp_build_modify_expr (input_location, to, NOP_EXPR, from,
complain);
else
gcc_unreachable ();
init = move (init);
if (DECL_NAME (field))
- init = cp_build_modify_expr (comp, NOP_EXPR, init,
+ init = cp_build_modify_expr (input_location, comp, NOP_EXPR, init,
tf_warning_or_error);
else
init = build2 (MODIFY_EXPR, TREE_TYPE (comp), comp, init);
++cp_unevaluated_operand;
to = build_stub_object (to);
from = build_stub_object (from);
- tree r = cp_build_modify_expr (to, NOP_EXPR, from, tf_none);
+ tree r = cp_build_modify_expr (input_location, to, NOP_EXPR, from, tf_none);
--cp_unevaluated_operand;
return r;
}
{
if (orig_incr)
TREE_VEC_ELT (orig_incr, i) = incr;
- incr = cp_build_modify_expr (TREE_OPERAND (incr, 0),
+ incr = cp_build_modify_expr (elocus, TREE_OPERAND (incr, 0),
TREE_CODE (TREE_OPERAND (incr, 1)),
TREE_OPERAND (incr, 2),
tf_warning_or_error);
if (!processing_template_decl)
{
init = fold_build_cleanup_point_expr (TREE_TYPE (init), init);
- init = cp_build_modify_expr (decl, NOP_EXPR, init, tf_warning_or_error);
+ init = cp_build_modify_expr (elocus, decl, NOP_EXPR, init,
+ tf_warning_or_error);
}
else
init = build2 (MODIFY_EXPR, void_type_node, decl, init);
static tree delta_from_ptrmemfunc (tree);
static tree convert_for_assignment (tree, tree, impl_conv_rhs, tree, int,
tsubst_flags_t, int);
-static tree cp_pointer_int_sum (enum tree_code, tree, tree, tsubst_flags_t);
+static tree cp_pointer_int_sum (location_t, enum tree_code, tree, tree,
+ tsubst_flags_t);
static tree rationalize_conditional_expr (enum tree_code, tree,
tsubst_flags_t);
static int comp_ptr_ttypes_real (tree, tree, int);
static bool comp_except_types (tree, tree, bool);
static bool comp_array_types (const_tree, const_tree, bool);
-static tree pointer_diff (tree, tree, tree, tsubst_flags_t);
+static tree pointer_diff (location_t, tree, tree, tree, tsubst_flags_t);
static tree get_delta_difference (tree, tree, bool, bool, tsubst_flags_t);
static void casts_away_constness_r (tree *, tree *, tsubst_flags_t);
static bool casts_away_constness (tree, tree, tsubst_flags_t);
if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
&& same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (type0),
TREE_TYPE (type1)))
- return pointer_diff (op0, op1, common_pointer_type (type0, type1),
- complain);
+ return pointer_diff (location, op0, op1,
+ common_pointer_type (type0, type1), complain);
/* In all other cases except pointer - int, the usual arithmetic
rules apply. */
else if (!(code0 == POINTER_TYPE && code1 == INTEGER_TYPE))
result_type = TREE_TYPE (ptr_operand);
break;
}
- return cp_pointer_int_sum (code,
- ptr_operand,
+ return cp_pointer_int_sum (location, code,
+ ptr_operand,
int_operand,
complain);
}
of pointer PTROP and integer INTOP. */
static tree
-cp_pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop,
- tsubst_flags_t complain)
+cp_pointer_int_sum (location_t loc, enum tree_code resultcode, tree ptrop,
+ tree intop, tsubst_flags_t complain)
{
tree res_type = TREE_TYPE (ptrop);
pointer_int_sum() anyway. */
complete_type (TREE_TYPE (res_type));
- return pointer_int_sum (input_location, resultcode, ptrop,
+ return pointer_int_sum (loc, resultcode, ptrop,
intop, complain & tf_warning_or_error);
}
The resulting tree has type int. */
static tree
-pointer_diff (tree op0, tree op1, tree ptrtype, tsubst_flags_t complain)
+pointer_diff (location_t loc, tree op0, tree op1, tree ptrtype,
+ tsubst_flags_t complain)
{
tree result;
tree restype = ptrdiff_type_node;
if (VOID_TYPE_P (target_type))
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids using pointer of "
+ permerror (loc, "ISO C++ forbids using pointer of "
"type %<void *%> in subtraction");
else
return error_mark_node;
if (TREE_CODE (target_type) == FUNCTION_TYPE)
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids using pointer to "
+ permerror (loc, "ISO C++ forbids using pointer to "
"a function in subtraction");
else
return error_mark_node;
if (TREE_CODE (target_type) == METHOD_TYPE)
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids using pointer to "
+ permerror (loc, "ISO C++ forbids using pointer to "
"a method in subtraction");
else
return error_mark_node;
/* First do the subtraction as integers;
then drop through to build the divide operator. */
- op0 = cp_build_binary_op (input_location,
+ op0 = cp_build_binary_op (loc,
MINUS_EXPR,
cp_convert (restype, op0, complain),
cp_convert (restype, op1, complain),
if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (op1))))
{
if (complain & tf_error)
- error ("invalid use of a pointer to an incomplete type in "
- "pointer arithmetic");
+ error_at (loc, "invalid use of a pointer to an incomplete type in "
+ "pointer arithmetic");
else
return error_mark_node;
}
if (pointer_to_zero_sized_aggr_p (TREE_TYPE (op1)))
{
if (complain & tf_error)
- error ("arithmetic on pointer to an empty aggregate");
+ error_at (loc, "arithmetic on pointer to an empty aggregate");
else
return error_mark_node;
}
op1 = (TYPE_PTROB_P (ptrtype)
- ? size_in_bytes (target_type)
+ ? size_in_bytes_loc (loc, target_type)
: integer_one_node);
/* Do the division. */
- result = build2 (EXACT_DIV_EXPR, restype, op0,
- cp_convert (restype, op1, complain));
+ result = build2_loc (loc, EXACT_DIV_EXPR, restype, op0,
+ cp_convert (restype, op1, complain));
return result;
}
\f
\f
/* For use from the C common bits. */
tree
-build_modify_expr (location_t /*location*/,
+build_modify_expr (location_t location,
tree lhs, tree /*lhs_origtype*/,
enum tree_code modifycode,
location_t /*rhs_location*/, tree rhs,
tree /*rhs_origtype*/)
{
- return cp_build_modify_expr (lhs, modifycode, rhs, tf_warning_or_error);
+ return cp_build_modify_expr (location, lhs, modifycode, rhs,
+ tf_warning_or_error);
}
/* Build an assignment expression of lvalue LHS from value RHS.
C++: If MODIFYCODE is INIT_EXPR, then leave references unbashed. */
tree
-cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
- tsubst_flags_t complain)
+cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
+ tree rhs, tsubst_flags_t complain)
{
tree result;
tree newrhs = rhs;
lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs),
cp_stabilize_reference (TREE_OPERAND (lhs, 0)),
TREE_OPERAND (lhs, 1));
- newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 0),
+ newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 0),
modifycode, rhs, complain);
if (newrhs == error_mark_node)
return error_mark_node;
/* Handle (a, b) used as an "lvalue". */
case COMPOUND_EXPR:
- newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 1),
+ newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 1),
modifycode, rhs, complain);
if (newrhs == error_mark_node)
return error_mark_node;
lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs),
cp_stabilize_reference (TREE_OPERAND (lhs, 0)),
TREE_OPERAND (lhs, 1));
- newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 0), modifycode, rhs,
- complain);
+ newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 0), modifycode,
+ rhs, complain);
if (newrhs == error_mark_node)
return error_mark_node;
return build2 (COMPOUND_EXPR, lhstype, lhs, newrhs);
cond = build_conditional_expr
(input_location, TREE_OPERAND (lhs, 0),
- cp_build_modify_expr (TREE_OPERAND (lhs, 1),
+ cp_build_modify_expr (loc, TREE_OPERAND (lhs, 1),
modifycode, rhs, complain),
- cp_build_modify_expr (TREE_OPERAND (lhs, 2),
+ cp_build_modify_expr (loc, TREE_OPERAND (lhs, 2),
modifycode, rhs, complain),
complain);
lhs = cp_stabilize_reference (lhs);
rhs = rvalue (rhs);
rhs = stabilize_expr (rhs, &init);
- newrhs = cp_build_binary_op (input_location,
- modifycode, lhs, rhs,
- complain);
+ newrhs = cp_build_binary_op (loc, modifycode, lhs, rhs, complain);
if (newrhs == error_mark_node)
{
if (complain & tf_error)
return rval;
}
}
- return cp_build_modify_expr (lhs, modifycode, rhs, complain);
+ return cp_build_modify_expr (loc, lhs, modifycode, rhs, complain);
}
/* Helper function for get_delta_difference which assumes FROM is a base
type of diagnostic (see diagnostic.def). */
void
-cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
- diagnostic_t diag_kind)
+cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
+ const_tree type, diagnostic_t diag_kind)
{
bool is_decl = false, complained = false;
retry:
/* We must print an error message. Be clever about what it says. */
- location_t loc = EXPR_LOC_OR_LOC (value, input_location);
-
switch (TREE_CODE (type))
{
case RECORD_TYPE:
}
}
-/* Backward-compatibility interface to incomplete_type_diagnostic;
- required by ../tree.c. */
-#undef cxx_incomplete_type_error
+/* Print an error message for invalid use of an incomplete type.
+ VALUE is the expression that was used (or 0 if that isn't known)
+ and TYPE is the type that was invalid. */
+
void
-cxx_incomplete_type_error (const_tree value, const_tree type)
+cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type)
{
- cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
+ cxx_incomplete_type_diagnostic (loc, value, type, DK_ERROR);
}
\f
const char *, struct diagnostic_info *);
extern void lhd_set_decl_assembler_name (tree);
extern bool lhd_warn_unused_global_decl (const_tree);
-extern void lhd_incomplete_type_error (const_tree, const_tree);
+extern void lhd_incomplete_type_error (location_t, const_tree, const_tree);
extern tree lhd_type_promotes_to (tree);
extern void lhd_register_builtin_type (tree, const char *);
extern bool lhd_decl_ok_for_sibcall (const_tree);
/* Invalid use of an incomplete type. */
void
-lhd_incomplete_type_error (const_tree ARG_UNUSED (value), const_tree type)
+lhd_incomplete_type_error (location_t ARG_UNUSED (loc),
+ const_tree ARG_UNUSED (value), const_tree type)
{
gcc_assert (TREE_CODE (type) == ERROR_MARK);
return;
/* This routine is called in tree.c to print an error message for
invalid use of an incomplete type. VALUE is the expression that
was used (or 0 if that isn't known) and TYPE is the type that was
- invalid. */
- void (*incomplete_type_error) (const_tree value, const_tree type);
+ invalid. LOC is the location of the use. */
+ void (*incomplete_type_error) (location_t loc, const_tree value,
+ const_tree type);
/* Called from assign_temp to return the maximum size, if there is one,
for a type. */
+2016-05-12 Marek Polacek <polacek@redhat.com>
+
+ PR c/70756
+ * c-c++-common/pr70756-2.c: New test.
+ * c-c++-common/pr70756.c: New test.
+
2016-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/71059
--- /dev/null
+/* PR c/70756 */
+/* { dg-do compile } */
+/* { dg-options "-Wpointer-arith" } */
+
+extern void bar (void);
+
+void
+fn (void *p)
+{
+ void *a = p + 1; /* { dg-warning "15:pointer of type" } */
+ void (*a2)(void) = &bar + 1; /* { dg-warning "27:pointer to a function" } */
+}
--- /dev/null
+/* PR c/70756 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+enum E e; /* { dg-error "storage size|use of enum" } */
+int (*A)[];
+
+void
+fn0 (void)
+{
+ struct
+ {
+ int x;
+ int y[];
+ } s;
+ 1234 && &s.y + 1; /* { dg-error "16:invalid use of" } */
+}
+
+void
+fn1 (void)
+{
+ 1234, A += 1; /* { dg-error "11:invalid use of array with unspecified bounds" } */
+}
make_unsigned_type). */
tree
-size_in_bytes (const_tree type)
+size_in_bytes_loc (location_t loc, const_tree type)
{
tree t;
if (t == 0)
{
- lang_hooks.types.incomplete_type_error (NULL_TREE, type);
+ lang_hooks.types.incomplete_type_error (loc, NULL_TREE, type);
return size_zero_node;
}
extern tree convert (tree, tree);
extern unsigned int expr_align (const_tree);
-extern tree size_in_bytes (const_tree);
+extern tree size_in_bytes_loc (location_t, const_tree);
+inline tree
+size_in_bytes (const_tree t)
+{
+ return size_in_bytes_loc (input_location, t);
+}
+
extern HOST_WIDE_INT int_size_in_bytes (const_tree);
extern HOST_WIDE_INT max_int_size_in_bytes (const_tree);
extern tree bit_position (const_tree);