From: Chris Lattner Date: Sun, 26 Aug 2007 05:02:07 +0000 (+0000) Subject: int X[] isn't a VLA. This improves support for stdio.h on darwin. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78e30fb5d9b8cb39af8214935e1afeeea259cf76;p=clang int X[] isn't a VLA. This improves support for stdio.h on darwin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41423 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index 9fb1568a03..8543cbd1d7 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -90,8 +90,10 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) { "FIXME: We only handle trivial array types so far!"); llvm::APSInt Size(32); - if (A.getSizeExpr() && - A.getSizeExpr()->isIntegerConstantExpr(Size, Context)) { + if (A.getSizeExpr() == 0) { + // int X[] -> [0 x int] + return llvm::ArrayType::get(ConvertType(A.getElementType()), 0); + } else if (A.getSizeExpr()->isIntegerConstantExpr(Size, Context)) { const llvm::Type *EltTy = ConvertType(A.getElementType()); return llvm::ArrayType::get(EltTy, Size.getZExtValue()); } else {