blob: 3625f7027aa479de4f80f55ddc6cadfcc9c0d5e4 [file] [log] [blame]
John McCalle402e722012-09-25 07:32:39 +00001// 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 }
18protected: // expected-error {{interface types cannot specify 'protected' access}}
19 typedef void void_t;
20 using int_t = int;
21private: // 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();
30private: // 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();
33protected: // 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();
36public:
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
54template <typename X>
55__interface I6 : X {
56};
57
58struct S { };
59class C { };
60__interface I { };
61
John McCallea30e2f2012-09-25 07:32:49 +000062static_assert(!__is_interface_class(S), "oops");
63static_assert(!__is_interface_class(C), "oops");
64static_assert(__is_interface_class(I), "oops");
65
John McCalle402e722012-09-25 07:32:39 +000066// expected-error@55 {{interface type cannot inherit from 'struct S'}}
67// expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}}
68struct 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}}
73class C1 : I6<C> {
74};
75
76class C2 : I6<I> {
77};