On Thu, May 21, 2026 at 2:49 PM Andrew Pinski
<[email protected]> wrote:
>
> On Sun, Mar 22, 2026 at 10:59 AM Jean-Christian CÎRSTEA
> <[email protected]> wrote:
> >
> > Before this commit, attempting to use non-ASCII characters in quoted
> > words failed, even though the protocol allows the usage of such
> > characters in quoted words. To fix this:
> >
> > 1. Remove `c >= 0x7f` comparison when parsing a quoted word.
> > 2. Use `unsigned char` instead of `char` such that `c < 0x20` fails for
> >    non-ASCII characters.
> >
> >         PR c++/120458
> >
> > libcody/ChangeLog:
> >
> >         * buffer.cc (S2C): Allow non-ASCII chars in quoted words.
> >         * cody.hh: Use unsigned char for S2C().
> >
> > gcc/testsuite/ChangeLog:
> >
> >         * g++.dg/README: Explain purpose of modules/ dir.
> >         * g++.dg/modules/pr120458-1_a.C: Define non-ASCII module with
> >           default mapper.
> >         * g++.dg/modules/pr120458-1_b.C: Import non-ASCII module with
> >           default mapper.
> >         * g++.dg/modules/pr120458-2_a.C: Define non-ASCII module with
> >           a file as mapper.
> >         * g++.dg/modules/pr120458-2_b.C: Import non-ASCII module with
> >           a file as mapper.
> >         * g++.db/modules/pr120458-2.map: Define mapping for pr120458-2
> >           test case.
>
> Looking into the history of reviews on this patch, I am going to say this is 
> ok.
> Since I think Jean-Christian does not have git push access, I will
> push this mid-next week
> to give Jason and others some time to object if needed.

I have now pushed it with some minor fixes to the commit log for the
changelog area.
No spaces after a tab and fix up the name of the last file added (s/db/dg/).

Thanks again for the contribution and sorry it took so long to have it reviewed.

Thanks,
Andrea

