diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-12 17:01:53 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-12 17:01:53 +0000 |
commit | f4578baa64018acd9ac5cee20cb753d5f7a53024 (patch) | |
tree | 91ae138d4bace4f374af6fe05a30a7980676effc /gcc/cpplib.c | |
parent | 868aa50a5e42f060d615058de6483727edb7c376 (diff) | |
download | gcc-f4578baa64018acd9ac5cee20cb753d5f7a53024.tar.gz |
* cpplib.c (do_include_common): Move warnings for
#include_next and #import out to callers. Use early-return
instead of nested ifs. Don't do check_eol here.
(parse_include): Do check_eol here with the rest of the
parsing stuff.
(do_include_next, do_import): Now handle warnings.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62772 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index a40fe1229ff..b63fd262339 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -655,6 +655,7 @@ parse_include (pfile) return NULL; } + check_eol (pfile); return header; } @@ -664,39 +665,25 @@ do_include_common (pfile, type) cpp_reader *pfile; enum include_type type; { - const cpp_token *header; + const cpp_token *header = parse_include (pfile); + if (!header) + return; - /* 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) + /* Prevent #include recursion. */ + if (pfile->line_maps.depth >= CPP_STACK_MAX) { - cpp_error (pfile, DL_WARNING, "#include_next in primary source file"); - type = IT_INCLUDE; - } - else if (type == IT_IMPORT && CPP_OPTION (pfile, warn_import)) - { - CPP_OPTION (pfile, warn_import) = 0; - cpp_error (pfile, DL_WARNING, - "#import is obsolete, use an #ifndef wrapper in the header file"); + cpp_error (pfile, DL_ERROR, "#include nested too deeply"); + return; } - header = parse_include (pfile); - if (header) - { - /* Prevent #include recursion. */ - if (pfile->line_maps.depth >= CPP_STACK_MAX) - cpp_error (pfile, DL_ERROR, "#include nested too deeply"); - else - { - check_eol (pfile); - /* Get out of macro context, if we are. */ - skip_rest_of_line (pfile); - if (pfile->cb.include) - (*pfile->cb.include) (pfile, pfile->directive_line, - pfile->directive->name, header); - _cpp_execute_include (pfile, header, type); - } - } + /* Get out of macro context, if we are. */ + skip_rest_of_line (pfile); + + if (pfile->cb.include) + (*pfile->cb.include) (pfile, pfile->directive_line, + pfile->directive->name, header); + + _cpp_execute_include (pfile, header, type); } static void @@ -710,6 +697,13 @@ static void do_import (pfile) cpp_reader *pfile; { + if (CPP_OPTION (pfile, warn_import)) + { + CPP_OPTION (pfile, warn_import) = 0; + cpp_error (pfile, DL_WARNING, + "#import is obsolete, use an #ifndef wrapper in the header file"); + } + do_include_common (pfile, IT_IMPORT); } @@ -717,7 +711,17 @@ static void do_include_next (pfile) cpp_reader *pfile; { - do_include_common (pfile, IT_INCLUDE_NEXT); + enum include_type type = IT_INCLUDE_NEXT; + + /* If this is the primary source file, warn and use the normal + search logic. */ + if (! pfile->buffer->prev) + { + cpp_error (pfile, DL_WARNING, + "#include_next in primary source file"); + type = IT_INCLUDE; + } + do_include_common (pfile, type); } /* Subroutine of do_linemarker. Read possible flags after file name. |