summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-28 20:14:46 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-28 20:14:46 +0000
commit1dc92c5913ffe255be1126b46a4a977d26e4ae19 (patch)
treeeceb7d4375de4bb00babcce955c7e39bab611ff1 /libcpp
parentb5cdaa0b3401db4ed1bcf12e74d33323569b9b40 (diff)
downloadgcc-1dc92c5913ffe255be1126b46a4a977d26e4ae19.tar.gz
Fix the use of linemap_add and remove unnecessary kludge
libcpp/ * line-map.c (linemap_add): Assert that reason must not be LC_RENAME when called for the first time on a "main input file". c-family/ * c-pch.c (c_common_read_pch): Call linemap_add with LC_ENTER as it's the first time it's being called on this main TU. gcc/lto/ * lto-lang.c (lto_init): Likewise. Also, avoid calling linemap_add twice. gcc/fortran/ * scanner.c (load_file): Don't abuse LC_RENAME reason while (indirectly) calling linemap_add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178146 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/line-map.c9
2 files changed, 9 insertions, 5 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 8a5e89921a0..4ecda03cfec 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-28 Dodji Seketeli <dodji@redhat.com>
+
+ * line-map.c (linemap_add): Assert that reason must not be
+ LC_RENAME when called for the first time on a "main input file".
+
2011-08-22 Gabriel Charette <gchare@google.com>
* init.c (cpp_create_reader): Inititalize forced_token_location_p.
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index dd3f11cd660..2a0749aad2e 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -114,11 +114,10 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
if (reason == LC_RENAME_VERBATIM)
reason = LC_RENAME;
- /* If we don't keep our line maps consistent, we can easily
- segfault. Don't rely on the client to do it for us. */
- if (set->depth == 0)
- reason = LC_ENTER;
- else if (reason == LC_LEAVE)
+ if (set->depth == 0 && reason == LC_RENAME)
+ abort ();
+
+ if (reason == LC_LEAVE)
{
struct line_map *from;
bool error;