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