re PR c++/79304 (diagnostic shows bogus expression ((X<T>*)this)->.c)
authorJakub Jelinek <jakub@redhat.com>
Tue, 31 Jan 2017 21:38:00 +0000 (22:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 31 Jan 2017 21:38:00 +0000 (22:38 +0100)
PR c++/79304
* error.c (dump_expr) <case COMPONENT_REF>: Don't print .
after ARROW_EXPR.

* g++.dg/diagnostic/pr79304.C: New test.

From-SVN: r245073

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/pr79304.C [new file with mode: 0644]

index 04d2a6017e810a5d7c256a4d5560291e774fdc8d..560bbfab3e859562097fc999789d89f2f32f1e77 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/79304
+       * error.c (dump_expr) <case COMPONENT_REF>: Don't print .
+       after ARROW_EXPR.
+
 2017-01-31  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/79298
index 4f4c11df570a957c5af6eb1f0c4ccce5efac0884..92137f7c0213f19d96335999bf77d7a9b4008c79 100644 (file)
@@ -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);
       }
index ef50edab562224e5e153dbd46fc07a7c97a50576..c313baa643799db06cbc09fe98335497198e676f 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/79304
+       * g++.dg/diagnostic/pr79304.C: New test.
+
 2017-01-31  David Malcolm  <dmalcolm@redhat.com>
 
        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 (file)
index 0000000..eedae42
--- /dev/null
@@ -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();
+}