[cfe-commits] r104550 - in /cfe/trunk: lib/Sema/SemaType.cpp test/SemaCXX/c99-variable-length-array.cpp

Douglas Gregor dgregor at apple.com
Mon May 24 13:42:30 PDT 2010


Author: dgregor
Date: Mon May 24 15:42:30 2010
New Revision: 104550

URL: http://llvm.org/viewvc/llvm-project?rev=104550&view=rev
Log:
Don't complain about VLAs of non-POD types when the array type is
dependent. Fixes <rdar://problem/8021385>.

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=104550&r1=104549&r2=104550&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 24 15:42:30 2010
@@ -711,7 +711,8 @@
   if (!getLangOptions().C99) {
     if (T->isVariableArrayType()) {
       // Prohibit the use of non-POD types in VLAs.
-      if (!Context.getBaseElementType(T)->isPODType()) {
+      if (!T->isDependentType() && 
+          !Context.getBaseElementType(T)->isPODType()) {
         Diag(Loc, diag::err_vla_non_pod)
           << Context.getBaseElementType(T);
         return QualType();

Modified: cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp?rev=104550&r1=104549&r2=104550&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp (original)
+++ cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp Mon May 24 15:42:30 2010
@@ -100,3 +100,17 @@
 
   template void f<int>(int); // expected-note{{instantiation of}}
 }
+
+namespace rdar8021385 {
+  typedef int my_int;
+  struct A { typedef int my_int; };
+  template<typename T>
+  struct B {
+    typedef typename T::my_int my_int;
+    void f0() {
+      int M = 4;
+      my_int a[M]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+    }
+  };
+  B<A> a;
+}





More information about the cfe-commits mailing list