Since r14-2893, we create a parser object in preprocess-only mode for the
purpose of parsing #pragma while preprocessing. The parser object was
formerly created after calling c_finish_options(), which leads to problems
on platforms that don't use stdc-predef.h (such as MinGW, as reported in
the PR). On such platforms, the call to c_finish_options() will process
the first command-line-specified include file. If that includes a PCH, then
c-ppoutput.cc will encounter a state it did not anticipate. Fix it by
creating the parser prior to calling c_finish_options().
gcc/c-family/ChangeLog:
PR pch/115312
* c-opts.cc (c_common_init): Call c_init_preprocess() before
c_finish_options() so that a parser is available to process any
includes specified on the command line.
gcc/testsuite/ChangeLog:
PR pch/115312
* g++.dg/pch/pr115312.C: New test.
* g++.dg/pch/pr115312.Hs: New test.
if (flag_preprocess_only)
{
- c_finish_options ();
c_init_preprocess ();
+ c_finish_options ();
preprocess_file (parse_in);
return false;
}
--- /dev/null
+/* { dg-additional-options "-include pr115312.H -save-temps" } */
+#error "suppress PCH assembly comparison, which does not work with -save-temps" /* { dg-error "." } */
--- /dev/null
+// This space intentionally left blank.