Commit 7a681365 by Geoffrey Keating Committed by Geoffrey Keating

re PR pch/12480 (pch error messages do not say they for PCH.)

	PR 12480
	* c-pch.c (pch_init): Improve error message when precompiled
	header can't be written.

	PR 12606
	* c-pch.c (pch_init): Make a PCH file appear invalid while it's
	being written.
	(c_common_write_pch): Make it valid once it's done.

From-SVN: r74754
parent 287ff198
2003-12-16 Geoffrey Keating <geoffk@apple.com>
PR 12480
* c-pch.c (pch_init): Improve error message when precompiled
header can't be written.
PR 12606
* c-pch.c (pch_init): Make a PCH file appear invalid while it's
being written.
(c_common_write_pch): Make it valid once it's done.
2003-12-17 Ulrich Weigand <uweigand@de.ibm.com> 2003-12-17 Ulrich Weigand <uweigand@de.ibm.com>
PR target/11992 PR target/11992
......
...@@ -102,13 +102,14 @@ pch_init (void) ...@@ -102,13 +102,14 @@ pch_init (void)
FILE *f; FILE *f;
struct c_pch_validity v; struct c_pch_validity v;
void *target_validity; void *target_validity;
static const char partial_pch[IDENT_LENGTH] = "gpcWrite";
if (! pch_file) if (! pch_file)
return; return;
f = fopen (pch_file, "w+b"); f = fopen (pch_file, "w+b");
if (f == NULL) if (f == NULL)
fatal_error ("can't open %s: %m", pch_file); fatal_error ("can't create precompiled header %s: %m", pch_file);
pch_outfile = f; pch_outfile = f;
if (strlen (host_machine) > 255 || strlen (target_machine) > 255 if (strlen (host_machine) > 255 || strlen (target_machine) > 255
...@@ -122,7 +123,7 @@ pch_init (void) ...@@ -122,7 +123,7 @@ pch_init (void)
v.pch_init = &pch_init; v.pch_init = &pch_init;
target_validity = targetm.get_pch_validity (&v.target_data_length); target_validity = targetm.get_pch_validity (&v.target_data_length);
if (fwrite (get_ident(), IDENT_LENGTH, 1, f) != 1 if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
|| fwrite (&v, sizeof (v), 1, f) != 1 || fwrite (&v, sizeof (v), 1, f) != 1
|| fwrite (host_machine, v.host_machine_length, 1, f) != 1 || fwrite (host_machine, v.host_machine_length, 1, f) != 1
|| fwrite (target_machine, v.target_machine_length, 1, f) != 1 || fwrite (target_machine, v.target_machine_length, 1, f) != 1
...@@ -189,6 +190,10 @@ c_common_write_pch (void) ...@@ -189,6 +190,10 @@ c_common_write_pch (void)
gt_pch_save (pch_outfile); gt_pch_save (pch_outfile);
cpp_write_pch_state (parse_in, pch_outfile); cpp_write_pch_state (parse_in, pch_outfile);
if (fseek (pch_outfile, 0, SEEK_SET) != 0
|| fwrite (get_ident (), IDENT_LENGTH, 1, pch_outfile) != 1)
fatal_error ("can't write %s: %m", pch_file);
fclose (pch_outfile); fclose (pch_outfile);
} }
......
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