Prevent codegen crash on sizeof(<function type>), a gcc extension.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53899 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2008-07-22 01:35:47 +00:00
Родитель 0c980d1997
Коммит 9140845f95
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -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!