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:
Chris Lattner 2011-07-22 06:27:26 +00:00
parent 43cae02689
commit e135b089d8
2 changed files with 14 additions and 0 deletions

View File

@ -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;
}

View File

@ -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; }
}