From: Daniel Dunbar Date: Tue, 22 Jul 2008 01:35:47 +0000 (+0000) Subject: Prevent codegen crash on sizeof(), a gcc extension. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9140845f95d7dedd410d93c3390dd00104c76b0a;p=clang Prevent codegen crash on sizeof(), a gcc extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53899 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 5a4236a42c..092513670e 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -660,8 +660,9 @@ Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize, uint32_t ResultWidth = static_cast(CGF.getContext().getTypeSize(RetType)); - // sizeof(void) and __alignof__(void) = 1 as a gcc extension. - if (TypeToSize->isVoidType()) + // sizeof(void) and __alignof__(void) = 1 as a gcc extension. Also + // for function types. + if (TypeToSize->isVoidType() || TypeToSize->isFunctionType()) return llvm::ConstantInt::get(llvm::APInt(ResultWidth, 1)); /// FIXME: This doesn't handle VLAs yet!