| Nikola Smiljanic | 2f32527 | 2014-09-29 01:11:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -fms-extensions -std=c++11 -verify | 
|  | 2 |  | 
|  | 3 | struct Errors { | 
|  | 4 | using __super::foo; // expected-error {{'__super' cannot be used with a using declaration}} | 
|  | 5 | __super::XXX x; // expected-error {{invalid use of '__super', Errors has no base classes}} expected-error {{expected}} | 
|  | 6 |  | 
|  | 7 | void foo() { | 
|  | 8 | // expected-note@+4 {{replace parentheses with an initializer to declare a variable}} | 
|  | 9 | // expected-warning@+3 {{empty parentheses interpreted as a function declaration}} | 
|  | 10 | // expected-error@+2 {{C++ requires a type specifier for all declarations}} | 
|  | 11 | // expected-error@+1 {{use of '__super' inside a lambda is unsupported}} | 
|  | 12 | auto lambda = []{ __super::foo(); }; | 
|  | 13 | } | 
|  | 14 | }; | 
|  | 15 |  | 
|  | 16 | struct Base1 { | 
|  | 17 | void foo(int) {} | 
|  | 18 |  | 
|  | 19 | static void static_foo() {} | 
|  | 20 |  | 
|  | 21 | typedef int XXX; | 
|  | 22 | }; | 
|  | 23 |  | 
|  | 24 | struct Derived : Base1 { | 
|  | 25 | __super::XXX x; | 
|  | 26 | typedef __super::XXX Type; | 
|  | 27 |  | 
|  | 28 | enum E { | 
|  | 29 | X = sizeof(__super::XXX) | 
|  | 30 | }; | 
|  | 31 |  | 
| Nikola Smiljanic | 905bfda | 2014-10-04 10:17:57 +0000 | [diff] [blame^] | 32 | void foo() { | 
|  | 33 | __super::foo(1); | 
| Nikola Smiljanic | 2f32527 | 2014-09-29 01:11:55 +0000 | [diff] [blame] | 34 |  | 
| Nikola Smiljanic | 905bfda | 2014-10-04 10:17:57 +0000 | [diff] [blame^] | 35 | if (true) { | 
|  | 36 | __super::foo(1); | 
| Nikola Smiljanic | 2f32527 | 2014-09-29 01:11:55 +0000 | [diff] [blame] | 37 | } | 
| Nikola Smiljanic | 905bfda | 2014-10-04 10:17:57 +0000 | [diff] [blame^] | 38 |  | 
|  | 39 | return __super::foo(1); | 
| Nikola Smiljanic | 2f32527 | 2014-09-29 01:11:55 +0000 | [diff] [blame] | 40 | } | 
|  | 41 |  | 
|  | 42 | static void bar() { | 
|  | 43 | __super::static_foo(); | 
|  | 44 | } | 
|  | 45 | }; | 
|  | 46 |  | 
|  | 47 | struct Outer { | 
|  | 48 | struct Inner : Base1 { | 
|  | 49 | static const int x = sizeof(__super::XXX); | 
|  | 50 | }; | 
|  | 51 | }; | 
|  | 52 |  | 
|  | 53 | struct Base2 { | 
|  | 54 | void foo(char) {} | 
|  | 55 | }; | 
|  | 56 |  | 
|  | 57 | struct MemberFunctionInMultipleBases : Base1, Base2 { | 
|  | 58 | void foo() { | 
|  | 59 | __super::foo('x'); | 
|  | 60 | } | 
|  | 61 | }; | 
|  | 62 |  | 
|  | 63 | struct Base3 { | 
|  | 64 | void foo(int) {} | 
|  | 65 | void foo(char) {} | 
|  | 66 | }; | 
|  | 67 |  | 
|  | 68 | struct OverloadedMemberFunction : Base3 { | 
|  | 69 | void foo() { | 
|  | 70 | __super::foo('x'); | 
|  | 71 | } | 
|  | 72 | }; | 
|  | 73 |  | 
|  | 74 | struct PointerToMember : Base1 { | 
|  | 75 | template <void (Base1::*MP)(int)> | 
|  | 76 | struct Wrapper { | 
|  | 77 | static void bar() {} | 
|  | 78 | }; | 
|  | 79 |  | 
|  | 80 | void baz(); | 
|  | 81 | }; | 
|  | 82 |  | 
|  | 83 | void PointerToMember::baz() { | 
|  | 84 | Wrapper<&__super::foo>::bar(); | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | template <typename T> | 
|  | 88 | struct BaseTemplate { | 
|  | 89 | typedef int XXX; | 
|  | 90 |  | 
|  | 91 | void foo() {} | 
|  | 92 | }; | 
|  | 93 |  | 
|  | 94 | struct DerivedFromKnownSpecialization : BaseTemplate<int> { | 
|  | 95 | __super::XXX a; | 
|  | 96 | typedef __super::XXX b; | 
|  | 97 |  | 
|  | 98 | void test() { | 
|  | 99 | __super::XXX c; | 
|  | 100 | typedef __super::XXX d; | 
|  | 101 |  | 
|  | 102 | __super::foo(); | 
|  | 103 | } | 
|  | 104 | }; | 
|  | 105 |  | 
|  | 106 | template <typename T> | 
|  | 107 | struct DerivedFromDependentBase : BaseTemplate<T> { | 
|  | 108 | typename __super::XXX a; | 
|  | 109 | typedef typename __super::XXX b; | 
|  | 110 |  | 
|  | 111 | __super::XXX c;         // expected-error {{missing 'typename'}} | 
|  | 112 | typedef __super::XXX d; // expected-error {{missing 'typename'}} | 
|  | 113 |  | 
|  | 114 | void test() { | 
|  | 115 | typename __super::XXX e; | 
|  | 116 | typedef typename __super::XXX f; | 
|  | 117 |  | 
|  | 118 | __super::XXX g;         // expected-error {{missing 'typename'}} | 
|  | 119 | typedef __super::XXX h; // expected-error {{missing 'typename'}} | 
|  | 120 |  | 
|  | 121 | __super::foo(); | 
|  | 122 | } | 
|  | 123 | }; | 
|  | 124 |  | 
|  | 125 | template <typename T> | 
|  | 126 | struct DerivedFromTemplateParameter : T { | 
|  | 127 | typename __super::XXX a; | 
|  | 128 | typedef typename __super::XXX b; | 
|  | 129 |  | 
|  | 130 | __super::XXX c;         // expected-error {{missing 'typename'}} | 
|  | 131 | typedef __super::XXX d; // expected-error {{missing 'typename'}} | 
|  | 132 |  | 
|  | 133 | void test() { | 
|  | 134 | typename __super::XXX e; | 
|  | 135 | typedef typename __super::XXX f; | 
|  | 136 |  | 
|  | 137 | __super::XXX g;         // expected-error {{missing 'typename'}} | 
|  | 138 | typedef __super::XXX h; // expected-error {{missing 'typename'}} | 
|  | 139 |  | 
|  | 140 | __super::foo(1); | 
|  | 141 | } | 
|  | 142 | }; | 
|  | 143 |  | 
|  | 144 | void instantiate() { | 
|  | 145 | DerivedFromDependentBase<int> d; | 
|  | 146 | d.test(); | 
|  | 147 | DerivedFromTemplateParameter<Base1> t; | 
|  | 148 | t.test(); | 
|  | 149 | } |