This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix diagnostic printing of COMPONENT_REF with ARROW_EXPR first operand (PR c++/79304)


OK.

On Tue, Jan 31, 2017 at 1:29 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> For dependent expression followed by -> and identifier or ~ identifier,
> the parser creates COMPONENT_REF with ARROW_EXPR as its first argument.
> When printing that, we actually print expr->.identifier , which is not
> what the user typed.  The following patch omits the undesirable dot in
> that case, we know that dump_expr on the ARROW_EXPR already printed ->
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-01-31  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/79304
>         * error.c (dump_expr) <case COMPONENT_REF>: Don't print .
>         after ARROW_EXPR.
>
>         * g++.dg/diagnostic/pr79304.C: New test.
>
> --- gcc/cp/error.c.jj   2017-01-21 02:26:06.000000000 +0100
> +++ gcc/cp/error.c      2017-01-31 17:03:17.737123973 +0100
> @@ -2247,7 +2247,8 @@ dump_expr (cxx_pretty_printer *pp, tree
>         else
>           {
>             dump_expr (pp, ob, flags | TFF_EXPR_IN_PARENS);
> -           pp_cxx_dot (pp);
> +           if (TREE_CODE (ob) != ARROW_EXPR)
> +             pp_cxx_dot (pp);
>           }
>         dump_expr (pp, TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
>        }
> --- gcc/testsuite/g++.dg/diagnostic/pr79304.C.jj        2017-01-31 17:08:17.347318113 +0100
> +++ gcc/testsuite/g++.dg/diagnostic/pr79304.C   2017-01-31 17:08:01.000000000 +0100
> @@ -0,0 +1,20 @@
> +// PR c++/79304
> +// { dg-do compile }
> +
> +struct C { };
> +
> +template<class T>
> +struct X
> +{
> +  C* c;
> +
> +  void f() {
> +    this->c.s();       // { dg-error "->c" }
> +  }
> +};
> +
> +int main()
> +{
> +  X<int> x;
> +  x.f();
> +}
>
>         Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]