mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libcpp: avoid extra spaces in module preprocessing
Within the compiler, module keywords "import", "module", and "export" that are recognized as part of module directives gain an extra trailing space to distinguish them from other non-keyword uses of those words in the code. But when dumping preprocessed output, printing those spaces creates a gratuitous inconsistency with non-modules preprocessing, as revealed by several of the g++.dg/modules/cpp* tests if modules are enabled by default in C++20 mode. libcpp/ChangeLog: * lex.cc (cpp_output_token): Omit terminal space from name. gcc/testsuite/ChangeLog: * g++.dg/modules/cpp-2_c.C: Expect only one space after import. * g++.dg/modules/cpp-5_c.C * g++.dg/modules/dep-2.C * g++.dg/modules/dir-only-2_b.C * g++.dg/modules/pr99050_b.C * g++.dg/modules/inc-xlate-1_b.H * g++.dg/modules/legacy-3_b.H * g++.dg/modules/legacy-3_c.H: Likewise.
This commit is contained in:
@@ -4411,14 +4411,17 @@ cpp_output_token (const cpp_token *token, FILE *fp)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned char * name = NODE_NAME (token->val.node.node);
|
||||
|
||||
for (i = 0; i < NODE_LEN (token->val.node.node); i++)
|
||||
unsigned len = NODE_LEN (token->val.node.node);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (name[i] & ~0x7F)
|
||||
{
|
||||
unsigned char buffer[10];
|
||||
i += utf8_to_ucn (buffer, name + i) - 1;
|
||||
fwrite (buffer, 1, 10, fp);
|
||||
}
|
||||
else if (name[i] == ' ' && i == len - 1)
|
||||
/* Omit terminal space in "export ". */;
|
||||
else
|
||||
fputc (NODE_NAME (token->val.node.node)[i], fp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user