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