diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /libcpp/lex.c | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r-- | libcpp/lex.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c index 06bcc31..8e3ef09 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1306,6 +1306,9 @@ warn_about_normalization (cpp_reader *pfile, if (NORMALIZE_STATE_RESULT (s) == normalized_C) cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, "`%.*s' is not in NFKC", (int) sz, buf); + else if (CPP_OPTION (pfile, cxx23_identifiers)) + cpp_pedwarning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, + "`%.*s' is not in NFC", (int) sz, buf); else cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0, "`%.*s' is not in NFC", (int) sz, buf); @@ -1548,18 +1551,28 @@ lex_number (cpp_reader *pfile, cpp_string *number, base = pfile->buffer->cur - 1; do { + const uchar *adj_digit_sep = NULL; cur = pfile->buffer->cur; /* N.B. ISIDNUM does not include $. */ - while (ISIDNUM (*cur) || *cur == '.' || DIGIT_SEP (*cur) - || VALID_SIGN (*cur, cur[-1])) + while (ISIDNUM (*cur) + || (*cur == '.' && !DIGIT_SEP (cur[-1])) + || DIGIT_SEP (*cur) + || (VALID_SIGN (*cur, cur[-1]) && !DIGIT_SEP (cur[-2]))) { NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur); + /* Adjacent digit separators do not form part of the pp-number syntax. + However, they can safely be diagnosed here as an error, since '' is + not a valid preprocessing token. */ + if (DIGIT_SEP (*cur) && DIGIT_SEP (cur[-1]) && !adj_digit_sep) + adj_digit_sep = cur; cur++; } /* A number can't end with a digit separator. */ while (cur > pfile->buffer->cur && DIGIT_SEP (cur[-1])) --cur; + if (adj_digit_sep && adj_digit_sep < cur) + cpp_error (pfile, CPP_DL_ERROR, "adjacent digit separators"); pfile->buffer->cur = cur; } @@ -3709,11 +3722,13 @@ cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1, case CPP_DEREF: return c == '*'; case CPP_DOT: return c == '.' || c == '%' || b == CPP_NUMBER; case CPP_HASH: return c == '#' || c == '%'; /* Digraph form. */ + case CPP_PRAGMA: case CPP_NAME: return ((b == CPP_NUMBER && name_p (pfile, &token2->val.str)) || b == CPP_NAME || b == CPP_CHAR || b == CPP_STRING); /* L */ case CPP_NUMBER: return (b == CPP_NUMBER || b == CPP_NAME + || b == CPP_CHAR || c == '.' || c == '+' || c == '-'); /* UCNs */ case CPP_OTHER: return ((token1->val.str.text[0] == '\\' @@ -4468,8 +4483,9 @@ cpp_directive_only_process (cpp_reader *pfile, break; } } - cpp_error_with_line (pfile, CPP_DL_ERROR, sloc, 0, - "unterminated comment"); + if (pos < limit || is_block) + cpp_error_with_line (pfile, CPP_DL_ERROR, sloc, 0, + "unterminated comment"); done_comment: lwm = pos; break; @@ -4756,7 +4772,18 @@ cpp_directive_only_process (cpp_reader *pfile, } if (buffer->rlimit > base && !pfile->state.skipping) - cb (pfile, CPP_DO_print, data, line_count, base, buffer->rlimit - base); + { + const unsigned char *limit = buffer->rlimit; + /* If the file was not newline terminated, add rlimit, which is + guaranteed to point to a newline, to the end of our range. */ + if (limit[-1] != '\n') + { + limit++; + CPP_INCREMENT_LINE (pfile, 0); + line_count++; + } + cb (pfile, CPP_DO_print, data, line_count, base, limit - base); + } _cpp_pop_buffer (pfile); } |