forked from OSchip/llvm-project
Fix rdar://6880874 - [sema] crash on array types with different index sizes
llvm-svn: 71634
This commit is contained in:
parent
851eb927d7
commit
e2df3f9fe5
|
@ -1133,9 +1133,14 @@ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls)
|
|||
/// 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);
|
||||
|
||||
|
|
|
@ -19,3 +19,14 @@ int b() {
|
|||
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}}
|
||||
|
|
Loading…
Reference in New Issue