This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: new pass to warn on questionable uses of alloca() and VLAs
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Martin Sebor <msebor at redhat dot com>, Jeff Law <law at redhat dot com>
- Cc: Andrew MacLeod <amacleod at redhat dot com>
- Date: Mon, 11 Jul 2016 00:41:31 +0100
- Subject: Re: RFA: new pass to warn on questionable uses of alloca() and VLAs
- Authentication-results: sourceware.org; auth=none
- References: <577F9301.10205@redhat.com>
+Walloca
+LangEnabledBy(C ObjC C++ ObjC++)
+; in common.opt
+
+Walloca=
+LangEnabledBy(C ObjC C++ ObjC++)
+; in common.opt
+
I'm not sure what you think the above means, but this is an invalid use of
LangEnabledBy(). (It would be nice if the .awk scripts were able to catch it
and give an error.)
+;; warn_vla == 0 for -Wno-vla
+;; warn_vla == -1 for nothing passed.
+;; warn_vla == -2 for -Wvla passed
+;; warn_vla == NUM for -Wvla=NUM
Wvla
C ObjC C++ ObjC++ Var(warn_vla) Init(-1) Warning
Warn if a variable length array is used.
+Wvla=
+C ObjC C++ ObjC++ Var(warn_vla) Warning Joined RejectNegative UInteger
+-Wvla=<number> Warn on unbounded uses of variable-length arrays, and
+warn on bounded uses of variable-length arrays whose bound can be
+larger than <number> bytes.
+
This overloading of warn_vla seems confusing (as shown by all the places that
require updating). Why not call it Wvla-larger-than= and use a different
warn_vla_larger_than variable? We already have -Wlarger-than= and
-Wframe-larger-than=.
Using warn_vla_larger_than (even if you wish to keep -Wvla= as the option name)
as a variable distinct from warn_vla would make things simpler:
-Wvla => warn_vla == 1
-Wno-vla => warn_vla == 0
-Wvla=N => warn_vla_larger_than == N (where N == 0 means disable).
If you wish that -Wno-vla implies -Wvla=0 then you'll need to handle that
manually. I don't think we have support for that in the .opt files. But that
seems far less complex than having a single shared Var().
Cheers,
Manuel.