Thanks! Can you also make sure the test case checks that the computed value matches what is expected?
- Daniel On Wed, Feb 18, 2009 at 8:55 PM, Anders Carlsson <[email protected]> wrote: > Author: andersca > Date: Wed Feb 18 22:55:58 2009 > New Revision: 65013 > > URL: http://llvm.org/viewvc/llvm-project?rev=65013&view=rev > Log: > Handle the GNU void* and function pointer arithmetic extensions for constant > expressions as well. > > Modified: > cfe/trunk/lib/AST/ExprConstant.cpp > cfe/trunk/test/Sema/const-eval.c > > Modified: cfe/trunk/lib/AST/ExprConstant.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=65013&r1=65012&r2=65013&view=diff > > ============================================================================== > --- cfe/trunk/lib/AST/ExprConstant.cpp (original) > +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 18 22:55:58 2009 > @@ -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(); > > > Modified: cfe/trunk/test/Sema/const-eval.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=65013&r1=65012&r2=65013&view=diff > > ============================================================================== > --- cfe/trunk/test/Sema/const-eval.c (original) > +++ cfe/trunk/test/Sema/const-eval.c Wed Feb 18 22:55:58 2009 > @@ -32,3 +32,5 @@ > > // ?: in constant expressions. > int g17[(3?:1) - 2]; > + > +EVAL_EXPR(18, (int)((void*)10 + 10)); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