>
> Thanks,
> Andrea
>
> >
> > Signed-off-by: Jean-Christian CÎRSTEA <[email protected]>
> > ---
> > Changelog v4:
> >
> > 1. Add new test using the default mapper
> > 2. Fix existing broken test
> >
> > Changelog v3:
> >
> > 1. Set test encoding to UTF-8
> > 2. Use module mapper for tests instead of names
> >
> > Changelog v2:
> >
> > 1. Fixed changelog entries
> > 2. Use East-Asian characters for test
> >
> >  gcc/testsuite/g++.dg/README                 |  1 +
> >  gcc/testsuite/g++.dg/modules/pr120458-1_a.C |  9 +++++++++
> >  gcc/testsuite/g++.dg/modules/pr120458-1_b.C | 11 +++++++++++
> >  gcc/testsuite/g++.dg/modules/pr120458-2.map |  2 ++
> >  gcc/testsuite/g++.dg/modules/pr120458-2_a.C | 11 +++++++++++
> >  gcc/testsuite/g++.dg/modules/pr120458-2_b.C | 12 ++++++++++++
> >  libcody/buffer.cc                           |  6 +++---
> >  libcody/cody.hh                             |  4 ++--
> >  8 files changed, 51 insertions(+), 5 deletions(-)
> >  create mode 100644 gcc/testsuite/g++.dg/modules/pr120458-1_a.C
> >  create mode 100644 gcc/testsuite/g++.dg/modules/pr120458-1_b.C
> >  create mode 100644 gcc/testsuite/g++.dg/modules/pr120458-2.map
> >  create mode 100644 gcc/testsuite/g++.dg/modules/pr120458-2_a.C
> >  create mode 100644 gcc/testsuite/g++.dg/modules/pr120458-2_b.C
> >
> > diff --git a/gcc/testsuite/g++.dg/README b/gcc/testsuite/g++.dg/README
> > index a7b3d5b783b..3301f17b4df 100644
> > --- a/gcc/testsuite/g++.dg/README
> > +++ b/gcc/testsuite/g++.dg/README
> > @@ -15,6 +15,7 @@ inherit        Tests for inheritance -- virtual 
> > functions, multiple inheritance, etc.
> >  init    Tests for initialization semantics, constructors/destructors, etc.
> >  lookup  Tests for lookup semantics, namespaces, using, etc.
> >  lto     Tests for Link Time Optimization.
> > +modules  Tests for C++20 modules.
> >  opt     Tests for fixes of bugs with particular optimizations.
> >  overload Tests for overload resolution and conversions.
> >  parse   Tests for parsing.
> > diff --git a/gcc/testsuite/g++.dg/modules/pr120458-1_a.C 
> > b/gcc/testsuite/g++.dg/modules/pr120458-1_a.C
> > new file mode 100644
> > index 00000000000..89d0bb5d293
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/modules/pr120458-1_a.C
> > @@ -0,0 +1,9 @@
> > +// { dg-module-do link }
> > +// { dg-additional-options "-fmodules -finput-charset=UTF-8" }
> > +
> > +export module 영혼;
> > +// { dg-module-cmi }
> > +
> > +export unsigned f(unsigned x) {
> > +       return x + 3;
> > +}
> > diff --git a/gcc/testsuite/g++.dg/modules/pr120458-1_b.C 
> > b/gcc/testsuite/g++.dg/modules/pr120458-1_b.C
> > new file mode 100644
> > index 00000000000..4b1023d5f3e
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/modules/pr120458-1_b.C
> > @@ -0,0 +1,11 @@
> > +// { dg-module-do link }
> > +// { dg-additional-options "-fmodules -finput-charset=UTF-8" }
> > +
> > +#include <iostream>
> > +
> > +import 영혼;
> > +
> > +int main(void) {
> > +       std::cout << f(13) << '\n';
> > +       return 0;
> > +}
> > diff --git a/gcc/testsuite/g++.dg/modules/pr120458-2.map 
> > b/gcc/testsuite/g++.dg/modules/pr120458-2.map
> > new file mode 100644
> > index 00000000000..86955e41ea1
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/modules/pr120458-2.map
> > @@ -0,0 +1,2 @@
> > +$root .
> > +灵魂 pr120458_a.gcm
> > diff --git a/gcc/testsuite/g++.dg/modules/pr120458-2_a.C 
> > b/gcc/testsuite/g++.dg/modules/pr120458-2_a.C
> > new file mode 100644
> > index 00000000000..940f6e771a0
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/modules/pr120458-2_a.C
> > @@ -0,0 +1,11 @@
> > +// { dg-module-do link }
> > +// { dg-additional-options "-fmodules 
> > -fmodule-mapper=[srcdir]/pr120458-2.map " }
> > +// { dg-additional-options "-finput-charset=UTF-8 " }
> > +// { dg-additional-files "pr120458-2.map" }
> > +
> > +export module 灵魂;
> > +// { dg-module-cmi }
> > +
> > +export unsigned f(unsigned x) {
> > +       return x + 3;
> > +}
> > diff --git a/gcc/testsuite/g++.dg/modules/pr120458-2_b.C 
> > b/gcc/testsuite/g++.dg/modules/pr120458-2_b.C
> > new file mode 100644
> > index 00000000000..dc4f66574fd
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/modules/pr120458-2_b.C
> > @@ -0,0 +1,12 @@
> > +// { dg-module-do link }
> > +// { dg-additional-options "-fmodules 
> > -fmodule-mapper=[srcdir]/pr120458-2.map " }
> > +// { dg-additional-options "-finput-charset=UTF-8" }
> > +
> > +import 灵魂;
> > +
> > +#include <iostream>
> > +
> > +int main(void) {
> > +       std::cout << f(13) << '\n';
> > +       return 0;
> > +}
> > diff --git a/libcody/buffer.cc b/libcody/buffer.cc
> > index 85c066fef71..d27882b7d4a 100644
> > --- a/libcody/buffer.cc
> > +++ b/libcody/buffer.cc
> > @@ -30,7 +30,7 @@
> >  namespace Cody {
> >  namespace Detail {
> >
> > -static const char CONTINUE = S2C(u8";");
> > +static const unsigned char CONTINUE = S2C(u8";");
> >
> >  void MessageBuffer::BeginLine ()
> >  {
> > @@ -239,7 +239,7 @@ int MessageBuffer::Lex (std::vector<std::string> 
> > &result)
> >
> >    for (std::string *word = nullptr;;)
> >      {
> > -      char c = *iter;
> > +      unsigned char c = *iter;
> >
> >        ++iter;
> >        if (c == S2C(u8" ") || c == S2C(u8"\t"))
> > @@ -292,7 +292,7 @@ int MessageBuffer::Lex (std::vector<std::string> 
> > &result)
> >                   return EINVAL;
> >                 }
> >
> > -             if (c < S2C(u8" ") || c >= 0x7f)
> > +             if (c < S2C(u8" "))
> >                 goto malformed;
> >
> >               ++iter;
> > diff --git a/libcody/cody.hh b/libcody/cody.hh
> > index 93bce93aa94..7c852eb3aa1 100644
> > --- a/libcody/cody.hh
> > +++ b/libcody/cody.hh
> > @@ -49,14 +49,14 @@ namespace Detail  {
> >
> >  #if __cpp_char8_t >= 201811
> >  template<unsigned I>
> > -constexpr char S2C (char8_t const (&s)[I])
> > +constexpr unsigned char S2C (char8_t const (&s)[I])
> >  {
> >    static_assert (I == 2, "only single octet strings may be converted");
> >    return s[0];
> >  }
> >  #else
> >  template<unsigned I>
> > -constexpr char S2C (char const (&s)[I])
> > +constexpr unsigned char S2C (char const (&s)[I])
> >  {
> >    static_assert (I == 2, "only single octet strings may be converted");
> >    return s[0];
> > --
> > 2.53.0
> >

Reply via email to