public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Giuliano Belinassi <giulianob@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/autopar_devel] c++: Fix consteval operator handling.
Date: Sat, 22 Aug 2020 22:45:29 +0000 (GMT)	[thread overview]
Message-ID: <20200822224529.AAB773987423@sourceware.org> (raw)

https://gcc.gnu.org/g:8b8adcfb55fdefaddeb65dd23bc22acd5d9b3214

commit 8b8adcfb55fdefaddeb65dd23bc22acd5d9b3214
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jun 16 00:19:53 2020 -0400

    c++: Fix consteval operator handling.
    
    We were crashing trying to find the CALL_EXPR in the result of a call to a
    consteval operator.
    
    gcc/cp/ChangeLog:
    
            * call.c (build_new_op_1): Don't look for a CALL_EXPR when
            calling a consteval function.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/consteval17.C: New test.

Diff:
---
 gcc/cp/call.c                            |  2 +-
 gcc/testsuite/g++.dg/cpp2a/consteval17.C | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1d95bd2d07b..5382b7620dc 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6341,7 +6341,7 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags,
 	      result = build_over_call (cand, LOOKUP_NORMAL, ocomplain);
 	    }
 
-	  if (trivial_fn_p (cand->fn))
+	  if (trivial_fn_p (cand->fn) || DECL_IMMEDIATE_FUNCTION_P (cand->fn))
 	    /* There won't be a CALL_EXPR.  */;
 	  else if (result && result != error_mark_node)
 	    {
diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval17.C b/gcc/testsuite/g++.dg/cpp2a/consteval17.C
new file mode 100644
index 00000000000..6af39aad8da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/consteval17.C
@@ -0,0 +1,11 @@
+// { dg-do compile { target c++20 } }
+
+struct A
+{
+  consteval int operator+() { return 42; }
+};
+
+int main()
+{
+  +A();
+}


                 reply	other threads:[~2020-08-22 22:45 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=20200822224529.AAB773987423@sourceware.org \
    --to=giulianob@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: 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).