aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-01-16 23:49:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-01-16 23:49:06 +0000
commit4d8a33b4cea46948f86afccf0ad3675aff924148 (patch)
treefbfbe1eb5cc63b692482448dac42c66ce2a9018a /lib/Sema/SemaDecl.cpp
parentafb7ce3f877594362381926eaeac8ed6bbe18069 (diff)
Delay linkage checks when validating the weakref attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0316654660..b85e94bce8 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4314,10 +4314,17 @@ bool Sema::inferObjCARCLifetime(ValueDecl *decl) {
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
// 'weak' only applies to declarations with external linkage.
- WeakAttr *WA = ND.getAttr<WeakAttr>();
- if (WA && ND.getLinkage() != ExternalLinkage) {
- S.Diag(WA->getLocation(), diag::err_attribute_weak_static);
- ND.dropAttr<WeakAttr>();
+ if (WeakAttr *Attr = ND.getAttr<WeakAttr>()) {
+ if (ND.getLinkage() != ExternalLinkage) {
+ S.Diag(Attr->getLocation(), diag::err_attribute_weak_static);
+ ND.dropAttr<WeakAttr>();
+ }
+ }
+ if (WeakRefAttr *Attr = ND.getAttr<WeakRefAttr>()) {
+ if (ND.getLinkage() == ExternalLinkage) {
+ S.Diag(Attr->getLocation(), diag::err_attribute_weakref_not_static);
+ ND.dropAttr<WeakRefAttr>();
+ }
}
}