public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1688] c++: non-dependent call to consteval operator [PR105912] Date: Wed, 13 Jul 2022 18:03:56 +0000 (GMT) [thread overview] Message-ID: <20220713180356.9AF53382C144@sourceware.org> (raw) https://gcc.gnu.org/g:f70c18524221dcefa6cd26cee7b55503181bd912 commit r13-1688-gf70c18524221dcefa6cd26cee7b55503181bd912 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Jul 13 14:02:08 2022 -0400 c++: non-dependent call to consteval operator [PR105912] Here we're crashing when substituting a non-dependent call to a consteval operator, whose CALL_EXPR_OPERATOR_SYNTAX flag we try to propagate to the result, but the result isn't a CALL_EXPR since the selected function is consteval. This patch fixes this by checking the result of extract_call_expr accordingly. (Note that we can't check DECL_IMMEDIATE_FUNCTION_P here because we don't know which function was selected by overload resolution from here.) PR c++/105912 gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Guard against NULL_TREE extract_call_expr result. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/consteval31.C: New test. Diff: --- gcc/cp/pt.cc | 12 ++++++------ gcc/testsuite/g++.dg/cpp2a/consteval31.C | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index da00ce1301a..718dfa5bfa8 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -21206,12 +21206,12 @@ tsubst_copy_and_build (tree t, bool ord = CALL_EXPR_ORDERED_ARGS (t); bool rev = CALL_EXPR_REVERSE_ARGS (t); if (op || ord || rev) - { - function = extract_call_expr (ret); - CALL_EXPR_OPERATOR_SYNTAX (function) = op; - CALL_EXPR_ORDERED_ARGS (function) = ord; - CALL_EXPR_REVERSE_ARGS (function) = rev; - } + if (tree call = extract_call_expr (ret)) + { + CALL_EXPR_OPERATOR_SYNTAX (call) = op; + CALL_EXPR_ORDERED_ARGS (call) = ord; + CALL_EXPR_REVERSE_ARGS (call) = rev; + } } RETURN (ret); diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval31.C b/gcc/testsuite/g++.dg/cpp2a/consteval31.C new file mode 100644 index 00000000000..85a4d1794e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/consteval31.C @@ -0,0 +1,26 @@ +// PR c++/105912 +// { dg-do compile { target c++20 } } + +struct A { + consteval A operator+() { + return {}; + } +}; + +consteval A operator~(A) { + return {}; +} + +consteval A operator+(A, A) { + return {}; +} + +template<class> +void f() { + A a; + ~a; + a + a; + +a; +} + +template void f<int>();
reply other threads:[~2022-07-13 18:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220713180356.9AF53382C144@sourceware.org \ --to=ppalka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).