cpplib.c (do_include_common): Move warnings for #include_next and #import out to callers.

* 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.

From-SVN: r62772
This commit is contained in:
Zack Weinberg 2003-02-12 17:01:53 +00:00
parent d1a86812fa
commit 3963c2e00e
2 changed files with 68 additions and 55 deletions

View File

@ -1,3 +1,12 @@
2003-02-12 Zack Weinberg <zack@codesourcery.com>
* 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.
2003-02-11 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
* doc/install.texi (Specific): Update AVR- and Darwin-related URLs.

View File

@ -655,6 +655,7 @@ parse_include (pfile)
return NULL;
}
check_eol (pfile);
return header;
}
@ -664,40 +665,26 @@ 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)
{
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");
}
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);
cpp_error (pfile, DL_ERROR, "#include nested too deeply");
return;
}
/* 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
do_include (pfile)
@ -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.