diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-23 19:57:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-23 19:57:01 +0000 |
commit | a09387df9ffbe0849288b6ba5ce9a31c0829eed5 (patch) | |
tree | 62ddf7fccee11b545778d1c19ea979882a26b82c /clang/test/SemaCXX/c99-variable-length-array.cpp | |
parent | 2788782164db1a55d40f18a43e11e58904aeb836 (diff) | |
download | bcm5719-llvm-a09387df9ffbe0849288b6ba5ce9a31c0829eed5.tar.gz bcm5719-llvm-a09387df9ffbe0849288b6ba5ce9a31c0829eed5.zip |
It turns out that people love using VLAs in templates, too. Weaken our
VLA restrictions so that one can use VLAs in templates (even
accidentally), but not as part of a non-type template parameter (which
would be very bad).
llvm-svn: 104471
Diffstat (limited to 'clang/test/SemaCXX/c99-variable-length-array.cpp')
-rw-r--r-- | clang/test/SemaCXX/c99-variable-length-array.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/c99-variable-length-array.cpp b/clang/test/SemaCXX/c99-variable-length-array.cpp index 8a2e35b012f..8a9bcb38cbf 100644 --- a/clang/test/SemaCXX/c99-variable-length-array.cpp +++ b/clang/test/SemaCXX/c99-variable-length-array.cpp @@ -20,10 +20,10 @@ void vla(int N) { NonPOD2 array4[N][3]; // expected-error{{variable length array of non-POD element type 'NonPOD2'}} } -// We disallow VLAs in templates +/// Warn about VLAs in templates. template<typename T> void vla_in_template(int N, T t) { - int array1[N]; // expected-error{{variable length array cannot be used in a template definition}} + int array1[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}} } struct HasConstantValue { @@ -36,7 +36,7 @@ struct HasNonConstantValue { template<typename T> void vla_in_template(T t) { - int array2[T::value]; // expected-error{{variable length array cannot be used in a template instantiation}} + int array2[T::value]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}} } template void vla_in_template<HasConstantValue>(HasConstantValue); @@ -53,7 +53,8 @@ void inst_with_vla(int N) { template<typename T> struct X1 { - template<int (&Array)[T::value]> // expected-error{{variable length array cannot be used in a template instantiation}} + template<int (&Array)[T::value]> // expected-error{{non-type template parameter of variably modified type 'int (&)[HasNonConstantValue::value]'}} \ + // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}} struct Inner { }; |