diff options
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 24 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 15 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 4 |
4 files changed, 36 insertions, 22 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f2f98c5c863..7c589acf20c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,18 @@ +2016-06-01 Eduard Sanou <dhole@openmailbox.org> + + * c-common.c (get_source_date_epoch): Rename to + cb_get_source_date_epoch. + * c-common.c (cb_get_source_date_epoch): Use a single generic erorr + message when the parsing fails. Use error_at instead of fatal_error. + * c-common.h (get_source_date_epoch): Rename to + cb_get_source_date_epoch. + * c-common.h (cb_get_source_date_epoch): Prototype. + * c-common.h (MAX_SOURCE_DATE_EPOCH): Define. + * c-common.h (c_omp_region_type): Remove trailing comma. + * c-lex.c (init_c_lex): Set cb->get_source_date_epoch callback. + * c-lex.c (c_lex_with_flags): Remove initialization of + pfile->source_date_epoch. + 2016-05-30 Jakub Jelinek <jakub@redhat.com> PR c++/71349 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 4568cf62a98..93ca274e7c8 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -12762,8 +12762,9 @@ valid_array_size_p (location_t loc, tree type, tree name) /* Read SOURCE_DATE_EPOCH from environment to have a deterministic timestamp to replace embedded current dates to get reproducible results. Returns -1 if SOURCE_DATE_EPOCH is not defined. */ + time_t -get_source_date_epoch () +cb_get_source_date_epoch (cpp_reader *pfile ATTRIBUTE_UNUSED) { char *source_date_epoch; long long epoch; @@ -12775,19 +12776,14 @@ get_source_date_epoch () errno = 0; epoch = strtoll (source_date_epoch, &endptr, 10); - if ((errno == ERANGE && (epoch == LLONG_MAX || epoch == LLONG_MIN)) - || (errno != 0 && epoch == 0)) - fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: " - "strtoll: %s\n", xstrerror(errno)); - if (endptr == source_date_epoch) - fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: " - "no digits were found: %s\n", endptr); - if (*endptr != '\0') - fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: " - "trailing garbage: %s\n", endptr); - if (epoch < 0) - fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: " - "value must be nonnegative: %lld \n", epoch); + if (errno != 0 || endptr == source_date_epoch || *endptr != '\0' + || epoch < 0 || epoch > MAX_SOURCE_DATE_EPOCH) + { + error_at (input_location, "environment variable SOURCE_DATE_EPOCH must " + "expand to a non-negative integer less than or equal to %wd", + MAX_SOURCE_DATE_EPOCH); + return (time_t) -1; + } return (time_t) epoch; } diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 0295532d3ea..4e6aa0051fa 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1088,6 +1088,16 @@ extern vec<tree, va_gc> *make_tree_vector_copy (const vec<tree, va_gc> *); c_register_builtin_type. */ extern GTY(()) tree registered_builtin_types; +/* Read SOURCE_DATE_EPOCH from environment to have a deterministic + timestamp to replace embedded current dates to get reproducible + results. Returns -1 if SOURCE_DATE_EPOCH is not defined. */ +extern time_t cb_get_source_date_epoch (cpp_reader *pfile); + +/* The value (as a unix timestamp) corresponds to date + "Dec 31 9999 23:59:59 UTC", which is the latest date that __DATE__ and + __TIME__ can store. */ +#define MAX_SOURCE_DATE_EPOCH HOST_WIDE_INT_C (253402300799) + /* In c-gimplify.c */ extern void c_genericize (tree); extern int c_gimplify_expr (tree *, gimple_seq *, gimple_seq *); @@ -1482,9 +1492,4 @@ extern bool valid_array_size_p (location_t, tree, tree); extern bool cilk_ignorable_spawn_rhs_op (tree); extern bool cilk_recognize_spawn (tree, tree *); -/* Read SOURCE_DATE_EPOCH from environment to have a deterministic - timestamp to replace embedded current dates to get reproducible - results. Returns -1 if SOURCE_DATE_EPOCH is not defined. */ -extern time_t get_source_date_epoch (void); - #endif /* ! GCC_C_COMMON_H */ diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index 38a428d5333..8f33d8616e3 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -80,6 +80,7 @@ init_c_lex (void) cb->valid_pch = c_common_valid_pch; cb->read_pch = c_common_read_pch; cb->has_attribute = c_common_has_attribute; + cb->get_source_date_epoch = cb_get_source_date_epoch; /* Set the debug callbacks if we can use them. */ if ((debug_info_level == DINFO_LEVEL_VERBOSE @@ -389,9 +390,6 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, enum cpp_ttype type; unsigned char add_flags = 0; enum overflow_type overflow = OT_NONE; - time_t source_date_epoch = get_source_date_epoch (); - - cpp_init_source_date_epoch (parse_in, source_date_epoch); timevar_push (TV_CPP); retry: |