llvm-capstone/clang/test/SemaCXX/ms-iunknown.cpp
Erich Keane 3e08f66bb0 [Sema] Correct IUnknown to support Unknwnbase.h Header.
Apparently, the MSVC SDK has a strange implementation that
causes a number of implicit functions as well as a template member
function of the IUnknown type. This patch allows these as InterfaceLike
types as well.

Additionally, it corrects the behavior where extern-C++ wrapped around an
Interface-Like type would permit an interface-like type to exist in a namespace.

Differential Revision: https://reviews.llvm.org/D38303

llvm-svn: 314557
2017-09-29 21:06:00 +00:00

51 lines
1.7 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
extern "C++" struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {
void foo();
// Definitions aren't allowed, unless they are a template.
template<typename T>
void bar(T t){}
};
struct IPropertyPageBase : public IUnknown {};
struct IPropertyPage : public IPropertyPageBase {};
__interface ISfFileIOPropertyPage : public IPropertyPage {};
namespace NS {
struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
// expected-error@+1 {{interface type cannot inherit from}}
__interface IPropertyPageBase : public IUnknown {};
}
namespace NS2 {
extern "C++" struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {};
// expected-error@+1 {{interface type cannot inherit from}}
__interface IPropertyPageBase : public IUnknown{};
}
// expected-error@+1 {{interface type cannot inherit from}}
__interface IPropertyPageBase2 : public NS::IUnknown {};
__interface temp_iface {};
struct bad_base : temp_iface {};
// expected-error@+1 {{interface type cannot inherit from}}
__interface bad_inherit : public bad_base{};
struct mult_inher_base : temp_iface, IUnknown {};
// expected-error@+1 {{interface type cannot inherit from}}
__interface bad_inherit2 : public mult_inher_base{};
struct PageBase : public IUnknown {};
struct Page3 : public PageBase {};
struct Page4 : public PageBase {};
__interface PropertyPage : public Page4 {};
struct Page5 : public Page3, Page4{};
// expected-error@+1 {{interface type cannot inherit from}}
__interface PropertyPage2 : public Page5 {};
__interface IF1 {};
__interface PP : IUnknown, IF1{};
__interface PP2 : PP, Page3, Page4{};