From: Steve Naroff Date: Sun, 11 Nov 2007 14:15:57 +0000 (+0000) Subject: Make sure Sema::CheckIncrementDecrementOperand() removes typedefs when doing it's... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d848a3867794f4a9297bced70178834936e59d3d;p=clang Make sure Sema::CheckIncrementDecrementOperand() removes typedefs when doing it's analysis. Thanks to Seo Sanghyeon for his excellent (first) bug fix! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43994 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index bd210c3adf..31c09be7cb 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -1414,7 +1414,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) { 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(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()); diff --git a/test/Sema/check-increment.c b/test/Sema/check-increment.c new file mode 100644 index 0000000000..4447feb0b8 --- /dev/null +++ b/test/Sema/check-increment.c @@ -0,0 +1,10 @@ +// RUN: clang -fsyntax-only -verify %s + +#include +typedef int *pint; +int main() { + int a[5] = {0}; + pint p = a; + p++; + printf("%d\n", *p); +}