diff options
author | Tobias Burnus <burnus@gcc.gnu.org> | 2013-11-05 21:27:22 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2013-11-05 21:27:22 +0100 |
commit | e8ff5196a89bdd14deca4ecb5d07d60cfd081b11 (patch) | |
tree | 61e37f9572a53a1c03ae93e5c3d39f8427a2be96 /libcpp | |
parent | df1c87913c623004b0ecf24ea37874d9addaa8c9 (diff) | |
download | gcc-e8ff5196a89bdd14deca4ecb5d07d60cfd081b11.zip gcc-e8ff5196a89bdd14deca4ecb5d07d60cfd081b11.tar.gz gcc-e8ff5196a89bdd14deca4ecb5d07d60cfd081b11.tar.bz2 |
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
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 10 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 6 | ||||
-rw-r--r-- | libcpp/init.c | 1 | ||||
-rw-r--r-- | libcpp/macro.c | 7 |
4 files changed, 22 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 2e98e34..670affd 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,6 +1,14 @@ +2013-11-05 Tobias Burnus <burnus@net-b.de> + + * 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. + 2013-10-31 Edward Smith-Rowland <3dw4rd@verizon.net> - Implement C++14 digit separators. + Implement C++14 digit separators. * include/cpplib.h (cpp_options): Add digit_separators flag. * internal.h (DIGIT_SEP(c)): New macro. * expr.c (cpp_classify_number): Check improper placement of digit sep; diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 34ad6c3..02927d4 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -337,6 +337,9 @@ struct cpp_options /* Nonzero means warn if slash-star appears in a comment. */ unsigned char warn_comments; + /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage. */ + unsigned char warn_date_time; + /* Nonzero means warn if a user-supplied include directory does not exist. */ unsigned char warn_missing_include_dirs; @@ -925,7 +928,8 @@ enum { CPP_W_NORMALIZE, CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE, - CPP_W_LITERAL_SUFFIX + CPP_W_LITERAL_SUFFIX, + CPP_W_DATE_TIME }; /* Output a diagnostic of some kind. */ diff --git a/libcpp/init.c b/libcpp/init.c index 97aa6cd..6744430 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -193,6 +193,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table, CPP_OPTION (pfile, canonical_system_headers) = ENABLE_CANONICAL_SYSTEM_HEADERS; CPP_OPTION (pfile, ext_numeric_literals) = 1; + CPP_OPTION (pfile, warn_date_time) = 0; /* Default CPP arithmetic to something sensible for the host for the benefit of dumb users like fix-header. */ diff --git a/libcpp/macro.c b/libcpp/macro.c index 6d46027..3a1728d 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -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 |