re PR pch/13419 (Clarification of invoke.texi requested)

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.

From-SVN: r80531
This commit is contained in:
Geoffrey Keating 2004-04-08 23:41:09 +00:00 committed by Geoffrey Keating
parent f07e9f0f28
commit 54e109edfb
18 changed files with 160 additions and 21 deletions

View file

@ -1,5 +1,18 @@
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.
* explow.c: Fix typo defining default of PROMOTE_FUNCTION_MODE.
2004-04-08 Mark Mitchell <mark@codesourcery.com>

View file

@ -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

View file

@ -11380,11 +11380,11 @@ they've already been included (in the precompiled header).
If you need to precompile the same header file for different
languages, targets, or compiler options, you can instead make a
@emph{directory} named like @file{all.h.gch}, and put each precompiled
header in the directory. (It doesn't matter what you call the files
in the directory, every precompiled header in the directory will be
considered.) The first precompiled header encountered in the
directory that is valid for this compilation will be used; they're
searched in no particular order.
header in the directory, perhaps using @option{-o}. It doesn't matter
what you call the files in the directory, every precompiled header in
the directory will be considered. The first precompiled header
encountered in the directory that is valid for this compilation will
be used; they're searched in no particular order.
There are many other possibilities, limited only by your imagination,
good sense, and the constraints of your build system.
@ -11394,40 +11394,68 @@ A precompiled header file can be used only when these conditions apply:
@itemize
@item
Only one precompiled header can be used in a particular compilation.
@item
A precompiled header can't be used once the first C token is seen. You
can have preprocessor directives before a precompiled header; you can
even include a precompiled header from inside another header, so long as
there are no C tokens before the @code{#include}.
@item
The precompiled header file must be produced for the same language as
the current compilation. You can't use a C precompiled header for a C++
compilation.
@item
The precompiled header file must be produced by the same compiler
version and configuration as the current compilation is using.
The easiest way to guarantee this is to use the same compiler binary
for creating and using precompiled headers.
@item
Any macros defined before the precompiled header (including with
@option{-D}) must either be defined in the same way as when the
precompiled header was generated, or must not affect the precompiled
header, which usually means that the they don't appear in the
precompiled header at all.
Any macros defined before the precompiled header is included must
either be defined in the same way as when the precompiled header was
generated, or must not affect the precompiled header, which usually
means that the they don't appear in the precompiled header at all.
The @option{-D} option is one way to define a macro before a
precompiled header is included; using a @code{#define} can also do it.
There are also some options that define macros implicitly, like
@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
defined this way.
@item If debugging information is output when using the precompiled
header, using @option{-g} or similar, the same kind of debugging information
must have been output when building the precompiled header. However,
a precompiled header built using @option{-g} can be used in a compilation
when no debugging information is being output.
@item The same @option{-m} options must generally be used when building
and using the precompiled header. @xref{Submodel Options},
for any cases where this rule is relaxed.
@item Each of the following options must be the same when building and using
the precompiled header:
@gccoptlist{-fexceptions -funit-at-a-time}
@item
Certain command-line options must be defined in the same way as when the
precompiled header was generated. At present, it's not clear which
options are safe to change and which are not; the safest choice is to
use exactly the same options when generating and using the precompiled
header.
Some other command-line options starting with @option{-f},
@option{-p}, or @option{-O} must be defined in the same way as when
the precompiled header was generated. At present, it's not clear
which options are safe to change and which are not; the safest choice
is to use exactly the same options when generating and using the
precompiled header. The following are known to be safe:
@gccoptlist{-pedantic-errors}
@end itemize
For all of these but the last, the compiler will automatically ignore
the precompiled header if the conditions aren't met. For the last item,
some option changes will cause the precompiled header to be rejected,
but not all incompatible option combinations have yet been found. If
you find a new incompatible combination, please consider filing a bug
report, see @ref{Bugs}.
For all of these except the last, the compiler will automatically
ignore the precompiled header if the conditions aren't met. If you
find an option combination that doesn't work and doesn't cause the
precompiled header to be ignored, please consider filing a bug report,
see @ref{Bugs}.
@node Running Protoize
@section Running Protoize

View file

@ -1,3 +1,11 @@
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.
2004-04-08 Paul Brook <paul@codesourcery.com>
* gcc.dg/spill-1.c: New test.

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -g" } */
#include "valid-1.h"/* { dg-error "created with -gnone, but used with -g|No such file|they were invalid" } */
int x;

View file

@ -0,0 +1,3 @@
/* { dg-options "-I. -Winvalid-pch -g0" } */
extern int x;

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -g0" } */
#include "valid-1b.h"
int x;

View file

@ -0,0 +1,3 @@
/* { dg-options "-I. -Winvalid-pch -g" } */
extern int x;

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -fexceptions" } */
#include "valid-2.h"/* { dg-error "settings for -fexceptions do not match|No such file|they were invalid" } */
int x;

View file

@ -0,0 +1 @@
extern int x;

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -fno-unit-at-a-time" } */
#include "valid-3.h"/* { dg-error "settings for -funit-at-a-time do not match|No such file|they were invalid" } */
int x;

View file

@ -0,0 +1,3 @@
/* { dg-options "-I. -Winvalid-pch -funit-at-a-time" } */
extern int x;

View file

@ -0,0 +1,6 @@
/* { dg-options "-I. -Winvalid-pch -Wtrigraphs" } */
#include "valid-4.h"
char * x = "??/"; /* { dg-error "trigraph" } */

View file

@ -0,0 +1 @@
extern char * x;

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -pedantic-errors" } */
#include "valid-5.h"
int x;

View file

@ -0,0 +1 @@
extern int x;

View file

@ -0,0 +1,5 @@
/* { dg-options "-I. -Winvalid-pch -dH -pipe -fcond-mismatch" } */
#include "valid-6.h"
int x;

View file

@ -0,0 +1 @@
extern int x;