diff options
author | Anders Carlsson <andersca@mac.com> | 2008-02-18 07:10:45 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-02-18 07:10:45 +0000 |
commit | 64a31ef8d46fcdf2bca38098e3206a45052b515d (patch) | |
tree | 0d295f042fe57a2a28ca08166a5782fff8d66add | |
parent | b7894b57a1739ee099053c2e3cd6040bee07ab0c (diff) |
Fix bug where we would report the wrong value for __alignof__ with an expr that is not a type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47259 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/Expr.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/AST/Expr.cpp b/AST/Expr.cpp index 0410e284a7..720b490d24 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -736,15 +736,16 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, 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(), - Exp->getOperatorLoc()); } else { unsigned CharSize = Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc())); - Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(), - Exp->getOperatorLoc()) / CharSize; + if (Exp->getOpcode() == UnaryOperator::AlignOf) + Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(), + Exp->getOperatorLoc()) / CharSize; + else + Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(), + Exp->getOperatorLoc()) / CharSize; } break; case UnaryOperator::LNot: { |