diff options
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 17 | ||||
-rw-r--r-- | libcpp/Makefile.in | 4 | ||||
-rw-r--r-- | libcpp/charset.c | 7 | ||||
-rwxr-xr-x | libcpp/configure | 6 | ||||
-rw-r--r-- | libcpp/configure.ac | 5 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 6 | ||||
-rw-r--r-- | libcpp/init.c | 52 | ||||
-rw-r--r-- | libcpp/lex.c | 2 | ||||
-rw-r--r-- | libcpp/macro.c | 72 |
9 files changed, 104 insertions, 67 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 8d43655..1c04bf2 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,20 @@ +2021-11-30 Richard Biener <rguenther@suse.de> + + * charset.c (convert_escape): Remove unreachable break. + +2021-11-30 Jakub Jelinek <jakub@redhat.com> + + PR c++/100977 + * init.c (lang_defaults): Enable cxx23_identifiers for + -std={gnu,c}++{11,14,17,20} too. + +2021-11-29 Eric Gallager <egallager@gcc.gnu.org> + + PR other/103021 + * Makefile.in: Use ETAGS variable in TAGS target. + * configure: Regenerate. + * configure.ac: Allow ETAGS variable to be overridden. + 2021-11-23 Christophe Lyon <christophe.lyon@foss.st.com> PR preprocessor/103355 diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in index 34e4206..6b6554b 100644 --- a/libcpp/Makefile.in +++ b/libcpp/Makefile.in @@ -264,11 +264,13 @@ po/$(PACKAGE).pot: $(libcpp_a_SOURCES) sed 's:$(srcdir)/::g' <po/$(PACKAGE).pot.tmp >po/$(PACKAGE).pot rm po/$(PACKAGE).pot.tmp +ETAGS = @ETAGS@ + TAGS_SOURCES = $(libcpp_a_SOURCES) internal.h system.h ucnid.h \ include/cpplib.h include/line-map.h include/mkdeps.h include/symtab.h TAGS: $(TAGS_SOURCES) - cd $(srcdir) && etags $(TAGS_SOURCES) + cd $(srcdir) && $(ETAGS) $(TAGS_SOURCES) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libcpp/charset.c b/libcpp/charset.c index 0b0ccc6..0854677 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -955,14 +955,12 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c, valid_flags = C99 | CXX | C11 | CXX23; if (CPP_PEDANTIC (pfile)) { - if (CPP_OPTION (pfile, cxx23_identifiers)) + if (CPP_OPTION (pfile, cplusplus)) valid_flags = CXX23; else if (CPP_OPTION (pfile, c11_identifiers)) valid_flags = C11; else if (CPP_OPTION (pfile, c99)) valid_flags = C99; - else if (CPP_OPTION (pfile, cplusplus)) - valid_flags = CXX; } if (! (ucnranges[mn].flags & valid_flags)) return 0; @@ -1021,7 +1019,7 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c, return 2; } - if (CPP_OPTION (pfile, cxx23_identifiers)) + if (CPP_OPTION (pfile, cplusplus)) invalid_start_flags = NXX23; else if (CPP_OPTION (pfile, c11_identifiers)) invalid_start_flags = N11; @@ -1534,7 +1532,6 @@ convert_escape (cpp_reader *pfile, const uchar *from, const uchar *limit, case 'x': return convert_hex (pfile, from, limit, tbuf, cvt, char_range, loc_reader, ranges); - break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': diff --git a/libcpp/configure b/libcpp/configure index 9674cd9..2797292 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -652,6 +652,7 @@ noexception_flags WARN_PEDANTIC c_warn warn +ETAGS AUTOHEADER AUTOCONF ACLOCAL @@ -4896,6 +4897,11 @@ done test -n "$AUTOHEADER" || AUTOHEADER="$MISSING autoheader" +if test -z "$ETAGS"; then + ETAGS=etags +fi + + # Figure out what compiler warnings we can enable. # See config/warnings.m4 for details. diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 1efa96f..bc2373c 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -22,6 +22,11 @@ AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) +if test -z "$ETAGS"; then + ETAGS=etags +fi +AC_SUBST([ETAGS]) + # Figure out what compiler warnings we can enable. # See config/warnings.m4 for details. diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 112b9c2..08c72e7 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -491,13 +491,9 @@ struct cpp_options unsigned char ext_numeric_literals; /* Nonzero means extended identifiers allow the characters specified - in C11 and C++11. */ + in C11. */ unsigned char c11_identifiers; - /* Nonzero means extended identifiers allow the characters specified - in C++23. */ - unsigned char cxx23_identifiers; - /* Nonzero for C++ 2014 Standard binary constants. */ unsigned char binary_constants; diff --git a/libcpp/init.c b/libcpp/init.c index f9a8f5f..198afd07 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -82,7 +82,6 @@ struct lang_flags char extended_numbers; char extended_identifiers; char c11_identifiers; - char cxx23_identifiers; char std; char digraphs; char uliterals; @@ -100,31 +99,31 @@ struct lang_flags }; static const struct lang_flags lang_defaults[] = -{ /* c99 c++ xnum xid c11 c++23 std digr ulit rlit udlit bincst digsep trig u8chlit vaopt scope dfp szlit elifdef */ - /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 0, 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, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0 }, - /* GNUCXX20 */ { 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* CXX20 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* GNUCXX23 */ { 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }, - /* CXX23 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }, - /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 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 szlit elifdef */ + /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1 }, + /* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 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 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }, + /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; /* Sets internal flags correctly for a given language. */ @@ -140,7 +139,6 @@ cpp_set_lang (cpp_reader *pfile, enum c_lang lang) CPP_OPTION (pfile, extended_numbers) = l->extended_numbers; CPP_OPTION (pfile, extended_identifiers) = l->extended_identifiers; CPP_OPTION (pfile, c11_identifiers) = l->c11_identifiers; - CPP_OPTION (pfile, cxx23_identifiers) = l->cxx23_identifiers; CPP_OPTION (pfile, std) = l->std; CPP_OPTION (pfile, digraphs) = l->digraphs; CPP_OPTION (pfile, uliterals) = l->uliterals; diff --git a/libcpp/lex.c b/libcpp/lex.c index 9c27d8b..7e56edc 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1838,7 +1838,7 @@ warn_about_normalization (cpp_reader *pfile, if (NORMALIZE_STATE_RESULT (s) == normalized_C) cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc, "`%.*s' is not in NFKC", (int) sz, buf); - else if (CPP_OPTION (pfile, cxx23_identifiers)) + else if (CPP_OPTION (pfile, cplusplus)) cpp_pedwarning_at (pfile, CPP_W_NORMALIZE, &rich_loc, "`%.*s' is not in NFC", (int) sz, buf); else diff --git a/libcpp/macro.c b/libcpp/macro.c index 95e5b8b..6269c15 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -295,7 +295,7 @@ static cpp_context *next_context (cpp_reader *); static const cpp_token *padding_token (cpp_reader *, const cpp_token *); static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int); static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **, - unsigned int, bool); + unsigned int); static void paste_all_tokens (cpp_reader *, const cpp_token *); static bool paste_tokens (cpp_reader *, location_t, const cpp_token **, const cpp_token *); @@ -834,8 +834,7 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len) /* Convert a token sequence FIRST to FIRST+COUNT-1 to a single string token according to the rules of the ISO C #-operator. */ static const cpp_token * -stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count, - bool va_opt) +stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count) { unsigned char *dest; unsigned int i, escape_it, backslash_count = 0; @@ -852,24 +851,6 @@ stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count, { const cpp_token *token = first[i]; - if (va_opt && (token->flags & PASTE_LEFT)) - { - location_t virt_loc = pfile->invocation_location; - const cpp_token *rhs; - do - { - if (i == count) - abort (); - rhs = first[++i]; - if (!paste_tokens (pfile, virt_loc, &token, rhs)) - { - --i; - break; - } - } - while (rhs->flags & PASTE_LEFT); - } - if (token->type == CPP_PADDING) { if (source == NULL @@ -1003,6 +984,7 @@ paste_tokens (cpp_reader *pfile, location_t location, return false; } + lhs->flags |= (*plhs)->flags & (PREV_WHITE | PREV_FALLTHROUGH); *plhs = lhs; _cpp_pop_buffer (pfile); return true; @@ -1945,8 +1927,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, if (src->flags & STRINGIFY_ARG) { if (!arg->stringified) - arg->stringified = stringify_arg (pfile, arg->first, arg->count, - false); + arg->stringified = stringify_arg (pfile, arg->first, arg->count); } else if ((src->flags & PASTE_LEFT) || (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT))) @@ -2066,11 +2047,46 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, { unsigned int count = start ? paste_flag - start : tokens_buff_count (buff); - const cpp_token *t - = stringify_arg (pfile, - start ? start + 1 - : (const cpp_token **) (buff->base), - count, true); + const cpp_token **first + = start ? start + 1 + : (const cpp_token **) (buff->base); + unsigned int i, j; + + /* Paste any tokens that need to be pasted before calling + stringify_arg, because stringify_arg uses pfile->u_buff + which paste_tokens can use as well. */ + for (i = 0, j = 0; i < count; i++, j++) + { + const cpp_token *token = first[i]; + + if (token->flags & PASTE_LEFT) + { + location_t virt_loc = pfile->invocation_location; + const cpp_token *rhs; + do + { + if (i == count) + abort (); + rhs = first[++i]; + if (!paste_tokens (pfile, virt_loc, &token, rhs)) + { + --i; + break; + } + } + while (rhs->flags & PASTE_LEFT); + } + + first[j] = token; + } + if (j != i) + { + while (i-- != j) + tokens_buff_remove_last_token (buff); + count = j; + } + + const cpp_token *t = stringify_arg (pfile, first, count); while (count--) tokens_buff_remove_last_token (buff); if (src->flags & PASTE_LEFT) |