From 9ec4099a0946a46108a8e22a4b30d45d5443decd Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 16 Jul 2013 02:07:49 +0000 Subject: [PATCH] Merge attributes on typedef decls. Not completely sure this is right, but it's clearly better than what we did before this commit (effectively dropping the attribute). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186373 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 ++ test/Sema/attr-deprecated.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5e535da19a..38de4db8ae 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1743,6 +1743,8 @@ void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) { if (TypedefNameDecl *Typedef = dyn_cast(Old)) New->setPreviousDeclaration(Typedef); + mergeDeclAttributes(New, Old); + if (getLangOpts().MicrosoftExt) return; diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index 565be7ff59..8124ab0ddd 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -120,3 +120,7 @@ struct test22 { foo_dep c, d __attribute((deprecated)); // expected-warning {{'foo_dep' is deprecated}} __attribute((deprecated)) foo_dep e, f; }; + +typedef int test23_ty __attribute((deprecated)); // expected-note {{previous definition is here}} +typedef int test23_ty; // expected-note {{'test23_ty' declared here}} expected-warning {{redefinition of typedef 'test23_ty' is a C11 feature}} +test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}} -- 2.40.0