From a09387df9ffbe0849288b6ba5ce9a31c0829eed5 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). llvm-svn: 104471 --- clang/test/SemaCXX/c99-variable-length-array.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'clang/test/SemaCXX/c99-variable-length-array.cpp') 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 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