Index: gcc/cpplib.h
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/cpplib.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/cpplib.h	26 Mar 2004 13:22:22 -0000	1.1
+++ gcc/cpplib.h	8 Sep 2004 14:45:38 -0000	1.2
@@ -345,6 +345,9 @@ struct cpp_options
   /* Nonzero means warn of unused macros from the main file.  */
   unsigned char warn_unused_macros;
 
+  /* Nonzero means issue a warning if input file ends without a newline. */
+  unsigned char warn_eof_newline;
+
   /* Nonzero for the 1999 C Standard, including corrigenda and amendments.  */
   unsigned char c99;
 
Index: gcc/cppinit.c
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/cppinit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/cppinit.c	26 Mar 2004 13:22:22 -0000	1.1
+++ gcc/cppinit.c	8 Sep 2004 14:45:38 -0000	1.2
@@ -529,6 +529,7 @@ cpp_create_reader (lang)
   CPP_OPTION (pfile, tabstop) = 8;
   CPP_OPTION (pfile, operator_names) = 1;
   CPP_OPTION (pfile, warn_endif_labels) = 1;
+  CPP_OPTION (pfile, warn_eof_newline) = 1;
   CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
   CPP_OPTION (pfile, sysroot) = cpp_SYSROOT;
 
Index: gcc/c-opts.c
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/c-opts.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/c-opts.c	26 Mar 2004 13:22:21 -0000	1.1
+++ gcc/c-opts.c	8 Sep 2004 14:45:38 -0000	1.2
@@ -1381,6 +1381,9 @@ c_common_post_options ()
 	}
     }
 
+  /* This should not really be here, as it could be more generically done elsewhere. */
+  cpp_opts->warn_eof_newline = warn_eof_newline;
+
   /* Special format checking options don't work without -Wformat; warn if
      they are used.  */
   if (warn_format_y2k && !warn_format)
Index: gcc/cpplex.c
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/cpplex.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/cpplex.c	26 Mar 2004 13:22:22 -0000	1.1
+++ gcc/cpplex.c	8 Sep 2004 14:45:38 -0000	1.2
@@ -911,7 +911,7 @@ continue_after_nul (pfile)
 	    {
 	      /* Non-empty files should end in a newline.  Don't warn
 		 for command line and _Pragma buffers.  */
-	      if (!buffer->from_stage3)
+	      if (!buffer->from_stage3 && CPP_OPTION (pfile, warn_eof_newline))
 		cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
 	      handle_newline (pfile);
 	    }
Index: gcc/flags.h
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/flags.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/flags.h	26 Mar 2004 13:22:22 -0000	1.1
+++ gcc/flags.h	8 Sep 2004 14:45:38 -0000	1.2
@@ -86,6 +86,10 @@ extern int inhibit_warnings;
 
 extern int warn_system_headers;
 
+/* Do/Don't issue a warning if input file ends without a newline. -Weof-newline. */
+
+extern int warn_eof_newline;
+
 /* Do print extra warnings (such as for uninitialized variables).  -W.  */
 
 extern int extra_warnings;
Index: gcc/cpptrad.c
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/cpptrad.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/cpptrad.c	26 Mar 2004 13:22:22 -0000	1.1
+++ gcc/cpptrad.c	8 Sep 2004 14:45:38 -0000	1.2
@@ -487,7 +487,7 @@ scan_out_logical_line (pfile, macro)
 
 	  /* Premature end of file.  Fake a new line.  */
 	  cur--;
-	  if (!pfile->buffer->from_stage3)
+	  if (!pfile->buffer->from_stage3 && CPP_OPTION (pfile, warn_eof_newline))
 	    cpp_error (pfile, DL_PEDWARN, "no newline at end of file");
 	  pfile->line++;
 	  goto done;
Index: gcc/toplev.c
===================================================================
RCS file: /sources/repository/external_source/gnu/gcc-3.3.3/gcc/toplev.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -p -u -r1.1 -r1.2
--- gcc/toplev.c	26 Mar 2004 13:22:23 -0000	1.1
+++ gcc/toplev.c	8 Sep 2004 14:45:38 -0000	1.2
@@ -1405,6 +1405,10 @@ int inhibit_warnings = 0;
 
 int warn_system_headers = 0;
 
+/* Do/Don't issue a warning if input file ends without a newline. -Weof-newline. */
+
+int warn_eof_newline = 1;
+
 /* Print various extra warnings.  -W.  */
 
 int extra_warnings = 0;
@@ -1504,6 +1508,8 @@ int warn_strict_aliasing;
 
 static const lang_independent_options W_options[] =
 {
+  {"eof-newline", &warn_eof_newline, 1,
+   N_("Warn when a file ends without a newline") },
   {"unused-function", &warn_unused_function, 1,
    N_("Warn when a function is unused") },
   {"unused-label", &warn_unused_label, 1,
