aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-12-10 15:06:58 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-12-10 15:06:58 -0500
commit1fb81d83a8857770be56df19c8a3b4e0ca87c71c (patch)
treeda7f04f9668a4910c244b85aa5d318ca5fb9ff1f
parent42aed35797ad46c1c98fcddf6a29ecb45b45ea9d (diff)
downloadgcc-1fb81d83a8857770be56df19c8a3b4e0ca87c71c.zip
gcc-1fb81d83a8857770be56df19c8a3b4e0ca87c71c.tar.gz
gcc-1fb81d83a8857770be56df19c8a3b4e0ca87c71c.tar.bz2
PR c++/92560 - ICE with decltype and rewritten operator.
A call as the immediate operand of decltype is handled differently; we don't create an object of the return type as we do normally. But in the case of a rewritten operator, we're adding another call as a wrapper, so the inner call doesn't get the special handling. * call.c (build_new_op_1): Clear tf_decltype on inner call. From-SVN: r279183
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/spaceship-decltype1.C11
3 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5140787..b640e15 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/92560 - ICE with decltype and rewritten operator.
+ * call.c (build_new_op_1): Clear tf_decltype on inner call.
+
2019-12-09 David Malcolm <dmalcolm@redhat.com>
* error.c (range_label_for_type_mismatch::get_text): Replace
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ce94297..48d49b7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6242,6 +6242,10 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags,
result = error_mark_node;
else
{
+ tsubst_flags_t ocomplain = complain;
+ if (cand->rewritten ())
+ /* We'll wrap this call in another one. */
+ ocomplain &= ~tf_decltype;
if (cand->reversed ())
{
/* We swapped these in add_candidate, swap them back now. */
@@ -6251,7 +6255,7 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags,
"current function recursively with reversed "
"arguments");
}
- result = build_over_call (cand, LOOKUP_NORMAL, complain);
+ result = build_over_call (cand, LOOKUP_NORMAL, ocomplain);
}
if (trivial_fn_p (cand->fn))
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-decltype1.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-decltype1.C
new file mode 100644
index 0000000..bc673b2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-decltype1.C
@@ -0,0 +1,11 @@
+// PR c++/92560
+// { dg-do compile { target c++2a } }
+
+#include <compare>
+
+struct X
+{
+ friend std::strong_ordering operator<=>(X, X);
+} x;
+
+using T = decltype(x < x);