This patch is for PR target/79868, where some aarch64 diagnostics are said to be not translatable due to how they are implemented. See the bug report for more details on why the current setup of passing the string 'pragma' or 'attribute' doesn't work.
This patch fixes it, unfortunately by increasing the number of calls we have to 'error' (16 calls become 32 calls), but that seems to be the most straight forward way to get translatable strings. This patch is an update to the one I originally attached to the bug report and I have fixed the issue that Frederic Marchal found in my original patch. OK to checkin? Steve Ellcey sell...@cavium.com 2017-09-18 Steve Ellcey <sell...@cavium.com> PR target/79868 * config/aarch64/aarch64-c.c (aarch64_pragma_target_parse): Change argument type on aarch64_process_target_attr call. * config/aarch64/aarch64-protos.h (aarch64_process_target_attr): Change argument type. * config/aarch64/aarch64.c (aarch64_attribute_info): Change field type. (aarch64_handle_attr_arch): Change argument type, use boolean argument to make different error calls. (aarch64_handle_attr_cpu): Ditto. (aarch64_handle_attr_tune): Ditto. (aarch64_handle_attr_isa_flags): Ditto. (aarch64_process_one_target_attr): Ditto. (aarch64_process_target_attr): Ditto. (aarch64_option_valid_attribute_p): Change argument type on aarch64_process_target_attr call.
diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c index 177e638..c9945db 100644 --- a/gcc/config/aarch64/aarch64-c.c +++ b/gcc/config/aarch64/aarch64-c.c @@ -165,7 +165,7 @@ aarch64_pragma_target_parse (tree args, tree pop_target) information that it specifies. */ if (args) { - if (!aarch64_process_target_attr (args, "pragma")) + if (!aarch64_process_target_attr (args, true)) return false; aarch64_override_options_internal (&global_options); diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index e67c2ed..4323e9e 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -445,7 +445,7 @@ bool aarch64_gen_adjusted_ldpstp (rtx *, bool, scalar_mode, RTX_CODE); void aarch64_init_builtins (void); -bool aarch64_process_target_attr (tree, const char*); +bool aarch64_process_target_attr (tree, bool); void aarch64_override_options_internal (struct gcc_options *); rtx aarch64_expand_builtin (tree exp, diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 1c14008..054b1d2 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -9554,7 +9554,7 @@ struct aarch64_attribute_info const char *name; enum aarch64_attr_opt_type attr_type; bool allow_neg; - bool (*handler) (const char *, const char *); + bool (*handler) (const char *, bool); enum opt_code opt_num; }; @@ -9562,7 +9562,7 @@ struct aarch64_attribute_info PRAGMA_OR_ATTR is used in potential error messages. */ static bool -aarch64_handle_attr_arch (const char *str, const char *pragma_or_attr) +aarch64_handle_attr_arch (const char *str, bool is_pragma) { const struct processor *tmp_arch = NULL; enum aarch64_parse_opt_result parse_res @@ -9579,15 +9579,24 @@ aarch64_handle_attr_arch (const char *str, const char *pragma_or_attr) switch (parse_res) { case AARCH64_PARSE_MISSING_ARG: - error ("missing architecture name in 'arch' target %s", pragma_or_attr); + if (is_pragma) + error ("missing architecture name in 'arch' target pragma"); + else + error ("missing architecture name in 'arch' target attribute"); break; case AARCH64_PARSE_INVALID_ARG: - error ("unknown value %qs for 'arch' target %s", str, pragma_or_attr); + if (is_pragma) + error ("unknown value %qs for 'arch' target pragma", str); + else + error ("unknown value %qs for 'arch' target attribute", str); aarch64_print_hint_for_arch (str); break; case AARCH64_PARSE_INVALID_FEATURE: - error ("invalid feature modifier %qs for 'arch' target %s", - str, pragma_or_attr); + if (is_pragma) + error ("invalid feature modifier %qs for 'arch' target pragma", str); + else + error ("invalid feature modifier %qs for 'arch' target attribute", + str); break; default: gcc_unreachable (); @@ -9600,7 +9609,7 @@ aarch64_handle_attr_arch (const char *str, const char *pragma_or_attr) PRAGMA_OR_ATTR is used in potential error messages. */ static bool -aarch64_handle_attr_cpu (const char *str, const char *pragma_or_attr) +aarch64_handle_attr_cpu (const char *str, bool is_pragma) { const struct processor *tmp_cpu = NULL; enum aarch64_parse_opt_result parse_res @@ -9620,15 +9629,24 @@ aarch64_handle_attr_cpu (const char *str, const char *pragma_or_attr) switch (parse_res) { case AARCH64_PARSE_MISSING_ARG: - error ("missing cpu name in 'cpu' target %s", pragma_or_attr); + if (is_pragma) + error ("missing cpu name in 'cpu' target pragma"); + else + error ("missing cpu name in 'cpu' target attribute"); break; case AARCH64_PARSE_INVALID_ARG: - error ("unknown value %qs for 'cpu' target %s", str, pragma_or_attr); + if (is_pragma) + error ("unknown value %qs for 'cpu' target pragma", str); + else + error ("unknown value %qs for 'cpu' target attribute", str); aarch64_print_hint_for_core (str); break; case AARCH64_PARSE_INVALID_FEATURE: - error ("invalid feature modifier %qs for 'cpu' target %s", - str, pragma_or_attr); + if (is_pragma) + error ("invalid feature modifier %qs for 'cpu' target pragma", str); + else + error ("invalid feature modifier %qs for 'cpu' target attribute", + str); break; default: gcc_unreachable (); @@ -9641,7 +9659,7 @@ aarch64_handle_attr_cpu (const char *str, const char *pragma_or_attr) PRAGMA_OR_ATTR is used in potential error messages. */ static bool -aarch64_handle_attr_tune (const char *str, const char *pragma_or_attr) +aarch64_handle_attr_tune (const char *str, bool is_pragma) { const struct processor *tmp_tune = NULL; enum aarch64_parse_opt_result parse_res @@ -9658,7 +9676,10 @@ aarch64_handle_attr_tune (const char *str, const char *pragma_or_attr) switch (parse_res) { case AARCH64_PARSE_INVALID_ARG: - error ("unknown value %qs for 'tune' target %s", str, pragma_or_attr); + if (is_pragma) + error ("unknown value %qs for 'tune' target pragma", str); + else + error ("unknown value %qs for 'tune' target attribute", str); aarch64_print_hint_for_core (str); break; default: @@ -9675,7 +9696,7 @@ aarch64_handle_attr_tune (const char *str, const char *pragma_or_attr) PRAGMA_OR_ATTR is used in potential error messages. */ static bool -aarch64_handle_attr_isa_flags (char *str, const char *pragma_or_attr) +aarch64_handle_attr_isa_flags (char *str, bool is_pragma) { enum aarch64_parse_opt_result parse_res; unsigned long isa_flags = aarch64_isa_flags; @@ -9699,13 +9720,17 @@ aarch64_handle_attr_isa_flags (char *str, const char *pragma_or_attr) switch (parse_res) { case AARCH64_PARSE_MISSING_ARG: - error ("missing feature modifier in target %s %qs", - pragma_or_attr, str); + if (is_pragma) + error ("missing feature modifier in target pragma %qs", str); + else + error ("missing feature modifier in target attribute %qs", str); break; case AARCH64_PARSE_INVALID_FEATURE: - error ("invalid feature modifier in target %s %qs", - pragma_or_attr, str); + if (is_pragma) + error ("invalid feature modifier in target pragma %qs", str); + else + error ("invalid feature modifier in target attribute %qs", str); break; default: @@ -9748,7 +9773,7 @@ static const struct aarch64_attribute_info aarch64_attributes[] = we're processing a target attribute or pragma. */ static bool -aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) +aarch64_process_one_target_attr (char *arg_str, bool is_pragma) { bool invert = false; @@ -9756,7 +9781,10 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) if (len == 0) { - error ("malformed target %s", pragma_or_attr); + if (is_pragma) + error ("malformed target pragma"); + else + error ("malformed target attribute"); return false; } @@ -9772,7 +9800,7 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) through the machinery for the rest of the target attributes in this function. */ if (*str_to_check == '+') - return aarch64_handle_attr_isa_flags (str_to_check, pragma_or_attr); + return aarch64_handle_attr_isa_flags (str_to_check, is_pragma); if (len > 3 && strncmp (str_to_check, "no-", 3) == 0) { @@ -9804,8 +9832,12 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) if (attr_need_arg_p ^ (arg != NULL)) { - error ("target %s %qs does not accept an argument", - pragma_or_attr, str_to_check); + if (is_pragma) + error ("target pragma %qs does not accept an argument", + str_to_check); + else + error ("target attribute %qs does not accept an argument", + str_to_check); return false; } @@ -9813,8 +9845,12 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) then we can't match. */ if (invert && !p_attr->allow_neg) { - error ("target %s %qs does not allow a negated form", - pragma_or_attr, str_to_check); + if (is_pragma) + error ("target pragma %qs does not allow a negated form", + str_to_check); + else + error ("target attribute %qs does not allow a negated form", + str_to_check); return false; } @@ -9824,7 +9860,7 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) For example, cpu=, arch=, tune=. */ case aarch64_attr_custom: gcc_assert (p_attr->handler); - if (!p_attr->handler (arg, pragma_or_attr)) + if (!p_attr->handler (arg, is_pragma)) return false; break; @@ -9868,8 +9904,12 @@ aarch64_process_one_target_attr (char *arg_str, const char* pragma_or_attr) } else { - error ("target %s %s=%s is not valid", - pragma_or_attr, str_to_check, arg); + if (is_pragma) + error ("target pragma %s=%s is not valid", + str_to_check, arg); + else + error ("target attribute %s=%s is not valid", + str_to_check, arg); } break; } @@ -9908,7 +9948,7 @@ num_occurences_in_str (char c, char *str) a target attribute or a target pragma. */ bool -aarch64_process_target_attr (tree args, const char* pragma_or_attr) +aarch64_process_target_attr (tree args, bool is_pragma) { if (TREE_CODE (args) == TREE_LIST) { @@ -9917,7 +9957,7 @@ aarch64_process_target_attr (tree args, const char* pragma_or_attr) tree head = TREE_VALUE (args); if (head) { - if (!aarch64_process_target_attr (head, pragma_or_attr)) + if (!aarch64_process_target_attr (head, is_pragma)) return false; } args = TREE_CHAIN (args); @@ -9938,7 +9978,10 @@ aarch64_process_target_attr (tree args, const char* pragma_or_attr) if (len == 0) { - error ("malformed target %s value", pragma_or_attr); + if (is_pragma) + error ("malformed target pragma value"); + else + error ("malformed target attribute value"); return false; } @@ -9953,9 +9996,12 @@ aarch64_process_target_attr (tree args, const char* pragma_or_attr) while (token) { num_attrs++; - if (!aarch64_process_one_target_attr (token, pragma_or_attr)) + if (!aarch64_process_one_target_attr (token, is_pragma)) { - error ("target %s %qs is invalid", pragma_or_attr, token); + if (is_pragma) + error ("target pragma %qs is invalid", token); + else + error ("target attribute %qs is invalid", token); return false; } @@ -9964,8 +10010,11 @@ aarch64_process_target_attr (tree args, const char* pragma_or_attr) if (num_attrs != num_commas + 1) { - error ("malformed target %s list %qs", - pragma_or_attr, TREE_STRING_POINTER (args)); + if (is_pragma) + error ("malformed target pragma list %qs", TREE_STRING_POINTER (args)); + else + error ("malformed target attribute list %qs", + TREE_STRING_POINTER (args)); return false; } @@ -10025,7 +10074,7 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int) TREE_TARGET_OPTION (target_option_current_node)); - ret = aarch64_process_target_attr (args, "attribute"); + ret = aarch64_process_target_attr (args, false); /* Set up any additional state. */ if (ret)