Perform placeholder conversions on the controller of a _Generic
authorJohn McCall <rjmccall@apple.com>
Tue, 12 Feb 2013 02:08:12 +0000 (02:08 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 12 Feb 2013 02:08:12 +0000 (02:08 +0000)
expression.

llvm-svn: 174930

clang/lib/Sema/SemaExpr.cpp
clang/test/SemaObjC/generic-selection.m [new file with mode: 0644]

index 689c149..f6c6fe1 100644 (file)
@@ -1173,6 +1173,12 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
                                  TypeSourceInfo **Types,
                                  Expr **Exprs,
                                  unsigned NumAssocs) {
+  if (ControllingExpr->getType()->isPlaceholderType()) {
+    ExprResult result = CheckPlaceholderExpr(ControllingExpr);
+    if (result.isInvalid()) return ExprError();
+    ControllingExpr = result.take();
+  }
+
   bool TypeErrorFound = false,
        IsResultDependent = ControllingExpr->isTypeDependent(),
        ContainsUnexpandedParameterPack
diff --git a/clang/test/SemaObjC/generic-selection.m b/clang/test/SemaObjC/generic-selection.m
new file mode 100644 (file)
index 0000000..70c77dc
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+__attribute__((objc_root_class))
+@interface Root {
+  Class isa;
+}
+@end
+
+@interface A
+@property (strong) id x;
+@end
+
+// rdar://13193560
+void test0(A *a) {
+  int kind = _Generic(a.x, id : 0, int : 1, float : 2);
+}