diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 8 | ||||
-rw-r--r-- | clang/test/Sema/const-eval.c | 2 |
2 files changed, 9 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(); diff --git a/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index 7307aea791f..a56504151cb 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/test/Sema/const-eval.c @@ -32,3 +32,5 @@ _Complex float g16 = (1.0f + 1.0fi); // ?: in constant expressions. int g17[(3?:1) - 2]; + +EVAL_EXPR(18, (int)((void*)10 + 10)); |