]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: improve print_node of PTRMEM_CST
authorJason Merrill <jason@redhat.com>
Fri, 29 Oct 2021 20:39:01 +0000 (16:39 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 16 Nov 2021 15:20:30 +0000 (10:20 -0500)
It's been inconvenient that pretty-printing of PTRMEM_CST didn't display
what member the constant refers to.

Adding that is complicated by the absence of a langhook for CONSTANT_CLASS_P
nodes; the simplest fix for that is to use the tcc_exceptional hook for
tcc_constant as well.

gcc/cp/ChangeLog:

* ptree.c (cxx_print_xnode): Handle PTRMEM_CST.

gcc/ChangeLog:

* langhooks.h (struct lang_hooks): Adjust comment.
* print-tree.c (print_node): Also call print_xnode hook for
tcc_constant class.

gcc/cp/ptree.c
gcc/langhooks.h
gcc/print-tree.c

index ca7884db39bf80aee50ce04575b4d7d920545e31..d514aa2cad2765d9eb7762a494cb2ac2490ea45e 100644 (file)
@@ -379,6 +379,9 @@ cxx_print_xnode (FILE *file, tree node, int indent)
       if (tree message = STATIC_ASSERT_MESSAGE (node))
        print_node (file, "message", message, indent+4);
       break;
+    case PTRMEM_CST:
+      print_node (file, "member", PTRMEM_CST_MEMBER (node), indent+4);
+      break;
     default:
       break;
     }
index 3e89134e8b436e1cb76bef982148102e05417bdb..3db8f2a550d9fe82d1d46c023b3e9e7d846046c4 100644 (file)
@@ -477,7 +477,7 @@ struct lang_hooks
   void (*print_statistics) (void);
 
   /* Called by print_tree when there is a tree of class tcc_exceptional
-     that it doesn't know how to display.  */
+     or tcc_constant that it doesn't know how to display.  */
   lang_print_tree_hook print_xnode;
 
   /* Called to print language-dependent parts of tcc_decl, tcc_type,
index d1fbd044c27bc245f35c29fd62e8caf5d9de0316..b5dc523fcb1e92372045d24a0b0a8e3617bb1760 100644 (file)
@@ -1004,8 +1004,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
          break;
 
        default:
-         if (EXCEPTIONAL_CLASS_P (node))
-           lang_hooks.print_xnode (file, node, indent);
+         lang_hooks.print_xnode (file, node, indent);
          break;
        }