1 // RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11
4 // expected-error@+1 {{user-declared constructor is not permitted within an interface type}}
6 // expected-error@+1 {{user-declared destructor is not permitted within an interface type}}
8 virtual void fn1() const;
9 // expected-error@+1 {{operator 'operator!' is not permitted within an interface type}}
11 // expected-error@+1 {{operator 'operator int' is not permitted within an interface type}}
13 // expected-error@+1 {{nested class I1::(anonymous) is not permitted within an interface type}}
16 struct A { }; // should be ignored: not a nested class
18 protected: // expected-error {{interface types cannot specify 'protected' access}}
21 private: // expected-error {{interface types cannot specify 'private' access}}
22 static_assert(true, "oops");
26 // expected-error@+1 {{data member 'i' is not permitted within an interface type}}
28 // expected-error@+1 {{static member function 'fn1' is not permitted within an interface type}}
30 private: // expected-error {{interface types cannot specify 'private' access}}
31 // expected-error@+1 {{non-public member function 'fn2' is not permitted within an interface type}}
33 protected: // expected-error {{interface types cannot specify 'protected' access}}
34 // expected-error@+1 {{non-public member function 'fn3' is not permitted within an interface type}}
40 // expected-error@+1 {{'final' keyword not permitted with interface types}}
41 __interface I3 final {
44 __interface I4 : I1, I2 {
45 void fn1() const override;
46 // expected-error@+1 {{'final' keyword not permitted with interface types}}
50 // expected-error@+1 {{interface type cannot inherit from non-public interface 'I1'}}
51 __interface I5 : private I1 {
63 static_assert(!__is_interface_class(S), "oops");
64 static_assert(!__is_interface_class(C), "oops");
65 static_assert(!__is_interface_class(I), "oops");
66 static_assert(!__is_interface_class(U), "oops");
68 // expected-error@55 {{interface type cannot inherit from struct 'S'}}
69 // expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}}
73 // expected-error@55 {{interface type cannot inherit from class 'C'}}
74 // expected-note@+1 {{in instantiation of template class 'I6<C>' requested here}}
82 // MSVC makes a special case in that an interface is allowed to have a data
83 // member if it is a property.
85 __declspec(property(get = Get, put = Put)) int data;
90 struct __declspec(uuid("00000000-0000-0000-C000-000000000046"))
93 __declspec(property(get = Get, put = Put), deprecated) int data;
98 struct IFaceStruct : IUnknown {
99 __declspec(property(get = Get2, put = Put2), deprecated) int data2;
104 __interface IFaceInheritsStruct : IFaceStruct {};
105 static_assert(!__is_interface_class(HasProp), "oops");
106 static_assert(!__is_interface_class(IUnknown), "oops");
107 static_assert(!__is_interface_class(IFaceStruct), "oops");
108 static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");