[cfe-commits] r104461 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaCXX/c99-variable-length-array.cpp

Douglas Gregor dgregor at apple.com
Sun May 23 09:10:32 PDT 2010


Author: dgregor
Date: Sun May 23 11:10:32 2010
New Revision: 104461

URL: http://llvm.org/viewvc/llvm-project?rev=104461&view=rev
Log:
Even though we don't unique VLA types, we still need to build a
canonical type where the element type is canonical. Fixes PR7206.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=104461&r1=104460&r2=104461&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun May 23 11:10:32 2010
@@ -1356,9 +1356,17 @@
                                           SourceRange Brackets) {
   // Since we don't unique expressions, it isn't possible to unique VLA's
   // that have an expression provided for their size.
-
+  QualType CanonType;
+  
+  if (!EltTy.isCanonical()) {
+    if (NumElts)
+      NumElts->Retain();
+    CanonType = getVariableArrayType(getCanonicalType(EltTy), NumElts, ASM,
+                                     EltTypeQuals, Brackets);
+  }
+  
   VariableArrayType *New = new(*this, TypeAlignment)
-    VariableArrayType(EltTy, QualType(), NumElts, ASM, EltTypeQuals, Brackets);
+    VariableArrayType(EltTy, CanonType, NumElts, ASM, EltTypeQuals, Brackets);
 
   VariableArrayTypes.push_back(New);
   Types.push_back(New);

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=104461&r1=104460&r2=104461&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp (original)
+++ cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp Sun May 23 11:10:32 2010
@@ -78,3 +78,13 @@
     int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}}
   };
 }
+
+namespace PR7206 {
+  void f(int x) {
+    struct edge_info {
+      float left;
+      float right;
+    };
+    struct edge_info edgeInfo[x];
+  }
+}





More information about the cfe-commits mailing list