PATCH column number support

Per Bothner per@bothner.com
Sun Nov 30 11:02:00 GMT 2003


This is actually two related patches, relative to the tree-ssa
branch.  (I don't think there is anything ssa-branch-specific,
but this kind of change is probably not appropriate for 3.4.)

The first patch enhances the line_map data structure to support
column numbers.  The source_location typedef (renamed from
fileline) now also encodes column numbers that you can extract
using the SOURCE_COLUMN macro.  Column number are recorded in
the low-order column_bits of a source_location.  The number of
bits can vary from line_map to line_map, and default to 8.
If more bits are needed, a new line_map is added.  The 'col'
field of a cpp_token is no longer needed.

This patch is clean and I believe ready to go into the tree-ssa
branch (after another test-run with a clean tree).

The second patch is a kludge, but demonstrates how we can get
column numbers in decl diagnostics.  Compiling this source file:

int    sdsa   ;
float    sdsa   ;
#define  12

with a patched cc1plus results in:

/tmp/bad.c:2:10: error: conflicting declaration 'float sdsa'
/tmp/bad.c:1:8: error: 'sdsa' has a previous declaration as `int sdsa'
/tmp/bad.c:2:17: error: type mismatch with previous external decl of 
`float sdsa'
/tmp/bad.c:1:8: error: previous external decl of `int sdsa'
/tmp/bad.c:2:17: error: declaration of `float sdsa'
/tmp/bad.c:1:8: error: conflicts with previous declaration `int sdsa'
/tmp/bad.c:3:10: macro names must be identifiers

(The duplicated error messages are a bug that pre-existed
this patch.)

This works by adding a source_location field to location_t.
This is of course not what we want to do.  Instead the goal
is to *replace* location_t by source_location.  I do have a
patch for this (both mainline and tree-ssa), though so far only
for the C front-end.  Also, the way I set DECL_LOCATION using a
declarator_location global is obviously bogus, but I'll let
someone more familiar with the C++ parser do it more cleanly.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: col.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20031130/47809aa3/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cp-col.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20031130/47809aa3/attachment-0001.ksh>


More information about the Gcc-patches mailing list