The attached patch fixes quoting, spelling, and other formatting issues in diagnostics issued by the D front end and pointed out by the -Wformat-diag warning.
Martin
gcc/d/ChangeLog: * d/d-builtins.cc (d_init_builtins): Quote keywords, operators, and types in diagnostics. * d/d-codegen.cc (get_array_length): Same. Replace can't with cannot. * d/d-convert.cc (convert_expr): Same. * d/d-frontend.cc (getTypeInfoType): Quote an option name in a diagnostic. * d/d-lang.cc (d_handle_option): Same. (d_parse_file): Same. * d/decl.cc: Remove a trailing period from a diagnostic. * d/expr.cc: Use a directive for an apostrophe. * d/toir.cc: Quote keywords, operators, and types in diagnostics. * d/typeinfo.cc (build_typeinfo): Quote an option name in a diagnostic. diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index 3dbdafb492a..3ebee721a25 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -1117,7 +1117,7 @@ d_init_builtins (void) Type::tvalist = build_frontend_type (va_list_type_node); if (!Type::tvalist) { - error ("cannot represent built-in va_list type in D"); + error ("cannot represent built-in %<va_list%> type in D"); gcc_unreachable (); } diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 2abff92fc88..1971064e334 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -316,7 +316,7 @@ get_array_length (tree exp, Type *type) return d_array_length (exp); default: - error ("can't determine the length of a %qs", type->toChars ()); + error ("cannot determine the length of a %qs", type->toChars ()); return error_mark_node; } } diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc index e9aa457d852..b020eab902f 100644 --- a/gcc/d/d-convert.cc +++ b/gcc/d/d-convert.cc @@ -376,7 +376,7 @@ convert_expr (tree exp, Type *etype, Type *totype) } else { - error ("can't convert a delegate expression to %qs", + error ("cannot convert a delegate expression to %qs", totype->toChars ()); return error_mark_node; } @@ -392,7 +392,7 @@ convert_expr (tree exp, Type *etype, Type *totype) } else { - error ("can't convert struct %qs to %qs", + error ("cannot convert struct %qs to %qs", etype->toChars (), totype->toChars ()); return error_mark_node; } @@ -475,7 +475,7 @@ convert_expr (tree exp, Type *etype, Type *totype) if ((dim * esize) % tsize != 0) { - error ("cannot cast %qs to %qs since sizes don't line up", + error ("cannot cast %qs to %qs since sizes do not line up", etype->toChars (), totype->toChars ()); return error_mark_node; } diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc index ccd5f50130f..77b6f22d824 100644 --- a/gcc/d/d-frontend.cc +++ b/gcc/d/d-frontend.cc @@ -625,7 +625,7 @@ getTypeInfoType (Loc loc, Type *type, Scope *sc) if (!warned) { error_at (make_location_t (loc), - "%<object.TypeInfo%> cannot be used with -fno-rtti"); + "%<object.TypeInfo%> cannot be used with %<-fno-rtti%>"); warned = 1; } } diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 62a8ddd69b2..f23f719a2c3 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -449,7 +449,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, break; } - error ("bad argument for -fdebug %qs", arg); + error ("bad argument for %<-fdebug%>: %qs", arg); break; case OPT_fdoc: @@ -497,7 +497,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, case OPT_fmodule_file_: global.params.modFileAliasStrings->push (arg); if (!strchr (arg, '=')) - error ("bad argument for -fmodule-file %qs", arg); + error ("bad argument for %<-fmodule-file%>: %qs", arg); break; case OPT_fmoduleinfo: @@ -588,7 +588,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, break; } - error ("bad argument for -fversion %qs", arg); + error ("bad argument for %<-fversion%>: %qs", arg); break; case OPT_H: @@ -1011,7 +1011,7 @@ d_parse_file (void) /* In this mode, the first file name is supposed to be a duplicate of one of the input files. */ if (d_option.fonly && strcmp (d_option.fonly, main_input_filename) != 0) - error ("-fonly= argument is different from first input file name"); + error ("%<-fonly=%> argument is different from first input file name"); for (size_t i = 0; i < num_in_fnames; i++) { diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 49723649230..bcce245e59c 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -463,7 +463,7 @@ public: fd2->toPrettyChars ()); inform (make_location_t (d->loc), "use %<alias %s = %s.%s;%> to introduce base class " - "overload set.", fd->toChars (), + "overload set", fd->toChars (), fd->parent->toChars (), fd->toChars ()); } else diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 6497619e5fd..826c32a059f 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1522,7 +1522,7 @@ public: } else { - error ("don't know how to delete %qs", e->e1->toChars ()); + error ("don%'t know how to delete %qs", e->e1->toChars ()); this->result_ = error_mark_node; } } diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc index f1b2e09a94d..1d125b43962 100644 --- a/gcc/d/toir.cc +++ b/gcc/d/toir.cc @@ -367,9 +367,11 @@ public: } if (ent->in_try_scope) - error_at (make_location_t (from->loc), "cannot goto into try block"); + error_at (make_location_t (from->loc), + "cannot %<goto%> into %<try%> block"); else if (ent->in_catch_scope) - error_at (make_location_t (from->loc), "cannot goto into catch block"); + error_at (make_location_t (from->loc), + "cannot %<goto%> into %<catch%> block"); } /* Check that a previously seen jump to a newly defined label is valid. @@ -391,21 +393,21 @@ public: { location = make_location_t (fwdref->statement->loc); if (b->kind == level_try) - error_at (location, "cannot goto into try block"); + error_at (location, "cannot %<goto%> into %<try%> block"); else - error_at (location, "cannot goto into catch block"); + error_at (location, "cannot %<goto%> into %<catch%> block"); } else if (s->isCaseStatement ()) { location = make_location_t (s->loc); error_at (location, "case cannot be in different " - "try block level from switch"); + "%<try%> block level from %<switch%>"); } else if (s->isDefaultStatement ()) { location = make_location_t (s->loc); error_at (location, "default cannot be in different " - "try block level from switch"); + "%<try%> block level from %<switch%>"); } else gcc_unreachable (); @@ -1125,8 +1127,8 @@ public: static int warned = 0; if (!warned) { - error_at (make_location_t (s->loc), "exception handling disabled, " - "use -fexceptions to enable"); + error_at (make_location_t (s->loc), "exception handling disabled; " + "use %<-fexceptions%> to enable"); warned = 1; } } diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index bbd3961181d..58c6ce1ba3c 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -1350,7 +1350,7 @@ build_typeinfo (const Loc &loc, Type *type) if (!warned) { error_at (make_location_t (loc), - "%<object.TypeInfo%> cannot be used with -fno-rtti"); + "%<object.TypeInfo%> cannot be used with %<-fno-rtti%>"); warned = 1; } }