aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp5
-rw-r--r--test/Sema/gcc-cast-ext.m6
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