From 78e30fb5d9b8cb39af8214935e1afeeea259cf76 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 26 Aug 2007 05:02:07 +0000 Subject: [PATCH] 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 --- CodeGen/CodeGenTypes.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 { -- 2.40.0