Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Warn about visibility attributes in typedefs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156534 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information...
commit dd44f34301316b814277d6a8c146d86c7115330b 1 parent 98ae834
@espindola espindola authored
Showing with 6 additions and 0 deletions.
  1. +4 −0 lib/Sema/SemaDeclAttr.cpp
  2. +2 −0  test/Sema/attr-visibility.c
View
4 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<TypedefNameDecl>(D)) {
+ Diag(Range.getBegin(), diag::warn_attribute_ignored) << "visibility";
+ return false;
+ }
VisibilityAttr *ExistingAttr = D->getAttr<VisibilityAttr>();
if (ExistingAttr) {
VisibilityAttr::VisibilityType ExistingVis = ExistingAttr->getVisibility();
View
2  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}}
Please sign in to comment.
Something went wrong with that request. Please try again.