OSDN Git Service

Change copyright header to refer to version 3 of the GNU General Public License and...
[pf3gnuchains/gcc-fork.git] / gcc / input.h
1 /* Declarations for variables relating to reading the source file.
2    Used by parsers, lexical analyzers, and error message routines.
3    Copyright (C) 1993, 1997, 1998, 2000, 2003, 2004, 2007
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef GCC_INPUT_H
23 #define GCC_INPUT_H
24
25 #include "line-map.h"
26 extern struct line_maps line_table;
27
28 /* The location for declarations in "<built-in>" */
29 #define BUILTINS_LOCATION ((source_location) 2)
30
31 /* Note: if any of the types defined inside this #ifdef are changed,
32    gengtype.c:define_location_structures must be updated to match.  */
33
34 #ifdef USE_MAPPED_LOCATION
35
36 typedef struct
37 {
38   /* The name of the source file involved.  */
39   const char *file;
40
41   /* The line-location in the source file.  */
42   int line;
43
44   int column;
45 } expanded_location;
46
47 extern expanded_location expand_location (source_location);
48
49 #define UNKNOWN_LOCATION ((source_location) 0)
50 typedef source_location location_t; /* deprecated typedef */
51 typedef source_location source_locus; /* to be removed */
52
53 #else /* ! USE_MAPPED_LOCATION */
54
55 struct location_s GTY(())
56 {
57   /* The name of the source file involved.  */
58   const char *file;
59
60   /* The line-location in the source file.  */
61   int line;
62 };
63
64 typedef struct location_s expanded_location;
65 typedef struct location_s location_t;
66 typedef location_t *source_locus;
67
68 #define expand_location(FILELINE) (FILELINE)
69 extern location_t unknown_location;
70 #define UNKNOWN_LOCATION unknown_location
71
72 #endif /* ! USE_MAPPED_LOCATION */
73
74 struct file_stack
75 {
76   struct file_stack *next;
77   location_t location;
78 };
79
80 /* Top-level source file.  */
81 extern const char *main_input_filename;
82
83 extern location_t input_location;
84 #ifdef USE_MAPPED_LOCATION
85 extern void push_srcloc (location_t);
86 #else /* ! USE_MAPPED_LOCATION */
87 extern void push_srcloc (const char *name, int line);
88 #endif /* ! USE_MAPPED_LOCATION */
89 extern void pop_srcloc (void);
90 extern void restore_input_file_stack (int);
91
92 #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
93 #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
94
95 #define input_line LOCATION_LINE(input_location)
96 #define input_filename LOCATION_FILE(input_location)
97
98 /* Stack of currently pending input files.
99    The line member is not accurate for the innermost file on the stack.  */
100 extern struct file_stack *input_file_stack;
101
102 /* Incremented on each change to input_file_stack.  */
103 extern int input_file_stack_tick;
104
105 /* The number of bits available for input_file_stack_tick.  */
106 #define INPUT_FILE_STACK_BITS   31
107
108 #endif