summaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-15 07:57:13 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-15 07:57:13 +0000
commit0d6d8dc06b3897f91ae37114b949a45fecca4473 (patch)
tree8a4a56e335e3fea702888b8f8de7fa5ee14ec72e /gcc/cpplib.c
parent35ccf3b05dece0d6de2fbfb098d5a7a77926f926 (diff)
downloadgcc-0d6d8dc06b3897f91ae37114b949a45fecca4473.tar.gz
* cpp.texi: Update documentation for -include and -imacros.
* cppfiles.c (struct include_file): Remove "defined" memeber. (find_or_create_entry): Make a copy of the file name, and simplify it. (open_file): Update to ensure we use the simplified filename. (stack_include_file): Don't set search_from. (cpp_included): Don't simplify the path name here. (find_include_file): New prototype. Call search_from to get the start of the "" include chain. Don't simplify the filenames here. (_cpp_execute_include): New prototype. Move diagnostics to do_include_common. Update. (_cpp_pop_file_buffer): Don't set defined. (search_from): New prototype. Use the preprocessor's cwd for files included from the command line. (read_name_map): Don't simplify the pathname here. * cpphash.h (enum include_type): New. (struct buffer): Delete search from. New search_cached. (_cpp_execute_include): Update prototype. * cppinit.c (do_includes): Use _cpp_execute_include. * cpplib.c (do_include_common): New function. (do_include, do_include_next, do_import): Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40486 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 963ab9b2a99..00fb1483cc0 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -95,6 +95,7 @@ static int strtoul_for_line PARAMS ((const U_CHAR *, unsigned int,
unsigned long *));
static void do_diagnostic PARAMS ((cpp_reader *, enum error_type, int));
static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *));
+static void do_include_common PARAMS ((cpp_reader *, enum include_type));
static void do_pragma_once PARAMS ((cpp_reader *));
static void do_pragma_poison PARAMS ((cpp_reader *));
static void do_pragma_system_header PARAMS ((cpp_reader *));
@@ -585,22 +586,47 @@ parse_include (pfile, header)
return 0;
}
+/* Handle #include, #include_next and #import. */
static void
-do_include (pfile)
+do_include_common (pfile, type)
cpp_reader *pfile;
+ enum include_type type;
{
cpp_token header;
if (!parse_include (pfile, &header))
- _cpp_execute_include (pfile, &header, 0, 0);
+ {
+ /* Prevent #include recursion. */
+ if (pfile->buffer_stack_depth >= CPP_STACK_MAX)
+ cpp_fatal (pfile, "#include nested too deeply");
+ else if (pfile->context->prev)
+ cpp_ice (pfile, "attempt to push file buffer with contexts stacked");
+ else
+ {
+ /* For #include_next, if this is the primary source file,
+ warn and use the normal search logic. */
+ if (type == IT_INCLUDE_NEXT && ! pfile->buffer->prev)
+ {
+ cpp_warning (pfile, "#include_next in primary source file");
+ type = IT_INCLUDE;
+ }
+
+ _cpp_execute_include (pfile, &header, type);
+ }
+ }
}
static void
-do_import (pfile)
+do_include (pfile)
cpp_reader *pfile;
{
- cpp_token header;
+ do_include_common (pfile, IT_INCLUDE);
+}
+static void
+do_import (pfile)
+ cpp_reader *pfile;
+{
if (!pfile->import_warning && CPP_OPTION (pfile, warn_import))
{
pfile->import_warning = 1;
@@ -608,25 +634,14 @@ do_import (pfile)
"#import is obsolete, use an #ifndef wrapper in the header file");
}
- if (!parse_include (pfile, &header))
- _cpp_execute_include (pfile, &header, 1, 0);
+ do_include_common (pfile, IT_IMPORT);
}
static void
do_include_next (pfile)
cpp_reader *pfile;
{
- cpp_token header;
-
- if (!parse_include (pfile, &header))
- {
- /* If this is the primary source file, warn and use the normal
- search logic. */
- if (! pfile->buffer->prev)
- cpp_warning (pfile, "#include_next in primary source file");
-
- _cpp_execute_include (pfile, &header, 0, pfile->buffer->prev != 0);
- }
+ do_include_common (pfile, IT_INCLUDE_NEXT);
}
/* Subroutine of do_line. Read possible flags after file name. LAST