aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-12-03 06:58:14 +0000
committerEric Christopher <echristo@apple.com>2010-12-03 06:58:14 +0000
commit722109c1b7718d3e8aab075ce65007b372822199 (patch)
tree168730fa5d448cd3ed0fdd51e8dc3aa5d2076a2b /lib/Sema/SemaDeclAttr.cpp
parent83300e884d0cfb78a2e8f889b65a77e6781456fe (diff)
Add some warning messages about invalid use of common/nocommon attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--lib/Sema/SemaDeclAttr.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index ee03d1f7f1..ad0313d976 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -745,12 +745,20 @@ static void HandleMayAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) {
static void HandleNoCommonAttr(Decl *d, const AttributeList &Attr, Sema &S) {
assert(Attr.isInvalid() == false);
- d->addAttr(::new (S.Context) NoCommonAttr(Attr.getLoc(), S.Context));
+ if (isa<VarDecl>(d))
+ d->addAttr(::new (S.Context) NoCommonAttr(Attr.getLoc(), S.Context));
+ else
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << Attr.getName() << 12 /* variable */;
}
static void HandleCommonAttr(Decl *d, const AttributeList &Attr, Sema &S) {
assert(Attr.isInvalid() == false);
- d->addAttr(::new (S.Context) CommonAttr(Attr.getLoc(), S.Context));
+ if (isa<VarDecl>(d))
+ d->addAttr(::new (S.Context) CommonAttr(Attr.getLoc(), S.Context));
+ else
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << Attr.getName() << 12 /* variable */;
}
static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) {