diff mbox

[C++14] implement [[deprecated]].

Message ID 52666F68.5080405@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland Oct. 22, 2013, 12:28 p.m. UTC
I think this is pretty easy - gnu::deprecated has the same semantics.

Bootstrapped and tested on x86_64-linux.

OK?
gcc/cp:

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

	* parser.c (cp_parser_std_attribute): Interpret [[deprecated]]
	as [[gnu::deprecated]].

gcc/testsuite:

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

	* g++.dg/cpp1y/attr-deprecated.C: New.
	* g++.dg/cpp1y/attr-deprecated-neg.C: New.

Comments

Paolo Carlini Oct. 22, 2013, 12:37 p.m. UTC | #1
On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
> I think this is pretty easy - gnu::deprecated has the same semantics.
Unfortunately however, gnu::deprecated has a number of long standing 
issues (just search Bugzilla), personally I'm not sure we want to say 
everybody that we have got [[deprecated]] implemented, until those are 
solved. Just my personal opinion.

Paolo.
Ed Smith-Rowland Oct. 22, 2013, 12:55 p.m. UTC | #2
On 10/22/2013 08:37 AM, Paolo Carlini wrote:
> On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
>> I think this is pretty easy - gnu::deprecated has the same semantics.
> Unfortunately however, gnu::deprecated has a number of long standing 
> issues (just search Bugzilla), personally I'm not sure we want to say 
> everybody that we have got [[deprecated]] implemented, until those are 
> solved. Just my personal opinion.
>
> Paolo.
>
I'll check bugzilla.  We'll hold...
Iain Sandoe Oct. 22, 2013, 1:07 p.m. UTC | #3
Hi Ed, Paolo,

On 22 Oct 2013, at 13:55, Ed Smith-Rowland wrote:

> On 10/22/2013 08:37 AM, Paolo Carlini wrote:
>> On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
>>> I think this is pretty easy - gnu::deprecated has the same semantics.
>> Unfortunately however, gnu::deprecated has a number of long standing issues (just search Bugzilla), personally I'm not sure we want to say everybody that we have got [[deprecated]] implemented, until those are solved. Just my personal opinion.
>> 

> I'll check bugzilla.  We'll hold…

Is PR17729 still the most significant? (there are related test-suite ones).

unfortunately, I still don't have time to address this - but perhaps someone could update the attempt I made before?

It would be nice to fix it and to add the associated "unavailable" error attribute ...

Iain
Paolo Carlini Oct. 22, 2013, 2:02 p.m. UTC | #4
Hi,

On 10/22/2013 03:07 PM, Iain Sandoe wrote:
> Is PR17729 still the most significant? (there are related test-suite ones).
For example, PR33911: still no warning for the line "goo<int> f2;" of 
the original testcase submitted by Benjamin. Funny that apparently 
current clang has the same issue; icc is fine. There is also PR40075, 
related to 17729. And more.

Paolo.
Jason Merrill Oct. 22, 2013, 4 p.m. UTC | #5
OK.

Jason
Ed Smith-Rowland Oct. 23, 2013, 1:45 a.m. UTC | #6
On 10/22/2013 12:00 PM, Jason Merrill wrote:
> OK.
>
> Jason
>
There is discussion about several bugs in gnu::deprecated upon which 
this is based over on the libstdc++ list.
I could see where we are with those bugs in a week or two.  Or just wait 
until they are fixed.
OTOH, I don't think my patch would change one way or the other.  I can't 
see a reason we'd want [[gnu::deprecated]] and [[deprecated]] to differ.
It's just that [[deprecated]] wouldn't quite work the way it should 
until the bugs are fixed.

What do you think?

Ed
Jason Merrill Oct. 23, 2013, 2:47 a.m. UTC | #7
I don't think this patch should be blocked on those bugs.

Jason
Paolo Carlini Oct. 23, 2013, 9:22 a.m. UTC | #8
On 10/23/2013 04:47 AM, Jason Merrill wrote:
> I don't think this patch should be blocked on those bugs.
Sure. My point essentially was that as a *GNU* thing we could still 
pretend to do whatever we wanted is corner cases, etc. As a Standard 
feature, those are really full blown bugs. Anyway, what *really* matters 
is that we do work on those ;)

Paolo.
Paolo Carlini Oct. 27, 2013, 9:17 a.m. UTC | #9
On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
> I think this is pretty easy - gnu::deprecated has the same semantics.
Since we decided to have this now, we should also update the docs, thus 
htdocs/projects/cxx1y.html (which normally would link 
htdocs/gcc-4.9/changes.html, thus a line or so there too).

