This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Identifying source file locations.


Per Bothner wrote:
> almquist2@hotmail.com (Kenneth Almquist) writes:
>
>> I want to number the lines coming out of the file inclusion pass
>> sequentially, and have a separate data structure to map these to
>> filename:line_number values.
>
> (1) The Java front-end can compile multiple source files in one
> invocation of the compiler. Which leads to the quetion:  Should
> the line numbers be re-set when starting a new top-level file
> (i.e. one specified on the command line), or should you just keep
> incrementing the counter?

I suspect that it would make sense to reinitialize everything
when starting a new top-level file.

> (2) The Java front-end already keeps track of column numbers.
> So it needs to be updated to any new scheme.

Thanks for calling my attention to this.

> (3) Is this "separate data structure" something global, or is
> it part of the tree structure?  If the former, if does further
> complicate (future) efforts to make gcc re-entrant?  In other
> words, I'd like it to be possible to assign meaning to tree
> nodes without consulting an external shared data structure.
> This becoems essential for a re-entrant compiler.  One way to
> do this is for top-level (or function-level) tree nodes
> to point to their mapping table.  Then this can be carries
> along while processing sub-tree nodes.

I was thinking of a global.  For a re-entrant version of gcc I
expect you would want a per-thread data structure indicating where
error messages should be written to.  The mapping table could be
placed in the same structure.

>> this approach allows error messages to be sorted.
>
> Which is more usable:  Sort by "logical order" or sort by
> "source order".  I suspect the latter.

By "source order" do you mean sort by file name followed by line
number within the file?  This leaves open the question of how to
sort the file names.  The main issue here is that errors can
cascade.  For example, if there is a syntax error in a declaration
in a header file leaves a variable undefined, then a subsequent
reference to that variable in another file will result in a second
diagnostic.  We want the diagnostic on the declaration to come out
first.
				Kenneth Almquist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]