}
static void
-composite_pointer_error (diagnostic_t kind, tree t1, tree t2,
+composite_pointer_error (const op_location_t &location,
+ diagnostic_t kind, tree t1, tree t2,
composite_pointer_operation operation)
{
switch (operation)
{
case CPO_COMPARISON:
- emit_diagnostic (kind, input_location, 0,
+ emit_diagnostic (kind, location, 0,
"comparison between "
"distinct pointer types %qT and %qT lacks a cast",
t1, t2);
break;
case CPO_CONVERSION:
- emit_diagnostic (kind, input_location, 0,
+ emit_diagnostic (kind, location, 0,
"conversion between "
"distinct pointer types %qT and %qT lacks a cast",
t1, t2);
break;
case CPO_CONDITIONAL_EXPR:
- emit_diagnostic (kind, input_location, 0,
+ emit_diagnostic (kind, location, 0,
"conditional expression between "
"distinct pointer types %qT and %qT lacks a cast",
t1, t2);
case. See that function for documentation of the parameters. */
static tree
-composite_pointer_type_r (tree t1, tree t2,
+composite_pointer_type_r (const op_location_t &location,
+ tree t1, tree t2,
composite_pointer_operation operation,
tsubst_flags_t complain)
{
else if ((TYPE_PTR_P (pointee1) && TYPE_PTR_P (pointee2))
|| (TYPE_PTRMEM_P (pointee1) && TYPE_PTRMEM_P (pointee2)))
{
- result_type = composite_pointer_type_r (pointee1, pointee2, operation,
- complain);
+ result_type = composite_pointer_type_r (location, pointee1, pointee2,
+ operation, complain);
if (result_type == error_mark_node)
return error_mark_node;
}
else
{
if (complain & tf_error)
- composite_pointer_error (DK_PERMERROR, t1, t2, operation);
+ composite_pointer_error (location, DK_PERMERROR,
+ t1, t2, operation);
else
return error_mark_node;
result_type = void_type_node;
TYPE_PTRMEM_CLASS_TYPE (t2)))
{
if (complain & tf_error)
- composite_pointer_error (DK_PERMERROR, t1, t2, operation);
+ composite_pointer_error (location, DK_PERMERROR,
+ t1, t2, operation);
else
return error_mark_node;
}
pointers-to-members as per [expr.eq]. */
tree
-composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
+composite_pointer_type (const op_location_t &location,
+ tree t1, tree t2, tree arg1, tree arg2,
composite_pointer_operation operation,
tsubst_flags_t complain)
{
switch (operation)
{
case CPO_COMPARISON:
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (location, OPT_Wpedantic,
"ISO C++ forbids comparison between pointer "
"of type %<void *%> and pointer-to-function");
break;
case CPO_CONVERSION:
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (location, OPT_Wpedantic,
"ISO C++ forbids conversion between pointer "
"of type %<void *%> and pointer-to-function");
break;
case CPO_CONDITIONAL_EXPR:
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (location, OPT_Wpedantic,
"ISO C++ forbids conditional expression between "
"pointer of type %<void *%> and "
"pointer-to-function");
else
{
if (complain & tf_error)
- composite_pointer_error (DK_ERROR, t1, t2, operation);
+ composite_pointer_error (location, DK_ERROR, t1, t2, operation);
return error_mark_node;
}
}
switch (operation)
{
case CPO_COMPARISON:
- error ("comparison between distinct "
- "pointer-to-member types %qT and %qT lacks a cast",
- t1, t2);
+ error_at (location, "comparison between distinct "
+ "pointer-to-member types %qT and %qT lacks a cast",
+ t1, t2);
break;
case CPO_CONVERSION:
- error ("conversion between distinct "
- "pointer-to-member types %qT and %qT lacks a cast",
- t1, t2);
+ error_at (location, "conversion between distinct "
+ "pointer-to-member types %qT and %qT lacks a cast",
+ t1, t2);
break;
case CPO_CONDITIONAL_EXPR:
- error ("conditional expression between distinct "
- "pointer-to-member types %qT and %qT lacks a cast",
- t1, t2);
+ error_at (location, "conditional expression between distinct "
+ "pointer-to-member types %qT and %qT lacks a cast",
+ t1, t2);
break;
default:
gcc_unreachable ();
}
}
- return composite_pointer_type_r (t1, t2, operation, complain);
+ return composite_pointer_type_r (location, t1, t2, operation, complain);
}
/* Return the merged type of two types.
|| (TYPE_PTRDATAMEM_P (t1) && TYPE_PTRDATAMEM_P (t2))
|| (TYPE_PTRMEMFUNC_P (t1) && TYPE_PTRMEMFUNC_P (t2)));
- return composite_pointer_type (t1, t2, error_mark_node, error_mark_node,
+ return composite_pointer_type (input_location, t1, t2,
+ error_mark_node, error_mark_node,
CPO_CONVERSION, tf_warning_or_error);
}
\f
else if (is_overloaded_fn (e))
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids applying %<sizeof%> to an expression of "
- "function type");
+ permerror (cp_expr_loc_or_input_loc (e),
+ "ISO C++ forbids applying %<sizeof%> to an expression "
+ "of function type");
else
return error_mark_node;
e = char_type_node;
else if (is_overloaded_fn (e))
{
if (complain & tf_error)
- permerror (input_location, "ISO C++ forbids applying %<__alignof%> to an expression of "
- "function type");
+ permerror (cp_expr_loc_or_input_loc (e),
+ "ISO C++ forbids applying %<__alignof%> to an expression "
+ "of function type");
else
return error_mark_node;
if (TREE_CODE (e) == FUNCTION_DECL)
&& TYPE_PTR_P (type1) && integer_zerop (op1)))
{
if (TYPE_PTR_P (type1))
- result_type = composite_pointer_type (type0, type1, op0, op1,
+ result_type = composite_pointer_type (location,
+ type0, type1, op0, op1,
CPO_COMPARISON, complain);
else
result_type = type0;
&& TYPE_PTR_P (type0) && integer_zerop (op0)))
{
if (TYPE_PTR_P (type0))
- result_type = composite_pointer_type (type0, type1, op0, op1,
+ result_type = composite_pointer_type (location,
+ type0, type1, op0, op1,
CPO_COMPARISON, complain);
else
result_type = type1;
}
else if ((code0 == POINTER_TYPE && code1 == POINTER_TYPE)
|| (TYPE_PTRDATAMEM_P (type0) && TYPE_PTRDATAMEM_P (type1)))
- result_type = composite_pointer_type (type0, type1, op0, op1,
+ result_type = composite_pointer_type (location,
+ type0, type1, op0, op1,
CPO_COMPARISON, complain);
else if (null_ptr_cst_p (orig_op0) && null_ptr_cst_p (orig_op1))
/* One of the operands must be of nullptr_t type. */
tree delta0;
tree delta1;
- type = composite_pointer_type (type0, type1, op0, op1,
+ type = composite_pointer_type (location, type0, type1, op0, op1,
CPO_COMPARISON, complain);
if (!same_type_p (TREE_TYPE (op0), type))
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
shorten = 1;
else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
- result_type = composite_pointer_type (type0, type1, op0, op1,
+ result_type = composite_pointer_type (location,
+ type0, type1, op0, op1,
CPO_COMPARISON, complain);
break;
|| code1 == ENUMERAL_TYPE))
short_compare = 1;
else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
- result_type = composite_pointer_type (type0, type1, op0, op1,
+ result_type = composite_pointer_type (location,
+ type0, type1, op0, op1,
CPO_COMPARISON, complain);
else if (code0 == POINTER_TYPE && null_ptr_cst_p (orig_op1))
{
if (!(complain & tf_error))
return 0;
/* Make this a permerror because we used to accept it. */
- permerror (input_location, "using rvalue as lvalue");
+ permerror (cp_expr_loc_or_input_loc (ref),
+ "using rvalue as lvalue");
}
return 1;
}
void f() { if (z) z(); } // { dg-warning "address" }
-void gl() { if (z != 0) z(); } // { dg-warning "address" }
-void hl() { if (z != (ptrf)0) z(); } // { dg-warning "address" }
-void il() { if (z != (void*)0) z(); } // { dg-warning "address|comparison" }
-void jl() { if (&n != (int*)0) z(); } // { dg-warning "address" }
-void kl() { if (&m != (int*)0) z(); } // { dg-warning "address" }
-void ll() { if (&s != (T*)0) z(); } // { dg-warning "address" }
-void ml() { if (&t != (S*)0) z(); } // { dg-warning "address" }
+void gl() { if (z != 0) z(); } // { dg-warning "19:address" }
+void hl() { if (z != (ptrf)0) z(); } // { dg-warning "19:address" }
+void il() { if (z != (void*)0) z(); } // { dg-warning "19:comparison" }
+// { dg-warning "19:address" "" { target *-*-* } .-1 }
+void jl() { if (&n != (int*)0) z(); } // { dg-warning "20:address" }
+void kl() { if (&m != (int*)0) z(); } // { dg-warning "20:address" }
+void ll() { if (&s != (T*)0) z(); } // { dg-warning "20:address" }
+void ml() { if (&t != (S*)0) z(); } // { dg-warning "20:address" }
-void nl() { if (z != (S*)0) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void pl() { if (z != (ptrfn)0) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void ql() { if (&d != (int*)0) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void rl() { if (&s != (U*)0) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
+void nl() { if (z != (S*)0) z(); } // { dg-error "19:comparison" }
+// { dg-warning "19:address" "" { target *-*-* } .-1 }
+void pl() { if (z != (ptrfn)0) z(); } // { dg-error "19:comparison" }
+// { dg-warning "19:address" "" { target *-*-* } .-1 }
+void ql() { if (&d != (int*)0) z(); } // { dg-error "20:comparison" }
+// { dg-warning "20:address" "" { target *-*-* } .-1 }
+void rl() { if (&s != (U*)0) z(); } // { dg-error "20:comparison" }
+// { dg-warning "20:address" "" { target *-*-* } .-1 }
-void gr() { if (0 != z) z(); } // { dg-warning "address" }
-void hr() { if ((ptrf)0 != z) z(); } // { dg-warning "address" }
-void ir() { if ((void*)0 != z) z(); } // { dg-warning "address|comparison" }
-void jr() { if ((int*)0 != &n) z(); } // { dg-warning "address" }
-void kr() { if ((int*)0 != &m) z(); } // { dg-warning "address" }
-void lr() { if ((T*)0 != &s) z(); } // { dg-warning "address" }
-void mr() { if ((S*)0 != &t) z(); } // { dg-warning "address" }
+void gr() { if (0 != z) z(); } // { dg-warning "19:address" }
+void hr() { if ((ptrf)0 != z) z(); } // { dg-warning "25:address" }
+void ir() { if ((void*)0 != z) z(); } // { dg-warning "26:comparison" }
+// { dg-warning "26:address" "" { target *-*-* } .-1 }
+void jr() { if ((int*)0 != &n) z(); } // { dg-warning "25:address" }
+void kr() { if ((int*)0 != &m) z(); } // { dg-warning "25:address" }
+void lr() { if ((T*)0 != &s) z(); } // { dg-warning "23:address" }
+void mr() { if ((S*)0 != &t) z(); } // { dg-warning "23:address" }
-void nr() { if ((S*)0 != z) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void pr() { if ((ptrfn)0 != z) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void qr() { if ((int*)0 != &d) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
-void rr() { if ((U*)0 != &s) z(); } // { dg-error "comparison" }
-// { dg-warning "address" "" { target *-*-* } .-1 }
+void nr() { if ((S*)0 != z) z(); } // { dg-error "23:comparison" }
+// { dg-warning "23:address" "" { target *-*-* } .-1 }
+void pr() { if ((ptrfn)0 != z) z(); } // { dg-error "26:comparison" }
+// { dg-warning "26:address" "" { target *-*-* } .-1 }
+void qr() { if ((int*)0 != &d) z(); } // { dg-error "25:comparison" }
+// { dg-warning "25:address" "" { target *-*-* } .-1 }
+void rr() { if ((U*)0 != &s) z(); } // { dg-error "23:comparison" }
+// { dg-warning "23:address" "" { target *-*-* } .-1 }