compiler: edit error messages to avoid -Wformat-diag warnings

GCC recently introduced -Wformat-diag to scrutinize GCC error messages.
It reports a number of warnings about gofrontend code, such as:

../../trunk/gcc/go/gofrontend/ In member function ‘Type* Import::type_for_index(int, const string&, size_t, bool*)’:
../../trunk/gcc/go/gofrontend/ warning: unquoted operator ‘>=’ in format [-Wformat-diag]
 1129 |         "error in %s at %lu: bad type index %d >= %d",
      |                                                ^~

../../trunk/gcc/go/gofrontend/ In member function ‘void Ast_dump_context::dump(Gogo*, const char*)’:
../../trunk/gcc/go/gofrontend/ warning: unquoted option name ‘-fgo-dump-ast’ in format [-Wformat-diag]
  203 |     "cannot open %s:%m, -fgo-dump-ast ignored", dumpname.c_str());
      |                         ^~~~~~~~~~~~~

../../trunk/gcc/go/gofrontend/ In static member function ‘static Bexpression* Func_expression::get_code_pointer(Gogo*, Named_object*, Location)’:
../../trunk/gcc/go/gofrontend/ warning: misspelled term ‘builtin function’ in format; use ‘built-in function’ instead [-Wformat-diag]
 1350 |     "invalid use of special builtin function %qs; must be called",
      |                             ^~~~~~~~~~~~~~~~

../../trunk/gcc/go/gofrontend/ In member function ‘void Gogo::add_linkname(const string&, bool, const string&, Location)’:
../../trunk/gcc/go/gofrontend/ warning: unquoted sequence of 2 consecutive punctuation characters ‘//’ in format [-Wformat-diag]
 2527 |   ("%s is not a function; "
      |   ~^~~~~~~~~~~~~~~~~~~~~~~~
 2528 |    "//go:linkname is only supported for functions"),
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This CL edits error messages to avoid these warnings.

Change-Id: If2f4881e9d02fefaf74efce04c63fab24845dea4
Reviewed-by: Cherry Zhang <>
9 files changed