[llvm-branch-commits] [cfe-branch] r71663 - in /cfe/branches/Apple/Dib: lib/AST/ASTContext.cpp test/Sema/types.c

Mike Stump mrs at apple.com
Wed May 13 08:26:33 PDT 2009


Author: mrs
Date: Wed May 13 10:26:30 2009
New Revision: 71663

URL: http://llvm.org/viewvc/llvm-project?rev=71663&view=rev
Log:
Merge in 71634:

Fix rdar://6880874 - [sema] crash on array types with different index sizes

Modified:
    cfe/branches/Apple/Dib/lib/AST/ASTContext.cpp
    cfe/branches/Apple/Dib/test/Sema/types.c

Modified: cfe/branches/Apple/Dib/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/AST/ASTContext.cpp?rev=71663&r1=71662&r2=71663&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/Apple/Dib/lib/AST/ASTContext.cpp Wed May 13 10:26:30 2009
@@ -1097,9 +1097,14 @@
 /// getConstantArrayType - Return the unique reference to the type for an 
 /// array of the specified element type.
 QualType ASTContext::getConstantArrayType(QualType EltTy, 
-                                          const llvm::APInt &ArySize,
+                                          const llvm::APInt &ArySizeIn,
                                           ArrayType::ArraySizeModifier ASM,
                                           unsigned EltTypeQuals) {
+  // Convert the array size into a canonical width matching the pointer size for
+  // the target.
+  llvm::APInt ArySize(ArySizeIn);
+  ArySize.zextOrTrunc(Target.getPointerWidth(EltTy.getAddressSpace()));
+  
   llvm::FoldingSetNodeID ID;
   ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, EltTypeQuals);
       

Modified: cfe/branches/Apple/Dib/test/Sema/types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Sema/types.c?rev=71663&r1=71662&r2=71663&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Sema/types.c (original)
+++ cfe/branches/Apple/Dib/test/Sema/types.c Wed May 13 10:26:30 2009
@@ -19,3 +19,14 @@
   int __int128_t;
   int __uint128_t;
 }
+
+
+// Array type merging should convert array size to whatever matches the target
+// pointer size.
+// rdar://6880874
+extern int i[1LL];
+int i[(short)1];
+
+enum e { e_1 };
+extern int j[sizeof(enum e)];  // expected-note {{previous definition}}
+int j[42];   // expected-error {{redefinition of 'j' with a different type}}





More information about the llvm-branch-commits mailing list