This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] disable -Walloc-size-larger-than and -Wstringop-overflow for non-C front ends (PR 80545)
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Jeff Law <law at redhat dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 9 May 2017 10:57:05 +0200
- Subject: Re: [PATCH] disable -Walloc-size-larger-than and -Wstringop-overflow for non-C front ends (PR 80545)
- Authentication-results: sourceware.org; auth=none
- References: <b343e5fc-8c62-53f3-22ba-1d38c043c4f2@gmail.com> <261ffc18-82fe-9b2f-3d46-32df14159ed7@redhat.com> <a22fda39-e090-8d50-6746-8e446bdf6c36@gmail.com>
On Mon, May 8, 2017 at 4:31 PM, Martin Sebor <msebor@gmail.com> wrote:
> On 05/04/2017 10:13 PM, Jeff Law wrote:
>>
>> On 04/28/2017 04:02 PM, Martin Sebor wrote:
>>>
>>> The two options were included in -Wall and enabled for all front
>>> ends but only made to be recognized by the driver for the C family
>>> of compilers. That made it impossible to suppress those warnings
>>> when compiling code for those other front ends (like Fortran).
>>>
>>> The attached patch adjusts the warnings so that they are only
>>> enabled for the C family of front ends and not for any others,
>>> as per Richard's suggestion. (The other solution would have
>>> been to make the warnings available to all front ends. Since
>>> non-C languages don't have a way of calling the affected
>>> functions -- or do they? -- this is probably not necessary.)
>>>
>>> Martin
>>>
>>> gcc-80545.diff
>>>
>>>
>>> PR driver/80545 - option -Wstringop-overflow not recognized by Fortran
>>>
>>> gcc/c-family/ChangeLog:
>>>
>>> PR driver/80545
>>> * c.opt (-Walloc-size-larger-than, -Wstringop-overflow): Enable
>>> and make available for the C family only.
>>
>> OK.
>> jeff
>
>
> It turns out that this is not the right fix. I overlooked that
> -Wstringop-overflow is meant to be enabled by default and while
> removing the Init(2) bit and replacing it with LangEnabledBy (C
> ObjC C++ ObjC++, Wall, 2, 0) suppresses the warning in Fortran
> it also disables it by default in C/C++ unless -Wall is used.
>
> By my reading of the Option properties part of the GCC Internals
> manual there is no way to initialize a warning to on by default
> while making it available only in a subset of languages. The
> only way I can think of is to initialize it in the .opt file to
> something like -1 and then change it at some point to 2 somewhere
> in the C/C++ front ends. That seems pretty cumbersome. Am I
> missing some trick?
Maybe just enhance the machinery to allow
LangEnabledBy (C ObjC C++ ObjC++, , 2, 0)
(note empty "by")
?
> Martin