Hi,
a bunch of straightforward tweaks: let's use the available location in
some additional places. Tested x86_64-linux, as usual.
Thanks, Paolo.
///
/cp
2019-11-15 Paolo Carlini
* typeck.c (cp_build_unary_op): Consistently use the accurate
location in seven additional diagnostic messages.
(cp_build_compound_expr): Use cp_expr_loc_or_input_loc in one place.
/testsuite
2019-11-15 Paolo Carlini
* g++.dg/cpp1z/bool-increment1.C: Test location(s) too.
* g++.dg/expr/bitfield3.C: Likewise.
* g++.dg/expr/bitfield4.C: Likewise.
* g++.dg/expr/bitfield5.C: Likewise.
* g++.dg/expr/bitfield6.C: Likewise.
* g++.dg/expr/bool1.C: Likewise.
* g++.dg/expr/bool2.C: Likewise.
* g++.dg/expr/bool3.C: Likewise.
* g++.dg/expr/bool4.C: Likewise.
* g++.dg/expr/lval3.C: Likewise.
* g++.dg/other/error18.C: Likewise.
* g++.dg/warn/Wpointer-arith-1.C: Likewise.
* g++.old-deja/g++.bugs/900212_01.C: Likewise.
* g++.old-deja/g++.bugs/900428_02.C: Likewise.
* g++.old-deja/g++.jason/rfg14.C: Likewise.
* g++.old-deja/g++.other/overload11.C: Likewise.
Index: cp/typeck.c
===
--- cp/typeck.c (revision 278692)
+++ cp/typeck.c (working copy)
@@ -6520,7 +6520,8 @@ cp_build_unary_op (enum tree_code code, tree xarg,
if (TREE_CODE (argtype) == ENUMERAL_TYPE)
{
if (complain & tf_error)
- permerror (input_location, (code == PREINCREMENT_EXPR || code ==
POSTINCREMENT_EXPR)
+ permerror (location, (code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
? G_("ISO C++ forbids incrementing an enum")
: G_("ISO C++ forbids decrementing an enum"));
else
@@ -6536,11 +6537,13 @@ cp_build_unary_op (enum tree_code code, tree xarg,
if (!COMPLETE_OR_VOID_TYPE_P (type))
{
if (complain & tf_error)
- error (((code == PREINCREMENT_EXPR
- || code == POSTINCREMENT_EXPR))
- ? G_("cannot increment a pointer to incomplete type
%qT")
- : G_("cannot decrement a pointer to incomplete type
%qT"),
- TREE_TYPE (argtype));
+ error_at (location, ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR))
+ ? G_("cannot increment a pointer to incomplete "
+"type %qT")
+ : G_("cannot decrement a pointer to incomplete "
+"type %qT"),
+ TREE_TYPE (argtype));
else
return error_mark_node;
}
@@ -6547,11 +6550,13 @@ cp_build_unary_op (enum tree_code code, tree xarg,
else if (!TYPE_PTROB_P (argtype))
{
if (complain & tf_error)
- pedwarn (input_location, OPT_Wpointer_arith,
+ pedwarn (location, OPT_Wpointer_arith,
(code == PREINCREMENT_EXPR
|| code == POSTINCREMENT_EXPR)
- ? G_("ISO C++ forbids incrementing a pointer of type
%qT")
- : G_("ISO C++ forbids decrementing a pointer of type
%qT"),
+ ? G_("ISO C++ forbids incrementing a pointer "
+ "of type %qT")
+ : G_("ISO C++ forbids decrementing a pointer "
+ "of type %qT"),
argtype);
else
return error_mark_node;
@@ -6597,8 +6602,9 @@ cp_build_unary_op (enum tree_code code, tree xarg,
if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR)
{
if (complain & tf_error)
- error ("use of an operand of type %qT in % "
-"is forbidden", boolean_type_node);
+ error_at (location,
+ "use of an operand of type %qT in % "
+ "is forbidden", boolean_type_node);
return error_mark_node;
}
else
@@ -6606,16 +6612,18 @@ cp_build_unary_op (enum tree_code code, tree xarg,
if (cxx_dialect >= cxx17)
{
if (complain & tf_error)
- error ("use of an operand of type %qT in "
-"% is forbidden in C++17",
-boolean_type_node);
+ error_at (location,
+ "use of an operand of type %qT in "
+ "% is forbidden in C++17",