]> granicus.if.org Git - clang/commitdiff
Type of a ?: expression whose either expression is a built-in 'id'
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 22 Aug 2009 22:27:17 +0000 (22:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 22 Aug 2009 22:27:17 +0000 (22:27 +0000)
type is 'id' type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79781 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjC/conditional-expr-5.m [new file with mode: 0644]

index 15a3e40e3f277420b2ab148d88a1f7491038ef76..f9ec6afc28d916105fd8dacc08e6db5d34f73e9e 100644 (file)
@@ -3213,9 +3213,9 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
     // FIXME: Consider unifying with 'areComparableObjCPointerTypes'.
     // It could return the composite type.
     if (Context.canAssignObjCInterfaces(LHSOPT, RHSOPT)) {
-      compositeType = LHSTy;
+      compositeType = RHSOPT->isObjCBuiltinType() ? RHSTy : LHSTy;
     } else if (Context.canAssignObjCInterfaces(RHSOPT, LHSOPT)) {
-      compositeType = RHSTy;
+      compositeType = LHSOPT->isObjCBuiltinType() ? LHSTy : RHSTy;
     } else if ((LHSTy->isObjCQualifiedIdType() || 
                 RHSTy->isObjCQualifiedIdType()) &&
                 Context.ObjCQualifiedIdTypesAreCompatible(LHSTy, RHSTy, true)) {
diff --git a/test/SemaObjC/conditional-expr-5.m b/test/SemaObjC/conditional-expr-5.m
new file mode 100644 (file)
index 0000000..d9c1a94
--- /dev/null
@@ -0,0 +1,27 @@
+// RUN: clang-cc  -fsyntax-only -verify %s
+
+@interface PBXBuildSettingsDictionary
+{
+  int i;
+}
+@end
+
+@interface XCConditionalBuildSettingsDictionary : PBXBuildSettingsDictionary
+{
+}
+@end
+
+@implementation PBXBuildSettingsDictionary
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet
+{
+  return i ? self : (id)0;
+}
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet2
+{
+  return i ? (id)0 : self;
+}
+@end
+
+