Commit 3caf0ca1 by Bernd Schmidt Committed by Jeff Law

re PR preprocessor/69650 (ICE in linemap_line_start, at libcpp/line-map.c:803)

	PR lto/69650
	* directives.c (do_linemarker): Test for file left but not entered
	here.
	* line-map.c (linemap_add): Not here.

	PR lto/69650
	* gcc.dg/pr69650.c: New test.

From-SVN: r234481
parent 634035b6
2016-03-25 Bernd Schmidt <bschmidt@redhat.com>
PR lto/69650
* gcc.dg/pr69650.c: New test.
2016-03-25 David Edelsohn <dje.gcc@gmail.com> 2016-03-25 David Edelsohn <dje.gcc@gmail.com>
* g++.dg/ext/pr70290.C: Prune non-standard ABI. * g++.dg/ext/pr70290.C: Prune non-standard ABI.
......
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
# 9 "somefile" 2 /* { dg-warning "linemarker ignored due to incorrect nesting" } */
not_a_type a; /* { dg-error "unknown type" } */
2016-03-25 Bernd Schmidt <bschmidt@redhat.com>
PR lto/69650
* directives.c (do_linemarker): Test for file left but not entered
here.
* line-map.c (linemap_add): Not here.
2016-03-21 Jakub Jelinek <jakub@redhat.com> 2016-03-21 Jakub Jelinek <jakub@redhat.com>
PR target/70296 PR target/70296
......
...@@ -1046,6 +1046,19 @@ do_linemarker (cpp_reader *pfile) ...@@ -1046,6 +1046,19 @@ do_linemarker (cpp_reader *pfile)
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
if (reason == LC_LEAVE)
{
const line_map_ordinary *from;
if (MAIN_FILE_P (map)
|| (new_file
&& (from = INCLUDED_FROM (pfile->line_table, map)) != NULL
&& filename_cmp (ORDINARY_MAP_FILE_NAME (from), new_file) != 0))
{
cpp_warning (pfile, CPP_W_NONE,
"file \"%s\" linemarker ignored due to incorrect nesting", new_file);
return;
}
}
/* Compensate for the increment in linemap_add that occurs in /* Compensate for the increment in linemap_add that occurs in
_cpp_do_file_change. We're currently at the start of the line _cpp_do_file_change. We're currently at the start of the line
*following* the #line directive. A separate source_location for this *following* the #line directive. A separate source_location for this
......
...@@ -512,43 +512,23 @@ linemap_add (struct line_maps *set, enum lc_reason reason, ...@@ -512,43 +512,23 @@ linemap_add (struct line_maps *set, enum lc_reason reason,
"included", this variable points the map in use right before the "included", this variable points the map in use right before the
#include "included", inside the same "includer" file. */ #include "included", inside the same "includer" file. */
line_map_ordinary *from; line_map_ordinary *from;
bool error;
if (MAIN_FILE_P (map - 1)) linemap_assert (!MAIN_FILE_P (map - 1));
{ /* (MAP - 1) points to the map we are leaving. The
/* So this _should_ mean we are leaving the main file -- map from which (MAP - 1) got included should be the map
effectively ending the compilation unit. But to_file not that comes right before MAP in the same file. */
being NULL means the caller thinks we are leaving to from = INCLUDED_FROM (set, map - 1);
another file. This is an erroneous behaviour but we'll
try to recover from it. Let's pretend we are not leaving
the main file. */
error = true;
reason = LC_RENAME;
from = map - 1;
}
else
{
/* (MAP - 1) points to the map we are leaving. The
map from which (MAP - 1) got included should be the map
that comes right before MAP in the same file. */
from = INCLUDED_FROM (set, map - 1);
error = to_file && filename_cmp (ORDINARY_MAP_FILE_NAME (from),
to_file);
}
/* Depending upon whether we are handling preprocessed input or
not, this can be a user error or an ICE. */
if (error)
fprintf (stderr, "line-map.c: file \"%s\" left but not entered\n",
to_file);
/* A TO_FILE of NULL is special - we use the natural values. */ /* A TO_FILE of NULL is special - we use the natural values. */
if (error || to_file == NULL) if (to_file == NULL)
{ {
to_file = ORDINARY_MAP_FILE_NAME (from); to_file = ORDINARY_MAP_FILE_NAME (from);
to_line = SOURCE_LINE (from, from[1].start_location); to_line = SOURCE_LINE (from, from[1].start_location);
sysp = ORDINARY_MAP_IN_SYSTEM_HEADER_P (from); sysp = ORDINARY_MAP_IN_SYSTEM_HEADER_P (from);
} }
else
linemap_assert (filename_cmp (ORDINARY_MAP_FILE_NAME (from),
to_file) == 0);
} }
map->sysp = sysp; map->sysp = sysp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment