From 7f967bd2a7ba156ede3fbb147e66dea5fb7137a6 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 18 Jun 2020 20:37:51 +0200 Subject: [PATCH] options: Properly compare string options. gcc/ChangeLog: * optc-save-gen.awk: Compare string options in cl_optimization_compare by strcmp. --- gcc/optc-save-gen.awk | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index 1b01008..760bf26 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -126,8 +126,10 @@ for (i = 0; i < n_opts; i++) { else if (otype ~ "^signed +char *$") var_opt_range[name] = "-128, 127" } - else if (otype ~ "^const char \\**$") + else if (otype ~ "^const char \\**$") { var_opt_string[n_opt_string++] = name; + string_options_names[name]++ + } else var_opt_other[n_opt_other++] = name; } @@ -382,8 +384,10 @@ if (have_save) { if (otype == var_type(flags[i])) var_target_range[name] = "" } - else if (otype ~ "^const char \\**$") + else if (otype ~ "^const char \\**$") { var_target_string[n_target_string++] = name; + string_options_names[name]++ + } else var_target_other[n_target_other++] = name; } @@ -966,8 +970,16 @@ for (i = 0; i < n_opts; i++) { continue; checked_options[name]++ - print " if (ptr1->x_" name " != ptr2->x_" name ")" - print " internal_error (\"% are modified in local context\");"; + if (name in string_options_names) { + print " if (ptr1->x_" name " != ptr2->x_" name ""; + print " && (!ptr1->x_" name" || !ptr2->x_" name + print " || strcmp (ptr1->x_" name", ptr2->x_" name ")))"; + print " internal_error (\"% are modified in local context\");"; + } + else { + print " if (ptr1->x_" name " != ptr2->x_" name ")" + print " internal_error (\"% are modified in local context\");"; + } } print "}"; -- 2.7.4