public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [pushed] c++: auto function as function argument [PR105779]
Date: Thu, 30 Jun 2022 17:06:47 -0400	[thread overview]
Message-ID: <CAMOnLZaJqULrkgXiYF3Fyxk863iNebbK86bNRfdbBa1BNtYQdg@mail.gmail.com> (raw)
In-Reply-To: <20220601192038.1778324-1-jason@redhat.com>

On Wed, Jun 1, 2022 at 3:21 PM Jason Merrill via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This testcase demonstrates that the issue in PR105623 is not limited to
> templates, so we should do the marking in a less template-specific place.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
>
>         PR c++/105779
>
> gcc/cp/ChangeLog:
>
>         * call.cc (resolve_args): Call mark_single_function here.
>         * pt.cc (unify_one_argument): Not here.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.dg/cpp1y/auto-fn63.C: New test.
> ---
>  gcc/cp/call.cc                         |  5 +++++
>  gcc/cp/pt.cc                           |  4 ----
>  gcc/testsuite/g++.dg/cpp1y/auto-fn63.C | 12 ++++++++++++
>  3 files changed, 17 insertions(+), 4 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/cpp1y/auto-fn63.C
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index 85fe9b5ab85..4710c3777c5 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -4672,6 +4672,11 @@ resolve_args (vec<tree, va_gc> *args, tsubst_flags_t complain)
>         }
>        else if (invalid_nonstatic_memfn_p (EXPR_LOCATION (arg), arg, complain))
>         return NULL;
> +
> +      /* Force auto deduction now.  Omit tf_warning to avoid redundant
> +        deprecated warning on deprecated-14.C.  */
> +      if (!mark_single_function (arg, tf_error))

I wonder why pass tf_error here instead of an appropriately masked 'complain'?


> +       return NULL;
>      }
>    return args;
>  }
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 4f0ace2644b..6de8e496859 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -22624,10 +22624,6 @@ unify_one_argument (tree tparms, tree targs, tree parm, tree arg,
>               return unify_success (explain_p);
>             }
>
> -         /* Force auto deduction now.  Use tf_none to avoid redundant
> -            deprecated warning on deprecated-14.C.  */
> -         mark_single_function (arg, tf_none);
> -
>           arg_expr = arg;
>           arg = unlowered_expr_type (arg);
>           if (arg == error_mark_node)
> diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C
> new file mode 100644
> index 00000000000..ca3bc854065
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn63.C
> @@ -0,0 +1,12 @@
> +// PR c++/105779
> +// { dg-do compile { target c++14 } }
> +
> +template<int>
> +struct struct1
> +{
> +  static auto apply() { return 1; }
> +};
> +
> +int method(int(*f)());
> +
> +int t = method(struct1<1>::apply);
>
> base-commit: ae54c1b09963779c5c3914782324ff48af32e2f1
> --
> 2.27.0
>


  reply	other threads:[~2022-06-30 21:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01 19:20 Jason Merrill
2022-06-30 21:06 ` Patrick Palka [this message]
2022-07-01 14:55   ` [pushed] c++: tweak resolve_args change Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMOnLZaJqULrkgXiYF3Fyxk863iNebbK86bNRfdbBa1BNtYQdg@mail.gmail.com \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).