Hi all,

They AArch64 general attribute handling code uses the strtok function to
separate comma-delimited attributes in a string. This causes problems for and
interfers with attribute-specific handling code that also uses strtok to
separate attribute arguments, since strtok isn't re-entrant. This patch
replaces calls to strtok with strtok_r to avoid these problems when
adding/modifying attribute behaviour in the future.

Bootstrapped and regression tested on aarch64-none-elf with no regressions.

OK for trunk?

gcc/ChangeLog:

2018-11-23  Sam Tebbs<sam.te...@arm.com>

        * config/aarch64/aarch64.c (aarch64_process_target_attr): Replace
        calls to strtok with strtok_r.

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 
0d89ba27e4a7a02903d6cb3de6c19b097cb84d16..18909f862d8e2151e19cd766b97f6989381124a3
 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -11981,7 +11981,7 @@ aarch64_process_target_attr (tree args)
   unsigned int num_commas = num_occurences_in_str (',', str_to_check);
 
   /* Handle multiple target attributes separated by ','.  */
-  char *token = strtok (str_to_check, ",");
+  char *token = strtok_r (str_to_check, ",", &str_to_check);
 
   unsigned int num_attrs = 0;
   while (token)
@@ -11993,7 +11993,7 @@ aarch64_process_target_attr (tree args)
          return false;
        }
 
-      token = strtok (NULL, ",");
+      token = strtok_r (NULL, ",", &str_to_check);
     }
 
   if (num_attrs != num_commas + 1)

Reply via email to