Thanks!
Paolo.
Ed Smith-Rowland Nov. 9, 2013, 7:59 p.m. UTC | #10
On 10/27/2013 05:17 AM, Paolo Carlini wrote:
> On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
>> I think this is pretty easy - gnu::deprecated has the same semantics.
> Since we decided to have this now, we should also update the docs, 
> thus htdocs/projects/cxx1y.html (which normally would link 
> htdocs/gcc-4.9/changes.html, thus a line or so there too).
>
> Thanks!
> Paolo.
>

Here is a patch to the web pages for new C++14 front-end and library 
additions.
Check to see if you agree or if I left anything out.

OK?

Ed
Index: htdocs/projects/cxx1y.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<       <td><a href="http://isocpp.org/files/papers/n3760.htm">N3760</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html">N3760</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
118,119c119,121
<       <td><a href="http://isocpp.org/files/papers/N3781.pdf">N3781</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf">N3781</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
Index: htdocs/gcc-4.9/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,174
>     G++ supports the <a href="../projects/cxx1y.html">C++1y</a> [[deprecated]]
>     attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  Classes
>     and functions can be marked deprecated and 
> <blockquote><pre>
> </pre></blockquote>
>   <li>
> class A {};
> #if __cplusplus > 201103:
> class A [[deprecated("A is deprecated in C++14; Use B instead")]];
> class B {};
> #endif
>   </li>
>   <li>
> <blockquote><pre>
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10'0000;
>   int m = 0'004'000'000;
>   int n = 0b0001'0000'0000'0000'0000'0000;
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> </pre></blockquote>
>   </li>
158a183,205
>     <li><a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014">
>        Improved experimental support for the upcoming ISO C++ standard, C++14</a>,
>        including:
>       <ul>
>         <li> fixing <code>constexpr</code> member functions without <code>const</code>; </li>
>         <li> implementation of the <code>exchange()</code> utility function; </li>
>         <li> addressing tuples by type; </li>
>         <li> implemention of <code>make_unique</code>; </li>
>         <li> making <code>std::result_of</code> SFINAE-friendly; </li>
>         <li> adding <code>operator()</code> to <code>integral_constant</code>; </li>
>         <li> adding user-defined literals for standard library types
>              </code>string</code>, </code>chrono</code>, and </code>complex</code>; </li>
>         <li> adding two range overloads to non-modifying sequence oprations; </li>
>         <li> adding IO manipulators for quoted strings; </li>
>         <li> adding <code>constexpr</code> members to utilities, <code>complex</code>,
>              <code>chrono</code>, and some containers; </li>
>         <li> adding compile-time <code>integer_sequence</code>s; </li>
>         <li> adding cleaner transformation traits; </li>
>         <li> adding a class for <code>optional</code> types; </li>
>         <li> making <code>functional</code>s operator functors easier to use and
>              more generic; </li>
>       </ul>
>     </li>
Ed Smith-Rowland Nov. 9, 2013, 8:15 p.m. UTC | #11
On 10/27/2013 05:17 AM, Paolo Carlini wrote:
> On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
>> I think this is pretty easy - gnu::deprecated has the same semantics.
> Since we decided to have this now, we should also update the docs, 
> thus htdocs/projects/cxx1y.html (which normally would link 
> htdocs/gcc-4.9/changes.html, thus a line or so there too).
>
> Thanks!
> Paolo.
>
My last email had a bad patch.

Try this one.

