Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -2398,6 +2398,13 @@ } } + +/// \brief Tests if the __interface base is public. +static bool IsBasePublicInterface(const CXXRecordDecl *RD, + AccessSpecifier spec) { + return RD->isInterface() && spec == AS_public; +} + /// \brief Performs the actual work of attaching the given base class /// specifiers to a C++ class. bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, @@ -2450,10 +2457,13 @@ if (const RecordType *Record = NewBaseType->getAs()) { const CXXRecordDecl *RD = cast(Record->getDecl()); if (Class->isInterface() && - (!RD->isInterface() || - KnownBase->getAccessSpecifier() != AS_public)) { - // The Microsoft extension __interface does not permit bases that - // are not themselves public interfaces. + !IsBasePublicInterface(RD, KnownBase->getAccessSpecifier()) && + // The Microsoft extension __interface does not permit bases that + // are not themselves public interfaces. + // An interface can inherit from a base, as long as it has + // uuid attributes. + (!RD->getAttr() || + Class->hasAttrs())) { Diag(KnownBase->getLocStart(), diag::err_invalid_base_in_interface) << getRecordDiagFromTagKind(RD->getTagKind()) << RD->getName() << RD->getSourceRange(); Index: test/SemaCXX/ms-uuid.cpp =================================================================== --- test/SemaCXX/ms-uuid.cpp +++ test/SemaCXX/ms-uuid.cpp @@ -93,3 +93,15 @@ [uuid("000000A0-0000-0000-C000-000000000049"), uuid("000000A0-0000-0000-C000-000000000049")] class C10; } + +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {}; +__interface ISfFileIOPropertyPage : public IUnknown {}; + +class __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown1 {}; +__interface __declspec(dllimport) ISfFileIOPropertyPage1 : public IUnknown1 {}; // expected-error{{interface type cannot inherit from}} + +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown2 {}; +__interface __declspec(dllimport) ISfFileIOPropertyPage2 : public IUnknown2 {}; // expected-error{{interface type cannot inherit from}} + +struct __declspec(dllexport) IUnknown3{}; +__interface foo : public IUnknown3{}; // expected-error{{interface type cannot inherit from}}