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]

[3.4 patch] Fix regression preprocessor/17610


Backport of fix from mainline to 3.4 branch.

Bootstrapped & regression tested on i686-pc-linux-gnu.

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: ../gcc/testsuite/gcc.dg/cpp/empty-include.c
===================================================================
RCS file: ../gcc/testsuite/gcc.dg/cpp/empty-include.c
diff -N ../gcc/testsuite/gcc.dg/cpp/empty-include.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ../gcc/testsuite/gcc.dg/cpp/empty-include.c	27 Nov 2004 21:21:42 -0000
@@ -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. */
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/cpplib.c,v
retrieving revision 1.355.4.2
diff -u -r1.355.4.2 cpplib.c
--- cpplib.c	24 Mar 2004 03:19:01 -0000	1.355.4.2
+++ cpplib.c	28 Nov 2004 23:09:48 -0000
@@ -680,6 +680,14 @@
   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_maps.depth >= CPP_STACK_MAX)
     cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply");

-- 
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]