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:
parent
d1a86812fa
commit
3963c2e00e
|
@ -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>
|
2003-02-11 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
|
||||||
|
|
||||||
* doc/install.texi (Specific): Update AVR- and Darwin-related URLs.
|
* doc/install.texi (Specific): Update AVR- and Darwin-related URLs.
|
||||||
|
|
52
gcc/cpplib.c
52
gcc/cpplib.c
|
@ -655,6 +655,7 @@ parse_include (pfile)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_eol (pfile);
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,40 +665,26 @@ do_include_common (pfile, type)
|
||||||
cpp_reader *pfile;
|
cpp_reader *pfile;
|
||||||
enum include_type type;
|
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. */
|
/* Prevent #include recursion. */
|
||||||
if (pfile->line_maps.depth >= CPP_STACK_MAX)
|
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. */
|
/* Get out of macro context, if we are. */
|
||||||
skip_rest_of_line (pfile);
|
skip_rest_of_line (pfile);
|
||||||
|
|
||||||
if (pfile->cb.include)
|
if (pfile->cb.include)
|
||||||
(*pfile->cb.include) (pfile, pfile->directive_line,
|
(*pfile->cb.include) (pfile, pfile->directive_line,
|
||||||
pfile->directive->name, header);
|
pfile->directive->name, header);
|
||||||
|
|
||||||
_cpp_execute_include (pfile, header, type);
|
_cpp_execute_include (pfile, header, type);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_include (pfile)
|
do_include (pfile)
|
||||||
|
@ -710,6 +697,13 @@ static void
|
||||||
do_import (pfile)
|
do_import (pfile)
|
||||||
cpp_reader *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);
|
do_include_common (pfile, IT_IMPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,7 +711,17 @@ static void
|
||||||
do_include_next (pfile)
|
do_include_next (pfile)
|
||||||
cpp_reader *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.
|
/* Subroutine of do_linemarker. Read possible flags after file name.
|
||||||
|
|
Loading…
Reference in New Issue