summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-25 22:21:57 +0000
committerChris Lattner <sabre@nondot.org>2009-10-25 22:21:57 +0000
commitecf328e6dd9af5c7c3f539c48225e5055e4cd569 (patch)
tree55c1bd8abd9f1e53f11fbd9ccaaa7cc1eeb39769
parente40853aabdaad151099b7061585e2782dcba02fb (diff)
downloadbcm5719-llvm-ecf328e6dd9af5c7c3f539c48225e5055e4cd569.tar.gz
bcm5719-llvm-ecf328e6dd9af5c7c3f539c48225e5055e4cd569.zip
When parsing a top level struct declaration, make sure to
process decl attributes instead of dropping them on the floor. This allows us to diagnose cases like the testcase. Also don't diagnose deprecated stuff in ActOnTag: not all uses of tags may be 'uses', and SemaType does this now. llvm-svn: 85071
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
-rw-r--r--clang/test/Sema/attr-deprecated.c6
2 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 08d7235665b..7b37df9cbee 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1319,6 +1319,10 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
}
if (RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
+ // If there are attributes in the DeclSpec, apply them to the record.
+ if (const AttributeList *AL = DS.getAttributes())
+ ProcessDeclAttributeList(S, Record, AL);
+
if (!Record->getDeclName() && Record->isDefinition() &&
DS.getStorageClassSpec() != DeclSpec::SCS_typedef) {
if (getLangOptions().CPlusPlus ||
@@ -4305,9 +4309,6 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
}
if (PrevDecl) {
- // Check whether the previous declaration is usable.
- (void)DiagnoseUseOfDecl(PrevDecl, NameLoc);
-
if (TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
// If this is a use of a previous tag, or if the tag is already declared
// in the same scope (so that the definition/declaration completes or
diff --git a/clang/test/Sema/attr-deprecated.c b/clang/test/Sema/attr-deprecated.c
index e15381e4c6d..45c5dd0676b 100644
--- a/clang/test/Sema/attr-deprecated.c
+++ b/clang/test/Sema/attr-deprecated.c
@@ -43,3 +43,9 @@ void test1(struct foo *F) {
typedef struct foo foo_dep __attribute__((deprecated));
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
+
+struct bar_dep __attribute__((deprecated,
+ invalid_attribute)); // expected-warning {{'invalid_attribute' attribute ignored}}
+
+struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
+
OpenPOWER on IntegriCloud