gcc/cp:
authoremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Oct 2013 11:43:25 +0000 (11:43 +0000)
committeremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Oct 2013 11:43:25 +0000 (11:43 +0000)
2013-10-23  Edward Smith-Rowland  <3dw4rd@verizon.net>

Implement C++14 [[deprecated]] modulo [[gnu::deprecated]] bugs.
* parser.c (cp_parser_std_attribute): Interpret [[deprecated]]
as [[gnu::deprecated]].

gcc/testsuite:

2013-10-23  Edward Smith-Rowland  <3dw4rd@verizon.net>

Implement C++14 [[deprecated]] modulo [[gnu::deprecated]] bugs.
* g++.dg/cpp1y/attr-deprecated.C: New.
* g++.dg/cpp1y/attr-deprecated-neg.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203955 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C [new file with mode: 0644]

index 50ec68d..c17e19d 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-23  Edward Smith-Rowland  <3dw4rd@verizon.net>
+
+       Implement C++14 [[deprecated]] modulo [[gnu::deprecated]] bugs.
+       * parser.c (cp_parser_std_attribute): Interpret [[deprecated]]
+       as [[gnu::deprecated]].
+
 2013-10-22  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58816
index 10a7b96..c5d19a4 100644 (file)
@@ -21426,6 +21426,9 @@ cp_parser_std_attribute (cp_parser *parser)
       /* C++11 noreturn attribute is equivalent to GNU's.  */
       if (is_attribute_p ("noreturn", attr_id))
        TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
+      /* C++14 deprecated attribute is equivalent to GNU's.  */
+      else if (cxx_dialect >= cxx1y && is_attribute_p ("deprecated", attr_id))
+       TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu");
     }
 
   /* Now parse the optional argument clause of the attribute.  */
index 28a379e..f71e314 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-23  Edward Smith-Rowland  <3dw4rd@verizon.net>
+
+       Implement C++14 [[deprecated]] modulo [[gnu::deprecated]] bugs.
+       * g++.dg/cpp1y/attr-deprecated.C: New.
+       * g++.dg/cpp1y/attr-deprecated-neg.C: New.
+
 2013-10-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/58793
diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-neg.C
new file mode 100644 (file)
index 0000000..b2f0e12
--- /dev/null
@@ -0,0 +1,59 @@
+// { dg-do compile }
+// { dg-options -std=c++11 }
+
+class [[deprecated]] A // { dg-warning "attribute directive ignored" }
+{
+};
+
+[[deprecated]]
+int
+foo(int n) // { dg-warning "attribute directive ignored" }
+{
+  return 42 + n;
+}
+
+class [[deprecated("B has been superceded by C")]] B // { dg-warning "attribute directive ignored" }
+{
+};
+
+[[deprecated("bar is unsafe; use foobar instead")]]
+int
+bar(int n) // { dg-warning "attribute directive ignored" }
+{
+  return 42 + n - 1;
+}
+
+#if __cplusplus > 201103L
+
+//  Deprecate C for C++14 onwards.
+class [[deprecated]] C;
+
+//  Deprecate foobar for C++14 onwards.
+[[deprecated]]
+int
+foobar(int n);
+
+#endif
+
+class C
+{
+};
+
+int
+foobar(int n)
+{
+  return 43 + n - 1;
+}
+
+int
+main()
+{
+  A aaa;
+  int n = foo(12);
+
+  B bbb;
+  int m = bar(666);
+
+  C ccc;
+  int l = foobar(8);
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated.C
new file mode 100644 (file)
index 0000000..8cd09c7
--- /dev/null
@@ -0,0 +1,59 @@
+// { dg-do compile }
+// { dg-options -std=c++1y }
+
+class [[deprecated]] A
+{
+};
+
+[[deprecated]]
+int
+foo(int n)
+{
+  return 42 + n;
+}
+
+class [[deprecated("B has been superceded by C")]] B
+{
+};
+
+[[deprecated("bar is unsafe; use foobar instead")]]
+int
+bar(int n)
+{
+  return 42 + n - 1;
+}
+
+#if __cplusplus > 201103L
+
+//  Deprecate C for C++14 onwards.
+class [[deprecated]] C;
+
+//  Deprecate foobar for C++14 onwards.
+[[deprecated]]
+int
+foobar(int n);
+
+#endif
+
+class C
+{
+};
+
+int
+foobar(int n)
+{
+  return 43 + n - 1;
+}
+
+int
+main()
+{
+  A aaa; // { dg-warning "is deprecated" }
+  int n = foo(12); // { dg-warning "is deprecated" }
+
+  B bbb; // { dg-warning "is deprecated" "B has been superceded by C" }
+  int m = bar(666); // { dg-warning "is deprecated" "bar is unsafe; use foobar instead" }
+
+  C ccc; // { dg-warning "is deprecated" }
+  int l = foobar(8); // { dg-warning "is deprecated" }
+}