This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix regression preprocessor/17610


Solves the bug (whee).  Bootstrapped & regression tested on i686-pc-linux-gnu.

A testcase is included (although it is imperfect, since in the failing case,
it has to wait and time out because it doesn't deal with stdin smoothly).
Testing of the testcase is in progress.  OK to commit?

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

Index: directives.c
===================================================================
RCS file: /cvs/gcc/gcc/libcpp/directives.c,v
retrieving revision 1.9
diff -u -p -r1.9 directives.c
--- directives.c	23 Nov 2004 23:25:39 -0000	1.9
+++ directives.c	27 Nov 2004 20:44:22 -0000
@@ -668,6 +668,14 @@ do_include_common (cpp_reader *pfile, en
   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");
--- /dev/null	2004-09-26 13:07:27.000000000 -0400
+++ empty-include.c	2004-11-27 15:40:59.000000000 -0500
@@ -0,0 +1,12 @@
+/* 
+ * 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" "include" } */
+

-- 
This space intentionally left blank.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]