1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc __interface I1 { 4*f4a2713aSLionel Sambuc // expected-error@+1 {{user-declared constructor is not permitted within an interface type}} 5*f4a2713aSLionel Sambuc I1(); 6*f4a2713aSLionel Sambuc // expected-error@+1 {{user-declared destructor is not permitted within an interface type}} 7*f4a2713aSLionel Sambuc ~I1(); 8*f4a2713aSLionel Sambuc virtual void fn1() const; 9*f4a2713aSLionel Sambuc // expected-error@+1 {{operator 'operator!' is not permitted within an interface type}} 10*f4a2713aSLionel Sambuc bool operator!(); 11*f4a2713aSLionel Sambuc // expected-error@+1 {{operator 'operator int' is not permitted within an interface type}} 12*f4a2713aSLionel Sambuc operator int(); 13*f4a2713aSLionel Sambuc // expected-error@+1 {{nested class I1::<anonymous> is not permitted within an interface type}} 14*f4a2713aSLionel Sambuc struct { int a; }; 15*f4a2713aSLionel Sambuc void fn2() { 16*f4a2713aSLionel Sambuc struct A { }; // should be ignored: not a nested class 17*f4a2713aSLionel Sambuc } 18*f4a2713aSLionel Sambuc protected: // expected-error {{interface types cannot specify 'protected' access}} 19*f4a2713aSLionel Sambuc typedef void void_t; 20*f4a2713aSLionel Sambuc using int_t = int; 21*f4a2713aSLionel Sambuc private: // expected-error {{interface types cannot specify 'private' access}} 22*f4a2713aSLionel Sambuc static_assert(true, "oops"); 23*f4a2713aSLionel Sambuc }; 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc __interface I2 { 26*f4a2713aSLionel Sambuc // expected-error@+1 {{data member 'i' is not permitted within an interface type}} 27*f4a2713aSLionel Sambuc int i; 28*f4a2713aSLionel Sambuc // expected-error@+1 {{static member function 'fn1' is not permitted within an interface type}} 29*f4a2713aSLionel Sambuc static int fn1(); 30*f4a2713aSLionel Sambuc private: // expected-error {{interface types cannot specify 'private' access}} 31*f4a2713aSLionel Sambuc // expected-error@+1 {{non-public member function 'fn2' is not permitted within an interface type}} 32*f4a2713aSLionel Sambuc void fn2(); 33*f4a2713aSLionel Sambuc protected: // expected-error {{interface types cannot specify 'protected' access}} 34*f4a2713aSLionel Sambuc // expected-error@+1 {{non-public member function 'fn3' is not permitted within an interface type}} 35*f4a2713aSLionel Sambuc void fn3(); 36*f4a2713aSLionel Sambuc public: 37*f4a2713aSLionel Sambuc void fn4(); 38*f4a2713aSLionel Sambuc }; 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc // expected-error@+1 {{'final' keyword not permitted with interface types}} 41*f4a2713aSLionel Sambuc __interface I3 final { 42*f4a2713aSLionel Sambuc }; 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc __interface I4 : I1, I2 { 45*f4a2713aSLionel Sambuc void fn1() const override; 46*f4a2713aSLionel Sambuc // expected-error@+1 {{'final' keyword not permitted with interface types}} 47*f4a2713aSLionel Sambuc void fn2() final; 48*f4a2713aSLionel Sambuc }; 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // expected-error@+1 {{interface type cannot inherit from non-public 'interface I1'}} 51*f4a2713aSLionel Sambuc __interface I5 : private I1 { 52*f4a2713aSLionel Sambuc }; 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambuc template <typename X> 55*f4a2713aSLionel Sambuc __interface I6 : X { 56*f4a2713aSLionel Sambuc }; 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc struct S { }; 59*f4a2713aSLionel Sambuc class C { }; 60*f4a2713aSLionel Sambuc __interface I { }; 61*f4a2713aSLionel Sambuc 62*f4a2713aSLionel Sambuc static_assert(!__is_interface_class(S), "oops"); 63*f4a2713aSLionel Sambuc static_assert(!__is_interface_class(C), "oops"); 64*f4a2713aSLionel Sambuc static_assert(__is_interface_class(I), "oops"); 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuc // expected-error@55 {{interface type cannot inherit from 'struct S'}} 67*f4a2713aSLionel Sambuc // expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}} 68*f4a2713aSLionel Sambuc struct S1 : I6<S> { 69*f4a2713aSLionel Sambuc }; 70*f4a2713aSLionel Sambuc 71*f4a2713aSLionel Sambuc // expected-error@55 {{interface type cannot inherit from 'class C'}} 72*f4a2713aSLionel Sambuc // expected-note@+1 {{in instantiation of template class 'I6<C>' requested here}} 73*f4a2713aSLionel Sambuc class C1 : I6<C> { 74*f4a2713aSLionel Sambuc }; 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc class C2 : I6<I> { 77*f4a2713aSLionel Sambuc }; 78