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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64634 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index cf7306a..772427b 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -462,8 +462,6 @@
   
   // 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/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 60a1bea..66f33c1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1592,6 +1592,9 @@
     // 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/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index ada06f0..f4ec0bc 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -32,3 +32,11 @@
   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}}
+}