]> granicus.if.org Git - clang/commitdiff
Now that we check visibility attributes in an appropriate order,
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 19 Apr 2012 05:24:05 +0000 (05:24 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 19 Apr 2012 05:24:05 +0000 (05:24 +0000)
there is no need for mergeVisibily to ever increase the visibility. Not
doing so lets us replace an incorrect use of mergeVisibilityWithMin. The
testcase

struct HIDDEN RECT {
  int top;
};
DEFAULT RECT foo = {0};

shows that we should give preference to one of the attributes instead of
keeping the minimum. We still get this testcase wrong because mergeVisibily
handles two explicit visibilities incorrectly, but this is a step in the
right direction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155101 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/AST/Decl.cpp

index 885286408b0546c34f7398fff74c13f7e6cdcb7d..0bf4615ca2611d6782fdf0cbf429ebc04a7424c4 100644 (file)
@@ -258,6 +258,10 @@ public:
     // down to one of its members. If the member has no explicit visibility,
     // the class visibility wins.
     void mergeVisibility(Visibility V, bool E = false) {
+      // Never increase the visibility
+      if (visibility() < V)
+        return;
+
       // If one has explicit visibility and the other doesn't, keep the
       // explicit one.
       if (visibilityExplicit() && !E)
index f26747bdf6f85bc98e3913892aaf2f2f01e2ae50..f4c0aa3c6be84bce07b84f06e7b25e17b43fb0ed 100644 (file)
@@ -327,7 +327,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) {
       LinkageInfo TypeLV = getLVForType(Var->getType());
       if (TypeLV.linkage() != ExternalLinkage)
         return LinkageInfo::uniqueExternal();
-      LV.mergeVisibilityWithMin(TypeLV);
+      LV.mergeVisibility(TypeLV);
     }
 
     if (Var->getStorageClass() == SC_PrivateExtern)