r191550 - Implement N3760, support for the [[deprecated]] attribute.

Chandler Carruth chandlerc at gmail.com
Fri Sep 27 13:20:17 PDT 2013


Author: chandlerc
Date: Fri Sep 27 15:20:17 2013
New Revision: 191550

URL: http://llvm.org/viewvc/llvm-project?rev=191550&view=rev
Log:
Implement N3760, support for the [[deprecated]] attribute.

This motion appears to have consensus in the C++ committee and is
expected to be voted into the C++14 draft tomorrow during the formal
vote.

No extension warning in C++11 as attributes not specified in the
standard using the standard syntax in C++11 have implementation defined
meaning, and we define the meaning proposed for C++14.

There is one bug exposed as we do not warn on a deprecated template
specialization. I've left a FIXME in the test case and will dig into
that next.

Also, I will add a few more exhaustive test cases of the other features
specified for this attribute in a follow-up commit.

Added:
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/
    cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
Modified:
    cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=191550&r1=191549&r2=191550&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Sep 27 15:20:17 2013
@@ -351,7 +351,8 @@ def OpenCLImageAccess : Attr {
 }
 
 def Deprecated : InheritableAttr {
-  let Spellings = [GNU<"deprecated">, CXX11<"gnu", "deprecated">];
+  let Spellings = [GNU<"deprecated">,
+                   CXX11<"gnu", "deprecated">, CXX11<"","deprecated">];
   let Args = [StringArgument<"Message", 1>];
 }
 

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp?rev=191550&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp Fri Sep 27 15:20:17 2013
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++1y -verify %s
+
+class [[deprecated]] C {}; // expected-note {{declared here}}
+C c; // expected-warning {{'C' is deprecated}}
+
+typedef int t [[deprecated]]; // expected-note {{declared here}}
+t x = 42; // expected-warning {{'t' is deprecated}}
+
+[[deprecated]] int old = 42; // expected-note {{declared here}}
+int use = old; // expected-warning {{'old' is deprecated}}
+
+struct S { [[deprecated]] int member = 42; } s; // expected-note {{declared here}}
+int use2 = s.member; // expected-warning {{'member' is deprecated}}
+
+[[deprecated]] int f() { return 42; } // expected-note {{declared here}}
+int use3 = f(); // expected-warning {{'f' is deprecated}}
+
+enum [[deprecated]] e { E }; // expected-note {{declared here}}
+e my_enum; // expected-warning {{'e' is deprecated}}
+
+template <typename T> class X {};
+template <> class [[deprecated]] X<int> {};
+X<char> x1;
+X<int> x2; // FIXME: no warning!
+
+template <typename T> class [[deprecated]] X2 {};
+template <> class X2<int> {};
+X2<char> x3; // FIXME: no warning!
+X2<int> x4;





More information about the cfe-commits mailing list