[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    [cfe-commits] r51828 - in /cfe/trunk: lib/Sema/SemaExpr.cpp
From:       Steve Naroff <snaroff () apple ! com>
Date:       2008-05-31 22:33:45
Message-ID: 200805312233.m4VMXj86023110 () zion ! cs ! uiuc ! edu
[Download RAW message or body]

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
+@protocol NSObject
+@end
+
+@protocol DTOutputStreams <NSObject>
+@end
+
+@interface DTFilterOutputStream <DTOutputStreams>
+- nextOutputStream;
+@end
+
+@implementation DTFilterOutputStream
+- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
+  id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
+  self = nextOutputStream;
+  return nextOutputStream ? nextOutputStream : self;
+}
+- nextOutputStream {
+  return self;
+}
+@end


_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic