OSDN Git Service

* cpplib.c (do_if): Don't save and restore only_seen_white here.
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2000 02:40:48 +0000 (02:40 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2000 02:40:48 +0000 (02:40 +0000)
* cppexp.c (_cpp_parse_expr): Save and restore only_seen_white
and skipping here.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34260 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cppexp.c
gcc/cpplib.c
gcc/testsuite/gcc.dg/20000529-1.c [new file with mode: 0644]

index 3fc2746..525c8b0 100644 (file)
@@ -1,3 +1,9 @@
+2000-05-29  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * 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.
+
 2000-05-29  Richard Earnshaw (rearnsha@arm.com)
 
        * flow.c (mark_used_reg): If a register is unconditionally live, 
@@ -249,14 +255,14 @@ Sun May 28 23:26:59 2000  Philippe De Muyter <phdm@macqel.be>
 
 2000-05-28  Neil Booth  <NeilB@earthling.net>
 
-        * cpplex.c (_cpp_init_toklist): No comment space to initialise.
+       * cpplex.c (_cpp_init_toklist): No comment space to initialise.
        (_cpp_free_toklist): No comment space to free.
        (expand_comment_space): Remove.
-        (save_comment_space): Place the comment in the current token and
-        not in a separate comment space.
-        (_cpp_lex_line): Save comments during plain code and #define
-        directives only.
-        * cpplib.h (struct _cpp_toklist): Remove comment space.
+       (save_comment_space): Place the comment in the current token and
+       not in a separate comment space.
+       (_cpp_lex_line): Save comments during plain code and #define
+       directives only.
+       * cpplib.h (struct _cpp_toklist): Remove comment space.
 
 2000-05-28  Neil Booth  <NeilB@earthling.net>
 
index b50acd8..58430c3 100644 (file)
@@ -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;
 }
index 3bc8825..e339c1e 100644 (file)
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/20000529-1.c b/gcc/testsuite/gcc.dg/20000529-1.c
new file mode 100644 (file)
index 0000000..6343a81
--- /dev/null
@@ -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;