[cfe-commits] r43994 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/check-increment.c

Steve Naroff snaroff at apple.com
Sun Nov 11 06:15:58 PST 2007


Author: snaroff
Date: Sun Nov 11 08:15:57 2007
New Revision: 43994

URL: http://llvm.org/viewvc/llvm-project?rev=43994&view=rev
Log:

Make sure Sema::CheckIncrementDecrementOperand() removes typedefs when doing it's analysis.

Thanks to Seo Sanghyeon for his excellent (first) bug fix!

Added:
    cfe/trunk/test/Sema/check-increment.c
Modified:
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43994&r1=43993&r2=43994&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sun Nov 11 08:15:57 2007
@@ -1414,7 +1414,7 @@
   assert(!resType.isNull() && "no type for increment/decrement expression");
 
   // C99 6.5.2.4p1: We allow complex as a GCC extension.
-  if (const PointerType *pt = dyn_cast<PointerType>(resType)) {
+  if (const PointerType *pt = resType->getAsPointerType()) {
     if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
       Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
            resType.getAsString(), op->getSourceRange());

Added: cfe/trunk/test/Sema/check-increment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/check-increment.c?rev=43994&view=auto

==============================================================================
--- cfe/trunk/test/Sema/check-increment.c (added)
+++ cfe/trunk/test/Sema/check-increment.c Sun Nov 11 08:15:57 2007
@@ -0,0 +1,10 @@
+// RUN: clang -fsyntax-only -verify %s
+
+#include <stdio.h>
+typedef int *pint;
+int main() {
+   int a[5] = {0};
+   pint p = a;
+   p++;
+   printf("%d\n", *p);
+}





More information about the cfe-commits mailing list