diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-23 22:04:53 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-23 22:04:53 +0000 |
commit | 26fcb396d1eecc73636ad5a694a16c5bb54fcd26 (patch) | |
tree | 53b821c50064bde8bbd29d5745b030eb7d96c1f0 /gcc/go/gofrontend/go-diagnostics.cc | |
parent | d7e96c4608ae4e37334add5ecc2bea594a9e940a (diff) | |
download | gcc-26fcb396d1eecc73636ad5a694a16c5bb54fcd26.zip gcc-26fcb396d1eecc73636ad5a694a16c5bb54fcd26.tar.gz gcc-26fcb396d1eecc73636ad5a694a16c5bb54fcd26.tar.bz2 |
compiler: add go_debug and use it for debug messages
GCC recently added a new warning -Wformat-diag which does a lot of
rigorous checks on GCC diagnostic messages. This produces a number of
unnecessary diagnostics on gofrontend diagnostic output, such as
../../trunk/gcc/go/gofrontend/escape.cc: In member function ‘virtual int Escape_analysis_assign::statement(Block*, size_t*, Statement*)’:
../../trunk/gcc/go/gofrontend/escape.cc:1336:33: warning: spurious leading punctuation sequence ‘[’ in format [-Wformat-diag]
1336 | go_inform(s->location(), "[%d] %s esc: %s",
| ^
../../trunk/gcc/go/gofrontend/escape.cc: In member function ‘void Escape_analysis_assign::call(Call_expression*)’:
../../trunk/gcc/go/gofrontend/escape.cc:1964:17: warning: unquoted operator ‘::’ in format [-Wformat-diag]
1964 | "esccall:: indirect call <- %s, untracked",
| ^~
../../trunk/gcc/go/gofrontend/escape.cc:1964:34: warning: unbalanced punctuation character ‘<’ in format [-Wformat-diag]
1964 | "esccall:: indirect call <- %s, untracked",
| ^
Avoid these messages by adding a new function go_debug that uses only
printf formatting, not GCC diagnostic formatting, and change all the
optimization debugging messages to use it. None of the debugging
messages used the GCC diagnostic formatting specifiers anyhow.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183437
From-SVN: r272607
Diffstat (limited to 'gcc/go/gofrontend/go-diagnostics.cc')
-rw-r--r-- | gcc/go/gofrontend/go-diagnostics.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/go-diagnostics.cc b/gcc/go/gofrontend/go-diagnostics.cc index 21e45b3..4a091e3 100644 --- a/gcc/go/gofrontend/go-diagnostics.cc +++ b/gcc/go/gofrontend/go-diagnostics.cc @@ -175,3 +175,25 @@ go_inform(const Location location, const char* fmt, ...) go_be_inform(location, expand_message(fmt, ap)); va_end(ap); } + +// go_debug uses normal printf formatting, not GCC diagnostic formatting. + +void +go_debug(const Location location, const char* fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + char* mbuf = NULL; + int nwr = vasprintf(&mbuf, fmt, ap); + va_end(ap); + if (nwr == -1) + { + go_be_error_at(Linemap::unknown_location(), + "memory allocation failed in vasprintf"); + go_assert(0); + } + std::string rval = std::string(mbuf); + free(mbuf); + go_be_inform(location, rval); +} |