This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix structs, c-decl rewrite, and PCH


Andrew Pinski <apinski@apple.com> writes:

> The problem I am seeing is that after the PCH is read in some
> structs which you declare in not in the PCH file but in the
> source file is not being finished.  This is caused by there
> being an extra scope being pushed for the file but there is
> an already a scope for the file.  This patch fixes this
> problem by checking if there exist a file scope already exist
> in push_file_scope and return right way.
> 
> OK? Bootstrapped on powerpc-apple-darwin with no regressions?

This patch is OK.

This is what, the fourth?  fifth?  sixth?  eighth?  fix to Zack's
patch.  I wonder how many more we'll need, and what the C frontend
will look like once they're all piled on top of each other.  Maybe
we'd be better off just backing it out.

> Testcase:
> Index: struct-1.c
> ===================================================================
> RCS file: struct-1.c
> diff -N struct-1.c
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ struct-1.c	22 Jun 2004 05:04:49 -0000
> @@ -0,0 +1,11 @@
> +#include "struct-1.h"
> +
> +struct ChainSearchRecord {
> + int identity;
> +};
> +typedef struct ChainSearchRecord ChainSearchRecord;
> +void foo (ChainSearchPtr s)
> +{
> +  s->identity = 0x6a73616d;
> +}
> +
> Index: struct-1.hs
> ===================================================================
> RCS file: struct-1.hs
> diff -N struct-1.hs
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ struct-1.hs	22 Jun 2004 05:04:49 -0000
> @@ -0,0 +1,3 @@
> +struct ChainSearchRecord;
> +typedef struct ChainSearchRecord *ChainSearchPtr;
> +
> 
> 
> ChangeLog:
> 	* c-decl.c (push_file_scope): Return early if we already
> 	have a file scope.
> 
> Patch:
> Index: c-decl.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
> retrieving revision 1.513
> diff -u -p -r1.513 c-decl.c
> --- c-decl.c	21 Jun 2004 23:04:49 -0000	1.513
> +++ c-decl.c	21 Jun 2004 23:18:18 -0000
> @@ -809,6 +809,9 @@ void
>   push_file_scope (void)
>   {
>     tree decl;
> +
> +  if (file_scope)
> +    return;
> 
>     push_scope ();
>     file_scope = current_scope;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]