Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue Jun 29, 2012 · 6 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@llvmbot
Copy link
Member

llvmbot commented Jun 29, 2012

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).

@llvmbot
Copy link
Member Author

llvmbot commented Jun 29, 2012

Initial implementation: avakar/clang@__super

@llvmbot
Copy link
Member Author

llvmbot commented Jun 29, 2012

Also note that the nested-name-specified may not precede __super.

struct A { void foo(); };
struct B: A {
    void test() {
        __super::foo();     // OK
        B::__super::foo();  // error: illegal token on right side of '::'
    }
};

@llvmbot
Copy link
Member Author

llvmbot commented Nov 20, 2013

If initial implementation below works, any possibility of it being merged into trunk?
Currently this is a blocker for me using Clang-modernize on my MS VC++ codebase.

@llvmbot
Copy link
Member Author

llvmbot commented Dec 11, 2013

I would also greatly appreciate if the __super extension was supported. I am trying to compile code that makes extensive use of this extension.

@llvmbot
Copy link
Member Author

llvmbot commented Sep 26, 2014

Fixed in r218484.

@tritao
Copy link
Mannequin

tritao mannequin commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#13707

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

1 participant