Add support for deprecated members of RecordDecls (e.g. struct fields).

llvm-svn: 64634
This commit is contained in:
Chris Lattner 2009-02-16 17:07:21 +00:00
parent 73b85e30ed
commit ee4b5235e3
3 changed files with 11 additions and 2 deletions

View File

@ -462,8 +462,6 @@ static void InitializePredefinedMacros(Preprocessor &PP,
// Initialize language-specific preprocessor defines.
// FIXME: Implement magic like cpp_init_builtins for things like __STDC__
// and __DATE__ etc.
// These should all be defined in the preprocessor according to the
// current language configuration.
if (!PP.getLangOptions().Microsoft)

View File

@ -1593,6 +1593,9 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
if (MemberDecl->isInvalidDecl())
return ExprError();
// Check if referencing a field with __attribute__((deprecated)).
DiagnoseUseOfDeprecatedDecl(MemberDecl, MemberLoc);
if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
// We may have found a field within an anonymous union or struct
// (C++ [class.union]).

View File

@ -32,3 +32,11 @@ int old_fn() {
return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
}
struct foo {
int x __attribute__((deprecated));
};
void test1(struct foo *F) {
++F->x; // expected-warning {{'x' is deprecated}}
}