gt_pch_restore (f);
cpp_set_line_map (pfile, line_table);
rebuild_location_adhoc_htab (line_table);
+ line_table->trace_includes = saved_trace_includes;
+ linemap_add (line_table, LC_ENTER, 0, saved_loc.file, saved_loc.line);
timevar_push (TV_PCH_CPP_RESTORE);
if (cpp_read_state (pfile, name, f, smd) != 0)
fclose (f);
- line_table->trace_includes = saved_trace_includes;
- linemap_add (line_table, LC_ENTER, 0, saved_loc.file, saved_loc.line);
-
/* Give the front end a chance to take action after a PCH file has
been loaded. */
if (lang_post_pch_load)
--- /dev/null
+/* PR preprocessor/105608 */
+/* { dg-do compile } */
+#define MACRO_ON_A_LONG_LINE "this line is long enough that it forces the line table to create an LC_RENAME map, which formerly triggered an ICE after PCH restore"
+#include "line-map-1.H"
--- /dev/null
+/* This space intentionally left blank. */
--- /dev/null
+/* PR preprocessor/105608 */
+/* { dg-do compile } */
+/* { dg-additional-options "-save-temps" } */
+#define MACRO_ON_A_LONG_LINE "this line is long enough that it forces the line table to create an LC_RENAME map, which formerly triggered an ICE after PCH restore"
+#include "line-map-2.H"
+#error "suppress PCH assembly comparison, which does not work with -save-temps" /* { dg-error "." } */
--- /dev/null
+/* This space intentionally left blank. */
--- /dev/null
+#define UNUSED_MACRO /* { dg-error "UNUSED_MACRO" "" { xfail *-*-* } } */
+#include "line-map-3.H" /* { dg-bogus "-:UNUSED_MACRO" "" { xfail *-*-* } } */
+
+/* { dg-do compile } */
+/* { dg-additional-options "-Werror=unused-macros" } */
+
+/* PR preprocessor/105608 */
+/* This test case is currently xfailed and requires work in libcpp/pch.cc to
+ resolve. Currently, the macro location is incorrectly assigned to line 2
+ of the header file when read via PCH, because libcpp doesn't try to
+ assign locations relative to the newly loaded line map after restoring
+ the PCH. */
+
+/* In PCH mode we also complain incorrectly about the command line macro -Dwith_PCH
+ added by dejagnu; that warning would get suppressed if the macro location were
+ correctly restored by libcpp to reflect that it was a command line macro. */
+/* { dg-bogus "-:with_PCH" "" { xfail *-*-* } 2 } */
+
+/* The reason we used -Werror was to prevent pch.exp from rerunning without PCH;
+ in that case we would get unnecessary XPASS outputs since the test does work
+ fine without PCH. Once the bug is fixed, remove the -Werror and switch to
+ dg-warning. */
+/* { dg-regexp {[^[:space:]]*: some warnings being treated as errors} } */
--- /dev/null
+/* This space intentionally left blank. */