Handle the GNU void* and function pointer arithmetic extensions for constant expressions as well.
llvm-svn: 65013
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d573236..da251fc 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -292,7 +292,13 @@
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();