[cfe-commits] r65013 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c

Anders Carlsson andersca at mac.com
Wed Feb 18 20:55:58 PST 2009


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));





More information about the cfe-commits mailing list