forked from OSchip/llvm-project
Fix PR1895: a crash on an ugly gcc extension.
llvm-svn: 45505
This commit is contained in:
parent
266a2ff3ac
commit
7977cca8e8
|
@ -657,7 +657,10 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
|
||||||
Exp->getOperatorLoc())));
|
Exp->getOperatorLoc())));
|
||||||
|
|
||||||
// Get information about the size or align.
|
// Get information about the size or align.
|
||||||
if (Exp->getOpcode() == UnaryOperator::AlignOf) {
|
if (Exp->getSubExpr()->getType()->isFunctionType()) {
|
||||||
|
// GCC extension: sizeof(function) = 1.
|
||||||
|
Result = Exp->getOpcode() == UnaryOperator::AlignOf ? 4 : 1;
|
||||||
|
} else if (Exp->getOpcode() == UnaryOperator::AlignOf) {
|
||||||
Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(),
|
Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(),
|
||||||
Exp->getOperatorLoc());
|
Exp->getOperatorLoc());
|
||||||
} else {
|
} else {
|
||||||
|
@ -700,7 +703,10 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
|
||||||
static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())));
|
static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())));
|
||||||
|
|
||||||
// Get information about the size or align.
|
// Get information about the size or align.
|
||||||
if (Exp->isSizeOf()) {
|
if (Exp->getArgumentType()->isFunctionType()) {
|
||||||
|
// GCC extension: sizeof(function) = 1.
|
||||||
|
Result = Exp->isSizeOf() ? 1 : 4;
|
||||||
|
} else if (Exp->isSizeOf()) {
|
||||||
unsigned CharSize =
|
unsigned CharSize =
|
||||||
Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc()));
|
Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc()));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// RUN: clang %s -emit-llvm
|
||||||
|
|
||||||
|
// PR1895
|
||||||
|
// sizeof function
|
||||||
|
int zxcv(void);
|
||||||
|
int x=sizeof(zxcv);
|
||||||
|
int y=__alignof__(zxcv);
|
||||||
|
|
Loading…
Reference in New Issue