[PATCH] D37308: Interface class with uuid base record

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 05:32:09 PDT 2017


zahiraam updated this revision to Diff 113387.
zahiraam added a comment.

Removed the helper function.

If RD (base class) has uuid attribute, we want to ensure that the interface doesn't have attributes. Otherwise cases like:

class __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown1 {};
__interface __declspec(dllimport) ISfFileIOPropertyPage1 : public IUnknown1 {};

will compile.


https://reviews.llvm.org/D37308

Files:
  lib/Sema/SemaDeclCXX.cpp


Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2398,13 +2398,6 @@
   }
 }
 
-
-/// \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,
@@ -2457,13 +2450,13 @@
       if (const RecordType *Record = NewBaseType->getAs<RecordType>()) {
         const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
         if (Class->isInterface() &&
-            !IsBasePublicInterface(RD, KnownBase->getAccessSpecifier()) &&
+            !(RD->isInterface() &&
+              KnownBase->getAccessSpecifier() == AS_public) &&
             // 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<UuidAttr>() ||
-	     Class->hasAttrs())) {
+            (!RD->getAttr<UuidAttr>() || Class->hasAttrs())) {
           Diag(KnownBase->getLocStart(), diag::err_invalid_base_in_interface)
             << getRecordDiagFromTagKind(RD->getTagKind()) << RD->getName()
             << RD->getSourceRange();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37308.113387.patch
Type: text/x-patch
Size: 1530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170831/62045faf/attachment.bin>


More information about the cfe-commits mailing list