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 | a481ec4150ad203440852a2bfee0883dd26f7530 (patch) | |
tree | 5b39dca0a86ea1a9747f4731470c78b761efaba7 /test/SemaCXX/c99-variable-length-array.cpp | |
parent | 9ba6af8bedba28d10a6906c62c19d43f81c5d386 (diff) |
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).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/c99-variable-length-array.cpp')
-rw-r--r-- | test/SemaCXX/c99-variable-length-array.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp index 8a2e35b012..8a9bcb38cb 100644 --- a/test/SemaCXX/c99-variable-length-array.cpp +++ b/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 { }; |