Fix implicit-extern-C problem with PCH

Geoffrey Keating gkeating@apple.com
Wed Apr 7 20:45:00 GMT 2004


Obvious, once you've spent a few hours with the debugger to find the
variable in the first place.  The symptom of the problem is that the
implicit extern "C" around stddef.h persists once the PCH is loaded,
because there are pending pops that don't get saved, so you get:

externc-1.C:4: error: template with C linkage

Bootstrapped & tested on powerpc-darwin, and I checked that the
testcase does fail without the patch.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-3485838.patch=========================
Index: ChangeLog
2004-04-06  Geoffrey Keating  <geoffk@apple.com>

	* c-common.h (pending_lang_change): Mark for PCH.

Index: testsuite/ChangeLog
2004-04-06  Geoffrey Keating  <geoffk@apple.com>

	* g++.dg/pch/externc-1.Hs: New.
	* g++.dg/pch/externc-1.C: New.

Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.223
diff -u -p -u -p -r1.223 c-common.h
--- c-common.h	23 Mar 2004 23:47:34 -0000	1.223
+++ c-common.h	7 Apr 2004 20:39:45 -0000
@@ -1271,7 +1271,7 @@ extern void c_cpp_builtins (cpp_reader *
 
 /* Positive if an implicit `extern "C"' scope has just been entered;
    negative if such a scope has just been exited.  */
-extern int pending_lang_change;
+extern GTY(()) int pending_lang_change;
 
 /* Information recorded about each file examined during compilation.  */
 
Index: testsuite/g++.dg/pch/externc-1.C
===================================================================
RCS file: testsuite/g++.dg/pch/externc-1.C
diff -N testsuite/g++.dg/pch/externc-1.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/pch/externc-1.C	7 Apr 2004 20:39:46 -0000
@@ -0,0 +1,6 @@
+#include "externc-1.H"
+
+template <typename X> struct foo 
+{
+  X y;
+}
Index: testsuite/g++.dg/pch/externc-1.Hs
===================================================================
RCS file: testsuite/g++.dg/pch/externc-1.Hs
diff -N testsuite/g++.dg/pch/externc-1.Hs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/pch/externc-1.Hs	7 Apr 2004 20:39:46 -0000
@@ -0,0 +1 @@
+#include <stddef.h>
============================================================



More information about the Gcc-patches mailing list