diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-07-03 23:13:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-07-03 23:13:09 +0000 |
commit | 0baa9d1d59bf17177e80838ebe66df10a7a909c0 (patch) | |
tree | a1b956eacf43ba6ac1d052faad8a2df8f4f6ef5a /libcpp | |
parent | 133d3bd8362f0c438017ca18adb51afb7288f78b (diff) | |
parent | 651c754cfbd1928abd8ac6b3121fc37c85907dcb (diff) | |
download | gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.zip gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.tar.gz gcc-0baa9d1d59bf17177e80838ebe66df10a7a909c0.tar.bz2 |
Merge from trunk revision 273026.
From-SVN: r273027
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 62 | ||||
-rw-r--r-- | libcpp/directives.c | 9 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 3 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 4 | ||||
-rw-r--r-- | libcpp/init.c | 1 | ||||
-rw-r--r-- | libcpp/internal.h | 4 | ||||
-rw-r--r-- | libcpp/lex.c | 6 | ||||
-rw-r--r-- | libcpp/line-map.c | 60 | ||||
-rw-r--r-- | libcpp/mkdeps.c | 20 |
9 files changed, 124 insertions, 45 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 1c314ea..ff5f0aa 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,65 @@ +2019-07-03 Martin Liska <mliska@suse.cz> + + * line-map.c (linemap_get_expansion_filename): Remove + dead assignemts. + * mkdeps.c (make_write): Likewise. + +2019-07-02 qing zhao <qing.zhao@oracle.com> + + PR preprocessor/90581 + * directives.c (do_include_common): Replace CPP_STACK_MAX with + CPP_OPTION (pfile, max_include_depth). + * include/cpplib.h (struct cpp_options): Add new field + max_include_depth. + * init.c (cpp_create_reader): Initiate new field max_include_depth. + * internal.h: Delete CPP_STACK_MAX. + +2019-06-26 Nathan Sidwell <nathan@acm.org> + + PR preprocessor/90927 + * mkdeps.c (mkdeps::vec::operator[]): Add non-const variant. + (deps_add_target): Deal with out of order unquoted targets. + +2019-05-19 Andrew Pinski <apinski@marvell.com> + + PR pch/81721 + * lex.c (cpp_token_val_index <case SPELL_OPERATOR>): If tok->flags + has NAMED_OP set, then return CPP_TOKEN_FLD_NODE. + +2019-05-14 Martin Liska <mliska@suse.cz> + + PR preprocessor/90382 + * line-map.c (first_map_in_common_1): Handle ADHOC + locations. + +2019-05-14 Martin Liska <mliska@suse.cz> + + PR preprocessor/90382 + * include/line-map.h (get_data_from_adhoc_loc): Add const to + the first argument. + (get_location_from_adhoc_loc): Likewise. + * line-map.c(get_data_from_adhoc_loc): Add const to + the first argument. + (get_location_from_adhoc_loc): Likewise. + (get_combined_adhoc_loc): Use get_location_from_adhoc_loc + (or get_data_from_adhoc_loc). + (get_range_from_adhoc_loc): Likewise. + (get_pure_location): Likewise. + (linemap_position_for_loc_and_offset): Likewise. + (linemap_lookup): Likewise. + (linemap_ordinary_map_lookup): Likewise. + (linemap_macro_map_lookup): Likewise. + (linemap_get_expansion_line): Likewise. + (linemap_get_expansion_filename): Likewise. + (linemap_location_in_system_header_p): Likewise. + (linemap_location_from_macro_expansion_p): Likewise. + (linemap_macro_loc_to_exp_point): Likewise. + (linemap_resolve_location): Likewise. + (linemap_unwind_toward_expansion): Likewise. + (linemap_unwind_to_first_non_reserved_loc): Likewise. + (linemap_expand_location): Likewise. + (linemap_dump_location): Likewise. + 2019-05-07 Nathan Sidwell <nathan@acm.org> * files.c (_cpp_stack_file): Empty filenames aren't dependencies. diff --git a/libcpp/directives.c b/libcpp/directives.c index 3ee8bc4..2fdfaf0 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -831,8 +831,13 @@ do_include_common (cpp_reader *pfile, enum include_type type) } /* Prevent #include recursion. */ - if (pfile->line_table->depth >= CPP_STACK_MAX) - cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply"); + if (pfile->line_table->depth >= CPP_OPTION (pfile, max_include_depth)) + cpp_error (pfile, + CPP_DL_ERROR, + "#include nested depth %u exceeds maximum of %u" + " (use -fmax-include-depth=DEPTH to increase the maximum)", + pfile->line_table->depth, + CPP_OPTION (pfile, max_include_depth)); else { /* Get out of macro context, if we are. */ diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 3edb93d..91d97f9 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -550,6 +550,9 @@ struct cpp_options /* True enables canonicalization of system header file paths. */ bool canonical_system_headers; + + /* The maximum depth of the nested #include. */ + unsigned int max_include_depth; }; /* Diagnostic levels. To get a diagnostic without associating a diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 6c77c28..7649700 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1054,8 +1054,8 @@ extern location_t get_combined_adhoc_loc (struct line_maps *, location_t, source_range, void *); -extern void *get_data_from_adhoc_loc (struct line_maps *, location_t); -extern location_t get_location_from_adhoc_loc (struct line_maps *, +extern void *get_data_from_adhoc_loc (const struct line_maps *, location_t); +extern location_t get_location_from_adhoc_loc (const struct line_maps *, location_t); extern source_range get_range_from_loc (line_maps *set, location_t loc); diff --git a/libcpp/init.c b/libcpp/init.c index c0c9020..d06f95e 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -185,6 +185,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table, CPP_OPTION (pfile, warn_multichar) = 1; CPP_OPTION (pfile, discard_comments) = 1; CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1; + CPP_OPTION (pfile, max_include_depth) = 200; CPP_OPTION (pfile, tabstop) = 8; CPP_OPTION (pfile, operator_names) = 1; CPP_OPTION (pfile, warn_trigraphs) = 2; diff --git a/libcpp/internal.h b/libcpp/internal.h index 5b9c389..0ab4470 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -74,10 +74,6 @@ struct cset_converter linemap_line_start (PFILE->line_table, line + 1, COLS_HINT); \ } while (0) -/* Maximum nesting of cpp_buffers. We use a static limit, partly for - efficiency, and partly to limit runaway recursion. */ -#define CPP_STACK_MAX 200 - /* Host alignment handling. */ struct dummy { diff --git a/libcpp/lex.c b/libcpp/lex.c index eedfcbb..16ded6e 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -3756,7 +3756,11 @@ cpp_token_val_index (const cpp_token *tok) case SPELL_LITERAL: return CPP_TOKEN_FLD_STR; case SPELL_OPERATOR: - if (tok->type == CPP_PASTE) + /* Operands which were originally spelled as ident keep around + the node for the exact spelling. */ + if (tok->flags & NAMED_OP) + return CPP_TOKEN_FLD_NODE; + else if (tok->type == CPP_PASTE) return CPP_TOKEN_FLD_TOKEN_NO; else return CPP_TOKEN_FLD_NONE; diff --git a/libcpp/line-map.c b/libcpp/line-map.c index b73f506..8ab873b 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -163,8 +163,7 @@ get_combined_adhoc_loc (struct line_maps *set, struct location_adhoc_data **slot; if (IS_ADHOC_LOC (locus)) - locus - = set->location_adhoc_data_map.data[locus & MAX_LOCATION_T].locus; + locus = get_location_from_adhoc_loc (set, locus); if (locus == 0 && data == NULL) return 0; @@ -243,7 +242,7 @@ get_combined_adhoc_loc (struct line_maps *set, /* Return the data for the adhoc loc. */ void * -get_data_from_adhoc_loc (struct line_maps *set, location_t loc) +get_data_from_adhoc_loc (const struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; @@ -252,7 +251,7 @@ get_data_from_adhoc_loc (struct line_maps *set, location_t loc) /* Return the location for the adhoc loc. */ location_t -get_location_from_adhoc_loc (struct line_maps *set, location_t loc) +get_location_from_adhoc_loc (const struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; @@ -261,7 +260,7 @@ get_location_from_adhoc_loc (struct line_maps *set, location_t loc) /* Return the source_range for adhoc location LOC. */ static source_range -get_range_from_adhoc_loc (struct line_maps *set, location_t loc) +get_range_from_adhoc_loc (const struct line_maps *set, location_t loc) { linemap_assert (IS_ADHOC_LOC (loc)); return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range; @@ -321,8 +320,7 @@ location_t get_pure_location (line_maps *set, location_t loc) { if (IS_ADHOC_LOC (loc)) - loc - = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + loc = get_location_from_adhoc_loc (set, loc); if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (set)) return loc; @@ -872,7 +870,7 @@ linemap_position_for_loc_and_offset (struct line_maps *set, const line_map_ordinary * map = NULL; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + loc = get_location_from_adhoc_loc (set, loc); /* This function does not support virtual locations yet. */ if (linemap_location_from_macro_expansion_p (set, loc)) @@ -934,7 +932,7 @@ const struct line_map* linemap_lookup (struct line_maps *set, location_t line) { if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; + line = get_location_from_adhoc_loc (set, line); if (linemap_location_from_macro_expansion_p (set, line)) return linemap_macro_map_lookup (set, line); return linemap_ordinary_map_lookup (set, line); @@ -952,7 +950,7 @@ linemap_ordinary_map_lookup (struct line_maps *set, location_t line) const line_map_ordinary *cached, *result; if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; + line = get_location_from_adhoc_loc (set, line); if (set == NULL || line < RESERVED_LOCATION_COUNT) return NULL; @@ -1000,7 +998,7 @@ linemap_macro_map_lookup (struct line_maps *set, location_t line) const struct line_map_macro *cached, *result; if (IS_ADHOC_LOC (line)) - line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus; + line = get_location_from_adhoc_loc (set, line); linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set)); @@ -1130,8 +1128,7 @@ linemap_get_expansion_line (struct line_maps *set, const line_map_ordinary *map = NULL; if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_LOCATION_T].locus; + location = get_location_from_adhoc_loc (set, location); if (location < RESERVED_LOCATION_COUNT) return 0; @@ -1158,14 +1155,12 @@ linemap_get_expansion_filename (struct line_maps *set, const struct line_map_ordinary *map = NULL; if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_LOCATION_T].locus; + location = get_location_from_adhoc_loc (set, location); if (location < RESERVED_LOCATION_COUNT) return NULL; - location = - linemap_macro_loc_to_exp_point (set, location, &map); + linemap_macro_loc_to_exp_point (set, location, &map); return LINEMAP_FILE (map); } @@ -1196,8 +1191,7 @@ linemap_location_in_system_header_p (struct line_maps *set, const struct line_map *map = NULL; if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_LOCATION_T].locus; + location = get_location_from_adhoc_loc (set, location); if (location < RESERVED_LOCATION_COUNT) return false; @@ -1240,8 +1234,7 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set, location_t location) { if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_LOCATION_T].locus; + location = get_location_from_adhoc_loc (set, location); return IS_MACRO_LOC (location); } @@ -1257,8 +1250,13 @@ first_map_in_common_1 (struct line_maps *set, location_t *loc1) { location_t l0 = *loc0, l1 = *loc1; - const struct line_map *map0 = linemap_lookup (set, l0), - *map1 = linemap_lookup (set, l1); + const struct line_map *map0 = linemap_lookup (set, l0); + if (IS_ADHOC_LOC (l0)) + l0 = get_location_from_adhoc_loc (set, l0); + + const struct line_map *map1 = linemap_lookup (set, l1); + if (IS_ADHOC_LOC (l1)) + l1 = get_location_from_adhoc_loc (set, l1); while (linemap_macro_expansion_map_p (map0) && linemap_macro_expansion_map_p (map1) @@ -1467,8 +1465,7 @@ linemap_macro_loc_to_exp_point (struct line_maps *set, struct line_map *map; if (IS_ADHOC_LOC (location)) - location = set->location_adhoc_data_map.data[location - & MAX_LOCATION_T].locus; + location = get_location_from_adhoc_loc (set, location); linemap_assert (set && location >= RESERVED_LOCATION_COUNT); @@ -1542,7 +1539,7 @@ linemap_resolve_location (struct line_maps *set, { location_t locus = loc; if (IS_ADHOC_LOC (loc)) - locus = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + locus = get_location_from_adhoc_loc (set, loc); if (locus < RESERVED_LOCATION_COUNT) { @@ -1624,7 +1621,7 @@ linemap_unwind_toward_expansion (struct line_maps *set, const struct line_map *resolved_map; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + loc = get_location_from_adhoc_loc (set, loc); resolved_location = linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, loc); @@ -1664,7 +1661,7 @@ linemap_unwind_to_first_non_reserved_loc (struct line_maps *set, const line_map_ordinary *map1 = NULL; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + loc = get_location_from_adhoc_loc (set, loc); map0 = linemap_lookup (set, loc); if (!linemap_macro_expansion_map_p (map0)) @@ -1709,9 +1706,8 @@ linemap_expand_location (struct line_maps *set, memset (&xloc, 0, sizeof (xloc)); if (IS_ADHOC_LOC (loc)) { - xloc.data - = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data; - loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + xloc.data = get_data_from_adhoc_loc (set, loc); + loc = get_location_from_adhoc_loc (set, loc); } if (loc < RESERVED_LOCATION_COUNT) @@ -1815,7 +1811,7 @@ linemap_dump_location (struct line_maps *set, int l = -1, c = -1, s = -1, e = -1; if (IS_ADHOC_LOC (loc)) - loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus; + loc = get_location_from_adhoc_loc (set, loc); if (loc == 0) return; diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c index 96cc49b..50f0fb2 100644 --- a/libcpp/mkdeps.c +++ b/libcpp/mkdeps.c @@ -59,6 +59,10 @@ public: { return ary[ix]; } + T &operator[] (unsigned ix) + { + return ary[ix]; + } void push (const T &elt) { if (num == alloc) @@ -235,14 +239,22 @@ deps_free (struct mkdeps *d) void deps_add_target (struct mkdeps *d, const char *t, int quote) { - t = apply_vpath (d, t); + t = xstrdup (apply_vpath (d, t)); + if (!quote) { - gcc_assert (d->quote_lwm == d->targets.size ()); + /* Sometimes unquoted items are added after quoted ones. + Swap out the lowest quoted. */ + if (d->quote_lwm != d->targets.size ()) + { + const char *lowest = d->targets[d->quote_lwm]; + d->targets[d->quote_lwm] = t; + t = lowest; + } d->quote_lwm++; } - d->targets.push (xstrdup (t)); + d->targets.push (t); } /* Sets the default target if none has been given already. An empty @@ -366,7 +378,7 @@ make_write (const struct mkdeps *d, FILE *fp, bool phony, unsigned int colmax) column = make_write_vec (d->targets, fp, 0, colmax, d->quote_lwm); fputs (":", fp); column++; - column = make_write_vec (d->deps, fp, column, colmax); + make_write_vec (d->deps, fp, column, colmax); fputs ("\n", fp); if (phony) for (unsigned i = 1; i < d->deps.size (); i++) |