This is the mail archive of the gcc-patches@gcc.gnu.org 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: PR35503 - warn for restrict pointer (-Wrestrict)


On 30 August 2016 at 17:11, Eric Gallager <egall@gwmail.gwu.edu> wrote:
> On 8/29/16, Jason Merrill <jason@redhat.com> wrote:
>> On Mon, Aug 29, 2016 at 10:28 AM, Marek Polacek <polacek@redhat.com> wrote:
>>> On Mon, Aug 29, 2016 at 09:20:53AM -0400, Eric Gallager wrote:
>>>> I tried this patch on my fork of gdb-binutils and got a few warnings
>>>> from it. Would it be possible to have the caret point to the argument
>>>> mentioned, instead of the function name? And also print the option
>>>> name? E.g., instead of the current:
>>>>
>>>> or32-opc.c: In function ‘or32_print_register’:
>>>> or32-opc.c:956:3: warning: passing argument 1 to restrict qualified
>>>> parameter aliases with argument 3
>>>>    sprintf (disassembled, "%sr%d", disassembled, regnum);
>>>>    ^~~~~~~
>>>>
>>>> could it look like:
>>>>
>>>> or32-opc.c: In function ‘or32_print_register’:
>>>> or32-opc.c:956:3: warning: passing argument 1 to restrict qualified
>>>> parameter aliases with argument 3 [-Wrestrict]
>>>>    sprintf (disassembled, "%sr%d", disassembled, regnum);
>>>>             ^~~~~~~~~~~~
>>>>
>>>> instead?
>>>
>>> I didn't try to implement it, but I think this should be fairly easy to
>>> achieve in the C FE, because c_parser_postfix_expression_after_primary
>>> has arg_loc, which is a vector of parameter locations.
>>
>> The C++ FE doesn't have this currently, but it could be added without
>> too much trouble: in cp_parser_parenthesized_expression_list, extract
>> the locations from the cp_expr return value of
>> cp_parser_assignment_expression, and then pass the locations back up
>> to cp_parser_postfix_expression.
>>
>> Jason
>>
>
>
> On the topic of how to get this warning working with various
> frontends, is there any reason why the Objective C frontend doesn't
> handle -Wrestrict? Currently when trying to use it, it just says:
>
> cc1obj: warning: command line option '-Wrestrict' is valid for C/C++
> but not for ObjC
Hi Eric,
I am not sure if restrict is valid for ObjC/Obj-C++ and hence didn't
add the option for these front-ends.
If it is valid, I will enable the option for ObjC and Obj-C++.

Thanks,
Prathamesh


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