This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] disable -Walloc-size-larger-than and -Wstringop-overflow for non-C front ends (PR 80545)
- From: Martin Sebor <msebor at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 28 Apr 2017 16:02:45 -0600
- Subject: [PATCH] disable -Walloc-size-larger-than and -Wstringop-overflow for non-C front ends (PR 80545)
- Authentication-results: sourceware.org; auth=none
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
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.
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 6ecbfca..9ad2f6e 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -304,7 +304,7 @@ C ObjC C++ ObjC++ Var(warn_alloca) Warning
Warn on any use of alloca.
Walloc-size-larger-than=
-C ObjC C++ ObjC++ Var(warn_alloc_size_limit) Warning Joined
+C ObjC C++ ObjC++ Var(warn_alloc_size_limit) Warning Joined LangEnabledBy(C ObjC C++ ObjC++, Wall)
-Walloc-size-larger-than=<bytes> Warn for calls to allocation functions that
attempt to allocate objects larger than the specified number of bytes.
@@ -716,7 +716,7 @@ Warn about buffer overflow in string manipulation functions like memcpy
and strcpy.
Wstringop-overflow=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Init(2) Warning
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Warning LangEnabledBy(C ObjC C++ ObjC++, Wall, 2, 0)
Under the control of Object Size type, warn about buffer overflow in string
manipulation functions like memcpy and strcpy.