diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2008-07-22 01:35:47 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2008-07-22 01:35:47 +0000 |
| commit | ee8bbb3ccc671496ffa05fbc5784a887981b0463 (patch) | |
| tree | 4ea56cfb6724b71c2d14c5298a661da3cf507ce3 | |
| parent | cb13d705957a99145042ca2941019ceb4666c8d3 (diff) | |
| download | bcm5719-llvm-ee8bbb3ccc671496ffa05fbc5784a887981b0463.tar.gz bcm5719-llvm-ee8bbb3ccc671496ffa05fbc5784a887981b0463.zip | |
Prevent codegen crash on sizeof(<function type>), a gcc extension.
llvm-svn: 53899
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 5a4236a42c5..092513670ea 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -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! |

