c.opt (-Wdate-time): New option

2013-11-05  Tobias Burnus  <burnus@net-b.de>

gcc/c-family/
        * c.opt (-Wdate-time): New option
        * c-opts.c (sanitize_cpp_opts): Pass on to libcpp.

gcc/
        * doc/invoke.texi (-Wdate-time): Document.

gcc/fortran
        * lang.opt (-Wdate-time): New option
        * cpp.c (gfc_cpp_option_data): Add warn_date_time.
        (gfc_cpp_init_options, gfc_cpp_handle_option,
        gfc_cpp_post_options): Handle it and pass on to libcpp.

gcc/testsuite/
        * g++.dg/warn/wdate-time.C: New.
        * gcc.dg/wdate-time.c: New.
        * gfortran.dg/wdate-time.F90: New.

libcpp/
        * include/cpplib.h (CPP_W_DATE_TIME): Added.
        (cpp_options): Add warn_date_time.
        * init.c (cpp_create_reader): Init it.
        * macro.c (_cpp_builtin_macro_text): Warn when
        __DATE__/__TIME__/__TIMESTAMP__ is used.

From-SVN: r204420
This commit is contained in:
Tobias Burnus
2013-11-05 21:27:22 +01:00
parent df1c87913c
commit e8ff5196a8
16 changed files with 85 additions and 3 deletions
+7
View File
@@ -232,6 +232,10 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
case BT_TIMESTAMP:
{
if (CPP_OPTION (pfile, warn_date_time))
cpp_warning (pfile, CPP_W_DATE_TIME, "Macro \"%s\" might prevent "
"reproduce builds", NODE_NAME (node));
cpp_buffer *pbuffer = cpp_get_buffer (pfile);
if (pbuffer->timestamp == NULL)
{
@@ -325,6 +329,9 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
case BT_DATE:
case BT_TIME:
if (CPP_OPTION (pfile, warn_date_time))
cpp_warning (pfile, CPP_W_DATE_TIME, "Macro \"%s\" might prevent "
"reproduce builds", NODE_NAME (node));
if (pfile->date == NULL)
{
/* Allocate __DATE__ and __TIME__ strings from permanent