[cfe-commits] r51828 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/conditional-expr.m

Steve Naroff snaroff at apple.com
Sat May 31 15:33:45 PDT 2008


Author: snaroff
Date: Sat May 31 17:33:45 2008
New Revision: 51828

URL: http://llvm.org/viewvc/llvm-project?rev=51828&view=rev
Log:
Teach Sema::CheckConditionalOperands() to check for ObjCQualifiedIdType's. This fixes a bogus error.

<rdar://problem/5967036> clang on xcode: error: incompatible operand types ('id<DTOutputStreams>' and 'DTFilterOutputStream *')

Added:
    cfe/trunk/test/Sema/conditional-expr.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=51828&r1=51827&r2=51828&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat May 31 17:33:45 2008
@@ -972,7 +972,13 @@
       return compositeType;
     }
   }
-  
+  // Need to handle "id<xx>" explicitly. Unlike "id", whose canonical type
+  // evaluates to "struct objc_object *" (and is handled above when comparing
+  // id with statically typed objects). FIXME: Do we need an ImpCastExprToType?
+  if (lexT->isObjCQualifiedIdType() || rexT->isObjCQualifiedIdType()) {
+    if (ObjCQualifiedIdTypesAreCompatible(lexT, rexT, true))
+      return Context.getObjCIdType();
+  }
   // Otherwise, the operands are not compatible.
   Diag(questionLoc, diag::err_typecheck_cond_incompatible_operands,
        lexT.getAsString(), rexT.getAsString(),

Added: cfe/trunk/test/Sema/conditional-expr.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conditional-expr.m?rev=51828&view=auto

==============================================================================
--- cfe/trunk/test/Sema/conditional-expr.m (added)
+++ cfe/trunk/test/Sema/conditional-expr.m Sat May 31 17:33:45 2008
@@ -0,0 +1,21 @@
+// RUN: clang -fsyntax-only -verify -pedantic %s
+ at protocol NSObject
+ at end
+
+ at protocol DTOutputStreams <NSObject>
+ at end
+
+ at interface DTFilterOutputStream <DTOutputStreams>
+- nextOutputStream;
+ at end
+
+ at implementation DTFilterOutputStream
+- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
+  id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
+  self = nextOutputStream;
+  return nextOutputStream ? nextOutputStream : self;
+}
+- nextOutputStream {
+  return self;
+}
+ at end





More information about the cfe-commits mailing list