From: Rafael Espindola Date: Thu, 10 May 2012 03:01:34 +0000 (+0000) Subject: Warn about visibility attributes in typedefs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd44f34301316b814277d6a8c146d86c7115330b;p=clang 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 280e3d7fca..9cd72b2e1e 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1857,6 +1857,10 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, bool Sema::mergeVisibilityAttr(Decl *D, SourceRange Range, bool Inherited, VisibilityAttr::VisibilityType Vis) { + if (isa(D)) { + Diag(Range.getBegin(), diag::warn_attribute_ignored) << "visibility"; + return false; + } VisibilityAttr *ExistingAttr = D->getAttr(); if (ExistingAttr) { VisibilityAttr::VisibilityType ExistingVis = ExistingAttr->getVisibility(); diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c index cc3c54a047..77bc39c9e6 100644 --- a/test/Sema/attr-visibility.c +++ b/test/Sema/attr-visibility.c @@ -20,3 +20,5 @@ void test6() __attribute__((visibility("hidden"), // expected-note {{previous at 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}}