OK?
Index: htdocs/projects/cxx1y.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<       <td><a href="http://isocpp.org/files/papers/n3760.htm">N3760</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html">N3760</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
118,119c119,121
<       <td><a href="http://isocpp.org/files/papers/N3781.pdf">N3781</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf">N3781</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
Index: htdocs/gcc-4.9/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,182
>     G++ supports the <a href="../projects/cxx1y.html">C++1y</a> [[deprecated]]
>     attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  Classes
>     and functions can be marked deprecated and 
> <blockquote><pre>
> </pre></blockquote>
>   <li>
> class A {};
> int bar(int n)
> { return 42 + n - 1; }
> #if __cplusplus > 201103:
> class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
> [[deprecated("bar is unsafe; use foo() instead")]]
> int bar(int n);
> 
> int foo(int n) { return 42 + n; }
> class B {};
> #endif
>   </li>
>   <li>
>     G++ supports <a href="../projects/cxx1y.html">C++1y</a> digit separators.
>     Long numeric literals can be subdivided with a single quote ' to enhance readability:
> <blockquote><pre>
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10'0000;
>   int m = 0'004'000'000;
>   int n = 0b0001'0000'0000'0000'0000'0000;
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> </pre></blockquote>
>   </li>
158a191,213
>     <li><a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014">
>        Improved experimental support for the upcoming ISO C++ standard, C++14</a>,
>        including:
>       <ul>
>         <li> fixing <code>constexpr</code> member functions without <code>const</code>; </li>
>         <li> implementation of the <code>exchange()</code> utility function; </li>
>         <li> addressing tuples by type; </li>
>         <li> implemention of <code>make_unique</code>; </li>
>         <li> making <code>std::result_of</code> SFINAE-friendly; </li>
>         <li> adding <code>operator()</code> to <code>integral_constant</code>; </li>
>         <li> adding user-defined literals for standard library types
>              </code>string</code>, </code>chrono</code>, and </code>complex</code>; </li>
>         <li> adding two range overloads to non-modifying sequence oprations; </li>
>         <li> adding IO manipulators for quoted strings; </li>
>         <li> adding <code>constexpr</code> members to utilities, <code>complex</code>,
>              <code>chrono</code>, and some containers; </li>
>         <li> adding compile-time <code>integer_sequence</code>s; </li>
>         <li> adding cleaner transformation traits; </li>
>         <li> adding a class for <code>optional</code> types; </li>
>         <li> making <code>functional</code>s operator functors easier to use and
>              more generic; </li>
>       </ul>
>     </li>
Paolo Carlini Nov. 9, 2013, 11:46 p.m. UTC | #12
On 11/09/2013 08:59 PM, Ed Smith-Rowland wrote:
> On 10/27/2013 05:17 AM, Paolo Carlini wrote:
>> On 10/22/2013 02:28 PM, Ed Smith-Rowland wrote:
>>> I think this is pretty easy - gnu::deprecated has the same semantics.
>> Since we decided to have this now, we should also update the docs, 
>> thus htdocs/projects/cxx1y.html (which normally would link 
>> htdocs/gcc-4.9/changes.html, thus a line or so there too).
>>
>> Thanks!
>> Paolo.
>>
> Here is a patch to the web pages for new C++14 front-end and library 
> additions.
Please send it to the library mailing list too.

Thanks,
Paolo.
Ed Smith-Rowland Nov. 10, 2013, 8:28 p.m. UTC | #13
On 11/10/2013 11:54 AM, Jonathan Wakely wrote:
> On 10 November 2013 16:52, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> I thought I'd already made similar changes to gcc-4.9/changes.html for
>> the C++14 changes but I never committed it.  The only comment I have
>> is that "chrono" isn't a type, but the change is fine as far as I'm
>> concerned, thanks.
> Oh, and optional isn't part of C++14.
Right. i guess there are interesting conversations to be had about how 
we document and flag all these TSs and constraints...
>    Here's what I had, although it
> doesn't mention all the changes:
>
> Index: changes.html
> ===================================================================
> RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
> retrieving revision 1.31
> diff -u -r1.31 changes.html
> --- changes.html        31 Oct 2013 18:03:28 -0000      1.31
> +++ changes.html        10 Nov 2013 16:53:19 -0000
> @@ -142,8 +142,20 @@
>
>     <ul>
>       <li><a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011">
> -       Improved support for C++11</a>, including support for &lt;regex&gt;.
> +       Improved support for C++11</a>, including support for
> <code>&lt;regex&gt;</code>.
>       </li>
> +    <li>Experimental support for most C++1y library features, including:
> +      <ul>
> +        <li>User-defined literals for strings, durations and complex
> numbers.</li>
> +        <li>Additional overloads for <code>std::equal</code>,
> <code>std::mismatch</code>
> +            and <code>std::is_permutation</code>.</li>
> +        <li><code>std::make_unique</code></li>
> +        <li><code>std::quoted</code></li>
> +        <li><code>std::shared_lock</code></li>
> +        <li><code>std::integer_sequence</code></li>
> +      </ul>
> +    </li>
> +    <li>An implementation of <code>std::experimental::optional</code>.</li>
>       <li>The non-standard function <code>std::copy_exception</code>
> has been deprecated
>           and will be removed in a future version.
> <code>std::make_exception_ptr</code>
>           should be used instead.
>

OK, I folded our versions together.  Thank you.  I also fixed up my code 
examples.

OK?

