This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] Better location info for function parameters (PR c/56724)

On 05/26/14 08:01, Marek Polacek wrote:
This patch introduces $subject, so if the warning says "passing
argument N of X", the caret points to actual argument and not
to function decl.  So e.g.:
pr56724-2.c:23:17: warning: passing argument 3 of âfoo_scâ from incompatible pointer type
    foo_sc (1, 2, f);
pr56724-2.c:9:13: note: expected âsigned char *â but argument is of type âfloat *â
  extern void foo_sc (int, int, signed char *);

Note that the column info for "note:" is still not optimal :( (and fixing this will
be probably a little bit harder).

Furthermore, the patch adds missing OPT_Wtraditional_conversion to warning_at
calls, alongside with some whitespace fixes.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

[Joseph is away this week, so it would be appreciated if someone else could approve this.]

2014-05-26  Marek Polacek  <>

	PR c/56724
	* c-typeck.c (convert_arguments): Get location of a parameter.  Change
	error and warning calls to error_at and warning_at.  Pass location of
	a parameter to it.  Call warning_at with OPT_Wtraditional_conversion.
	(convert_for_assignment): Add parameter to WARN_FOR_ASSIGNMENT and
	WARN_FOR_QUALIFIERS.  Pass expr_loc to those.

	* gcc.dg/pr56724-1.c: New test.
	* gcc.dg/pr56724-2.c: New test.
	* gcc.dg/wtr-conversion-1.c: Use -Wtraditional-conversion instead of
	* gcc.dg/dfp/wtr-conversion-1.c: Likewise.

diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 74a5ebd..0e31d39 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -3072,6 +3072,12 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
        bool excess_precision = false;
        bool npc;
        tree parmval;
+      /* Some __atomic_* builtins have additional hidden argument at
+	 position 0.  */
+      location_t ploc
+	= !arg_loc.is_empty () && values->length () == arg_loc.length ()
+	  ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
+	  : input_location;

        if (type == void_type_node)
@@ -3114,7 +3120,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,

  	  if (type == error_mark_node || !COMPLETE_TYPE_P (type))
-	      error ("type of formal parameter %d is incomplete", parmnum + 1);
+	      error_at (ploc, "type of formal parameter %d is incomplete",
+			argnum);
Is the change from parnum+1 to argnum really correct? Note that they are not equal for certain ObjC situations.

The rest is OK. If you're sure the parnum+1 -> argnum change is really correct, then the whole thing is good. If you change that back to parnum+1 after further review, then that is pre-approved.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]