[PATCH] PR13236 - Microsoft compatibility: support __super specifier to access members of base classes

Nikola Smiljanic popizdeh at gmail.com
Mon Jul 14 16:57:19 PDT 2014


On Tue, Jul 15, 2014 at 9:27 AM, Reid Kleckner <rnk at google.com> wrote:

> I think their documentation is trying to warn the user that it won't work
> if you use it in a class template.
>

I find you interpretation a bit of a stretch :) To me it means exactly what
it says even though they don't implement it that way. Note that Aarons
example with dependent base does work so this seems to break only if the
base class is a template parameter.

template <typename T>
struct Base {
  void foo();
};

template <typename T>
struct Derived : Base<T> {
  void bar() {
    __super::foo();
  }
};

I was also trying to figure out what you meant by "instantiate a template
with a non-type template parameter using __super" and came up with this
insanity:

struct Base {
  enum Enumerator {
    One, Two
  };

  template <Enumerator e>
  struct Inner {};
};

struct Derived : Base
{
  Inner<__super::One> x;
  __super::Inner<Two> y;
};

First member declaration is ok but not the second one. It does work if you
replace __super with Base. I can't say I understand their rules and that's
why I suggested implementing __super only inside member functions as their
documentation suggests.

I think we need to do some overload resolution.  MSVC resolves __super to B
> in this case:
> struct A { void foo(int); };
> struct B { void foo(short); };
> struct C : A, B {
>   void foo(short x) {
>     __super::foo(x);
>   }
> };
>
> And they error out if you s/short/int/.
>

No surprises here, besides that I don't know how to exactly do this.
Hopefully Richard will point me in the right direction. I had a look at
OverloadCandidateSet and Sema::addOverloadCandidate but I couldn't figure
out where to get argument expressions from.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140715/9276d4e7/attachment.html>


More information about the cfe-commits mailing list