[cfe-commits] r104462 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/c99-variable-length-array.cpp

Douglas Gregor dgregor at apple.com
Tue May 25 08:07:19 PDT 2010


On May 23, 2010, at 7:31 PM, Chris Lattner wrote:

> Should -Wvla be a subgroup of -Wgcc?

Sure, r104606.

	- Doug

> On May 23, 2010, at 9:51 AM, Douglas Gregor <dgregor at apple.com> wrote:
> 
>> Author: dgregor
>> Date: Sun May 23 11:51:27 2010
>> New Revision: 104462
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=104462&view=rev
>> Log:
>> Put the VLA-is-an-extension warning into its own warning group (-Wvla)
>> so that it can be selectively enabled/disabled.
>> 
>> Modified:
>>   cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>   cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=104462&r1=104461&r2=104462&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sun May 23 11:51:27 2010
>> @@ -123,6 +123,7 @@
>> def : DiagGroup<"variadic-macros">;
>> def VariadicMacros : DiagGroup<"variadic-macros">;
>> def VectorConversions : DiagGroup<"vector-conversions">;      // clang specific
>> +def VLA : DiagGroup<"vla">;
>> def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
>> def : DiagGroup<"write-strings">;
>> def CharSubscript : DiagGroup<"char-subscripts">;
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=104462&r1=104461&r2=104462&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun May 23 11:51:27 2010
>> @@ -38,7 +38,8 @@
>> 
>> // C99 variable-length arrays
>> def ext_vla : Extension<
>> -  "variable length arrays are a C99 feature, accepted as an extension">;
>> +  "variable length arrays are a C99 feature, accepted as an extension">,
>> +  InGroup<VLA>;
>> def err_vla_non_pod : Error<"variable length array of non-POD element type %0">;
>> def err_vla_in_template : Error<
>>  "variable length array cannot be used in a template %select{definition|"
>> 
>> Modified: cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp?rev=104462&r1=104461&r2=104462&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp Sun May 23 11:51:27 2010
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -fsyntax-only -verify %s
>> +// RUN: %clang_cc1 -fsyntax-only -verify -Wvla %s
>> struct NonPOD {
>>  NonPOD();
>> };
>> @@ -14,8 +14,8 @@
>> 
>> // We allow VLAs of POD types, only.
>> void vla(int N) {
>> -  int array1[N];
>> -  POD array2[N];
>> +  int array1[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>> +  POD array2[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>>  NonPOD array3[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}}
>>  NonPOD2 array4[N][3]; // expected-error{{variable length array of non-POD element type 'NonPOD2'}}
>> }
>> @@ -47,7 +47,7 @@
>> // Cannot use any variably-modified type with a template parameter or
>> // argument.
>> void inst_with_vla(int N) {
>> -  int array[N];
>> +  int array[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>>  X0<__typeof__(array)> x0a; // expected-error{{variably modified type 'typeof (array)' (aka 'int [N]') cannot be used as a template argument}}
>> }
>> 
>> @@ -67,7 +67,7 @@
>> void accept_array(T (&array)[N]); // expected-note{{candidate template ignored: failed template argument deduction}}
>> 
>> void test_accept_array(int N) {
>> -  int array[N];
>> +  int array[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>>  accept_array(array); // expected-error{{no matching function for call to 'accept_array'}}
>> }
>> 
>> @@ -75,7 +75,8 @@
>> void local_classes(int N) {
>>  struct X {
>>    int size;
>> -    int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}}
>> +    int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}} \
>> +                  // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>>  };
>> }
>> 
>> @@ -85,6 +86,6 @@
>>      float left;
>>      float right;
>>    };
>> -    struct edge_info edgeInfo[x];
>> +    struct edge_info edgeInfo[x]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
>>  }
>> }
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list