public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/41543] New: BUILTINS_LOCATION wrong with -fpreprocessed
@ 2009-10-02 9:53 jakub at gcc dot gnu dot org
2009-10-02 20:36 ` [Bug preprocessor/41543] " manu at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-10-02 9:53 UTC (permalink / raw)
To: gcc-bugs
With -fpreprocessed, expand_location (BUILTINS_LOCATION) yields the
preprocessed source file name (e.g. bar.ii), line 1, column 1, instead of
<built-in> filename, line 0. So e.g. ./cc1 -g -dA -fpreprocessed bar.ii
where bar.ii is:
# 1 "foo.C"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "foo.C"
int
foo (__builtin_va_list ap)
{
return __builtin_va_arg (ap,int);
}
will have bar.ii in the filemap and e.g. on x86-64 va_list struct and its
fields will use that as location.
BUILTINS_LOCATION is 2, and for normal compilation without -fpreprocessed
there is just a:
cpp_read_main_file -> _cpp_stack_file -> _cpp_do_file_change -> linemap_add
call that bumps line_table->highest_location to 1, and then there is:
1491 if (!cpp_opts->preprocessed)
1492 {
1493 size_t i;
1494
1495 cb_file_change (parse_in,
1496 linemap_add (line_table, LC_RENAME, 0,
1497 _("<built-in>"), 0));
in c-opts.c which ensures that location 2 maps to <built-in>.
But with -fpreprocessed cpp_read_main_file does additionally:
/* For foo.i, read the original filename foo.c now, for the benefit
of the front ends. */
if (CPP_OPTION (pfile, preprocessed))
{
read_original_filename (pfile);
fname = pfile->line_table->maps[pfile->line_table->used-1].to_file;
}
and read_original_filename during lexing of the first character already eats
some locations, bumping line_table->highest_location.
Not sure what would be best to fix it.
--- init.c.xx 2009-06-30 13:10:43.000000000 +0200
+++ init.c 2009-10-02 11:49:51.000000000 +0200
@@ -554,6 +554,13 @@ cpp_read_main_file (cpp_reader *pfile, c
of the front ends. */
if (CPP_OPTION (pfile, preprocessed))
{
+ /* Hack: GCC expects that (source_location) 2 is BUILTINS_LOCATION,
+ but after read_original_filename lexing it will be at the start of
+ the first line of the preprocessed file. */
+ linemap_add (pfile->line_table, LC_RENAME, 0, _("<built-in>"), 0);
+ linemap_add (pfile->line_table, LC_RENAME, 0,
+ pfile->line_table->maps[pfile->line_table->used-2].to_file,
+ 1);
read_original_filename (pfile);
fname = pfile->line_table->maps[pfile->line_table->used-1].to_file;
}
cures this, but feels like a hack. As it is gcc specific, it would need to be
some libcpp callback or something. Changing BUILTINS_LOCATION to say
(source_location) -1, changing the places that check e.g. that location is <=
BUILTINS_LOCATION and special casing BUILTINS_LOCATION in expand_location could
perhaps work too.
Tom, what do you prefer?
--
Summary: BUILTINS_LOCATION wrong with -fpreprocessed
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41543
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug preprocessor/41543] BUILTINS_LOCATION wrong with -fpreprocessed
2009-10-02 9:53 [Bug preprocessor/41543] New: BUILTINS_LOCATION wrong with -fpreprocessed jakub at gcc dot gnu dot org
@ 2009-10-02 20:36 ` manu at gcc dot gnu dot org
2009-10-14 10:04 ` jakub at gcc dot gnu dot org
2009-10-14 10:09 ` jakub at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-10-02 20:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from manu at gcc dot gnu dot org 2009-10-02 20:36 -------
Shouldn't location 0, location 1 and location 2 be reserved and allocated as
soon as the line_table is created? I think this was already in my patch moving
all location stuff to its own library.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41543
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug preprocessor/41543] BUILTINS_LOCATION wrong with -fpreprocessed
2009-10-02 9:53 [Bug preprocessor/41543] New: BUILTINS_LOCATION wrong with -fpreprocessed jakub at gcc dot gnu dot org
2009-10-02 20:36 ` [Bug preprocessor/41543] " manu at gcc dot gnu dot org
@ 2009-10-14 10:04 ` jakub at gcc dot gnu dot org
2009-10-14 10:09 ` jakub at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-10-14 10:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jakub at gcc dot gnu dot org 2009-10-14 10:04 -------
Subject: Bug 41543
Author: jakub
Date: Wed Oct 14 10:04:22 2009
New Revision: 152761
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152761
Log:
PR preprocessor/41543
* input.h (BUILTINS_LOCATION): Change to 1 from 2.
Assert BUILTINS_LOCATION < RESERVED_LOCATION_COUNT.
* tree.c: Include intl.h.
(expand_location): Handle BUILTINS_LOCATION.
* Makefile.in (tree.o): Depend on intl.h.
* include/line-map.h (RESERVED_LOCATION_COUNT): Define.
* line-map.c (linemap_init): Initialize highest_location and
highest_line to RESERVED_LOCATION_COUNT-1 instead of 0.
* gcc.dg/debug/dwarf2/pr41543.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/debug/dwarf2/pr41543.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/Makefile.in
trunk/gcc/input.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.c
trunk/libcpp/ChangeLog
trunk/libcpp/include/line-map.h
trunk/libcpp/line-map.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41543
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug preprocessor/41543] BUILTINS_LOCATION wrong with -fpreprocessed
2009-10-02 9:53 [Bug preprocessor/41543] New: BUILTINS_LOCATION wrong with -fpreprocessed jakub at gcc dot gnu dot org
2009-10-02 20:36 ` [Bug preprocessor/41543] " manu at gcc dot gnu dot org
2009-10-14 10:04 ` jakub at gcc dot gnu dot org
@ 2009-10-14 10:09 ` jakub at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-10-14 10:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jakub at gcc dot gnu dot org 2009-10-14 10:09 -------
Fixed.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41543
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-14 10:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-02 9:53 [Bug preprocessor/41543] New: BUILTINS_LOCATION wrong with -fpreprocessed jakub at gcc dot gnu dot org
2009-10-02 20:36 ` [Bug preprocessor/41543] " manu at gcc dot gnu dot org
2009-10-14 10:04 ` jakub at gcc dot gnu dot org
2009-10-14 10:09 ` jakub at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).