On May 16, 2013, at 5:11 PM, jahanian <[email protected]> wrote:
> Attached patch fixes a sema crash when gnu’s ?: extension is used for 
> Objective-C++’s dictionary subscripting.
> This is done by essentially allowing application of unary conversion on the 
> common expression when
> its type is pseudo-object type. (common expression is ObjCSubscriptRefExpr 
> with the
> pseudo-object type which is not suitable for the lhs expression of the 
> conditional).
> Please review. This is for // rdar://13749180

This is the right way to fix this, but (1) go ahead and filter out all the
placeholder types instead of just pseudo-objects, and (2) please do
that before this check so that we can do the right thing for getters
of reference type.

That is, do this:
  // Lower out placeholder types first.  This is important so that we don't
  // try to capture a placeholder, and it also lets us do the right thing in
  // a few cases in C++.
  // the placeholder happens
  if (commonExpr->hasPlaceholderType()) {
    ExprResult result = CheckPlaceholderExpr(commonExpr);
    if (!result.isUsable()) return ExprError();
    commonExpr = result.take();
  }

This should make us do the right thing with overloaded function
references;  here's a test case for that:

  template <class T, class U = T> T foo(U x) { return x; }
  ...
  int (*fn)(int) = (&foo<int> ?: 0);

(this might not be *useful*, but it should *work*)

And here's an ObjC++ test case for a reference-valued property:
  @interface A
  - (int &) foo;
  @end
  ...
  void test(A *a) {
    int x = 0;
    int &y = a.foo ?: x;
  }

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to