Ed
Index: htdocs/projects/cxx1y.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<       <td><a href="http://isocpp.org/files/papers/n3760.htm">N3760</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html">N3760</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
118,119c119,121
<       <td><a href="http://isocpp.org/files/papers/N3781.pdf">N3781</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf">N3781</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
Index: htdocs/gcc-4.9/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.32
diff -r1.32 changes.html
150a151,183
>   <li>
>     G++ supports the <a href="../projects/cxx1y.html">C++1y</a> [[deprecated]]
>     attribute modulo bugs in the underying [[gnu::deprecated]] attribute.  Classes
>     and functions can be marked deprecated and 
> <blockquote><pre>
> class A;
> int bar(int n);
> #if __cplusplus > 201103
> class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
> [[deprecated("bar is unsafe; use foo() instead")]]
> int bar(int n);
> 
> int foo(int n);
> class B;
> #endif
> A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
> int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use foo() instead
> </pre></blockquote>
>   </li>
>   <li>
>     G++ supports <a href="../projects/cxx1y.html">C++1y</a> digit separators.
>     Long numeric literals can be subdivided with a single quote ' to enhance readability:
> <blockquote><pre>
>   int i = 1048576;
>   int j = 1'048'576;
>   int k = 0x10'0000;
>   int m = 0'004'000'000;
>   int n = 0b0001'0000'0000'0000'0000'0000;
> 
>   double x = 1.602'176'565e-19;
>   double y = 1.602'176'565e-1'9;
> </pre></blockquote>
>   </li>
157c190
<        Improved support for C++11</a>, including support for &lt;regex&gt;.
---
>        Improved support for C++11</a>, including support for <code>&lt;regex&gt;</code>.
158a192,217
>     <li><a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014">
>        Improved experimental support for the upcoming ISO C++ standard, C++14</a>,
>        including:
>       <ul>
>         <li> fixing <code>constexpr</code> member functions without <code>const</code>; </li>
>         <li> implementation of the <code>std::exchange()</code> utility function; </li>
>         <li> addressing tuples by type; </li>
>         <li> implemention of <code>std::make_unique</code>; </li>
>         <li> implemention of <code>std::shared_lock</code>; </li>
>         <li> making <code>std::result_of</code> SFINAE-friendly; </li>
>         <li> adding <code>operator()</code> to <code>integral_constant</code>; </li>
>         <li> adding user-defined literals for standard library types
>              </code>std::basic_string</code>, </code>std::chrono::duration</code>,
>              and </code>std::complex</code>; </li>
>         <li> adding two range overloads to non-modifying sequence oprations
>              <code>std::equal</code> and <code>std::mismatch</code>; </li>
>         <li> adding IO manipulators for quoted strings; </li>
>         <li> adding <code>constexpr</code> members to <code>&lt;utility&gt;</code>,
>              <code>&lt;complex&gt;</code>, <code>&lt;chrono&gt;</code>, and some containers; </li>
>         <li> adding compile-time <code>std::integer_sequence</code>; </li>
>         <li> adding cleaner transformation traits; </li>
>         <li> making <code>&lt;functional&gt;</code>s operator functors easier to use
>              and more generic; </li>
>       </ul>
>     </li>
>     <li>An implementation of <code>std::experimental::optional</code>.</li>
Jonathan Wakely Nov. 10, 2013, 8:59 p.m. UTC | #14
On 10 November 2013 20:28, Ed Smith-Rowland wrote:
>
> OK, I folded our versions together.  Thank you.  I also fixed up my code
> examples.
>
> OK?

That looks good, thanks very much for updating it.
Ed Smith-Rowland Nov. 11, 2013, 2:41 a.m. UTC | #15
On 11/10/2013 03:59 PM, Jonathan Wakely wrote:
> On 10 November 2013 20:28, Ed Smith-Rowland wrote:
>> OK, I folded our versions together.  Thank you.  I also fixed up my code
>> examples.
>>
>> OK?
> That looks good, thanks very much for updating it.
>
OK, I got gcc-4.9/changes.html checked in (after some trouble).
Apparently I can't get projects/cxx1y.html checked in now.

Here is the patch.

Could someone else please check it and check it in?

Sorry.

Ed
Index: htdocs/projects/cxx1y.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/projects/cxx1y.html,v
retrieving revision 1.8
diff -r1.8 cxx1y.html
113,114c113,115
<       <td><a href="http://isocpp.org/files/papers/n3760.htm">N3760</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html">N3760</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
118,119c119,121
<       <td><a href="http://isocpp.org/files/papers/N3781.pdf">N3781</a></td>
<       <td class="unsupported" align="center">No</td>
---
>       <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf">N3781</a></td>
>       <td class="supported" align="center">
>         <a href="../gcc-4.9/changes.html#cxx">4.9</a> (N3797)</td>
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 203915)
+++ cp/parser.c	(working copy)
@@ -21426,6 +21443,9 @@ 
       /* 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: testsuite/g++.dg/cpp1y/attr-deprecated.C
===================================================================
--- testsuite/g++.dg/cpp1y/attr-deprecated.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/attr-deprecated.C	(working copy)
@@ -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" }
+}
Index: testsuite/g++.dg/cpp1y/attr-deprecated-neg.C
===================================================================
--- testsuite/g++.dg/cpp1y/attr-deprecated-neg.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/attr-deprecated-neg.C	(working copy)
@@ -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);
+}