[0/3] Implement C2X N2653 (char8_t) and correct UTF-8 character literal type in preprocessor directives for C++

Message ID 20220725175948.1424695-1-tom@honermann.net
Headers
Series Implement C2X N2653 (char8_t) and correct UTF-8 character literal type in preprocessor directives for C++ |

Message

Tom Honermann July 25, 2022, 5:59 p.m. UTC
  This patch series provides an implementation and tests for the WG14 N2653
paper as adopted for C2X.

Additionally, a fix is included for the C++ preprocessor to treat UTF-8
character literals in preprocessor directives as an unsigned type in char8_t
enabled modes (in C++17 and earlier with -fchar8_t or in C++20 or later
without -fno-char8_t).

Tom Honermann (3):
  C: Implement C2X N2653 char8_t and UTF-8 string literal changes
  testsuite: Add tests for C2X N2653 char8_t and UTF-8 string literal
    changes
  c++/106426: Treat u8 character literals as unsigned in char8_t modes.

 gcc/c-family/c-lex.cc                         | 13 ++++--
 gcc/c-family/c-opts.cc                        |  5 ++-
 gcc/c/c-parser.cc                             | 16 ++++++-
 gcc/c/c-typeck.cc                             |  2 +-
 gcc/ginclude/stdatomic.h                      |  8 ++++
 .../g++.dg/ext/char8_t-char-literal-1.C       |  6 ++-
 .../g++.dg/ext/char8_t-char-literal-2.C       |  4 ++
 .../atomic/c2x-stdatomic-lockfree-char8_t.c   | 42 +++++++++++++++++++
 .../atomic/gnu2x-stdatomic-lockfree-char8_t.c |  5 +++
 gcc/testsuite/gcc.dg/c2x-predefined-macros.c  | 11 +++++
 gcc/testsuite/gcc.dg/c2x-utf8str-type.c       |  6 +++
 gcc/testsuite/gcc.dg/c2x-utf8str.c            | 34 +++++++++++++++
 .../gcc.dg/gnu2x-predefined-macros.c          |  5 +++
 gcc/testsuite/gcc.dg/gnu2x-utf8str-type.c     |  5 +++
 gcc/testsuite/gcc.dg/gnu2x-utf8str.c          | 34 +++++++++++++++
 libcpp/charset.cc                             |  4 +-
 libcpp/include/cpplib.h                       |  4 +-
 libcpp/init.cc                                |  1 +
 18 files changed, 191 insertions(+), 14 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/atomic/c2x-stdatomic-lockfree-char8_t.c
 create mode 100644 gcc/testsuite/gcc.dg/atomic/gnu2x-stdatomic-lockfree-char8_t.c
 create mode 100644 gcc/testsuite/gcc.dg/c2x-predefined-macros.c
 create mode 100644 gcc/testsuite/gcc.dg/c2x-utf8str-type.c
 create mode 100644 gcc/testsuite/gcc.dg/c2x-utf8str.c
 create mode 100644 gcc/testsuite/gcc.dg/gnu2x-predefined-macros.c
 create mode 100644 gcc/testsuite/gcc.dg/gnu2x-utf8str-type.c
 create mode 100644 gcc/testsuite/gcc.dg/gnu2x-utf8str.c