Extend the error about incompatible visibility attributes in different
decls to work on function templates specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155943 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 47e393c..c8af3a4 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1752,7 +1752,13 @@
return;
}
- VisibilityAttr *PrevAttr = D->getCanonicalDecl()->getAttr<VisibilityAttr>();
+ Decl *PrevDecl;
+ if (isa<FunctionDecl>(D))
+ PrevDecl = D->getMostRecentDecl()->getPreviousDecl();
+ else
+ PrevDecl = D->getCanonicalDecl();
+
+ VisibilityAttr *PrevAttr = PrevDecl ? PrevDecl->getAttr<VisibilityAttr>() : 0;
if (PrevAttr) {
VisibilityAttr::VisibilityType PrevVisibility = PrevAttr->getVisibility();
if (PrevVisibility != type) {