https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61914

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
This works:

diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index ffe3f94..ce143ad 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -599,7 +599,8 @@ create_user_defined_type (const char *type_name, struct
fileloc *pos)
      comma-separated list of strings, implicitly assumed to
      be type names, potentially with "*" characters.  */
       char *arg = open_bracket + 1;
-      char *type_id = strtok (arg, ",>");
+      char *saved_pointer;
+      char *type_id = strtok_r (arg, ",>", &saved_pointer);
       pair_p fields = 0;
       while (type_id)
     {
@@ -628,7 +629,7 @@ create_user_defined_type (const char *type_name, struct
fileloc *pos)
         arg_type = resolve_typedef (field_name, pos);

       fields = create_field_at (fields, arg_type, field_name, 0, pos);
-      type_id = strtok (0, ",>");
+      type_id = strtok_r (0, ",>", &saved_pointer);
     }

       /* Associate the field list to TY.  */

But we may need a strtok_r in libiberty.

Reply via email to