Hi!

I'd like to ping following patch.  Thanks.

On Fri, Jan 10, 2020 at 09:28:20PM +0100, Jakub Jelinek wrote:
> 2020-01-10  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c++/93228
>       * parser.c (cp_parser_template_name): Look up deprecated attribute
>       in DECL_TEMPLATE_RESULT or its type's attributes.
> 
>       * g++.dg/cpp1y/attr-deprecated-3.C: New test.
> 
> --- gcc/cp/parser.c.jj        2020-01-10 17:52:48.084062620 +0100
> +++ gcc/cp/parser.c   2020-01-10 19:15:29.019861630 +0100
> @@ -16882,7 +16882,17 @@ cp_parser_template_name (cp_parser* pars
>      {
>        if (TREE_DEPRECATED (decl)
>         && deprecated_state != DEPRECATED_SUPPRESS)
> -     warn_deprecated_use (decl, NULL_TREE);
> +     {
> +       tree d = DECL_TEMPLATE_RESULT (decl);
> +       tree attr;
> +       if (TREE_CODE (d) == TYPE_DECL)
> +         attr = lookup_attribute ("deprecated",
> +                                  TYPE_ATTRIBUTES (TREE_TYPE (d)));
> +       else
> +         attr = lookup_attribute ("deprecated",
> +                                  DECL_ATTRIBUTES (d));
> +       warn_deprecated_use (decl, attr);
> +     }
>      }
>    else
>      {
> --- gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C.jj 2020-01-10 
> 19:20:44.165196267 +0100
> +++ gcc/testsuite/g++.dg/cpp1y/attr-deprecated-3.C    2020-01-10 
> 19:20:48.699129148 +0100
> @@ -0,0 +1,13 @@
> +// PR c++/93228
> +// { dg-do compile { target c++14 } }
> +
> +template <typename T>
> +struct [[deprecated("foo")]] bar {}; // { dg-message "declared here" }
> +struct [[deprecated("baz")]] qux {};         // { dg-message "declared here" 
> }
> +
> +void
> +quux ()
> +{
> +  bar<int> b;        // { dg-warning "is deprecated: foo" }
> +  qux c;     // { dg-warning "is deprecated: baz" }
> +}
> 

        Jakub

Reply via email to