From f1ac6d3a6b43d81a9b3927061e4a71b789d065bf Mon Sep 17 00:00:00 2001 From: Nikola Smiljanic Date: Mon, 29 Sep 2014 01:11:55 +0000 Subject: [PATCH] Add the tests for __super that I forgot to commit in as part of r218484. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218587 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/SemaCXX/MicrosoftSuper.cpp | 147 ++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test/SemaCXX/MicrosoftSuper.cpp diff --git a/test/SemaCXX/MicrosoftSuper.cpp b/test/SemaCXX/MicrosoftSuper.cpp new file mode 100644 index 0000000000..1bf97ac5e0 --- /dev/null +++ b/test/SemaCXX/MicrosoftSuper.cpp @@ -0,0 +1,147 @@ +// RUN: %clang_cc1 %s -fsyntax-only -fms-extensions -std=c++11 -verify + +struct Errors { + using __super::foo; // expected-error {{'__super' cannot be used with a using declaration}} + __super::XXX x; // expected-error {{invalid use of '__super', Errors has no base classes}} expected-error {{expected}} + + void foo() { + // expected-note@+4 {{replace parentheses with an initializer to declare a variable}} + // expected-warning@+3 {{empty parentheses interpreted as a function declaration}} + // expected-error@+2 {{C++ requires a type specifier for all declarations}} + // expected-error@+1 {{use of '__super' inside a lambda is unsupported}} + auto lambda = []{ __super::foo(); }; + } +}; + +struct Base1 { + void foo(int) {} + + static void static_foo() {} + + typedef int XXX; +}; + +struct Derived : Base1 { + __super::XXX x; + typedef __super::XXX Type; + + enum E { + X = sizeof(__super::XXX) + }; + + void foo(int i) { + __super::foo(i); + + if (i == 0) { + __super::foo(i); + } + } + + static void bar() { + __super::static_foo(); + } +}; + +struct Outer { + struct Inner : Base1 { + static const int x = sizeof(__super::XXX); + }; +}; + +struct Base2 { + void foo(char) {} +}; + +struct MemberFunctionInMultipleBases : Base1, Base2 { + void foo() { + __super::foo('x'); + } +}; + +struct Base3 { + void foo(int) {} + void foo(char) {} +}; + +struct OverloadedMemberFunction : Base3 { + void foo() { + __super::foo('x'); + } +}; + +struct PointerToMember : Base1 { + template + struct Wrapper { + static void bar() {} + }; + + void baz(); +}; + +void PointerToMember::baz() { + Wrapper<&__super::foo>::bar(); +} + +template +struct BaseTemplate { + typedef int XXX; + + void foo() {} +}; + +struct DerivedFromKnownSpecialization : BaseTemplate { + __super::XXX a; + typedef __super::XXX b; + + void test() { + __super::XXX c; + typedef __super::XXX d; + + __super::foo(); + } +}; + +template +struct DerivedFromDependentBase : BaseTemplate { + typename __super::XXX a; + typedef typename __super::XXX b; + + __super::XXX c; // expected-error {{missing 'typename'}} + typedef __super::XXX d; // expected-error {{missing 'typename'}} + + void test() { + typename __super::XXX e; + typedef typename __super::XXX f; + + __super::XXX g; // expected-error {{missing 'typename'}} + typedef __super::XXX h; // expected-error {{missing 'typename'}} + + __super::foo(); + } +}; + +template +struct DerivedFromTemplateParameter : T { + typename __super::XXX a; + typedef typename __super::XXX b; + + __super::XXX c; // expected-error {{missing 'typename'}} + typedef __super::XXX d; // expected-error {{missing 'typename'}} + + void test() { + typename __super::XXX e; + typedef typename __super::XXX f; + + __super::XXX g; // expected-error {{missing 'typename'}} + typedef __super::XXX h; // expected-error {{missing 'typename'}} + + __super::foo(1); + } +}; + +void instantiate() { + DerivedFromDependentBase d; + d.test(); + DerivedFromTemplateParameter t; + t.test(); +} -- 2.40.0