diff mbox series

[C++] PR c++/92496 - ICE with <=> and no #include <compare>.

Message ID 20191213050518.29669-1-jason@redhat.com
State New
Headers show
Series [C++] PR c++/92496 - ICE with <=> and no #include <compare>. | expand

Commit Message

Jason Merrill Dec. 13, 2019, 5:05 a.m. UTC
Normal error-recovery.

Tested x86_64-pc-linux-gnu, applying to trunk.

	* typeck.c (cp_build_binary_op): Handle error from spaceship_type.
---
 gcc/cp/typeck.c                                   |  6 +++++-
 gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C | 12 ++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C


base-commit: 3dbaca45883c354c9d4e9542d5c95f054997f844
diff mbox series

Patch

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index d0f739895c9..d3814585e3f 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5418,7 +5418,11 @@  cp_build_binary_op (const op_location_t &location,
 	result_type = NULL_TREE;
 
       if (result_type)
-	build_type = spaceship_type (result_type, complain);
+	{
+	  build_type = spaceship_type (result_type, complain);
+	  if (build_type == error_mark_node)
+	    return error_mark_node;
+	}
 
       if (result_type && arithmetic_types_p)
 	{
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C
new file mode 100644
index 00000000000..45ce4ee047a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth-neg3.C
@@ -0,0 +1,12 @@ 
+// PR c++/92496
+// { dg-do compile { target c++2a } }
+
+template<auto V>
+struct A {};
+
+struct B {
+    constexpr auto operator<=>(const B&) const = default; // { dg-error "" }
+    int value;
+};
+
+A<B{}> t;