fix PR10384: C++ allows external arrays of incomplete type as well.
Many thanks to Eli for reducing this great testcase. llvm-svn: 135752
This commit is contained in:
parent
43cae02689
commit
e135b089d8
|
@ -419,6 +419,14 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
|||
case Type::ConstantArray: {
|
||||
const ConstantArrayType *A = cast<ConstantArrayType>(Ty);
|
||||
llvm::Type *EltTy = ConvertTypeForMem(A->getElementType());
|
||||
|
||||
// Lower arrays of undefined struct type to arrays of i8 just to have a
|
||||
// concrete type.
|
||||
if (!EltTy->isSized()) {
|
||||
SkippedLayout = true;
|
||||
EltTy = llvm::Type::getInt8Ty(getLLVMContext());
|
||||
}
|
||||
|
||||
ResultType = llvm::ArrayType::get(EltTy, A->getSize().getZExtValue());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,3 +35,9 @@ namespace PR10395 {
|
|||
extern T x[];
|
||||
T* f() { return x; }
|
||||
}
|
||||
|
||||
namespace PR10384 {
|
||||
struct X;
|
||||
extern X x[1];
|
||||
X* f() { return x; }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue