From 19bdccb4be4b0c3eae14c5634d25e1a83506a2f0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 31 Jan 2017 22:38:00 +0100 Subject: [PATCH] re PR c++/79304 (diagnostic shows bogus expression ((X*)this)->.c) PR c++/79304 * error.c (dump_expr) : Don't print . after ARROW_EXPR. * g++.dg/diagnostic/pr79304.C: New test. From-SVN: r245073 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/error.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/diagnostic/pr79304.C | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/pr79304.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 04d2a6017e8..560bbfab3e8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-01-31 Jakub Jelinek + + PR c++/79304 + * error.c (dump_expr) : Don't print . + after ARROW_EXPR. + 2017-01-31 David Malcolm PR c++/79298 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 4f4c11df570..92137f7c021 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2247,7 +2247,8 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) 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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef50edab562..c313baa6437 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-31 Jakub Jelinek + + PR c++/79304 + * g++.dg/diagnostic/pr79304.C: New test. + 2017-01-31 David Malcolm PR c++/79298 diff --git a/gcc/testsuite/g++.dg/diagnostic/pr79304.C b/gcc/testsuite/g++.dg/diagnostic/pr79304.C new file mode 100644 index 00000000000..eedae42cbdf --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr79304.C @@ -0,0 +1,20 @@ +// PR c++/79304 +// { dg-do compile } + +struct C { }; + +template +struct X +{ + C* c; + + void f() { + this->c.s(); // { dg-error "->c" } + } +}; + +int main() +{ + X x; + x.f(); +} -- 2.30.2