[cfe-commits] r108333 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/method-sentinel-attr.m

Fariborz Jahanian fjahanian at apple.com
Wed Jul 14 09:37:51 PDT 2010


Author: fjahanian
Date: Wed Jul 14 11:37:51 2010
New Revision: 108333

URL: http://llvm.org/viewvc/llvm-project?rev=108333&view=rev
Log:
Consider obective-c pointer arguments as valid sentinel args
as well. Fixes radar 7975788.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaObjC/method-sentinel-attr.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=108333&r1=108332&r2=108333&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jul 14 11:37:51 2010
@@ -164,7 +164,7 @@
   if (!sentinelExpr) return;
   if (sentinelExpr->isTypeDependent()) return;
   if (sentinelExpr->isValueDependent()) return;
-  if (sentinelExpr->getType()->isPointerType() &&
+  if (sentinelExpr->getType()->isAnyPointerType() &&
       sentinelExpr->IgnoreParenCasts()->isNullPointerConstant(Context,
                                             Expr::NPC_ValueDependentIsNull))
     return;

Modified: cfe/trunk/test/SemaObjC/method-sentinel-attr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-sentinel-attr.m?rev=108333&r1=108332&r2=108333&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-sentinel-attr.m (original)
+++ cfe/trunk/test/SemaObjC/method-sentinel-attr.m Wed Jul 14 11:37:51 2010
@@ -15,6 +15,12 @@
 - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1)));
 - (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3)));  // expected-error {{attribute requires 0, 1 or 2 argument(s)}}
 - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
+
+// rdar:// 7975788
+- (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo14 : (id)firstObj :  (Class)secondObj, ... __attribute__((sentinel(0,1)));
+- (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1)));
 @end
 
 int main ()
@@ -33,5 +39,11 @@
   [p foo7:1, NULL]; // ok
 
   [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}}
+
+  // rdar:// 7975788
+  [ p foo13 : NULL]; 
+  [ p foo14 : 0 : NULL]; 
+  [ p foo16 : NULL]; 
+  [ p foo15 : NULL];
 }
  





More information about the cfe-commits mailing list