[gcc(refs/vendors/redhat/heads/gcc-10-branch)] c++: Fix consteval operator handling.
Jakub Jelinek
jakub@gcc.gnu.org
Thu Jul 23 09:19:47 GMT 2020
https://gcc.gnu.org/g:9014cb7c1695707740507c1671b90961e069d4a9
commit 9014cb7c1695707740507c1671b90961e069d4a9
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 8a72fbd0408..07d1215c560 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6307,7 +6307,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();
+}
More information about the Gcc-cvs
mailing list