This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpp w/ glibc
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: Re: cpp w/ glibc
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Mon, 29 May 2000 17:02:11 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- References: <m33dn1mcel.fsf@localhost.localnet>
On Mon, May 29, 2000 at 11:36:34AM -0700, Ulrich Drepper wrote:
> Zack,
>
> you recent changes (I assume those from today) completely screw up
> cpp. Compiling glibc leads to completey bogus messages. Please try
> compiling glibc on x86.
This patch should fix the bug. I'll commit it if it survives a
bootstrap and builds the entire of libc correctly.
zw
* cpplib.c (do_if): Don't save and restore only_seen_white here.
* cppexp.c (_cpp_parse_expr): Save and restore only_seen_white
and skipping here.
===================================================================
Index: testsuite/gcc.dg/20000529-1.c
--- testsuite/gcc.dg/20000529-1.c Tue May 5 13:32:27 1998
+++ testsuite/gcc.dg/20000529-1.c Mon May 29 17:00:28 2000
@@ -0,0 +1,14 @@
+/* Regression test for bug with macro expansion on #if lines -
+ exposed by glibc. */
+/* { dg-do compile } */
+
+# define SHLIB_COMPAT(lib, introduced, obsoleted) \
+ (!(ABI_##lib##_##obsoleted - 0) \
+ || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0)))
+
+#if 0
+bad
+#elif SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+int
+#endif
+x;
===================================================================
Index: cpplib.c
--- cpplib.c 2000/05/29 16:19:31 1.171
+++ cpplib.c 2000/05/29 23:58:42
@@ -1186,15 +1186,11 @@ do_if (pfile)
{
const cpp_hashnode *cmacro = 0;
int value = 0;
- int save_only_seen_white = pfile->only_seen_white;
if (! pfile->skipping)
{
cmacro = detect_if_not_defined (pfile);
-
- pfile->only_seen_white = 0;
value = _cpp_parse_expr (pfile);
- pfile->only_seen_white = save_only_seen_white;
}
push_conditional (pfile, value == 0, T_IF, cmacro);
return 0;
===================================================================
Index: cppexp.c
--- cppexp.c 2000/05/28 05:56:37 1.59
+++ cppexp.c 2000/05/29 23:58:42
@@ -843,6 +843,12 @@ _cpp_parse_expr (pfile)
int result;
char buff[5];
+ /* Save parser state and set it to something sane. */
+ int save_only_seen_white = pfile->only_seen_white;
+ int save_skipping = pfile->skipping;
+ pfile->only_seen_white = 0;
+ pfile->skipping = 0;
+
/* We've finished when we try to reduce this. */
top->op = FINISHED;
/* Nifty way to catch missing '('. */
@@ -1162,5 +1168,7 @@ _cpp_parse_expr (pfile)
if (stack != init_stack)
free (stack);
CPP_SET_WRITTEN (pfile, old_written);
+ pfile->only_seen_white = save_only_seen_white;
+ pfile->skipping = save_skipping;
return result;
}