aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-05-06 23:36:31 +0200
committerJakub Jelinek <jakub@redhat.com>2020-05-06 23:36:31 +0200
commit25ee2155ead87a5ea1c152a29341ee1e3275d706 (patch)
tree13883e8b157af22e2ba0e308c9793a746035e25b /gcc
parent72a54e5e8157508c87594d1a6b53de90b76524ce (diff)
downloadgcc-25ee2155ead87a5ea1c152a29341ee1e3275d706.zip
gcc-25ee2155ead87a5ea1c152a29341ee1e3275d706.tar.gz
gcc-25ee2155ead87a5ea1c152a29341ee1e3275d706.tar.bz2
c++: Don't synthesize sfk_comparison method multiple times [PR94907]
On the following testcase we ICE, because synthesize_method is called twice on the same sfk_comparison method fndecl, the first time it works fine because start_preparsed_function in that case sets both current_function_decl and cfun, but second time it is called it only sets the former and keeps cfun NULL, so we ICE when trying to store current_function_returns_value. I think it is just wrong to call synthesize_method multiple times, and most synthesize_method callers avoid that by not calling it if DECL_INITIAL is already set, so this patch does that too. 2020-05-06 Jakub Jelinek <jakub@redhat.com> PR c++/94907 * method.c (defaulted_late_check): Don't call synthesize_method on constexpr sfk_comparison if it has been called on it already. * g++.dg/cpp2a/spaceship-synth8.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/method.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/spaceship-synth8.C12
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7e41433..32bb9f5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/94907
+ * method.c (defaulted_late_check): Don't call synthesize_method
+ on constexpr sfk_comparison if it has been called on it already.
+
2020-05-06 Nathan Sidwell <nathan@acm.org>
PR c++/94946
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index fb2dd47..47f96aa 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -2939,7 +2939,7 @@ defaulted_late_check (tree fn)
{
/* If the function was declared constexpr, check that the definition
qualifies. Otherwise we can define the function lazily. */
- if (DECL_DECLARED_CONSTEXPR_P (fn))
+ if (DECL_DECLARED_CONSTEXPR_P (fn) && !DECL_INITIAL (fn))
synthesize_method (fn);
return;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6aa4378..a2c0e85 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/94907
+ * g++.dg/cpp2a/spaceship-synth8.C: New test.
+
2020-05-06 qing zhao <qing.zhao@oracle.com>
PR c/94230
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth8.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth8.C
new file mode 100644
index 0000000..d0d68c7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth8.C
@@ -0,0 +1,12 @@
+// PR c++/94907
+// { dg-do compile { target c++2a } }
+
+namespace std { struct strong_ordering { }; }
+
+struct E;
+struct D {
+ virtual std::strong_ordering operator<=>(const struct E&) const = 0;
+};
+struct E : D {
+ std::strong_ordering operator<=>(const E&) const override = default;
+};