diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGenCXX/microsoft-interface.cpp | 43 | ||||
-rw-r--r-- | test/SemaCXX/ms-interface.cpp | 73 |
2 files changed, 116 insertions, 0 deletions
diff --git a/test/CodeGenCXX/microsoft-interface.cpp b/test/CodeGenCXX/microsoft-interface.cpp new file mode 100644 index 0000000000..3887d18df1 --- /dev/null +++ b/test/CodeGenCXX/microsoft-interface.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -std=c++11 -fms-extensions -Wno-microsoft -triple=i386-pc-win32 -emit-llvm %s -o - | FileCheck %s + +__interface I { + int test() { + return 1; + } +}; + +struct S : I { + virtual int test() override { + return I::test(); + } +}; + +int fn() { + S s; + return s.test(); +} + +// CHECK: @_ZTV1S = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI1S to i8*), i8* bitcast (i32 (%struct.S*)* @_ZN1S4testEv to i8*)] + +// CHECK: define i32 @_Z2fnv() +// CHECK: call void @_ZN1SC1Ev(%struct.S* %s) +// CHECK: %call = call i32 @_ZN1S4testEv(%struct.S* %s) + +// CHECK: define linkonce_odr void @_ZN1SC1Ev(%struct.S* %this) +// CHECK: call void @_ZN1SC2Ev(%struct.S* %this1) + +// CHECK: define linkonce_odr i32 @_ZN1S4testEv(%struct.S* %this) +// CHECK: %call = call i32 @_ZN1I4testEv(%__interface.I* %0) + +// CHECK: define linkonce_odr i32 @_ZN1I4testEv(%__interface.I* %this) +// CHECK: ret i32 1 + +// CHECK: define linkonce_odr void @_ZN1SC2Ev(%struct.S* %this) +// CHECK: call void @_ZN1IC2Ev(%__interface.I* %0) +// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1S, i64 0, i64 2), i8*** %1 + +// CHECK: define linkonce_odr void @_ZN1IC2Ev(%__interface.I* %this) +// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1I, i64 0, i64 2), i8*** %0 + +// CHECK-NOT: define linkonce_odr %__interface.I* @_ZN1IaSERKS_(%__interface.I* %this, %__interface.I*) +// CHECK-NOT: define linkonce_odr %__interface.I* @_ZN1IaSEOS_(%__interface.I* %this, %__interface.I*) diff --git a/test/SemaCXX/ms-interface.cpp b/test/SemaCXX/ms-interface.cpp new file mode 100644 index 0000000000..62ae25482f --- /dev/null +++ b/test/SemaCXX/ms-interface.cpp @@ -0,0 +1,73 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11 + +__interface I1 { + // expected-error@+1 {{user-declared constructor is not permitted within an interface type}} + I1(); + // expected-error@+1 {{user-declared destructor is not permitted within an interface type}} + ~I1(); + virtual void fn1() const; + // expected-error@+1 {{operator 'operator!' is not permitted within an interface type}} + bool operator!(); + // expected-error@+1 {{operator 'operator int' is not permitted within an interface type}} + operator int(); + // expected-error@+1 {{nested class I1::<anonymous> is not permitted within an interface type}} + struct { int a; }; + void fn2() { + struct A { }; // should be ignored: not a nested class + } +protected: // expected-error {{interface types cannot specify 'protected' access}} + typedef void void_t; + using int_t = int; +private: // expected-error {{interface types cannot specify 'private' access}} + static_assert(true, "oops"); +}; + +__interface I2 { + // expected-error@+1 {{data member 'i' is not permitted within an interface type}} + int i; + // expected-error@+1 {{static member function 'fn1' is not permitted within an interface type}} + static int fn1(); +private: // expected-error {{interface types cannot specify 'private' access}} + // expected-error@+1 {{non-public member function 'fn2' is not permitted within an interface type}} + void fn2(); +protected: // expected-error {{interface types cannot specify 'protected' access}} + // expected-error@+1 {{non-public member function 'fn3' is not permitted within an interface type}} + void fn3(); +public: + void fn4(); +}; + +// expected-error@+1 {{'final' keyword not permitted with interface types}} +__interface I3 final { +}; + +__interface I4 : I1, I2 { + void fn1() const override; + // expected-error@+1 {{'final' keyword not permitted with interface types}} + void fn2() final; +}; + +// expected-error@+1 {{interface type cannot inherit from non-public 'interface I1'}} +__interface I5 : private I1 { +}; + +template <typename X> +__interface I6 : X { +}; + +struct S { }; +class C { }; +__interface I { }; + +// expected-error@55 {{interface type cannot inherit from 'struct S'}} +// expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}} +struct S1 : I6<S> { +}; + +// expected-error@55 {{interface type cannot inherit from 'class C'}} +// expected-note@+1 {{in instantiation of template class 'I6<C>' requested here}} +class C1 : I6<C> { +}; + +class C2 : I6<I> { +}; |