]> granicus.if.org Git - clang/commitdiff
Add support for deprecated members of RecordDecls (e.g. struct fields).
authorChris Lattner <sabre@nondot.org>
Mon, 16 Feb 2009 17:07:21 +0000 (17:07 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 16 Feb 2009 17:07:21 +0000 (17:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64634 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Preprocessor.cpp
lib/Sema/SemaExpr.cpp
test/Sema/attr-deprecated.c

index cf7306a41cc9b612396d3288cde8a6cd15975aed..772427b6ae55490b99bdbfeefdba93074c61e4d1 100644 (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)
index 60a1bea2f47cc5f8e40dc17d318c0eccefb472db..66f33c1ea2403f1a31f4d8ed608634fe633544c2 100644 (file)
@@ -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
index ada06f01e5e8a82e8455ee0de2005a3cf75c4e45..f4ec0bc278e5e1f8667d169b59bdb0a9c91f1ea4 100644 (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}}
+}