struct __attribute__((visibility("hidden"))) a;
struct __attribute__((visibility("default"))) b;
which gcc already rejects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155603
91177308-0d34-0410-b5e6-
96231b3b80d8
def warn_attribute_protected_visibility :
Warning<"target does not support 'protected' visibility; using 'default'">,
InGroup<DiagGroup<"unsupported-visibility">>;
+def err_mismatched_visibilit: Error<"visibility does not match previous declaration">;
+def note_previous_attribute : Note<"previous attribute is here">;
def err_unknown_machine_mode : Error<"unknown machine mode %0">;
def err_unsupported_machine_mode : Error<"unsupported machine mode %0">;
def err_mode_not_primitive : Error<
return;
}
+ VisibilityAttr *PrevAttr = D->getCanonicalDecl()->getAttr<VisibilityAttr>();
+ if (PrevAttr) {
+ VisibilityAttr::VisibilityType PrevVisibility = PrevAttr->getVisibility();
+ if (PrevVisibility != type) {
+ S.Diag(Attr.getLoc(), diag::err_mismatched_visibilit);
+ S.Diag(PrevAttr->getLocation(), diag::note_previous_attribute);
+ return;
+ }
+ }
D->addAttr(::new (S.Context) VisibilityAttr(Attr.getRange(), S.Context, type));
}
// rdar://problem/10753392
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 __attribute__((visibility("default"))) test4; // expected-error {{visibility does not match previous declaration}}