How do I print the name of a variable created with create_tmp_var_raw

Thomas Koenig tkoenig@netcologne.de
Tue Dec 8 18:34:00 GMT 2020


Hi,

I would like to know the name of a variable created with
create_tmp_var_raw, but it is not clear to my how to do it.

gimple_decl_printable_name sounded like a likely candidate,
but that just returns a null pointer.  Any combination of
IDENTIFIER_POINTER and DECL_NAME that I tried also led to
checking errors or segfaults.

More specifically,

diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index f1c8f0ee17f..11043406840 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -96,7 +96,7 @@ gfc_create_var_np (tree type, const char *prefix)
    tree t;

    t = create_tmp_var_raw (type, prefix);
-
+  dprintf (2, "%s\n", IDENTIFIER_POINTER (DECL_NAME (t)));
    /* No warnings for anonymous variables.  */
    if (prefix == NULL)
      TREE_NO_WARNING (t) = 1;

which I thought should work according to the documentation I've
read resulted in a segfault.

Any pointers? Is there a magic incantation that I am missing?

Best regards

	Thomas


More information about the Gcc mailing list