http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52952
--- Comment #15 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-03-30 12:32:08 UTC --- (In reply to comment #13) > I guess the C/C++ FEs could for non-trivial string literals put into a hash > table mapping from locus_t (of ADDR_EXPR around STRING_CST) to the first cpp > token for that string, then the diagnostic code could go from there. > Trivial string literal above would be a string literal that doesn't have any > prefixes (L/u/u8/U and variants with R), isn't contatenated from several parts > and didn't need to be translated. So, printf ("%.*d"); (the common case) > wouldn't have to be recorded, while printf (R"<<<(%)>>>" "." R"(*)" "d"); > would > need that. For "trivial" string literals you'd just shift the locus by the > offset, for non-trivial look up the tokens and process them again, looking at > where the corresponding byte would appear to come from. Jakub, I am trying to implement this idea, but I am not sure I got the hash_table right. It looks overly complicated to me. Could you take a look?