Warn about visibility attributes in typedefs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156534 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 280e3d7..9cd72b2 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1857,6 +1857,10 @@
 bool Sema::mergeVisibilityAttr(Decl *D, SourceRange Range,
                                bool Inherited,
                                VisibilityAttr::VisibilityType Vis) {
+  if (isa<TypedefNameDecl>(D)) {
+    Diag(Range.getBegin(), diag::warn_attribute_ignored) << "visibility";
+    return false;
+  }
   VisibilityAttr *ExistingAttr = D->getAttr<VisibilityAttr>();
   if (ExistingAttr) {
     VisibilityAttr::VisibilityType ExistingVis = ExistingAttr->getVisibility();
diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c
index cc3c54a..77bc39c 100644
--- a/test/Sema/attr-visibility.c
+++ b/test/Sema/attr-visibility.c
@@ -20,3 +20,5 @@
 
 extern int test7 __attribute__((visibility("default"))); // expected-note {{previous attribute is here}}
 extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visibility does not match previous declaration}}
+
+typedef int __attribute__((visibility("default"))) bar; // expected-warning {{visibility attribute ignored}}