summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-05-02 20:36:57 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-05-02 20:36:57 +0000
commitcd997e02b25fbda462817c35d34157bb006a119c (patch)
treec7eb4bf749b398f37820cb33daff615de8c25e83 /clang/lib/Sema/SemaDeclAttr.cpp
parentc2d64c428a8a924405e905a3a42794ebc85f0aa8 (diff)
downloadbcm5719-llvm-cd997e02b25fbda462817c35d34157bb006a119c.tar.gz
bcm5719-llvm-cd997e02b25fbda462817c35d34157bb006a119c.zip
Walk the decls looking for the last one that has an attribute. We do have to walk
them, otherwise we cannot produce an error for both struct HIDDEN test4; // canonical struct test4; struct DEFAULT test4; and struct test5; // canonical struct HIDDEN test5; struct DEFAULT test5; llvm-svn: 156016
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 13bf0aa4875..6b3f4f97340 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1757,13 +1757,16 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
return;
}
- Decl *PrevDecl;
- if (isa<FunctionDecl>(D))
- PrevDecl = D->getMostRecentDecl()->getPreviousDecl();
- else
- PrevDecl = D->getCanonicalDecl();
+ // Find the last Decl that has an attribute.
+ VisibilityAttr *PrevAttr;
+ assert(D->redecls_begin() == D);
+ for (Decl::redecl_iterator I = D->redecls_begin(), E = D->redecls_end();
+ I != E; ++I) {
+ PrevAttr = I->getAttr<VisibilityAttr>() ;
+ if (PrevAttr)
+ break;
+ }
- VisibilityAttr *PrevAttr = PrevDecl ? PrevDecl->getAttr<VisibilityAttr>() : 0;
if (PrevAttr) {
VisibilityAttr::VisibilityType PrevVisibility = PrevAttr->getVisibility();
if (PrevVisibility != type) {
OpenPOWER on IntegriCloud