forked from OSchip/llvm-project
Issue deprecated warning when typeof uses an
expression of deprecated type. llvm-svn: 115713
This commit is contained in:
parent
36e40a8449
commit
121f5148fd
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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}}
|
Loading…
Reference in New Issue