aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-10-12 09:46:38 -0700
committerIan Lance Taylor <iant@golang.org>2020-10-12 09:46:38 -0700
commit9cd320ea6572c577cdf17ce1f9ea5230b166af6d (patch)
treed1c8e7c2e09a91ed75f0e5476c648c2e745aa2de /libcpp
parent4854d721be78358e59367982bdd94461b4be3c5a (diff)
parent3175d40fc52fb8eb3c3b18cc343d773da24434fb (diff)
downloadgcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.zip
gcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.tar.gz
gcc-9cd320ea6572c577cdf17ce1f9ea5230b166af6d.tar.bz2
Merge from trunk revision 3175d40fc52fb8eb3c3b18cc343d773da24434fb.
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog80
-rw-r--r--libcpp/charset.c98
-rwxr-xr-xlibcpp/configure21
-rw-r--r--libcpp/files.c12
-rw-r--r--libcpp/include/cpplib.h40
-rw-r--r--libcpp/include/line-map.h6
-rw-r--r--libcpp/init.c153
-rw-r--r--libcpp/internal.h4
-rw-r--r--libcpp/lex.c7
-rw-r--r--libcpp/line-map.c54
-rw-r--r--libcpp/po/ChangeLog4
-rw-r--r--libcpp/po/cpplib.pot244
-rw-r--r--libcpp/traditional.c4
13 files changed, 459 insertions, 268 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index ed65d15..1aa2764 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,83 @@
+2020-10-08 Nathan Sidwell <nathan@acm.org>
+
+ * internal.h (enum include_type): Rename IT_MAIN_INJECT to
+ IT_PRE_MAIN.
+ * init.c (cpp_read_main_file): If there is no line marker, adjust
+ the initial line marker.
+ (read_original_filename): Return bool, peek the buffer directly
+ before trying to tokenize.
+ (read_original_directory): Likewise. Directly prod the string
+ literal.
+ * files.c (_cpp_stack_file): Adjust for IT_PRE_MAIN change.
+
+2020-09-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR bootstrap/97163
+ * lex.c (search_line_fast): Only use _ARCH_PWR8 Altivec version
+ for GCC >= 4.5.
+
+2020-09-17 Patrick Palka <ppalka@redhat.com>
+
+ PR c/80076
+ * include/line-map.h (first_map_in_common): Declare.
+ * line-map.c (first_map_in_common): Remove static.
+
+2020-09-07 Martin Storsjö <martin@martin.st>
+
+ * files.c (remap_filename): Make a strchr return value pointer
+ to const.
+
+2020-07-30 H.J. Lu <hjl.tools@gmail.com>
+
+ PR bootstrap/96202
+ * configure: Regenerated.
+
+2020-07-29 Tiziano Müller <tiziano.mueller@chem.uzh.ch>
+
+ * init.c (builtin_array): Add xref comment.
+ * traditional.c (fun_like_macro): Add HAS_INCLUDE codes.
+
+2020-07-28 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/96323
+ * lex.c (lex_raw_string): For c == '\n' don't continue after reporting
+ an prefix delimiter error.
+
+2020-07-28 Nathan Sidwell <nathan@acm.org>
+
+ * init.c (cpp_read_main_file): Always use the last map for
+ the return value.
+
+2020-07-20 Nathan Sidwell <nathan@acm.org>
+
+ * line-map.c (linemap_add): Simplify column overflow calculation.
+ Add comment about range and column bit init.
+ (linemap_ordinary_map_lookup): Refactor for RAII
+ (linemap_macro_map_lookup): Likewise.
+
+2020-07-14 Lewis Hyatt <lhyatt@gmail.com>
+
+ PR preprocessor/49973
+ PR other/86904
+ * include/cpplib.h (struct cpp_options): Removed support for -ftabstop,
+ which is now handled by diagnostic_context.
+ (class cpp_display_width_computation): New class.
+ (cpp_byte_column_to_display_column): Add optional tabstop argument.
+ (cpp_display_width): Likewise.
+ (cpp_display_column_to_byte_column): Likewise.
+ * charset.c
+ (cpp_display_width_computation::cpp_display_width_computation): New
+ function.
+ (cpp_display_width_computation::advance_display_cols): Likewise.
+ (compute_next_display_width): Removed and implemented this
+ functionality in a new function...
+ (cpp_display_width_computation::process_next_codepoint): ...here.
+ (cpp_byte_column_to_display_column): Added tabstop argument.
+ Reimplemented in terms of class cpp_display_width_computation.
+ (cpp_display_column_to_byte_column): Likewise.
+ * init.c (cpp_create_reader): Remove handling of -ftabstop, which is now
+ handled by diagnostic_context.
+
2020-07-07 Nathan Sidwell <nathan@acm.org>
* directives.c (do_linemarker): Optimize rewinding to line zero.
diff --git a/libcpp/charset.c b/libcpp/charset.c
index db47235..28b81c9c 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -2276,49 +2276,90 @@ cpp_string_location_reader::get_next ()
return result;
}
-/* Helper for cpp_byte_column_to_display_column and its inverse. Given a
- pointer to a UTF-8-encoded character, compute its display width. *INBUFP
- points on entry to the start of the UTF-8 encoding of the character, and
- is updated to point just after the last byte of the encoding. *INBYTESLEFTP
- contains on entry the remaining size of the buffer into which *INBUFP
- points, and this is also updated accordingly. If *INBUFP does not
+cpp_display_width_computation::
+cpp_display_width_computation (const char *data, int data_length, int tabstop) :
+ m_begin (data),
+ m_next (m_begin),
+ m_bytes_left (data_length),
+ m_tabstop (tabstop),
+ m_display_cols (0)
+{
+ gcc_assert (m_tabstop > 0);
+}
+
+
+/* The main implementation function for class cpp_display_width_computation.
+ m_next points on entry to the start of the UTF-8 encoding of the next
+ character, and is updated to point just after the last byte of the encoding.
+ m_bytes_left contains on entry the remaining size of the buffer into which
+ m_next points, and this is also updated accordingly. If m_next does not
point to a valid UTF-8-encoded sequence, then it will be treated as a single
- byte with display width 1. */
+ byte with display width 1. m_cur_display_col is the current display column,
+ relative to which tab stops should be expanded. Returns the display width of
+ the codepoint just processed. */
-static inline int
-compute_next_display_width (const uchar **inbufp, size_t *inbytesleftp)
+int
+cpp_display_width_computation::process_next_codepoint ()
{
cppchar_t c;
- if (one_utf8_to_cppchar (inbufp, inbytesleftp, &c) != 0)
+ int next_width;
+
+ if (*m_next == '\t')
+ {
+ ++m_next;
+ --m_bytes_left;
+ next_width = m_tabstop - (m_display_cols % m_tabstop);
+ }
+ else if (one_utf8_to_cppchar ((const uchar **) &m_next, &m_bytes_left, &c)
+ != 0)
{
/* Input is not convertible to UTF-8. This could be fine, e.g. in a
string literal, so don't complain. Just treat it as if it has a width
of one. */
- ++*inbufp;
- --*inbytesleftp;
- return 1;
+ ++m_next;
+ --m_bytes_left;
+ next_width = 1;
+ }
+ else
+ {
+ /* one_utf8_to_cppchar() has updated m_next and m_bytes_left for us. */
+ next_width = cpp_wcwidth (c);
}
- /* one_utf8_to_cppchar() has updated inbufp and inbytesleftp for us. */
- return cpp_wcwidth (c);
+ m_display_cols += next_width;
+ return next_width;
+}
+
+/* Utility to advance the byte stream by the minimum amount needed to consume
+ N display columns. Returns the number of display columns that were
+ actually skipped. This could be less than N, if there was not enough data,
+ or more than N, if the last character to be skipped had a sufficiently large
+ display width. */
+int
+cpp_display_width_computation::advance_display_cols (int n)
+{
+ const int start = m_display_cols;
+ const int target = start + n;
+ while (m_display_cols < target && !done ())
+ process_next_codepoint ();
+ return m_display_cols - start;
}
/* For the string of length DATA_LENGTH bytes that begins at DATA, compute
how many display columns are occupied by the first COLUMN bytes. COLUMN
may exceed DATA_LENGTH, in which case the phantom bytes at the end are
- treated as if they have display width 1. */
+ treated as if they have display width 1. Tabs are expanded to the next tab
+ stop, relative to the start of DATA. */
int
cpp_byte_column_to_display_column (const char *data, int data_length,
- int column)
+ int column, int tabstop)
{
- int display_col = 0;
- const uchar *udata = (const uchar *) data;
const int offset = MAX (0, column - data_length);
- size_t inbytesleft = column - offset;
- while (inbytesleft)
- display_col += compute_next_display_width (&udata, &inbytesleft);
- return display_col + offset;
+ cpp_display_width_computation dw (data, column - offset, tabstop);
+ while (!dw.done ())
+ dw.process_next_codepoint ();
+ return dw.display_cols_processed () + offset;
}
/* For the string of length DATA_LENGTH bytes that begins at DATA, compute
@@ -2328,14 +2369,11 @@ cpp_byte_column_to_display_column (const char *data, int data_length,
int
cpp_display_column_to_byte_column (const char *data, int data_length,
- int display_col)
+ int display_col, int tabstop)
{
- int column = 0;
- const uchar *udata = (const uchar *) data;
- size_t inbytesleft = data_length;
- while (column < display_col && inbytesleft)
- column += compute_next_display_width (&udata, &inbytesleft);
- return data_length - inbytesleft + MAX (0, display_col - column);
+ cpp_display_width_computation dw (data, data_length, tabstop);
+ const int avail_display = dw.advance_display_cols (display_col);
+ return dw.bytes_processed () + MAX (0, display_col - avail_display);
}
/* Our own version of wcwidth(). We don't use the actual wcwidth() in glibc,
diff --git a/libcpp/configure b/libcpp/configure
index 3329e20..7e28606 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -7564,7 +7564,7 @@ case "$host" in
case "$enable_cet" in
auto)
# Check if target supports multi-byte NOPs
- # and if assembler supports CET insn.
+ # and if compiler and assembler support CET.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7590,7 +7590,7 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
yes)
- # Check if assembler supports CET.
+ # Check if compiler and assembler support CET.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7603,11 +7603,24 @@ asm ("setssbsy");
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
-
+ support_cet=yes
else
- as_fn_error $? "assembler with CET support is required for --enable-cet" "$LINENO" 5
+ support_cet=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test $support_cet = "no"; then
+ if test x$enable_bootstrap != xno \
+ && test -z "${with_build_subdir}" \
+ && (test ! -f ../stage_current \
+ || test `cat ../stage_current` != "stage1"); then
+ # Require CET support only for the final GCC build.
+ as_fn_error $? "compiler and assembler with CET support are required for --enable-cet" "$LINENO" 5
+ else
+ # Don't enable CET without CET support for non-bootstrap
+ # build, in stage1 nor for build support.
+ enable_cet=no
+ fi
+ fi
;;
esac
CFLAGS="$cet_save_CFLAGS"
diff --git a/libcpp/files.c b/libcpp/files.c
index 3d48c38..5af4136 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -948,10 +948,12 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type,
/* Add line map and do callbacks. */
_cpp_do_file_change (pfile, LC_ENTER, file->path,
- /* With preamble injection, start on line zero, so
- the preamble doesn't appear to have been
- included from line 1. */
- type == IT_MAIN_INJECT ? 0 : 1, sysp);
+ /* With preamble injection, start on line zero,
+ so the preamble doesn't appear to have been
+ included from line 1. Likewise when
+ starting preprocessed, we expect an initial
+ locating line. */
+ type == IT_PRE_MAIN ? 0 : 1, sysp);
return true;
}
@@ -1693,7 +1695,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
p = strchr (fname, '/');
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
{
- char *p2 = strchr (fname, '\\');
+ const char *p2 = strchr (fname, '\\');
if (!p || (p > p2))
p = p2;
}
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index e8bb15d..8e39886 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -312,9 +312,6 @@ enum cpp_normalize_level {
carries all the options visible to the command line. */
struct cpp_options
{
- /* Characters between tab stops. */
- unsigned int tabstop;
-
/* The language we're preprocessing. */
enum c_lang lang;
@@ -1335,14 +1332,43 @@ extern const char * cpp_get_userdef_suffix
(const cpp_token *);
/* In charset.c */
+
+/* A class to manage the state while converting a UTF-8 sequence to cppchar_t
+ and computing the display width one character at a time. */
+class cpp_display_width_computation {
+ public:
+ cpp_display_width_computation (const char *data, int data_length,
+ int tabstop);
+ const char *next_byte () const { return m_next; }
+ int bytes_processed () const { return m_next - m_begin; }
+ int bytes_left () const { return m_bytes_left; }
+ bool done () const { return !bytes_left (); }
+ int display_cols_processed () const { return m_display_cols; }
+
+ int process_next_codepoint ();
+ int advance_display_cols (int n);
+
+ private:
+ const char *const m_begin;
+ const char *m_next;
+ size_t m_bytes_left;
+ const int m_tabstop;
+ int m_display_cols;
+};
+
+/* Convenience functions that are simple use cases for class
+ cpp_display_width_computation. Tab characters will be expanded to spaces
+ as determined by TABSTOP. */
int cpp_byte_column_to_display_column (const char *data, int data_length,
- int column);
-inline int cpp_display_width (const char *data, int data_length)
+ int column, int tabstop);
+inline int cpp_display_width (const char *data, int data_length,
+ int tabstop)
{
- return cpp_byte_column_to_display_column (data, data_length, data_length);
+ return cpp_byte_column_to_display_column (data, data_length, data_length,
+ tabstop);
}
int cpp_display_column_to_byte_column (const char *data, int data_length,
- int display_col);
+ int display_col, int tabstop);
int cpp_wcwidth (cppchar_t c);
#endif /* ! LIBCPP_CPPLIB_H */
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 217f916..44008be 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1225,6 +1225,12 @@ LINEMAP_SYSP (const line_map_ordinary *ord_map)
return ord_map->sysp;
}
+const struct line_map *first_map_in_common (line_maps *set,
+ location_t loc0,
+ location_t loc1,
+ location_t *res_loc0,
+ location_t *res_loc1);
+
/* Return a positive value if PRE denotes the location of a token that
comes before the token of POST, 0 if PRE denotes the location of
the same token as the token for POST, and a negative value
diff --git a/libcpp/init.c b/libcpp/init.c
index d641d0a1..84c0a9e 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -36,7 +36,7 @@ along with this program; see the file COPYING3. If not see
static void init_library (void);
static void mark_named_operators (cpp_reader *, int);
-static void read_original_filename (cpp_reader *);
+static bool read_original_filename (cpp_reader *);
static void read_original_directory (cpp_reader *);
static void post_options (cpp_reader *);
@@ -190,7 +190,6 @@ cpp_create_reader (enum c_lang lang, cpp_hash_table *table,
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;
CPP_OPTION (pfile, warn_endif_labels) = 1;
@@ -401,6 +400,9 @@ static const struct builtin_macro builtin_array[] =
B("__LINE__", BT_SPECLINE, true),
B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true),
B("__COUNTER__", BT_COUNTER, true),
+ /* Make sure to update the list of built-in
+ function-like macros in traditional.c:
+ fun_like_macro() when adding more following */
B("__has_attribute", BT_HAS_ATTRIBUTE, true),
B("__has_cpp_attribute", BT_HAS_ATTRIBUTE, true),
B("__has_builtin", BT_HAS_BUILTIN, true),
@@ -679,97 +681,114 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname, bool injecting)
return NULL;
_cpp_stack_file (pfile, pfile->main_file,
- injecting ? IT_MAIN_INJECT : IT_MAIN, 0);
+ injecting || CPP_OPTION (pfile, preprocessed)
+ ? IT_PRE_MAIN : IT_MAIN, 0);
/* For foo.i, read the original filename foo.c now, for the benefit
of the front ends. */
if (CPP_OPTION (pfile, preprocessed))
- {
- read_original_filename (pfile);
- fname = (ORDINARY_MAP_FILE_NAME
- ((LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table))));
- }
- return fname;
+ if (!read_original_filename (pfile))
+ {
+ /* We're on line 1 after all. */
+ auto *last = linemap_check_ordinary
+ (LINEMAPS_LAST_MAP (pfile->line_table, false));
+ last->to_line = 1;
+ /* Inform of as-if a file change. */
+ _cpp_do_file_change (pfile, LC_RENAME_VERBATIM, LINEMAP_FILE (last),
+ LINEMAP_LINE (last), LINEMAP_SYSP (last));
+ }
+
+ return ORDINARY_MAP_FILE_NAME (LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table));
}
-/* For preprocessed files, if the first tokens are of the form # NUM.
- handle the directive so we know the original file name. This will
- generate file_change callbacks, which the front ends must handle
- appropriately given their state of initialization. */
-static void
+/* For preprocessed files, if the very first characters are
+ '#<SPACE>[01]<SPACE>', then handle a line directive so we know the
+ original file name. This will generate file_change callbacks,
+ which the front ends must handle appropriately given their state of
+ initialization. We peek directly into the character buffer, so
+ that we're not confused by otherwise-skipped white space &
+ comments. We can be very picky, because this should have been
+ machine-generated text (by us, no less). This way we do not
+ interfere with the module directive state machine. */
+
+static bool
read_original_filename (cpp_reader *pfile)
{
- const cpp_token *token, *token1;
-
- /* Lex ahead; if the first tokens are of the form # NUM, then
- process the directive, otherwise back up. */
- token = _cpp_lex_direct (pfile);
- if (token->type == CPP_HASH)
+ auto *buf = pfile->buffer->next_line;
+
+ if (pfile->buffer->rlimit - buf > 4
+ && buf[0] == '#'
+ && buf[1] == ' '
+ // Also permit '1', as that's what used to be here
+ && (buf[2] == '0' || buf[2] == '1')
+ && buf[3] == ' ')
{
- pfile->state.in_directive = 1;
- token1 = _cpp_lex_direct (pfile);
- _cpp_backup_tokens (pfile, 1);
- pfile->state.in_directive = 0;
-
- /* If it's a #line directive, handle it. */
- if (token1->type == CPP_NUMBER
- && _cpp_handle_directive (pfile, token->flags & PREV_WHITE))
+ const cpp_token *token = _cpp_lex_direct (pfile);
+ gcc_checking_assert (token->type == CPP_HASH);
+ if (_cpp_handle_directive (pfile, token->flags & PREV_WHITE))
{
read_original_directory (pfile);
- return;
+ return true;
}
}
- /* Backup as if nothing happened. */
- _cpp_backup_tokens (pfile, 1);
+ return false;
}
/* For preprocessed files, if the tokens following the first filename
line is of the form # <line> "/path/name//", handle the
- directive so we know the original current directory. */
+ directive so we know the original current directory.
+
+ As with the first line peeking, we can do this without lexing by
+ being picky. */
static void
read_original_directory (cpp_reader *pfile)
{
- const cpp_token *hash, *token;
-
- /* Lex ahead; if the first tokens are of the form # NUM, then
- process the directive, otherwise back up. */
- hash = _cpp_lex_direct (pfile);
- if (hash->type != CPP_HASH)
+ auto *buf = pfile->buffer->next_line;
+
+ if (pfile->buffer->rlimit - buf > 4
+ && buf[0] == '#'
+ && buf[1] == ' '
+ // Also permit '1', as that's what used to be here
+ && (buf[2] == '0' || buf[2] == '1')
+ && buf[3] == ' ')
{
- _cpp_backup_tokens (pfile, 1);
- return;
- }
-
- token = _cpp_lex_direct (pfile);
+ const cpp_token *hash = _cpp_lex_direct (pfile);
+ gcc_checking_assert (hash->type == CPP_HASH);
+ pfile->state.in_directive = 1;
+ const cpp_token *number = _cpp_lex_direct (pfile);
+ gcc_checking_assert (number->type == CPP_NUMBER);
+ const cpp_token *string = _cpp_lex_direct (pfile);
+ pfile->state.in_directive = 0;
- if (token->type != CPP_NUMBER)
- {
- _cpp_backup_tokens (pfile, 2);
- return;
- }
+ const unsigned char *text = nullptr;
+ size_t len = 0;
+ if (string->type == CPP_STRING)
+ {
+ /* The string value includes the quotes. */
+ text = string->val.str.text;
+ len = string->val.str.len;
+ }
+ if (len < 5
+ || !IS_DIR_SEPARATOR (text[len - 2])
+ || !IS_DIR_SEPARATOR (text[len - 3]))
+ {
+ /* That didn't work out, back out. */
+ _cpp_backup_tokens (pfile, 3);
+ return;
+ }
- token = _cpp_lex_direct (pfile);
+ if (pfile->cb.dir_change)
+ {
+ /* Smash the string directly, it's dead at this point */
+ char *smashy = (char *)text;
+ smashy[len - 3] = 0;
+
+ pfile->cb.dir_change (pfile, smashy + 1);
+ }
- if (token->type != CPP_STRING
- || ! (token->val.str.len >= 5
- && IS_DIR_SEPARATOR (token->val.str.text[token->val.str.len-2])
- && IS_DIR_SEPARATOR (token->val.str.text[token->val.str.len-3])))
- {
- _cpp_backup_tokens (pfile, 3);
- return;
+ /* We should be at EOL. */
}
-
- if (pfile->cb.dir_change)
- {
- char *debugdir = (char *) alloca (token->val.str.len - 3);
-
- memcpy (debugdir, (const char *) token->val.str.text + 1,
- token->val.str.len - 4);
- debugdir[token->val.str.len - 4] = '\0';
-
- pfile->cb.dir_change (pfile, debugdir);
- }
}
/* This is called at the end of preprocessing. It pops the last
diff --git a/libcpp/internal.h b/libcpp/internal.h
index 4bafe1c..b728df7 100644
--- a/libcpp/internal.h
+++ b/libcpp/internal.h
@@ -124,8 +124,8 @@ enum include_type
IT_CMDLINE, /* -include */
IT_DEFAULT, /* forced header */
IT_MAIN, /* main, start on line 1 */
- IT_MAIN_INJECT, /* main, but there will be an injected preamble
- before line 1 */
+ IT_PRE_MAIN, /* main, but there will be a preamble before line
+ 1 */
IT_DIRECTIVE_HWM = IT_IMPORT + 1, /* Directives below this. */
IT_HEADER_HWM = IT_DEFAULT + 1 /* Header files below this. */
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 5d94882..2fe77d1 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -531,11 +531,11 @@ init_vectorized_lexer (void)
search_line_fast = impl;
}
-#elif defined(_ARCH_PWR8) && defined(__ALTIVEC__)
+#elif (GCC_VERSION >= 4005) && defined(_ARCH_PWR8) && defined(__ALTIVEC__)
/* A vection of the fast scanner using AltiVec vectorized byte compares
and VSX unaligned loads (when VSX is available). This is otherwise
- the same as the pre-GCC 5 version. */
+ the same as the AltiVec version. */
ATTRIBUTE_NO_SANITIZE_UNDEFINED
static const uchar *
@@ -1885,7 +1885,8 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
the best failure mode. */
prefix_len = 0;
}
- continue;
+ if (c != '\n')
+ continue;
}
if (phase != PHASE_NONE)
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 8a390d0..5a74174 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -462,17 +462,12 @@ linemap_add (line_maps *set, enum lc_reason reason,
{
/* Generate a start_location above the current highest_location.
If possible, make the low range bits be zero. */
- location_t start_location;
- if (set->highest_location < LINE_MAP_MAX_LOCATION_WITH_COLS)
- {
- start_location = set->highest_location + (1 << set->default_range_bits);
- if (set->default_range_bits)
- start_location &= ~((1 << set->default_range_bits) - 1);
- linemap_assert (0 == (start_location
- & ((1 << set->default_range_bits) - 1)));
- }
- else
- start_location = set->highest_location + 1;
+ location_t start_location = set->highest_location + 1;
+ unsigned range_bits = 0;
+ if (start_location < LINE_MAP_MAX_LOCATION_WITH_COLS)
+ range_bits = set->default_range_bits;
+ start_location += (1 << range_bits) - 1;
+ start_location &= ~((1 << range_bits) - 1);
linemap_assert (!LINEMAPS_ORDINARY_USED (set)
|| (start_location
@@ -537,8 +532,9 @@ linemap_add (line_maps *set, enum lc_reason reason,
map->to_file = to_file;
map->to_line = to_line;
LINEMAPS_ORDINARY_CACHE (set) = LINEMAPS_ORDINARY_USED (set) - 1;
- map->m_column_and_range_bits = 0;
- map->m_range_bits = 0;
+ /* Do not store range_bits here. That's readjusted in
+ linemap_line_start. */
+ map->m_range_bits = map->m_column_and_range_bits = 0;
set->highest_location = start_location;
set->highest_line = start_location;
set->max_column_hint = 0;
@@ -954,19 +950,16 @@ linemap_lookup (const line_maps *set, location_t line)
static const line_map_ordinary *
linemap_ordinary_map_lookup (const line_maps *set, location_t line)
{
- unsigned int md, mn, mx;
- const line_map_ordinary *cached, *result;
-
if (IS_ADHOC_LOC (line))
line = get_location_from_adhoc_loc (set, line);
if (set == NULL || line < RESERVED_LOCATION_COUNT)
return NULL;
- mn = LINEMAPS_ORDINARY_CACHE (set);
- mx = LINEMAPS_ORDINARY_USED (set);
+ unsigned mn = LINEMAPS_ORDINARY_CACHE (set);
+ unsigned mx = LINEMAPS_ORDINARY_USED (set);
- cached = LINEMAPS_ORDINARY_MAP_AT (set, mn);
+ const line_map_ordinary *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))
{
@@ -981,7 +974,7 @@ linemap_ordinary_map_lookup (const line_maps *set, location_t line)
while (mx - mn > 1)
{
- md = (mn + mx) / 2;
+ unsigned md = (mn + mx) / 2;
if (MAP_START_LOCATION (LINEMAPS_ORDINARY_MAP_AT (set, md)) > line)
mx = md;
else
@@ -989,7 +982,7 @@ linemap_ordinary_map_lookup (const line_maps *set, location_t line)
}
LINEMAPS_ORDINARY_CACHE (set) = mn;
- result = LINEMAPS_ORDINARY_MAP_AT (set, mn);
+ const line_map_ordinary *result = LINEMAPS_ORDINARY_MAP_AT (set, mn);
linemap_assert (line >= MAP_START_LOCATION (result));
return result;
}
@@ -1002,21 +995,18 @@ linemap_ordinary_map_lookup (const line_maps *set, location_t line)
static const line_map_macro *
linemap_macro_map_lookup (const line_maps *set, location_t line)
{
- unsigned int md, mn, mx;
- const struct line_map_macro *cached, *result;
-
if (IS_ADHOC_LOC (line))
line = get_location_from_adhoc_loc (set, line);
linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set));
- if (set == NULL)
+ if (set == NULL)
return NULL;
- mn = LINEMAPS_MACRO_CACHE (set);
- mx = LINEMAPS_MACRO_USED (set);
- cached = LINEMAPS_MACRO_MAP_AT (set, mn);
-
+ unsigned mn = LINEMAPS_MACRO_CACHE (set);
+ unsigned mx = LINEMAPS_MACRO_USED (set);
+ const struct line_map_macro *cached = LINEMAPS_MACRO_MAP_AT (set, mn);
+
if (line >= MAP_START_LOCATION (cached))
{
if (mn == 0 || line < MAP_START_LOCATION (&cached[-1]))
@@ -1027,7 +1017,7 @@ linemap_macro_map_lookup (const line_maps *set, location_t line)
while (mn < mx)
{
- md = (mx + mn) / 2;
+ unsigned md = (mx + mn) / 2;
if (MAP_START_LOCATION (LINEMAPS_MACRO_MAP_AT (set, md)) > line)
mn = md + 1;
else
@@ -1035,7 +1025,7 @@ linemap_macro_map_lookup (const line_maps *set, location_t line)
}
LINEMAPS_MACRO_CACHE (set) = mx;
- result = LINEMAPS_MACRO_MAP_AT (set, LINEMAPS_MACRO_CACHE (set));
+ const struct line_map_macro *result = LINEMAPS_MACRO_MAP_AT (set, mx);
linemap_assert (MAP_START_LOCATION (result) <= line);
return result;
@@ -1299,7 +1289,7 @@ first_map_in_common_1 (line_maps *set,
virtual location of the token inside the resulting macro, upon
return of a non-NULL result. */
-static const struct line_map*
+const struct line_map*
first_map_in_common (line_maps *set,
location_t loc0,
location_t loc1,
diff --git a/libcpp/po/ChangeLog b/libcpp/po/ChangeLog
index 6241652..ef050aac 100644
--- a/libcpp/po/ChangeLog
+++ b/libcpp/po/ChangeLog
@@ -1,3 +1,7 @@
+2020-07-20 Joseph Myers <joseph@codesourcery.com>
+
+ * cpplib.pot: Regenerate.
+
2020-05-15 Joseph Myers <joseph@codesourcery.com>
* sv.po: Update.
diff --git a/libcpp/po/cpplib.pot b/libcpp/po/cpplib.pot
index c389157..81aa102a 100644
--- a/libcpp/po/cpplib.pot
+++ b/libcpp/po/cpplib.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n"
-"POT-Creation-Date: 2020-02-07 22:33+0000\n"
+"POT-Creation-Date: 2020-07-20 18:03+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -301,153 +301,147 @@ msgstr ""
msgid "file \"%s\" linemarker ignored due to incorrect nesting"
msgstr ""
-#: directives.c:1162
-#: directives.c:1164
-#: directives.c:1166
-#: directives.c:1754
+#: directives.c:1178
+#: directives.c:1180
+#: directives.c:1182
+#: directives.c:1770
#, c-format
msgid "%s"
msgstr ""
-#: directives.c:1190
+#: directives.c:1206
#, c-format
msgid "invalid #%s directive"
msgstr ""
-#: directives.c:1253
+#: directives.c:1269
#, c-format
msgid "registering pragmas in namespace \"%s\" with mismatched name expansion"
msgstr ""
-#: directives.c:1262
+#: directives.c:1278
#, c-format
msgid "registering pragma \"%s\" with name expansion and no namespace"
msgstr ""
-#: directives.c:1280
+#: directives.c:1296
#, c-format
msgid "registering \"%s\" as both a pragma and a pragma namespace"
msgstr ""
-#: directives.c:1283
+#: directives.c:1299
#, c-format
msgid "#pragma %s %s is already registered"
msgstr ""
-#: directives.c:1286
+#: directives.c:1302
#, c-format
msgid "#pragma %s is already registered"
msgstr ""
-#: directives.c:1316
+#: directives.c:1332
msgid "registering pragma with NULL handler"
msgstr ""
-#: directives.c:1533
+#: directives.c:1549
msgid "#pragma once in main file"
msgstr ""
-#: directives.c:1556
+#: directives.c:1572
msgid "invalid #pragma push_macro directive"
msgstr ""
-#: directives.c:1613
+#: directives.c:1629
msgid "invalid #pragma pop_macro directive"
msgstr ""
-#: directives.c:1668
+#: directives.c:1684
msgid "invalid #pragma GCC poison directive"
msgstr ""
-#: directives.c:1677
+#: directives.c:1693
#, c-format
msgid "poisoning existing macro \"%s\""
msgstr ""
-#: directives.c:1696
+#: directives.c:1712
msgid "#pragma system_header ignored outside include file"
msgstr ""
-#: directives.c:1721
+#: directives.c:1737
#, c-format
msgid "cannot find source file %s"
msgstr ""
-#: directives.c:1725
+#: directives.c:1741
#, c-format
msgid "current file is older than %s"
msgstr ""
-#: directives.c:1749
+#: directives.c:1765
#, c-format
msgid "invalid \"#pragma GCC %s\" directive"
msgstr ""
-#: directives.c:1950
+#: directives.c:1966
msgid "_Pragma takes a parenthesized string literal"
msgstr ""
-#: directives.c:2033
+#: directives.c:2049
msgid "#else without #if"
msgstr ""
-#: directives.c:2038
+#: directives.c:2054
msgid "#else after #else"
msgstr ""
-#: directives.c:2040
-#: directives.c:2073
+#: directives.c:2056
+#: directives.c:2089
msgid "the conditional began here"
msgstr ""
-#: directives.c:2066
+#: directives.c:2082
msgid "#elif without #if"
msgstr ""
-#: directives.c:2071
+#: directives.c:2087
msgid "#elif after #else"
msgstr ""
-#: directives.c:2102
+#: directives.c:2118
msgid "#endif without #if"
msgstr ""
-#: directives.c:2178
+#: directives.c:2194
msgid "missing '(' after predicate"
msgstr ""
-#: directives.c:2196
+#: directives.c:2212
msgid "missing ')' to complete answer"
msgstr ""
-#: directives.c:2208
+#: directives.c:2224
msgid "predicate's answer is empty"
msgstr ""
-#: directives.c:2238
+#: directives.c:2254
msgid "assertion without predicate"
msgstr ""
-#: directives.c:2241
+#: directives.c:2257
msgid "predicate must be an identifier"
msgstr ""
-#: directives.c:2323
+#: directives.c:2339
#, c-format
msgid "\"%s\" re-asserted"
msgstr ""
-#: directives.c:2604
+#: directives.c:2620
#, c-format
msgid "unterminated #%s"
msgstr ""
-#: directives-only.c:221
-#: lex.c:2879
-#: traditional.c:174
-msgid "unterminated comment"
-msgstr ""
-
#: errors.c:291
#, c-format
msgid "%s: %s"
@@ -622,15 +616,15 @@ msgstr ""
msgid "division by zero in #if"
msgstr ""
-#: files.c:576
+#: files.c:571
msgid "one or more PCH files were found, but they were invalid"
msgstr ""
-#: files.c:580
+#: files.c:575
msgid "use -Winvalid-pch for more information"
msgstr ""
-#: files.c:1004
+#: files.c:1003
#, c-format
msgid "no include path in which to search for %s"
msgstr ""
@@ -639,38 +633,38 @@ msgstr ""
msgid "Multiple include guards may be useful for:\n"
msgstr ""
-#: init.c:598
+#: init.c:597
msgid "cppchar_t must be an unsigned type"
msgstr ""
-#: init.c:602
+#: init.c:601
#, c-format
msgid ""
"preprocessor arithmetic has maximum precision of %lu bits; target requires "
"%lu bits"
msgstr ""
-#: init.c:609
+#: init.c:608
msgid "CPP arithmetic must be at least as precise as a target int"
msgstr ""
-#: init.c:612
+#: init.c:611
msgid "target char is less than 8 bits wide"
msgstr ""
-#: init.c:616
+#: init.c:615
msgid "target wchar_t is narrower than target char"
msgstr ""
-#: init.c:620
+#: init.c:619
msgid "target int is narrower than target char"
msgstr ""
-#: init.c:625
+#: init.c:624
msgid "CPP half-integer narrower than CPP character"
msgstr ""
-#: init.c:629
+#: init.c:628
#, c-format
msgid ""
"CPP on this host cannot handle wide character constants over %lu bits, but "
@@ -719,11 +713,11 @@ msgid "`%.*s' is not in NFC"
msgstr ""
#: lex.c:1375
-msgid "__VA_OPT__ is not available until C++2a"
+msgid "__VA_OPT__ is not available until C++20"
msgstr ""
#: lex.c:1382
-msgid "__VA_OPT__ can only appear in the expansion of a C++2a variadic macro"
+msgid "__VA_OPT__ can only appear in the expansion of a C++20 variadic macro"
msgstr ""
#: lex.c:1413
@@ -748,249 +742,265 @@ msgstr ""
msgid "identifier \"%s\" is a special operator name in C++"
msgstr ""
-#: lex.c:1837
+#: lex.c:1872
msgid "raw string delimiter longer than 16 characters"
msgstr ""
-#: lex.c:1841
+#: lex.c:1876
msgid "invalid new-line in raw string delimiter"
msgstr ""
-#: lex.c:1845
+#: lex.c:1880
+#: lex.c:4265
#, c-format
msgid "invalid character '%c' in raw string delimiter"
msgstr ""
-#: lex.c:1894
-#: lex.c:1916
+#: lex.c:1918
+#: lex.c:1941
msgid "unterminated raw string"
msgstr ""
-#: lex.c:1936
-#: lex.c:2065
+#: lex.c:1963
+#: lex.c:2092
msgid ""
"invalid suffix on literal; C++11 requires a space between literal and string "
"macro"
msgstr ""
-#: lex.c:2048
+#: lex.c:2075
msgid "null character(s) preserved in literal"
msgstr ""
-#: lex.c:2051
+#: lex.c:2078
#, c-format
msgid "missing terminating %c character"
msgstr ""
-#: lex.c:2083
+#: lex.c:2110
msgid "C++11 requires a space between string literal and macro"
msgstr ""
-#: lex.c:2893
+#: lex.c:2913
+#: lex.c:4098
+#: traditional.c:174
+msgid "unterminated comment"
+msgstr ""
+
#: lex.c:2927
+#: lex.c:2961
msgid "C++ style comments are not allowed in ISO C90"
msgstr ""
-#: lex.c:2895
-#: lex.c:2906
-#: lex.c:2930
+#: lex.c:2929
+#: lex.c:2940
+#: lex.c:2964
msgid "(this will be reported only once per input file)"
msgstr ""
-#: lex.c:2904
+#: lex.c:2938
msgid "C++ style comments are incompatible with C90"
msgstr ""
-#: lex.c:2936
+#: lex.c:2970
msgid "multi-line comment"
msgstr ""
-#: lex.c:3330
+#: lex.c:3364
#, c-format
msgid "unspellable token %s"
msgstr ""
+#: lex.c:4253
+#, c-format
+msgid "raw string delimiter longer than %d characters"
+msgstr ""
+
+#: lex.c:4323
+msgid "unterminated literal"
+msgstr ""
+
#: macro.c:94
msgid "'##' cannot appear at either end of __VA_OPT__"
msgstr ""
-#: macro.c:364
+#: macro.c:388
#, c-format
msgid "\"%s\" used outside of preprocessing directive"
msgstr ""
-#: macro.c:374
+#: macro.c:398
#, c-format
msgid "missing '(' before \"%s\" operand"
msgstr ""
-#: macro.c:389
+#: macro.c:413
#, c-format
msgid "operator \"%s\" requires a header-name"
msgstr ""
-#: macro.c:406
+#: macro.c:430
#, c-format
msgid "missing ')' after \"%s\" operand"
msgstr ""
-#: macro.c:426
+#: macro.c:450
#, c-format
msgid "macro \"%s\" is not used"
msgstr ""
-#: macro.c:465
-#: macro.c:723
+#: macro.c:489
+#: macro.c:747
#, c-format
msgid "invalid built-in macro \"%s\""
msgstr ""
-#: macro.c:472
-#: macro.c:574
+#: macro.c:496
+#: macro.c:598
#, c-format
msgid "macro \"%s\" might prevent reproducible builds"
msgstr ""
-#: macro.c:503
+#: macro.c:527
msgid "could not determine file timestamp"
msgstr ""
-#: macro.c:620
+#: macro.c:644
msgid "could not determine date and time"
msgstr ""
-#: macro.c:636
+#: macro.c:660
msgid "__COUNTER__ expanded inside directive with -fdirectives-only"
msgstr ""
-#: macro.c:842
+#: macro.c:866
msgid "invalid string literal, ignoring final '\\'"
msgstr ""
-#: macro.c:904
+#: macro.c:928
#, c-format
msgid "pasting \"%s\" and \"%s\" does not give a valid preprocessing token"
msgstr ""
-#: macro.c:1030
+#: macro.c:1054
msgid ""
"ISO C++11 requires at least one argument for the \"...\" in a variadic macro"
msgstr ""
-#: macro.c:1034
+#: macro.c:1058
msgid ""
"ISO C99 requires at least one argument for the \"...\" in a variadic macro"
msgstr ""
-#: macro.c:1041
+#: macro.c:1065
#, c-format
msgid "macro \"%s\" requires %u arguments, but only %u given"
msgstr ""
-#: macro.c:1046
+#: macro.c:1070
#, c-format
msgid "macro \"%s\" passed %u arguments, but takes just %u"
msgstr ""
-#: macro.c:1244
-#: traditional.c:815
+#: macro.c:1270
+#: traditional.c:819
#, c-format
msgid "unterminated argument list invoking macro \"%s\""
msgstr ""
-#: macro.c:1386
+#: macro.c:1412
#, c-format
msgid "function-like macro \"%s\" must be used with arguments in traditional C"
msgstr ""
-#: macro.c:2165
+#: macro.c:2190
#, c-format
msgid ""
"invoking macro %s argument %d: empty macro arguments are undefined in ISO C+"
"+98"
msgstr ""
-#: macro.c:2173
-#: macro.c:2182
+#: macro.c:2198
+#: macro.c:2207
#, c-format
msgid ""
"invoking macro %s argument %d: empty macro arguments are undefined in ISO C90"
msgstr ""
-#: macro.c:3141
+#: macro.c:3164
#, c-format
msgid "duplicate macro parameter \"%s\""
msgstr ""
-#: macro.c:3223
+#: macro.c:3246
#, c-format
msgid "expected parameter name, found \"%s\""
msgstr ""
-#: macro.c:3224
+#: macro.c:3247
#, c-format
msgid "expected ',' or ')', found \"%s\""
msgstr ""
-#: macro.c:3225
+#: macro.c:3248
msgid "expected parameter name before end of line"
msgstr ""
-#: macro.c:3226
+#: macro.c:3249
msgid "expected ')' before end of line"
msgstr ""
-#: macro.c:3227
+#: macro.c:3250
msgid "expected ')' after \"...\""
msgstr ""
-#: macro.c:3284
+#: macro.c:3307
msgid "anonymous variadic macros were introduced in C++11"
msgstr ""
-#: macro.c:3285
-#: macro.c:3289
+#: macro.c:3308
+#: macro.c:3312
msgid "anonymous variadic macros were introduced in C99"
msgstr ""
-#: macro.c:3295
+#: macro.c:3318
msgid "ISO C++ does not permit named variadic macros"
msgstr ""
-#: macro.c:3296
+#: macro.c:3319
msgid "ISO C does not permit named variadic macros"
msgstr ""
-#: macro.c:3342
+#: macro.c:3365
msgid "'##' cannot appear at either end of a macro expansion"
msgstr ""
-#: macro.c:3380
+#: macro.c:3403
msgid "ISO C++11 requires whitespace after the macro name"
msgstr ""
-#: macro.c:3381
+#: macro.c:3404
msgid "ISO C99 requires whitespace after the macro name"
msgstr ""
-#: macro.c:3405
+#: macro.c:3428
msgid "missing whitespace after the macro name"
msgstr ""
-#: macro.c:3455
+#: macro.c:3478
msgid "'#' is not followed by a macro parameter"
msgstr ""
-#: macro.c:3606
+#: macro.c:3629
#, c-format
msgid "\"%s\" redefined"
msgstr ""
-#: macro.c:3611
+#: macro.c:3634
msgid "this is the location of the previous definition"
msgstr ""
-#: macro.c:3715
+#: macro.c:3738
#, c-format
msgid "macro argument \"%s\" would be stringified in traditional C"
msgstr ""
@@ -1035,11 +1045,11 @@ msgstr ""
msgid "while reading precompiled header"
msgstr ""
-#: traditional.c:884
+#: traditional.c:888
#, c-format
msgid "detected recursion whilst expanding macro \"%s\""
msgstr ""
-#: traditional.c:1107
+#: traditional.c:1111
msgid "syntax error in macro parameter list"
msgstr ""
diff --git a/libcpp/traditional.c b/libcpp/traditional.c
index 77adb3b..b087072 100644
--- a/libcpp/traditional.c
+++ b/libcpp/traditional.c
@@ -330,7 +330,9 @@ fun_like_macro (cpp_hashnode *node)
{
if (cpp_builtin_macro_p (node))
return (node->value.builtin == BT_HAS_ATTRIBUTE
- || node->value.builtin == BT_HAS_BUILTIN);
+ || node->value.builtin == BT_HAS_BUILTIN
+ || node->value.builtin == BT_HAS_INCLUDE
+ || node->value.builtin == BT_HAS_INCLUDE_NEXT);
return node->value.macro->fun_like;
}