OSDN Git Service

* cpplib.c (do_elif): Skip the rest of the line if we're
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Apr 2000 21:09:51 +0000 (21:09 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Apr 2000 21:09:51 +0000 (21:09 +0000)
not going to bother evaluating it.
(skip_if_group): Clear pfile->only_seen_white.  Reorder loop
to avoid pointless calls to the lexer.

* gcc.dg/cpp-mi2.c: New test.
* gcc.dg/cpp-mi2[abc].h: New files.

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

gcc/ChangeLog
gcc/cpplib.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp-mi2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-mi2a.h [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-mi2b.h [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-mi2c.h [new file with mode: 0644]

index c6e5b97..be0f998 100644 (file)
@@ -1,3 +1,10 @@
+2000-04-07  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * cpplib.c (do_elif): Skip the rest of the line if we're
+       not going to bother evaluating it.
+       (skip_if_group): Clear pfile->only_seen_white.  Reorder loop
+       to avoid pointless calls to the lexer.
+
 Fri Apr  7 11:50:54 2000  Jim Wilson  <wilson@cygnus.com>
 
        * config/ia64/ia64.c: Delete stdio.h and ctype.h includes.
index 52e83ba..babd20e 100644 (file)
@@ -1266,7 +1266,10 @@ do_elif (pfile)
     }
 
   if (pfile->if_stack->if_succeeded)
-    return skip_if_group (pfile);
+    {
+      _cpp_skip_rest_of_line (pfile);
+      return skip_if_group (pfile);
+    }
   if (_cpp_parse_expr (pfile) == 0)
     return skip_if_group (pfile);
 
@@ -1498,11 +1501,24 @@ skip_if_group (pfile)
   long old_written;
   int ret = 0;
 
+  /* We are no longer at the start of the file.  */
+  pfile->only_seen_white = 0;
+
   old_written = CPP_WRITTEN (pfile);
   pfile->no_macro_expand++;
   CPP_OPTION (pfile, no_line_commands)++;
   for (;;)
     {
+      /* We are at the end of a line.  Only cpp_get_token knows how to
+        advance the line number correctly.  */
+      token = cpp_get_token (pfile);
+      if (token == CPP_POP)
+       break;  /* Caller will issue error.  */
+      
+      else if (token != CPP_VSPACE)
+       cpp_ice (pfile, "cpp_get_token returned %d in skip_if_group", token);
+      CPP_SET_WRITTEN (pfile, old_written);
+
       token = _cpp_get_directive_token (pfile);
 
       if (token == CPP_DIRECTIVE)
@@ -1514,16 +1530,6 @@ skip_if_group (pfile)
 
       if (token != CPP_VSPACE)
        _cpp_skip_rest_of_line (pfile);
-
-      /* Only cpp_get_token knows how to advance the line number
-        properly.  */
-      token = cpp_get_token (pfile);
-      if (token == CPP_POP)
-       break;  /* Caller will issue error.  */
-      
-      else if (token != CPP_VSPACE)
-       cpp_ice (pfile, "cpp_get_token returned %d in skip_if_group", token);
-      CPP_SET_WRITTEN (pfile, old_written);
     }
   CPP_SET_WRITTEN (pfile, old_written);
   pfile->no_macro_expand--;
index d5f6bbd..afce1fb 100644 (file)
@@ -1,3 +1,8 @@
+2000-04-07  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * gcc.dg/cpp-mi2.c: New test.
+       * gcc.dg/cpp-mi2[abc].h: New files.
+
 2000-04-07  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.abi/vmihint.C: Adjust __vmi_class_type_info
diff --git a/gcc/testsuite/gcc.dg/cpp-mi2.c b/gcc/testsuite/gcc.dg/cpp-mi2.c
new file mode 100644 (file)
index 0000000..d5c814c
--- /dev/null
@@ -0,0 +1,12 @@
+/* Test for overly eager multiple include optimization.
+   Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h.
+   Problem noted by Tom Tromey <tromey@cygnus.com>.  */
+/* { dg-do compile } */
+
+#include "cpp-mi2a.h"
+#include "cpp-mi2b.h"
+
+int main (void)
+{
+  return x;
+}
diff --git a/gcc/testsuite/gcc.dg/cpp-mi2a.h b/gcc/testsuite/gcc.dg/cpp-mi2a.h
new file mode 100644 (file)
index 0000000..c86838c
--- /dev/null
@@ -0,0 +1,5 @@
+/* Test for overly eager multiple include optimization.
+   Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h. 
+   Problem noted by Tom Tromey <tromey@cygnus.com>.  */
+
+#include "cpp-mi2c.h"
diff --git a/gcc/testsuite/gcc.dg/cpp-mi2b.h b/gcc/testsuite/gcc.dg/cpp-mi2b.h
new file mode 100644 (file)
index 0000000..8d1970c
--- /dev/null
@@ -0,0 +1,6 @@
+/* Test for overly eager multiple include optimization.
+   Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h. 
+   Problem noted by Tom Tromey <tromey@cygnus.com>.  */
+
+#define need_x
+#include "cpp-mi2c.h"
diff --git a/gcc/testsuite/gcc.dg/cpp-mi2c.h b/gcc/testsuite/gcc.dg/cpp-mi2c.h
new file mode 100644 (file)
index 0000000..521792b
--- /dev/null
@@ -0,0 +1,15 @@
+/* Test for overly eager multiple include optimization.
+   Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h. 
+   Problem noted by Tom Tromey <tromey@cygnus.com>.  */
+#ifdef need_x
+#undef need_x
+#ifndef have_x
+#define have_x
+extern int x;
+#endif
+#endif
+
+#ifndef t_h
+#define t_h
+extern int y;
+#endif