On Thu, Aug 11, 2011 at 10:45 AM, Dodji Seketeli <do...@seketeli.org> wrote: >> As I mentioned, we have the same problem in pph where we need to force >> a location (i.e. the lexer is assigning new locations, but we don't >> want it to when we are replaying pre-processor tokens), so just a >> "builtin_location" field is potentially insufficient. > > I see. So maybe a cpp_reader::forced_token_location, initialized to -1 > rather than 0 (in case someone wants to force a location to > UNKNOWN_LOCATION, which is zero for the C/C++ FE at least). There would > then still be a new parm added to cpp_init_builtins, that would be the > value of the location of the builtin macros to build. cpp_init_builtins > would then just set cpp_reader::force_token_location to that value. >
Yes, I did think about using -1 to represent no-force. The problem is, source_location is defined as unsigned int... So my solution was to use a source_location* which when non-null means you want to force the location to the referenced source_location. For some reason however when I add a simple field `source_location *forced_location` to struct line_maps I get the following compile error: libcpp/include/line-map.h:99: field `(*x).forced_location' is pointer to unimplemented type Adding a source_location* to cpp_reader compiles fine however. This must be a tricky corner of the C syntax I'm not aware of...? Gabriel