From 730e175910936eae49e65caea8b2ba81c67edff7 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 6 Oct 2010 17:00:02 +0000 Subject: [PATCH] Issue deprecated warning when typeof uses typedef based on underlying type's deprecatedness. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115800 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaType.cpp | 5 ++++- test/Sema/typeof-use-deprecated.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 4d1256577d..b86dce06b4 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -339,6 +339,10 @@ static QualType ConvertDeclSpecToType(Sema &TheSema, // FIXME: Preserve type source info. Result = TheSema.GetTypeFromParser(DS.getRepAsType()); assert(!Result.isNull() && "Didn't get a type for typeof?"); + if (!Result->isDependentType()) + if (const TagType *TT = Result->getAs()) + TheSema.DiagnoseUseOfDecl(TT->getDecl(), + DS.getTypeSpecTypeLoc()); // TypeQuals handled by caller. Result = Context.getTypeOfType(Result); break; @@ -2213,7 +2217,6 @@ QualType Sema::BuildTypeofExprType(Expr *E) { } if (!E->isTypeDependent()) { QualType T = E->getType(); - // FIXME. Issue warning for types built from deprecated types as well. if (const TagType *TT = T->getAs()) DiagnoseUseOfDecl(TT->getDecl(), E->getExprLoc()); } diff --git a/test/Sema/typeof-use-deprecated.c b/test/Sema/typeof-use-deprecated.c index 2e080bae1f..238e5019f1 100644 --- a/test/Sema/typeof-use-deprecated.c +++ b/test/Sema/typeof-use-deprecated.c @@ -11,3 +11,16 @@ typeof( u) z; // expected-warning {{'un' is deprecated}} enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} typeof( e) w; // expected-warning {{'E' is deprecated}} + +struct foo { int x; } __attribute__((deprecated)); +typedef struct foo bar __attribute__((deprecated)); +bar x1; // expected-warning {{'bar' is deprecated}} + +int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}} + +struct gorf { int x; }; +typedef struct gorf T __attribute__((deprecated)); +T t; // expected-warning {{'T' is deprecated}} +void wee() { typeof(t) y; } + + -- 2.40.0