https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68815
Bug ID: 68815 Summary: Error/warning diagnostic: '%s' should be converted to %qs-like or %<%s%>-like string strings Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Fortran has code like: sprintf (msg, _("Unknown operator '%s' at %%L"), ... Expected: The strings are handled like %qs, i.e. the proper quotes are used. (Of cause, except for run-time errors.) In several cases - as in this one - the code enters as fmt string of a diagnostic function (visible as %%L is used). In those cases, '%s' can be replaced by %%<%s%%>. The question is how to deal with those strings (if any), which enter as argument to "%s" and are used as verbatim. (When working on it: Don't convert strings used by the run-time diagnostic.) * * * Related but simpler: The following goes as fmt string directly into the diagnostic system and can thus simply be applied (untested): --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3866 +3866 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape, - "%<%d%> duplicated)", + "%qd duplicated)", --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1197 +1197 @@ gfc_verify_c_interop_param (gfc_symbol *sym) - "procedure '%s' at %L", sym->name, + "procedure %qs at %L", sym->name, @@ -2026 +2026 @@ variable_decl (int elem) - gfc_error ("'%s' at %C is a redefinition of the declaration " + gfc_error ("%qs at %C is a redefinition of the declaration " @@ -2028 +2028 @@ variable_decl (int elem) - "PROCEDURE '%s'", sym->name, + "PROCEDURE %qs", sym->name, --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -552 +552 @@ check_format (bool is_input) - const char *unexpected_element = _("Unexpected element %<%c%> in format " + const char *unexpected_element = _("Unexpected element %qc in format " --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -168 +168 @@ gfc_add_new_implicit_range (int c1, int c2) - gfc_error ("Letter %<%c%> already set in IMPLICIT statement at %C", + gfc_error ("Letter %qc already set in IMPLICIT statement at %C", @@ -468 +468 @@ check_conflict (symbol_attribute *attr, const char *name, locus *where) - gfc_error_now ("internal procedure '%s' at %L conflicts with " + gfc_error_now ("internal procedure %qs at %L conflicts with " --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -1169 +1169 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) - gfc_error ("COMMON '%s' at %L does not exist", + gfc_error ("COMMON %qs at %L does not exist",