PR35503 - warn for restrict pointer

Tobias Burnus tobias.burnus@physik.fu-berlin.de
Mon Aug 29 14:25:00 GMT 2016


Prathamesh Kulkarni wrote:
> Attachment: pr35503-3.txt

I tried the patch - and it found a bug in our code; nice!


(a) Regarding the [-Werror] output:

   error: passing argument 24 to restrict qualified parameter aliases with argument 29 [-Werror]

Shouldn't that output "[-Werror=restrict]" instead of a bare "[-Werror]? Namely, instead of

+	warning_at (loc, 0,
+		    "passing argument %u to restrict qualified parameter aliases with "
+		    "argument %u", param_pos + 1, i + 1);

I think one gets this with
        warning_at (loc, OPT_Wrestrict, ...


 * * *

(b) I get:


file.cc:5582:41: error: passing argument 24 to restrict qualified parameter aliases with argument 29 [-Werror]
                                out, out2);
                                         ^
file.cc:5582:41: error: passing argument 29 to restrict qualified parameter aliases with argument 24 [-Werror]


Thus, the message is kind of shown twice, one for 24 and once for 29;
but only one has a "^" possition, pointing after the 31st argument.


(i) I had expected that the message is shown only once. The issue here that
both the 24th and the 29th argument have the restrict qualifier. A simple

+      if (i < param_pos)
+	continue;

in warn_for_restrict would have silenced the second call, but would have
missed the output if only the 29th argument had the qualifier and not
also the 24th argument. Thus, one needs some more logic.


(ii) It would be great if the "^" wouldn't point to the end of the
argument list but to the one of the aliasing arguments - or even better
to "^~~~~~~" to the first argument and to "~~~~~~~~~" to the second.

I have to admit that I don't know how to use rich_location, but I am sure
digging in the source would help; possibly, also David or Marek can give
you a hint.

Cheers,

Tobias



More information about the Gcc-patches mailing list