diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-04-08 23:41:09 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-04-08 23:41:09 +0000 |
commit | a08be054061d45117d45148efbb5d4689302468e (patch) | |
tree | b710236520736bf983ada97e6a7351511798518e /gcc/c-pch.c | |
parent | aa4a0945d04e016741b6cdb6661c73fe5a3161d3 (diff) | |
download | gcc-a08be054061d45117d45148efbb5d4689302468e.tar.gz |
2004-04-08 Geoffrey Keating <geoffk@apple.com>
PR pch/13419
PR pch/14137
Radar #: 3315288
* doc/invoke.texi (Precompiled Headers): Suggest -o
to put an output file in a particular place. Be more detailed
about which options affect PCH validity and which options
might not work.
* c-pch.c (pch_matching): New.
(MATCH_SIZE): New.
(struct c_pch_validity): New field 'match'.
(pch_init): Handle pch_matching.
(c_common_valid_pch): Check pch_matching.
Index: testsuite/ChangeLog
2004-04-08 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/pch/valid-1.c, gcc.dg/pch/valid-2.c, gcc.dg/pch/valid-3.c,
gcc.dg/pch/valid-4.c, gcc.dg/pch/valid-5.c, gcc.dg/pch/valid-6.c,
gcc.dg/pch/valid-1.hs, gcc.dg/pch/valid-2.hs, gcc.dg/pch/valid-3.hs,
gcc.dg/pch/valid-4.hs, gcc.dg/pch/valid-5.hs, gcc.dg/pch/valid-6.hs:
New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80531 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-pch.c')
-rw-r--r-- | gcc/c-pch.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/c-pch.c b/gcc/c-pch.c index 61418afaf49..8e2e6f126fa 100644 --- a/gcc/c-pch.c +++ b/gcc/c-pch.c @@ -35,6 +35,23 @@ Boston, MA 02111-1307, USA. */ #include "hosthooks.h" #include "target.h" +/* This is a list of flag variables that must match exactly, and their + names for the error message. The possible values for *flag_var must + fit in a 'signed char'. */ + +static const struct c_pch_matching +{ + int *flag_var; + const char *flag_name; +} pch_matching[] = { + { &flag_exceptions, "-fexceptions" }, + { &flag_unit_at_a_time, "-funit-at-a-time" } +}; + +enum { + MATCH_SIZE = ARRAY_SIZE (pch_matching) +}; + /* This structure is read very early when validating the PCH, and might be read for a PCH which is for a completely different compiler for a different operating system. Thus, it should really only contain @@ -52,6 +69,7 @@ struct c_pch_validity unsigned char target_machine_length; unsigned char version_length; unsigned char debug_info_type; + signed char match[MATCH_SIZE]; void (*pch_init) (void); size_t target_data_length; }; @@ -120,6 +138,15 @@ pch_init (void) v.target_machine_length = strlen (target_machine); v.version_length = strlen (version_string); v.debug_info_type = write_symbols; + { + size_t i; + for (i = 0; i < MATCH_SIZE; i++) + { + v.match[i] = *pch_matching[i].flag_var; + if (v.match[i] != *pch_matching[i].flag_var) + abort (); + } + } v.pch_init = &pch_init; target_validity = targetm.get_pch_validity (&v.target_data_length); @@ -302,6 +329,20 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd) return 2; } + /* Check flags that must match exactly. */ + { + size_t i; + for (i = 0; i < MATCH_SIZE; i++) + if (*pch_matching[i].flag_var != v.match[i]) + { + if (cpp_get_options (pfile)->warn_invalid_pch) + cpp_error (pfile, CPP_DL_WARNING, + "%s: settings for %s do not match", name, + pch_matching[i].flag_name); + return 2; + } + } + /* If the text segment was not loaded at the same address as it was when the PCH file was created, function pointers loaded from the PCH will not be valid. We could in theory remap all the function |