[cfe-commits] r120799 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Eric Christopher
echristo at apple.com
Thu Dec 2 22:58:14 PST 2010
Author: echristo
Date: Fri Dec 3 00:58:14 2010
New Revision: 120799
URL: http://llvm.org/viewvc/llvm-project?rev=120799&view=rev
Log:
Add some warning messages about invalid use of common/nocommon attributes.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=120799&r1=120798&r2=120799&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Dec 3 00:58:14 2010
@@ -745,12 +745,20 @@
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) {
More information about the cfe-commits
mailing list