118334Speter/* Declarations for variables relating to reading the source file.
218334Speter   Used by parsers, lexical analyzers, and error message routines.
3169689Skan   Copyright (C) 1993, 1997, 1998, 2000, 2003, 2004 Free Software Foundation, Inc.
418334Speter
590075SobrienThis file is part of GCC.
618334Speter
790075SobrienGCC is free software; you can redistribute it and/or modify it under
890075Sobrienthe terms of the GNU General Public License as published by the Free
990075SobrienSoftware Foundation; either version 2, or (at your option) any later
1090075Sobrienversion.
1118334Speter
1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1490075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1590075Sobrienfor more details.
1618334Speter
1718334SpeterYou should have received a copy of the GNU General Public License
1890075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
19169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20169689Skan02110-1301, USA.  */
2118334Speter
22132718Skan#ifndef GCC_INPUT_H
23132718Skan#define GCC_INPUT_H
2418334Speter
25169689Skan#include "line-map.h"
26169689Skanextern struct line_maps line_table;
27169689Skan
28169689Skan/* The location for declarations in "<built-in>" */
29169689Skan#define BUILTINS_LOCATION ((source_location) 2)
30169689Skan
31169689Skan#ifdef USE_MAPPED_LOCATION
32169689Skan
33169689Skantypedef struct
34132718Skan{
35132718Skan  /* The name of the source file involved.  */
36132718Skan  const char *file;
37132718Skan
38132718Skan  /* The line-location in the source file.  */
39132718Skan  int line;
40169689Skan
41169689Skan  int column;
42169689Skan} expanded_location;
43169689Skan
44169689Skanextern expanded_location expand_location (source_location);
45169689Skan
46169689Skan#define UNKNOWN_LOCATION ((source_location) 0)
47169689Skantypedef source_location location_t; /* deprecated typedef */
48169689Skantypedef source_location source_locus; /* to be removed */
49169689Skan
50169689Skan#else /* ! USE_MAPPED_LOCATION */
51169689Skan
52169689Skanstruct location_s GTY(())
53169689Skan{
54169689Skan  /* The name of the source file involved.  */
55169689Skan  const char *file;
56169689Skan
57169689Skan  /* The line-location in the source file.  */
58169689Skan  int line;
59132718Skan};
60169689Skan
61169689Skantypedef struct location_s expanded_location;
62132718Skantypedef struct location_s location_t;
63169689Skantypedef location_t *source_locus;
64132718Skan
65169689Skan#define expand_location(FILELINE) (FILELINE)
66169689Skanextern location_t unknown_location;
67169689Skan#define UNKNOWN_LOCATION unknown_location
68169689Skan
69169689Skan#endif /* ! USE_MAPPED_LOCATION */
70169689Skan
71132718Skanstruct file_stack
72132718Skan{
73132718Skan  struct file_stack *next;
74132718Skan  location_t location;
75132718Skan};
76132718Skan
7718334Speter/* Top-level source file.  */
7890075Sobrienextern const char *main_input_filename;
7918334Speter
80132718Skanextern location_t input_location;
81169689Skan#ifdef USE_MAPPED_LOCATION
82169689Skanextern void push_srcloc (location_t);
83169689Skan#else /* ! USE_MAPPED_LOCATION */
84169689Skanextern void push_srcloc (const char *name, int line);
85169689Skan#endif /* ! USE_MAPPED_LOCATION */
86169689Skanextern void pop_srcloc (void);
87169689Skanextern void restore_input_file_stack (int);
8818334Speter
89169689Skan#define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
90169689Skan#define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
91169689Skan
92169689Skan#define input_line LOCATION_LINE(input_location)
93169689Skan#define input_filename LOCATION_FILE(input_location)
94169689Skan
9518334Speter/* Stack of currently pending input files.
9618334Speter   The line member is not accurate for the innermost file on the stack.  */
9718334Speterextern struct file_stack *input_file_stack;
9818334Speter
9918334Speter/* Incremented on each change to input_file_stack.  */
10018334Speterextern int input_file_stack_tick;
10190075Sobrien
102169689Skan/* The number of bits available for input_file_stack_tick.  */
103169689Skan#define INPUT_FILE_STACK_BITS	31
104132718Skan
105132718Skan#endif
106