>>>>> "Jonathan" == Jonathan Wakely via Gcc <[email protected]> writes:

Jonathan> That doesn't have to be a problem:

Jonathan> #define ALLOW_VLA  \
Jonathan>   _Pragma("GCC diagnostic push"); \
Jonathan>   _Pragma("GCC diagnostic ignored \"-Wvla\"")

Jonathan> #define DISALLOW_VLA \
Jonathan>   _Pragma("GCC diagnostic pop")


Jonathan> ALLOW_VLA;
Jonathan> for (int vla[n]; ; )
Jonathan>   ...
Jonathan> DISALLOW_VLA;

Jonathan> That doesn't interfere with the declaration.

A long time ago I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108811
for something like this -- the ability to enable a certain warning for
just a subset of switch statements.

Putting pragmas before and after the switch is possible but it would be
nicer if it could be done with a single line, so instead of

ENABLE_WARNING;
switch (blah) {
 // it is gdb so of course there's hundreds of lines here
}
DISABLE_WARNING;

we could write

[[enable_warning_for_this_statement]] switch(...)

I'm indifferent to whether this is an attribute or pragma, it's more
about having it automatically narrow its scope to a single statement.

Jonathan> Somebody has to
Jonathan> develop and test and maintain that attribute forever, for a very
Jonathan> narrow use case which is arguably just user error. Don't use -Wvla if
Jonathan> you want to compile code that uses VLAs.

I'm sympathetic to that but it seems like the machinery is there already
and it's more a matter of how it is applied by the user.

But OTOH maybe the other thing to do is WONTFIX that bug.

thanks,
Tom

Reply via email to