]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/input.h
gcc:
[thirdparty/gcc.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 GTY(()) 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 #define location_from_locus(LOCUS) (LOCUS)
54
55 #else /* ! USE_MAPPED_LOCATION */
56
57 struct location_s GTY(())
58 {
59 /* The name of the source file involved. */
60 const char *file;
61
62 /* The line-location in the source file. */
63 int line;
64 };
65
66 typedef struct location_s expanded_location;
67 typedef struct location_s location_t;
68 typedef location_t *source_locus;
69
70 #define expand_location(FILELINE) (FILELINE)
71 extern location_t unknown_location;
72 #define UNKNOWN_LOCATION unknown_location
73
74 #define location_from_locus(LOCUS) (* (LOCUS))
75
76 #endif /* ! USE_MAPPED_LOCATION */
77
78 struct file_stack
79 {
80 struct file_stack *next;
81 location_t location;
82 };
83
84 /* Top-level source file. */
85 extern const char *main_input_filename;
86
87 extern location_t input_location;
88 #ifdef USE_MAPPED_LOCATION
89 extern void push_srcloc (location_t);
90 #else /* ! USE_MAPPED_LOCATION */
91 extern void push_srcloc (const char *name, int line);
92 #endif /* ! USE_MAPPED_LOCATION */
93 extern void pop_srcloc (void);
94 extern void restore_input_file_stack (int);
95
96 #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
97 #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
98
99 #define input_line LOCATION_LINE(input_location)
100 #define input_filename LOCATION_FILE(input_location)
101
102 /* Stack of currently pending input files.
103 The line member is not accurate for the innermost file on the stack. */
104 extern struct file_stack *input_file_stack;
105
106 /* Incremented on each change to input_file_stack. */
107 extern int input_file_stack_tick;
108
109 /* The number of bits available for input_file_stack_tick. */
110 #define INPUT_FILE_STACK_BITS 31
111
112 #endif