On Mon, Dec 12, 2016 at 01:09:16PM +0100, Marek Polacek wrote:
> Yeah, given
> expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr);
> in build_va_arg it seems it'll always be a pointer, so the following is

Well, if you think it is guaranteed it always is a pointer, then you could
just gcc_{,checking_}assert it there.
The code will fail an assertion anyway if it is not a pointer type, because
then have_va_type will be still NULL and thus
  gcc_assert (have_va_type != NULL_TREE);
will ICE, so I bet it really doesn't matter if you write it as:
  if (have_va_type == NULL_TREE)
    {
      gcc_assert (POINTER_TYPE_P (TREE_TYPE (valist)));
      have_va_type
        = targetm.canonical_va_list_type (TREE_TYPE (TREE_TYPE (valist)));
    }
  gcc_assert (have_va_type != NULL_TREE);
or as you wrote it.

So your patch LGTM.

> Bootstrap/regtest running on x86_64-linux, ok for trunk if it passes?
> 
> 2016-12-12  Marek Polacek  <pola...@redhat.com>
> 
>       PR middle-end/78716
>       * gimplify.c (gimplify_va_arg_expr): Don't require ADDR_EXPR for
>       Case 1; check POINTER_TYPE_P instead.
> 
>       * g++.dg/other/vararg-5.C: New.

        Jakub

Reply via email to