decls to work on function templates specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155943
91177308-0d34-0410-b5e6-
96231b3b80d8
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) {
void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
struct __attribute__((visibility("hidden"))) test4; // expected-note {{previous attribute is here}}
+struct test4;
struct __attribute__((visibility("default"))) test4; // expected-error {{visibility does not match previous declaration}}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class Element>
+void foo() {
+}
+template <>
+ __attribute__((visibility("hidden"))) // expected-note {{previous attribute is here}}
+void foo<int>();
+
+template <>
+void foo<int>();
+
+template <>
+ __attribute__((visibility("default"))) // expected-error {{visibility does not match previous declaration}}
+void foo<int>() {
+}