diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-02-16 17:07:21 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-02-16 17:07:21 +0000 |
| commit | ee4b5235e3e92e52fca65cd8578e5850293c15e9 (patch) | |
| tree | edca571a90bceb87154f1fbddfaf110c1d407752 | |
| parent | 73b85e30edefc5443c9c9a8a7115b97729fbef38 (diff) | |
| download | bcm5719-llvm-ee4b5235e3e92e52fca65cd8578e5850293c15e9.tar.gz bcm5719-llvm-ee4b5235e3e92e52fca65cd8578e5850293c15e9.zip | |
Add support for deprecated members of RecordDecls (e.g. struct fields).
llvm-svn: 64634
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Sema/attr-deprecated.c | 8 |
3 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index cf7306a41cc..772427b6ae5 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -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) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 60a1bea2f47..66f33c1ea24 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1592,6 +1592,9 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // error cases. 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 diff --git a/clang/test/Sema/attr-deprecated.c b/clang/test/Sema/attr-deprecated.c index ada06f01e5e..f4ec0bc278e 100644 --- a/clang/test/Sema/attr-deprecated.c +++ b/clang/test/Sema/attr-deprecated.c @@ -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}} +} |

