Issue deprecated warning when typeof uses an

expression of deprecated type.

llvm-svn: 115713
This commit is contained in:
Fariborz Jahanian 2010-10-05 23:24:00 +00:00
parent 36e40a8449
commit 121f5148fd
2 changed files with 20 additions and 1 deletions

View File

@ -2211,7 +2211,13 @@ QualType Sema::BuildTypeofExprType(Expr *E) {
return QualType();
}
}
if (!E->isTypeDependent()) {
QualType T = E->getType();
if (const RecordType *EltTy = T->getAs<RecordType>())
DiagnoseUseOfDecl(EltTy->getDecl(), E->getExprLoc());
else if (const EnumType *Enum = T->getAs<EnumType>())
DiagnoseUseOfDecl(Enum->getDecl(), E->getExprLoc());
}
return Context.getTypeOfExprType(E);
}

View File

@ -0,0 +1,13 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}}
typeof(x) y; // expected-warning {{'s' is deprecated}}
union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}}
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}}