From owner-svn-src-all@FreeBSD.ORG Wed Dec 18 14:53:38 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BF2B530B; Wed, 18 Dec 2013 14:53:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AA31B14E7; Wed, 18 Dec 2013 14:53:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBIErcT3037474; Wed, 18 Dec 2013 14:53:38 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBIEranx037463; Wed, 18 Dec 2013 14:53:36 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201312181453.rBIEranx037463@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Wed, 18 Dec 2013 14:53:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259555 - in head/contrib: gcc gcc/doc gcclibs/libcpp gcclibs/libcpp/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2013 14:53:38 -0000 Author: pfg Date: Wed Dec 18 14:53:36 2013 New Revision: 259555 URL: http://svnweb.freebsd.org/changeset/base/259555 Log: gcc: add Apple compatible -Wnewline-eof GCC 4.2 and previous have always warned about "No newline at end of file". Upstream GCC removed the warning completely but Apple made it an optional warning. Adopt it for compatibility with older GCC and clang. While here, add comment to complement r258712. Obtained from: Apple Inc. (Apple GCC 4.2 - 5531) MFC after: 1 week Added: head/contrib/gcclibs/libcpp/ChangeLog.apple Modified: head/contrib/gcc/c-opts.c head/contrib/gcc/c.opt head/contrib/gcc/doc/invoke.texi head/contrib/gcclibs/libcpp/charset.c head/contrib/gcclibs/libcpp/include/cpplib.h head/contrib/gcclibs/libcpp/init.c head/contrib/gcclibs/libcpp/lex.c Modified: head/contrib/gcc/c-opts.c ============================================================================== --- head/contrib/gcc/c-opts.c Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcc/c-opts.c Wed Dec 18 14:53:36 2013 (r259555) @@ -487,6 +487,12 @@ c_common_handle_option (size_t scode, co cpp_opts->warn_multichar = value; break; + /* APPLE LOCAL begin -Wnewline-eof */ + case OPT_Wnewline_eof: + cpp_opts->warn_newline_at_eof = value; + break; + /* APPLE LOCAL end -Wnewline-eof */ + case OPT_Wnormalized_: if (!value || (arg && strcasecmp (arg, "none") == 0)) cpp_opts->warn_normalize = normalized_none; Modified: head/contrib/gcc/c.opt ============================================================================== --- head/contrib/gcc/c.opt Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcc/c.opt Wed Dec 18 14:53:36 2013 (r259555) @@ -292,6 +292,12 @@ Wnested-externs C ObjC Var(warn_nested_externs) Warn about \"extern\" declarations not at file scope +; APPLE LOCAL begin -Wnewline-eof +Wnewline-eof +C ObjC C++ ObjC++ +Warn about files missing a newline at the end of the file +; APPLE LOCAL end -Wnewline-eof + Wnon-template-friend C++ ObjC++ Var(warn_nontemplate_friend) Init(1) Warn when non-templatized friend functions are declared within a template Modified: head/contrib/gcc/doc/invoke.texi ============================================================================== --- head/contrib/gcc/doc/invoke.texi Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcc/doc/invoke.texi Wed Dec 18 14:53:36 2013 (r259555) @@ -169,6 +169,8 @@ in the following sections. -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol -fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol -fsigned-bitfields -fsigned-char @gol +@c APPLE LOCAL -Wnewline-eof 2001-08-23 --sts ** +-Wnewline-eof (Apple compatible) @gol -funsigned-bitfields -funsigned-char} @item C++ Language Options @@ -2082,6 +2084,12 @@ Inhibit all warning messages. @opindex Wno-import Inhibit warning messages about the use of @samp{#import}. +@c APPLE LOCAL begin -Wnewline-eof 2001-08-23 --sts ** +@item -Wnewline-eof +@opindex Wnewline-eof +Warn about files missing a newline at the end of the file. (FreeBSD ONLY) +@c APPLE LOCAL end -Wnewline-eof 2001-08-23 --sts ** + @item -Wchar-subscripts @opindex Wchar-subscripts Warn if an array subscript has type @code{char}. This is a common cause Added: head/contrib/gcclibs/libcpp/ChangeLog.apple ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/gcclibs/libcpp/ChangeLog.apple Wed Dec 18 14:53:36 2013 (r259555) @@ -0,0 +1,9 @@ +2008-08-04 Bill Wendling + + Radar 6121572 + * charset.c (_cpp_convert_input): Don't read to.text[-1]. + +2005-02-17 Devang Patel + + Radar 3958387 + * libcpp/lex.c (_cpp_get_fresh_line): Check warn_newline_at_eof. Modified: head/contrib/gcclibs/libcpp/charset.c ============================================================================== --- head/contrib/gcclibs/libcpp/charset.c Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcclibs/libcpp/charset.c Wed Dec 18 14:53:36 2013 (r259555) @@ -1628,6 +1628,7 @@ _cpp_convert_input (cpp_reader *pfile, c terminate with another \r, not an \n, so that we do not mistake the \r\n sequence for a single DOS line ending and erroneously issue the "No newline at end of file" diagnostic. */ + /* APPLE LOCAL don't access to.text[-1] radar 6121572 */ if (to.len > 0 && to.text[to.len - 1] == '\r') to.text[to.len] = '\r'; else Modified: head/contrib/gcclibs/libcpp/include/cpplib.h ============================================================================== --- head/contrib/gcclibs/libcpp/include/cpplib.h Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcclibs/libcpp/include/cpplib.h Wed Dec 18 14:53:36 2013 (r259555) @@ -320,6 +320,11 @@ struct cpp_options /* Nonzero means warn if there are any trigraphs. */ unsigned char warn_trigraphs; + /* APPLE LOCAL begin -Wnewline-eof 2001-08-23 --sts */ + /* Nonzero means warn if no newline at end of file. */ + unsigned char warn_newline_at_eof; + /* APPLE LOCAL end -Wnewline-eof 2001-08-23 --sts */ + /* Nonzero means warn about multicharacter charconsts. */ unsigned char warn_multichar; Modified: head/contrib/gcclibs/libcpp/init.c ============================================================================== --- head/contrib/gcclibs/libcpp/init.c Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcclibs/libcpp/init.c Wed Dec 18 14:53:36 2013 (r259555) @@ -146,6 +146,10 @@ cpp_create_reader (enum c_lang lang, has pfile = XCNEW (cpp_reader); cpp_set_lang (pfile, lang); + /* APPLE LOCAL begin -Wnewline-eof 2001-08-23 --sts */ + /* Suppress warnings about missing newlines at ends of files. */ + CPP_OPTION (pfile, warn_newline_at_eof) = 0; + /* APPLE LOCAL end -Wnewline-eof 2001-08-23 --sts */ CPP_OPTION (pfile, warn_multichar) = 1; CPP_OPTION (pfile, discard_comments) = 1; CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1; Modified: head/contrib/gcclibs/libcpp/lex.c ============================================================================== --- head/contrib/gcclibs/libcpp/lex.c Wed Dec 18 14:46:13 2013 (r259554) +++ head/contrib/gcclibs/libcpp/lex.c Wed Dec 18 14:53:36 2013 (r259555) @@ -854,6 +854,14 @@ _cpp_get_fresh_line (cpp_reader *pfile) { /* Clip to buffer size. */ buffer->next_line = buffer->rlimit; + /* APPLE LOCAL begin suppress no newline warning. */ + if ( CPP_OPTION (pfile, warn_newline_at_eof)) + { + cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->line_table->highest_line, + CPP_BUF_COLUMN (buffer, buffer->cur), + "no newline at end of file"); + } + /* APPLE LOCAL end suppress no newline warning. */ } return_at_eof = buffer->return_at_eof;