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();


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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to