[cfe-commits] r64634 - in /cfe/trunk: lib/Lex/Preprocessor.cpp lib/Sema/SemaExpr.cpp test/Sema/attr-deprecated.c

Chris Lattner sabre at nondot.org
Mon Feb 16 09:07:21 PST 2009


Author: lattner
Date: Mon Feb 16 11:07:21 2009
New Revision: 64634

URL: http://llvm.org/viewvc/llvm-project?rev=64634&view=rev
Log:
Add support for deprecated members of RecordDecls (e.g. struct fields).

Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/attr-deprecated.c

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=64634&r1=64633&r2=64634&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Feb 16 11:07:21 2009
@@ -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)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=64634&r1=64633&r2=64634&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 16 11:07:21 2009
@@ -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

Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=64634&r1=64633&r2=64634&view=diff

==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Mon Feb 16 11:07:21 2009
@@ -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}}
+}





More information about the cfe-commits mailing list