This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/70449 (ICE when printing a filename of unknown location)
- From: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- To: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 30 Mar 2016 23:51:26 +0100
- Subject: Re: C++ PATCH for c++/70449 (ICE when printing a filename of unknown location)
- Authentication-results: sourceware.org; auth=none
- References: <20160330161456 dot GB13362 at redhat dot com> <56FC564A dot 9080901 at gmail dot com>
On 30 March 2016 at 23:42, Manuel LÃpez-IbÃÃez <lopezibanez@gmail.com> wrote:
> On 30/03/16 17:14, Marek Polacek wrote:
>>
>> This test ICEs since the addition of the assert in pp_string which ensures
>> that
>> we aren't trying to print an empty string. But that's what happens here,
>> the
>> location is actually UNKNOWN_LOCATION, so LOCATION_FILE on that yields
>> null.
>> Fixed byt not trying to print the filename of UNKNOWN_LOCATION.
> Even if we accept the broken location for now (adding some FIXME to the code
> would help the next person to realise this is not normal), if
> LOCATION_FILE() is NULL, we should print "progname" like
> diagnostic_build_prefix() does. Moreover, the filename string should be
> built with file_name_as_prefix() to get correct coloring.
Even better: Use "f ? f : progname" in file_name_as_prefix() and
simplify the code to:
/* FIXME: Somehow we may get UNKNOWN_LOCATION here: See
g++.dg/cpp0x/constexpr-70449.C */
const char * prefix = file_name_as_prefix (context,
LOCATION_FILE (location));
pp_verbatim (context->printer,
TREE_CODE (p->decl) == TREE_LIST
? _("%s: In substitution of %qS:\n")
: _("%s: In instantiation of %q#D:\n"),
prefix, p->decl);
free (prefix);
Fixes the ICE, adds colors, mentions the broken location and does not
add extra strings.
Cheers,
Manuel.