1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | // 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() { __super::foo(1); if (true) { __super::foo(1); } return __super::foo(1); } 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 <void (Base1::*MP)(int)> struct Wrapper { static void bar() {} }; void baz(); }; void PointerToMember::baz() { Wrapper<&__super::foo>::bar(); } template <typename T> struct BaseTemplate { typedef int XXX; int foo() { return 0; } }; struct DerivedFromKnownSpecialization : BaseTemplate<int> { __super::XXX a; typedef __super::XXX b; void foo() { __super::XXX c; typedef __super::XXX d; __super::foo(); } }; template <typename T> struct DerivedFromDependentBase : BaseTemplate<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 foo() { typename __super::XXX e; typedef typename __super::XXX f; __super::XXX g; // expected-error {{missing 'typename'}} typedef __super::XXX h; // expected-error {{missing 'typename'}} int x = __super::foo(); } }; template <typename T> 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 foo() { 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<int> d; d.foo(); DerivedFromTemplateParameter<Base1> t; t.foo(); } namespace { struct B { int a; }; template <class C> struct A : B { // Don't crash on dependent_type_var '->' '__super' void f() { int a = this->__super::a; } }; } |