forked from OSchip/llvm-project
Put the VLA-is-an-extension warning into its own warning group (-Wvla)
so that it can be selectively enabled/disabled. llvm-svn: 104462
This commit is contained in:
parent
5e8c8c0e12
commit
4b636a70d9
|
@ -123,6 +123,7 @@ def SuperSubClassMismatch : DiagGroup<"super-class-method-mismatch">;
|
|||
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">;
|
||||
|
|
|
@ -38,7 +38,8 @@ def warn_float_underflow : Warning<
|
|||
|
||||
// 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|"
|
||||
|
|
|
@ -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 @@ struct POD {
|
|||
|
||||
// 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 @@ template<typename T> struct X0 { };
|
|||
// 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 @@ template<typename T, unsigned N>
|
|||
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 test_accept_array(int N) {
|
|||
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 @@ namespace PR7206 {
|
|||
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}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue