[cfe-commits] r51907 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/gcc-cast-ext.m
Steve Naroff
snaroff at apple.com
Tue Jun 3 10:15:30 PDT 2008
Author: snaroff
Date: Tue Jun 3 12:15:29 2008
New Revision: 51907
URL: http://llvm.org/viewvc/llvm-project?rev=51907&view=rev
Log:
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
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/gcc-cast-ext.m
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=51907&r1=51906&r2=51907&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Jun 3 12:15:29 2008
@@ -918,6 +918,11 @@
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;
}
Modified: cfe/trunk/test/Sema/gcc-cast-ext.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/gcc-cast-ext.m?rev=51907&r1=51906&r2=51907&view=diff
==============================================================================
--- cfe/trunk/test/Sema/gcc-cast-ext.m (original)
+++ cfe/trunk/test/Sema/gcc-cast-ext.m Tue Jun 3 12:15:29 2008
@@ -8,6 +8,12 @@
+ 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
More information about the cfe-commits
mailing list