aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@gcc.gnu.org>2019-08-24 22:44:06 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-08-24 22:44:06 +0000
commit6dfc1e1f33a0b9cdbff194e02b94b8a1a69d1425 (patch)
treea00e2140d0f6090f3530745ca1f8900ad0ec8b11
parente68a35ae4a65d2b3f42b22e6920a7a29f5727b3f (diff)
downloadgcc-6dfc1e1f33a0b9cdbff194e02b94b8a1a69d1425.zip
gcc-6dfc1e1f33a0b9cdbff194e02b94b8a1a69d1425.tar.gz
gcc-6dfc1e1f33a0b9cdbff194e02b94b8a1a69d1425.tar.bz2
[C++ PATCH] vfunc overrider simplification
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01674.html cp/ * class.c (check_for_overrides): Conversion operators need checking too. testsuite/ * g++.dg/inherit/virtual14.C: New. From-SVN: r274903
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/class.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/inherit/virtual14.C24
4 files changed, 41 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d0a8c77..013de12 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,13 +1,18 @@
+2019-08-24 Nathan Sidwell <nathan@acm.org>
+
+ * class.c (check_for_overrides): Conversion operators need
+ checking too.
+
2019-08-24 Paolo Carlini <paolo.carlini@oracle.com>
* semantics.c (finish_switch_cond): Improve error message location.
-2019-08-22 Jason Merrill <jason@redhat.com>
+2019-08-23 Jason Merrill <jason@redhat.com>
* decl2.c (decl_dependent_p): New.
(mark_used): Check it instead of just processing_template_decl.
-2019-08-22 Jason Merrill <jason@redhat.com>
+2019-08-23 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
error.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 99332f4..47350c2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2817,10 +2817,12 @@ check_for_override (tree decl, tree ctype)
return;
/* IDENTIFIER_VIRTUAL_P indicates whether the name has ever been
- used for a vfunc. That avoids the expensive
- look_for_overrides call that when we know there's nothing to
- find. */
- if (IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
+ used for a vfunc. That avoids the expensive look_for_overrides
+ call that when we know there's nothing to find. As conversion
+ operators for the same type can have distinct identifiers, we
+ cannot optimize those in that way. */
+ if ((IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
+ || DECL_CONV_FN_P (decl))
&& look_for_overrides (ctype, decl)
/* Check staticness after we've checked if we 'override'. */
&& !DECL_STATIC_FUNCTION_P (decl))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index efb0157..08e48c3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-24 Nathan Sidwell <nathan@acm.org>
+
+ * g++.dg/inherit/virtual14.C: New.
+
2019-08-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/91390
diff --git a/gcc/testsuite/g++.dg/inherit/virtual14.C b/gcc/testsuite/g++.dg/inherit/virtual14.C
new file mode 100644
index 0000000..17aabf3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/virtual14.C
@@ -0,0 +1,24 @@
+// { dg-do run }
+
+struct base
+{
+ virtual operator int () { return 0;}
+};
+
+typedef int q;
+
+struct d : base
+{
+ operator q () { return 1; }
+};
+
+int invoke (base *d)
+{
+ return int (*d);
+}
+
+int main ()
+{
+ d d;
+ return !(invoke (&d) == 1);
+}