[cfe-commits] [PATCH] Implement -Wvla correctly
Dmitri Gribenko
gribozavr at gmail.com
Tue Jan 8 08:31:16 PST 2013
Hello Rafael,
I have added the requested tests.
On Tue, Jan 8, 2013 at 5:46 PM, Rafael EspĂndola
<rafael.espindola at gmail.com> wrote:
> On 7 January 2013 18:00, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> Hello,
>>
>> GCC implements -Wvla as "warn on every VLA" (this is useful to find
>> every VLA, for example, if they are forbidden by coding guidelines).
>> Currently Clang implements -Wvla as "warn on VLA when it is an
>> extension".
>>
>> The attached patch makes our behavior match GCC. The existing vla
>> extwarn is moved under -Wvla-extension and is still included into
>> -Wgnu.
>>
>> -Wvla is disabled by default, so I don't think that this change will
>> cause much fallout.
>
> Do you want this to warn (in C) for
>
> void test(int n, int v[n]) {
> }
>
> What about just declaring test? Please add a test for both.
Yes, we want to warn here. Added tests.
> In c++, do you expect an warning in
>
> template<typename T>
> void test(int n) {
> int v[n];
> }
>
> Even when the template is never instantiated? Please add a test one
> way or the other.
Added tests.
It is interesting that GCC does not implement VLA extension in C++
completely and errors on everything except test1() in
test/SemaCXX/warn-vla.cpp
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-wvla-correctly-v2.patch
Type: application/octet-stream
Size: 4513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130108/3cbdecc5/attachment.obj>
More information about the cfe-commits
mailing list