Skip to content

Microsoft compatibility: support __super specifier to access members of base classes #13608

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 13236
Resolution FIXED
Resolved on Sep 25, 2014 19:33
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#13707
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

Official docs: http://msdn.microsoft.com/en-us/library/94dw1w7x%28v=vs.80%29.aspx

Unofficially, the grammar seems to be

qualified-id:
  '__super' '::' unqualified-id

__super can't be chained (i.e. __super::__super is invalid).

__super is only valid in member function scope (in particular, the following is invalid:

struct A { typedef int t; };
struct B: A {
    typedef __super::t u; // error
}

).

The unqualified-id is looked up in all the base classes and the results are merged.

struct A { void foo(long); };
struct B { void foo(int); };
struct C: A, B { 
    void test() {
        __super::foo(1); // OK: calls B::foo
    }
};

The result may name a type-name.

struct A { typedef int t; };
struct B: A {
    typedef long t;
    void test() {
        __super::t v; // OK: the type of 'v' is 'int'
    }
};

__super is enabled only when compiling without /Za (disable language extensions).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions