diff options
author | Geoffrey Keating <geoffk@apple.com> | 2003-03-07 01:20:52 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-03-07 01:20:52 +0000 |
commit | 8643e92d0dd681d4effd5e65a0c9471a523fb7f6 (patch) | |
tree | 8ad6744b26cfc9c5e368db3e98047b9f2c161c89 /gcc/c-pch.c | |
parent | 7f3d80135f5d9e58ac87a6109eb1563e525a4c1a (diff) | |
download | gcc-8643e92d0dd681d4effd5e65a0c9471a523fb7f6.tar.gz |
c-pch.c: Include langhooks.h.
* c-pch.c: Include langhooks.h.
(IDENT_LENGTH): New.
(get_ident): New.
(pch_ident): Delete.
(pch_init): Use get_ident, IDENT_LENGTH.
(c_common_valid_pch): Likewise. Also, use actual language
in warning message.
* Makefile.in (c-pch.o): Add langhooks.h to dependencies.
* objc/config-lang.in (gtfiles): Add objc-act.c. Remove duplicate
c-parse.in.
* objc/Make-lang.in (objc/objc-act.o): Add dependency on
gt-objc-objc-act.h.
(gt-objc-objc-act.h): New rule.
* objc/lang-specs.h: Support PCH.
* objc/objc-act.c: Include gt-objc-objc-act.h.
(objc_add_static_instance): Move num_static_inst out, mark for PCH.
(build_selector_reference_decl): Move idx out, mark for PCH.
(build_class_reference_decl): Likewise.
(build_objc_string_decl): Move *_idx out, mark for PCH.
(build_tmp_function_decl): Move xxx out, mark for PCH.
From-SVN: r63924
Diffstat (limited to 'gcc/c-pch.c')
-rw-r--r-- | gcc/c-pch.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/gcc/c-pch.c b/gcc/c-pch.c index 13dc7631798..7e67248a325 100644 --- a/gcc/c-pch.c +++ b/gcc/c-pch.c @@ -29,19 +29,42 @@ Boston, MA 02111-1307, USA. */ #include "debug.h" #include "c-pragma.h" #include "ggc.h" +#include "langhooks.h" struct c_pch_header { unsigned long asm_size; }; -static const char pch_ident[8] = "gpchC010"; +#define IDENT_LENGTH 8 static FILE *pch_outfile; extern char *asm_file_name; static long asm_file_startpos; +static const char * get_ident PARAMS((void)); + +static const char * +get_ident() +{ + static char result[IDENT_LENGTH]; + static const char template[IDENT_LENGTH] = "gpch.010"; + + memcpy (result, template, IDENT_LENGTH); + if (strcmp (lang_hooks.name, "GNU C") == 0) + result[4] = 'C'; + else if (strcmp (lang_hooks.name, "GNU C++") == 0) + result[4] = '+'; + else if (strcmp (lang_hooks.name, "GNU Objective-C") == 0) + result[4] = 'o'; + else if (strcmp (lang_hooks.name, "GNU Objective-C++") == 0) + result[4] = 'O'; + else + abort (); + return result; +} + void pch_init () { @@ -58,7 +81,7 @@ pch_init () fatal_io_error ("can't open %s", pch_file); pch_outfile = f; - if (fwrite (pch_ident, sizeof (pch_ident), 1, f) != 1) + if (fwrite (get_ident(), IDENT_LENGTH, 1, f) != 1) fatal_io_error ("can't write to %s", pch_file); /* We need to be able to re-read the output. */ @@ -122,7 +145,8 @@ c_common_valid_pch (pfile, name, fd) { int sizeread; int result; - char ident[sizeof (pch_ident)]; + char ident[IDENT_LENGTH]; + const char *pch_ident; if (! allow_pch) return 2; @@ -130,16 +154,17 @@ c_common_valid_pch (pfile, name, fd) /* Perform a quick test of whether this is a valid precompiled header for C. */ - sizeread = read (fd, ident, sizeof (pch_ident)); + sizeread = read (fd, ident, IDENT_LENGTH); if (sizeread == -1) { fatal_io_error ("can't read %s", name); return 2; } - else if (sizeread != sizeof (pch_ident)) + else if (sizeread != IDENT_LENGTH) return 2; - if (memcmp (ident, pch_ident, sizeof (pch_ident)) != 0) + pch_ident = get_ident(); + if (memcmp (ident, pch_ident, IDENT_LENGTH) != 0) { if (cpp_get_options (pfile)->warn_invalid_pch) { @@ -150,7 +175,8 @@ c_common_valid_pch (pfile, name, fd) "%s: not compatible with this GCC version", name); else if (memcmp (ident, pch_ident, 4) == 0) /* It's a PCH for the wrong language. */ - cpp_error (pfile, DL_WARNING, "%s: not for C language", name); + cpp_error (pfile, DL_WARNING, "%s: not for %s", name, + lang_hooks.name); else /* Not any kind of PCH. */ cpp_error (pfile, DL_WARNING, "%s: not a PCH file", name); |