summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d573236783e..da251fcea9a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -292,7 +292,13 @@ APValue PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return APValue();
QualType PointeeType = PExp->getType()->getAsPointerType()->getPointeeType();
- uint64_t SizeOfPointee = Info.Ctx.getTypeSize(PointeeType) / 8;
+ uint64_t SizeOfPointee;
+
+ // Explicitly handle GNU void* and function pointer arithmetic extensions.
+ if (PointeeType->isVoidType() || PointeeType->isFunctionType())
+ SizeOfPointee = 1;
+ else
+ SizeOfPointee = Info.Ctx.getTypeSize(PointeeType) / 8;
uint64_t Offset = ResultLValue.getLValueOffset();
OpenPOWER on IntegriCloud