diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-05-31 22:33:45 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-05-31 22:33:45 +0000 |
| commit | 524011f389e753d67eea871e0dd2c23dfc366f2c (patch) | |
| tree | 34a27c1aa0d5879bc175f7484aa1c3e5528aa342 /clang | |
| parent | d3f3231a072c67989d6bd1aeeafa12636098ebd1 (diff) | |
| download | bcm5719-llvm-524011f389e753d67eea871e0dd2c23dfc366f2c.tar.gz bcm5719-llvm-524011f389e753d67eea871e0dd2c23dfc366f2c.zip | |
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 *')
llvm-svn: 51828
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 8 | ||||
| -rw-r--r-- | clang/test/Sema/conditional-expr.m | 21 |
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 500d5b7786e..f75c3924a00 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -972,7 +972,13 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 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(), diff --git a/clang/test/Sema/conditional-expr.m b/clang/test/Sema/conditional-expr.m new file mode 100644 index 00000000000..d2620416fd3 --- /dev/null +++ b/clang/test/Sema/conditional-expr.m @@ -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 |

