diff options
author | Nathanael Nerode <neroden@gcc.gnu.org> | 2004-11-28 22:28:13 +0000 |
---|---|---|
committer | Nathanael Nerode <neroden@gcc.gnu.org> | 2004-11-28 22:28:13 +0000 |
commit | 283038288ea4603511b9cc7088f2f1c38c9f3d54 (patch) | |
tree | 3a3b8763ec8b9788a57d6ba82b14ac6cdaf9d403 | |
parent | b20e82291eef31ef415bb218c172519d59da16ac (diff) | |
download | gcc-283038288ea4603511b9cc7088f2f1c38c9f3d54.zip gcc-283038288ea4603511b9cc7088f2f1c38c9f3d54.tar.gz gcc-283038288ea4603511b9cc7088f2f1c38c9f3d54.tar.bz2 |
re PR preprocessor/17610 (Empty #include statement halts gcc)
(libcpp)
PR preprocessor/17610
* directives.c (do_include_common): Error out if an empty filename
is given for #include (or #include_next or #import).
(gcc)
PR preprocessor/17610
* testsuite/gcc.dg/cpp/empty-include.c: New testcase.
From-SVN: r91428
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/empty-include.c | 13 | ||||
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/directives.c | 8 |
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b040c2a..4a87144 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-11-28 Nathanael Nerode <neroden@gcc.gnu.org> + + PR preprocessor/17610 + * testsuite/gcc.dg/cpp/empty-include.c: New testcase. + 2004-11-28 Jeff Law <law@redhat.com> * tree-ssa-alias.c (count_calls_and_maybe_create_global_var): New. diff --git a/gcc/testsuite/gcc.dg/cpp/empty-include.c b/gcc/testsuite/gcc.dg/cpp/empty-include.c new file mode 100644 index 0000000..6b5a47c --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/empty-include.c @@ -0,0 +1,13 @@ +/* + * Copyright 2004 Free Software Foundation, Inc. + * Contributed and written by Nathanael Nerode. + * + * GCC 3.4 would attempt to open stdin as the included file + * (PR 17610), causing a sort of hang. + * + * We should get an error. + */ + +/* {dg-do preprocess} */ +#include "" /* { dg-error "empty" "error on empty filename in include" } */ +int x; /* Otherwise we have an empty file and get more errors. */ diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 2b709b4..3b01f82 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2004-11-28 Nathanael Nerode <neroden@gcc.gnu.org> + + PR preprocessor/17610 + * directives.c (do_include_common): Error out if an empty filename + is given for #include (or #include_next or #import). + 2004-11-27 Roger Sayle <roger@eyesopen.com> Zack Weinberg <zack@codesourcery.com> diff --git a/libcpp/directives.c b/libcpp/directives.c index a835b68..fe1867d 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -668,6 +668,14 @@ do_include_common (cpp_reader *pfile, enum include_type type) if (!fname) return; + if (!*fname) + { + cpp_error (pfile, CPP_DL_ERROR, "empty filename in #%s", + pfile->directive->name); + free ((void *) fname); + return; + } + /* Prevent #include recursion. */ if (pfile->line_table->depth >= CPP_STACK_MAX) cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply"); |