From a481ec4150ad203440852a2bfee0883dd26f7530 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 23 May 2010 19:57:01 +0000 Subject: 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 --- test/SemaCXX/c99-variable-length-array.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/SemaCXX/c99-variable-length-array.cpp') 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 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 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); @@ -53,7 +53,8 @@ void inst_with_vla(int N) { template struct X1 { - template // expected-error{{variable length array cannot be used in a template instantiation}} + template // 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 { }; -- cgit v1.2.3-18-g5258