[C++ Patch] Consistently use OVL_P
Marek Polacek
polacek@redhat.com
Tue May 14 21:27:00 GMT 2019
On Tue, May 14, 2019 at 11:20:16PM +0200, Paolo Carlini wrote:
> Hi again,
>
> On 14/05/19 21:21, Paolo Carlini wrote:
> > Hi,
> >
> > On 14/05/19 21:05, Marek Polacek wrote:
> > > On Tue, May 14, 2019 at 03:01:35PM -0400, Nathan Sidwell wrote:
> > > > On 5/14/19 11:28 AM, Paolo Carlini wrote:
> > > >
> > > > > another straightforward one sitting in my tree... Sanity checked on
> > > > > x86_64-linux.
> > > > I suspect many/all of the TREE_CODE (x) == TEMPLATE_DECL
> > > > (or DECL_FUNCTION_TEMPLATE_P) could also be elided -- we don't
> > > > have naked
> > > > function templates at that point, they're always wrapped in overloads.
> > > > Could you see if that's true?
> > > That's what I pointed out here
> > > <https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00718.html>
> > > but I thought it might be better to do it as a follow-up.
> >
> > Yeah, on the other hand, we can as well sort out this now: after all, I
> > like to spend time on this kind of work also in the hope that little
> > buglets or issues will then become more evident. Thus, I'm removing all
> > those checks for TEMPLATE_DECL and DECL_FUNCTION_TEMPLATE_P, let's see
> > what regression testing tells us. To be clear: I'm leaving
> > TEMPLATE_ID_EXPR (two of those) alone.
>
> ... so the below passes testing on x86_64-linux. In fact, I think we are on
> a pretty safe ground, now at the beginning of Stage 1: if, over the next
> months we get a testcase which causes one of the 4 tightened gcc_assert to
> trip we'll comfortably deal with it.
Nice!
Just nits:
> Index: call.c
> ===================================================================
> --- call.c (revision 271166)
> +++ call.c (working copy)
> @@ -4383,9 +4383,7 @@ perform_overload_resolution (tree fn,
> *any_viable_p = true;
>
> /* Check FN. */
> - gcc_assert (TREE_CODE (fn) == FUNCTION_DECL
> - || TREE_CODE (fn) == TEMPLATE_DECL
> - || TREE_CODE (fn) == OVERLOAD
> + gcc_assert (OVL_P (fn)
> || TREE_CODE (fn) == TEMPLATE_ID_EXPR);
This can now fit on one line.
> Index: parser.c
> ===================================================================
> --- parser.c (revision 271166)
> +++ parser.c (working copy)
> @@ -16479,10 +16479,8 @@ cp_parser_template_id (cp_parser *parser,
> {
> /* If it's not a class-template or a template-template, it should be
> a function-template. */
> - gcc_assert ((DECL_FUNCTION_TEMPLATE_P (templ)
> - || TREE_CODE (templ) == OVERLOAD
> - || TREE_CODE (templ) == FUNCTION_DECL
> - || BASELINK_P (templ)));
> + gcc_assert (OVL_P (templ)
> + || BASELINK_P (templ));
Likewise.
> Index: search.c
> ===================================================================
> --- search.c (revision 271166)
> +++ search.c (working copy)
> @@ -1058,10 +1058,8 @@ build_baselink (tree binfo, tree access_binfo, tre
> {
> tree baselink;
>
> - gcc_assert (TREE_CODE (functions) == FUNCTION_DECL
> - || TREE_CODE (functions) == TEMPLATE_DECL
> - || TREE_CODE (functions) == TEMPLATE_ID_EXPR
> - || TREE_CODE (functions) == OVERLOAD);
> + gcc_assert (OVL_P (functions)
> + || TREE_CODE (functions) == TEMPLATE_ID_EXPR);
Likewise.
Marek
More information about the Gcc-patches
mailing list