]> granicus.if.org Git - clang/commitdiff
Prevent codegen crash on sizeof(<function type>), a gcc extension.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 22 Jul 2008 01:35:47 +0000 (01:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 22 Jul 2008 01:35:47 +0000 (01:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53899 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp

index 5a4236a42c58e4c1b266b56768fad4cbdfcbb3fe..092513670ea286ecdcc39a68781f6a4a0d28ffbc 100644 (file)
@@ -660,8 +660,9 @@ Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize,
   uint32_t ResultWidth = 
     static_cast<uint32_t>(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!