diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-10-25 23:18:41 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-10-25 23:18:41 +0000 |
commit | 0cec14923830569b8727d461bcf64adaf965de83 (patch) | |
tree | 39212625ea993fb193b64da0b13d64cd323dc23b /libcpp | |
parent | f67dc76907675065f34ed0bd14915df8d0b63b2d (diff) | |
parent | 9bdc2a8f06cef54650798fcb4c343e4415fd5992 (diff) | |
download | gcc-0cec14923830569b8727d461bcf64adaf965de83.zip gcc-0cec14923830569b8727d461bcf64adaf965de83.tar.gz gcc-0cec14923830569b8727d461bcf64adaf965de83.tar.bz2 |
Merge from trunk revision 277462.
From-SVN: r277464
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 34 | ||||
-rw-r--r-- | libcpp/expr.c | 17 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 7 | ||||
-rw-r--r-- | libcpp/include/line-map.h | 53 | ||||
-rw-r--r-- | libcpp/init.c | 49 | ||||
-rw-r--r-- | libcpp/line-map.c | 20 |
6 files changed, 104 insertions, 76 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index e13ff1d..670e97b 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,37 @@ +2019-10-15 Nathan Sidwell <nathan@acm.org> + + * include/line-map.h (struct maps_info_ordinary): Make cache + mutable. + (struct maps_info_macro): Likewise. + (LINEMAPS_CACHE): Remove non-ref accessor. Constify ref accessor. + (LINEMAPS_ORDINARY_CACHE, LINEMAPS_MACRO_CACHE): Likewise. + (LINEMAPS_ORDINARY_MAP_AT, LINEMAPS_MACRO_MAP_AT): Use + LINEMAPS_USED and LINEMAPS_MAP_AT. + (linemap_lookup): Constify line_map arg. + linemap.c (linemap_ordinary_map_lookup, linemap_macro_map_lookup): + Constify line_map arg. + +2019-10-11 Joseph Myers <joseph@codesourcery.com> + + * include/cpplib.h (struct cpp_options): Add dfp_constants and + cpp_warn_c11_c2x_compat. + (enum cpp_warning_reason): Add CPP_W_C11_C2X_COMPAT. + * init.c (struct lang_flags): Add dfp_constants. + (lang_defaults): Set dfp_constants to 1 for GNUC2X and STDC2X and + 0 for other languages. + (cpp_set_lang): Set dfp_constants from language. + (cpp_create_reader): Set cpp_warn_c11_c2x_compat to -1. + * expr.c (interpret_float_suffix): Mention DFP constants as C2X in + comment. + (cpp_classify_number): Do not diagnose DFP constants for languages + setting dfp_constants, unless cpp_warn_c11_c2x_compat. + +2019-10-04 Nathan Sidwell <nathan@acm.org> + + PR preprocessor/91991 + * line-map.c (linemap_line_start): Clear max_column_hint if we run + out of locations. + 2019-10-02 Richard Biener <rguenther@suse.de> * internal.h (enum include_type): Remove trailing comma. diff --git a/libcpp/expr.c b/libcpp/expr.c index 4b514b1..65baafe 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -98,8 +98,8 @@ interpret_float_suffix (cpp_reader *pfile, const uchar *s, size_t len) flags = 0; f = d = l = w = q = i = fn = fnx = fn_bits = 0; - /* The following decimal float suffixes, from TR 24732:2009 and TS - 18661-2:2015, are supported: + /* The following decimal float suffixes, from TR 24732:2009, TS + 18661-2:2015 and C2X, are supported: df, DF - _Decimal32. dd, DD - _Decimal64. @@ -744,9 +744,16 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token, cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, "fixed-point constants are a GCC extension"); - if ((result & CPP_N_DFLOAT) && CPP_PEDANTIC (pfile)) - cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, - "decimal float constants are a GCC extension"); + if (result & CPP_N_DFLOAT) + { + if (CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, dfp_constants)) + cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, + "decimal float constants are a C2X feature"); + else if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0) + cpp_warning_with_line (pfile, CPP_W_C11_C2X_COMPAT, + virtual_location, 0, + "decimal float constants are a C2X feature"); + } result |= CPP_N_FLOATING; } diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index ccbcfde..224369b 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -480,6 +480,9 @@ struct cpp_options /* Nonzero for C++ 2014 Standard digit separators. */ unsigned char digit_separators; + /* Nonzero for C2X decimal floating-point constants. */ + unsigned char dfp_constants; + /* Nonzero for C++2a __VA_OPT__ feature. */ unsigned char va_opt; @@ -508,6 +511,9 @@ struct cpp_options /* True if warn about differences between C90 and C99. */ signed char cpp_warn_c90_c99_compat; + /* True if warn about differences between C11 and C2X. */ + signed char cpp_warn_c11_c2x_compat; + /* True if warn about differences between C++98 and C++11. */ bool cpp_warn_cxx11_compat; @@ -607,6 +613,7 @@ enum cpp_warning_reason { CPP_W_DATE_TIME, CPP_W_PEDANTIC, CPP_W_C90_C99_COMPAT, + CPP_W_C11_C2X_COMPAT, CPP_W_CXX11_COMPAT, CPP_W_EXPANSION_TO_DEFINED }; diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index bde5e53..6f4cf5b 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -724,7 +724,7 @@ struct GTY(()) maps_info_ordinary { or equal to ALLOCATED. */ unsigned int used; - unsigned int cache; + mutable unsigned int cache; }; struct GTY(()) maps_info_macro { @@ -739,7 +739,7 @@ struct GTY(()) maps_info_macro { or equal to ALLOCATED. */ unsigned int used; - unsigned int cache; + mutable unsigned int cache; }; /* Data structure to associate a source_range together with an arbitrary @@ -865,19 +865,8 @@ LINEMAPS_USED (line_maps *set, bool map_kind) /* Returns the index of the last map that was looked up with linemap_lookup. MAP_KIND shall be TRUE if we are interested in macro maps, FALSE otherwise. */ -inline unsigned int -LINEMAPS_CACHE (const line_maps *set, bool map_kind) -{ - if (map_kind) - return set->info_macro.cache; - else - return set->info_ordinary.cache; -} - -/* As above, but by reference (e.g. as an lvalue). */ - inline unsigned int & -LINEMAPS_CACHE (line_maps *set, bool map_kind) +LINEMAPS_CACHE (const line_maps *set, bool map_kind) { if (map_kind) return set->info_macro.cache; @@ -927,9 +916,9 @@ LINEMAPS_ORDINARY_MAPS (const line_maps *set) inline line_map_ordinary * LINEMAPS_ORDINARY_MAP_AT (const line_maps *set, int index) { - linemap_assert (index >= 0); - linemap_assert ((unsigned int)index < set->info_ordinary.used); - return &set->info_ordinary.maps[index]; + linemap_assert (index >= 0 + && (unsigned int)index < LINEMAPS_USED (set, false)); + return (line_map_ordinary *)LINEMAPS_MAP_AT (set, false, index); } /* Return the number of ordinary maps allocated in the line table @@ -949,16 +938,8 @@ LINEMAPS_ORDINARY_USED (const line_maps *set) /* Return the index of the last ordinary map that was looked up with linemap_lookup. */ -inline unsigned int -LINEMAPS_ORDINARY_CACHE (const line_maps *set) -{ - return LINEMAPS_CACHE (set, false); -} - -/* As above, but by reference (e.g. as an lvalue). */ - inline unsigned int & -LINEMAPS_ORDINARY_CACHE (line_maps *set) +LINEMAPS_ORDINARY_CACHE (const line_maps *set) { return LINEMAPS_CACHE (set, false); } @@ -991,9 +972,9 @@ LINEMAPS_MACRO_MAPS (const line_maps *set) inline line_map_macro * LINEMAPS_MACRO_MAP_AT (const line_maps *set, int index) { - linemap_assert (index >= 0); - linemap_assert ((unsigned int)index < set->info_macro.used); - return &set->info_macro.maps[index]; + linemap_assert (index >= 0 + && (unsigned int)index < LINEMAPS_USED (set, true)); + return (line_map_macro *)LINEMAPS_MAP_AT (set, true, index); } /* Returns the number of macro maps that were allocated in the line @@ -1011,18 +992,10 @@ LINEMAPS_MACRO_USED (const line_maps *set) return LINEMAPS_USED (set, true); } -/* Returns the index of the last macro map looked up with +/* Return the index of the last macro map that was looked up with linemap_lookup. */ -inline unsigned int -LINEMAPS_MACRO_CACHE (const line_maps *set) -{ - return LINEMAPS_CACHE (set, true); -} - -/* As above, but by reference (e.g. as an lvalue). */ - inline unsigned int & -LINEMAPS_MACRO_CACHE (line_maps *set) +LINEMAPS_MACRO_CACHE (const line_maps *set) { return LINEMAPS_CACHE (set, true); } @@ -1130,7 +1103,7 @@ extern const line_map *linemap_add binary search. If no line map have been allocated yet, this function returns NULL. */ extern const line_map *linemap_lookup - (class line_maps *, location_t); + (const line_maps *, location_t); /* Returns TRUE if the line table set tracks token locations across macro expansion, FALSE otherwise. */ diff --git a/libcpp/init.c b/libcpp/init.c index c932598..4bcec7b 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -93,32 +93,33 @@ struct lang_flags char utf8_char_literals; char va_opt; char scope; + char dfp_constants; }; static const struct lang_flags lang_defaults[] = -{ /* c99 c++ xnum xid c11 std digr ulit rlit udlit bincst digsep trig u8chlit vaopt scope*/ - /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, - /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 }, - /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 }, - /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 }, - /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 }, - /* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, - /* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, - /* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, - /* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 }, - /* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 }, - /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1 }, - /* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, - /* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1 }, - /* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1 }, - /* CXX11 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1 }, - /* GNUCXX14 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1 }, - /* CXX14 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 }, - /* GNUCXX17 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 }, - /* CXX17 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1 }, - /* GNUCXX2A */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 }, - /* CXX2A */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 }, - /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +{ /* c99 c++ xnum xid c11 std digr ulit rlit udlit bincst digsep trig u8chlit vaopt scope dfp */ + /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }, + /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 }, + /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 }, + /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,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1, 0, 1, 1, 1, 0 }, + /* CXX2A */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0 }, + /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; /* Sets internal flags correctly for a given language. */ @@ -145,6 +146,7 @@ cpp_set_lang (cpp_reader *pfile, enum c_lang lang) CPP_OPTION (pfile, utf8_char_literals) = l->utf8_char_literals; CPP_OPTION (pfile, va_opt) = l->va_opt; CPP_OPTION (pfile, scope) = l->scope; + CPP_OPTION (pfile, dfp_constants) = l->dfp_constants; } /* Initialize library global state. */ @@ -193,6 +195,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table, CPP_OPTION (pfile, warn_trigraphs) = 2; CPP_OPTION (pfile, warn_endif_labels) = 1; CPP_OPTION (pfile, cpp_warn_c90_c99_compat) = -1; + CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) = -1; CPP_OPTION (pfile, cpp_warn_cxx11_compat) = 0; CPP_OPTION (pfile, cpp_warn_deprecated) = 1; CPP_OPTION (pfile, cpp_warn_long_long) = 0; diff --git a/libcpp/line-map.c b/libcpp/line-map.c index d6924eb..b86a116 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -27,9 +27,9 @@ along with this program; see the file COPYING3. If not see #include "hashtab.h" static void trace_include (const line_maps *, const line_map_ordinary *); -static const line_map_ordinary * linemap_ordinary_map_lookup (line_maps *, +static const line_map_ordinary * linemap_ordinary_map_lookup (const line_maps *, location_t); -static const line_map_macro* linemap_macro_map_lookup (line_maps *, +static const line_map_macro* linemap_macro_map_lookup (const line_maps *, location_t); static location_t linemap_macro_map_loc_to_def_point (const line_map_macro *, location_t); @@ -717,11 +717,11 @@ linemap_line_start (line_maps *set, linenum_type to_line, /* If the column number is ridiculous or we've allocated a huge number of location_ts, give up on column numbers (and on packed ranges). */ - max_column_hint = 0; + max_column_hint = 1; column_bits = 0; range_bits = 0; if (highest >= LINE_MAP_MAX_LOCATION) - return 0; + goto overflowed; } else { @@ -735,6 +735,7 @@ linemap_line_start (line_maps *set, linenum_type to_line, max_column_hint = 1U << column_bits; column_bits += range_bits; } + /* Allocate the new line_map. However, if the current map only has a single line we can sometimes just increase its column_bits instead. */ if (line_delta < 0 @@ -765,8 +766,11 @@ linemap_line_start (line_maps *set, linenum_type to_line, macro tokens. */ if (r >= LINE_MAP_MAX_LOCATION) { + overflowed: /* Remember we overflowed. */ set->highest_line = set->highest_location = LINE_MAP_MAX_LOCATION - 1; + /* No column numbers! */ + set->max_column_hint = 1; return 0; } @@ -933,7 +937,7 @@ linemap_position_for_loc_and_offset (line_maps *set, ordinary or a macro map), returns that map. */ const struct line_map* -linemap_lookup (line_maps *set, location_t line) +linemap_lookup (const line_maps *set, location_t line) { if (IS_ADHOC_LOC (line)) line = get_location_from_adhoc_loc (set, line); @@ -948,7 +952,7 @@ linemap_lookup (line_maps *set, location_t line) binary search. */ static const line_map_ordinary * -linemap_ordinary_map_lookup (line_maps *set, location_t line) +linemap_ordinary_map_lookup (const line_maps *set, location_t line) { unsigned int md, mn, mx; const line_map_ordinary *cached, *result; @@ -961,7 +965,7 @@ linemap_ordinary_map_lookup (line_maps *set, location_t line) mn = LINEMAPS_ORDINARY_CACHE (set); mx = LINEMAPS_ORDINARY_USED (set); - + cached = LINEMAPS_ORDINARY_MAP_AT (set, mn); /* We should get a segfault if no line_maps have been added yet. */ if (line >= MAP_START_LOCATION (cached)) @@ -996,7 +1000,7 @@ linemap_ordinary_map_lookup (line_maps *set, location_t line) binary search. */ static const line_map_macro * -linemap_macro_map_lookup (line_maps *set, location_t line) +linemap_macro_map_lookup (const line_maps *set, location_t line) { unsigned int md, mn, mx; const struct line_map_macro *cached, *result; |