diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-03 17:15:29 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-03 17:15:29 +0000 |
commit | a2ac06e9647bbac5e910201a570ed623e61b00e2 (patch) | |
tree | 92cefbd11079d8aa6176ffc8fe30eb7185c81da4 | |
parent | 20373221ce82022b7a0d31858af51bebf87e4af1 (diff) |
Change Expr::isIntegerConstantExpr() to allow for pointer types (for GCC compatibility). Note FIXME.
Fix <rdar://problem/5977870> clang on xcode: error: arrays with static storage duration must have constant integer length
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51907 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 5 | ||||
-rw-r--r-- | test/Sema/gcc-cast-ext.m | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 357d711978..a89fbd621a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -918,6 +918,11 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, if (!SubExpr->getType()->isArithmeticType() || !getType()->isIntegerType()) { if (Loc) *Loc = SubExpr->getLocStart(); + // GCC accepts pointers as an extension. + // FIXME: check getLangOptions().NoExtensions. At the moment, it doesn't + // appear possible to get langOptions() from the Expr. + if (SubExpr->getType()->isPointerType()) // && !NoExtensions + return true; return false; } diff --git a/test/Sema/gcc-cast-ext.m b/test/Sema/gcc-cast-ext.m index 5f6aa47128..866aee9069 100644 --- a/test/Sema/gcc-cast-ext.m +++ b/test/Sema/gcc-cast-ext.m @@ -8,6 +8,12 @@ typedef struct _NSRange { } NSRange; + alloc; - autorelease; @end + +// GCC allows pointer expressions in integer constant expressions. +struct { + char control[((int)(char *)2)]; +} xx; + @implementation PBXDocBookmark // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'autorelease' not found}} expected-warning {{method definition for 'alloc' not found}} + (id)bookmarkWithFileReference:(PBXFileReference *)fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor |