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

Andrew Pinski apinski@apple.com
Tue Jun 22 09:56:00 GMT 2004


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?

Thanks,
Andrew Pinski
apinski@apple.com
pinskia@physics.uc.edu


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;



More information about the Gcc-patches mailing list