Commit 6dfc1e1f by Nathan Sidwell

[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
parent e68a35ae
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> 2019-08-24 Paolo Carlini <paolo.carlini@oracle.com>
* semantics.c (finish_switch_cond): Improve error message location. * 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. * decl2.c (decl_dependent_p): New.
(mark_used): Check it instead of just processing_template_decl. (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 * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
error. error.
......
...@@ -2817,10 +2817,12 @@ check_for_override (tree decl, tree ctype) ...@@ -2817,10 +2817,12 @@ check_for_override (tree decl, tree ctype)
return; return;
/* IDENTIFIER_VIRTUAL_P indicates whether the name has ever been /* IDENTIFIER_VIRTUAL_P indicates whether the name has ever been
used for a vfunc. That avoids the expensive used for a vfunc. That avoids the expensive look_for_overrides
look_for_overrides call that when we know there's nothing to call that when we know there's nothing to find. As conversion
find. */ operators for the same type can have distinct identifiers, we
if (IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) cannot optimize those in that way. */
if ((IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
|| DECL_CONV_FN_P (decl))
&& look_for_overrides (ctype, decl) && look_for_overrides (ctype, decl)
/* Check staticness after we've checked if we 'override'. */ /* Check staticness after we've checked if we 'override'. */
&& !DECL_STATIC_FUNCTION_P (decl)) && !DECL_STATIC_FUNCTION_P (decl))
......
2019-08-24 Nathan Sidwell <nathan@acm.org>
* g++.dg/inherit/virtual14.C: New.
2019-08-24 Thomas Koenig <tkoenig@gcc.gnu.org> 2019-08-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/91390 PR fortran/91390
......
// { 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment