]> gcc.gnu.org Git - gcc.git/commitdiff
input.h (push_srcloc): New function.
authorMark Mitchell <mark@codesourcery.com>
Fri, 25 Feb 2000 01:07:31 +0000 (01:07 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 25 Feb 2000 01:07:31 +0000 (01:07 +0000)
* input.h (push_srcloc): New function.
(pop_srcloc): Likewise.
* toplev.c (push_srcloc): Define it.
(pop_srcloc): Likewise.

From-SVN: r32141

gcc/ChangeLog
gcc/input.h
gcc/toplev.c

index 5424ba46328dd5aad51ab0e21e25dfddefda04bc..92aea2909df30e35da272ddbd56fac8a4e0151b7 100644 (file)
@@ -1,3 +1,10 @@
+2000-02-24  Mark Mitchell  <mark@codesourcery.com>
+
+       * input.h (push_srcloc): New function.
+       (pop_srcloc): Likewise.
+       * toplev.c (push_srcloc): Define it.
+       (pop_srcloc): Likewise.
+
 2000-02-24  Richard Henderson  <rth@cygnus.com>
 
        * flow.c (life_analysis): When collecting reg info, clear
index 5de5cdeb0fee63aa15fe4c1a32bb57d5086daefc..3aee605f9b936d35dc793da54a2074bf819c796a 100644 (file)
@@ -1,6 +1,6 @@
 /* Declarations for variables relating to reading the source file.
    Used by parsers, lexical analyzers, and error message routines.
-   Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1997, 1998, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -45,3 +45,6 @@ extern struct file_stack *input_file_stack;
 
 /* Incremented on each change to input_file_stack.  */
 extern int input_file_stack_tick;
+
+extern void push_srcloc PARAMS ((char *name, int line));
+extern void pop_srcloc PARAMS ((void));
index 8a0fc8801e8ced158d3e4de62b1172ce371fe546..ada79f9ed1372e14e2c84efcd46d60cfba560a75 100644 (file)
@@ -1996,6 +1996,52 @@ check_global_declarations (vec, len)
     }
 }
 
+/* Save the current INPUT_FILENAME and LINENO on the top entry in the
+   INPUT_FILE_STACK.  Push a new entry for FILE and LINE, and set the
+   INPUT_FILENAME and LINENO accordingly.  */
+
+void
+push_srcloc (file, line)
+     char *file;
+     int line;
+{
+  struct file_stack *fs;
+
+  if (input_file_stack)
+    {
+      input_file_stack->name = input_filename;
+      input_file_stack->line = lineno;
+    }
+
+  fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
+  fs->name = input_filename = file;
+  fs->line = lineno = line;
+  fs->indent_level = 0;
+  fs->next = input_file_stack;
+  input_file_stack = fs;
+  input_file_stack_tick++;
+}
+
+/* Pop the top entry off the stack of presently open source files.
+   Restore the INPUT_FILENAME and LINENO from the new topmost entry on
+   the stack.  */
+
+void
+pop_srcloc ()
+{
+  struct file_stack *fs;
+  
+  fs = input_file_stack;
+  input_file_stack = fs->next;
+  free (fs);
+  input_file_stack_tick++;
+  /* The initial souce file is never popped.  */
+  if (!input_file_stack)
+    abort ();
+  input_filename = input_file_stack->name;
+  lineno = input_file_stack->line;
+}
+
 /* Compile an entire file of output from cpp, named NAME.
    Write a file of assembly output and various debugging dumps.  */
 
@@ -2257,10 +2303,7 @@ compile_file (name)
   input_filename = name;
 
   /* Put an entry on the input file stack for the main input file.  */
-  input_file_stack
-    = (struct file_stack *) xmalloc (sizeof (struct file_stack));
-  input_file_stack->next = 0;
-  input_file_stack->name = input_filename;
+  push_srcloc (input_filename, 0);
 
   /* Perform language-specific initialization.
      This may set main_input_filename.  */
This page took 0.074833 seconds and 5 git commands to generate.