aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-10-08 18:26:40 -0400
committerJason Merrill <jason@redhat.com>2024-10-14 18:42:18 -0400
commit2c08ddd3fdd4af794ce66dbabb81ba2e6aee0b7c (patch)
tree1d6737fe20e8a1c8b27c5cf22c729219696a8790 /gcc
parentdde19c600c3c8a1d765c9b4961d2556e89edad14 (diff)
downloadgcc-2c08ddd3fdd4af794ce66dbabb81ba2e6aee0b7c.zip
gcc-2c08ddd3fdd4af794ce66dbabb81ba2e6aee0b7c.tar.gz
gcc-2c08ddd3fdd4af794ce66dbabb81ba2e6aee0b7c.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/modules/cpp-2_c.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/cpp-5_c.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/dep-2.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/dir-only-2_b.C10
-rw-r--r--gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H2
-rw-r--r--gcc/testsuite/g++.dg/modules/legacy-3_b.H2
-rw-r--r--gcc/testsuite/g++.dg/modules/legacy-3_c.H2
-rw-r--r--gcc/testsuite/g++.dg/modules/pr99050_b.C2
8 files changed, 12 insertions, 12 deletions
diff --git a/gcc/testsuite/g++.dg/modules/cpp-2_c.C b/gcc/testsuite/g++.dg/modules/cpp-2_c.C
index c6e02b7..2a79031 100644
--- a/gcc/testsuite/g++.dg/modules/cpp-2_c.C
+++ b/gcc/testsuite/g++.dg/modules/cpp-2_c.C
@@ -11,7 +11,7 @@ import nope;
#endif
think
-// { dg-final { scan-file cpp-2_c.i {cpp-2_c.C"\n\n\n\nmodule bob;\n#pragma GCC unused\nimport "[^\n]*\./cpp-2_b.H" \[\[ CLOSE ]];\nimport "[^\n]*cpp-2_a.H" \[\[ ]];\n} } }
+// { dg-final { scan-file cpp-2_c.i {cpp-2_c.C"\n\n\n\nmodule bob;\n#pragma GCC unused\nimport "[^\n]*\./cpp-2_b.H" \[\[ CLOSE ]];\nimport "[^\n]*cpp-2_a.H" \[\[ ]];\n} } }
// { dg-final { scan-file cpp-2_c.i "int i;" } }
// { dg-final { scan-file-not cpp-2_c.i "import *nope;" } }
// { dg-final { scan-file cpp-2_c.i "THIS IS STDIO\n" } }
diff --git a/gcc/testsuite/g++.dg/modules/cpp-5_c.C b/gcc/testsuite/g++.dg/modules/cpp-5_c.C
index e0a78a5..7f75a22 100644
--- a/gcc/testsuite/g++.dg/modules/cpp-5_c.C
+++ b/gcc/testsuite/g++.dg/modules/cpp-5_c.C
@@ -7,4 +7,4 @@ import "cpp-5_a.H";
Q
-// { dg-final { scan-file cpp-5_c.i {\nimport "[^\n]*cpp-5_a.H";\n\n0\n} } }
+// { dg-final { scan-file cpp-5_c.i {\nimport "[^\n]*cpp-5_a.H";\n\n0\n} } }
diff --git a/gcc/testsuite/g++.dg/modules/dep-2.C b/gcc/testsuite/g++.dg/modules/dep-2.C
index 2dccab3..3c86975 100644
--- a/gcc/testsuite/g++.dg/modules/dep-2.C
+++ b/gcc/testsuite/g++.dg/modules/dep-2.C
@@ -9,4 +9,4 @@ module m:part;
// { dg-final { scan-file dep-2.d {\ngcm.cache/m:part\.gcm:| dep-2\.o} } }
// { dg-final { scan-file dep-2.d {\n\.PHONY: m:part\.c\+\+-module} } }
-// { dg-final { scan-file dep-2.i {\nmodule m:part;\n} } }
+// { dg-final { scan-file dep-2.i {\nmodule m:part;\n} } }
diff --git a/gcc/testsuite/g++.dg/modules/dir-only-2_b.C b/gcc/testsuite/g++.dg/modules/dir-only-2_b.C
index 1009ae5..b1ef9b9 100644
--- a/gcc/testsuite/g++.dg/modules/dir-only-2_b.C
+++ b/gcc/testsuite/g++.dg/modules/dir-only-2_b.C
@@ -21,8 +21,8 @@ export module bob;
export import q;
-// { dg-final { scan-file dir-only-2_b.i {// a comment\nmodule ;\nfrob} } }
-// { dg-final { scan-file dir-only-2_b.i {frob\nexport\nimport foo;\nimport 7;} } }
-// { dg-final { scan-file dir-only-2_b.i {import "[^\n]*/dir-only-2_a.H";\nimport "[^\n]*/dir-only-2_a.H";\nX} } }
-// { dg-final { scan-file dir-only-2_b.i {export module bob;\n\nexport import q;} } }
-// { dg-final { scan-file dir-only-2_b.i {import sing;\n\n\n// comment} } }
+// { dg-final { scan-file dir-only-2_b.i {// a comment\nmodule;\nfrob} } }
+// { dg-final { scan-file dir-only-2_b.i {frob\nexport\nimport foo;\nimport 7;} } }
+// { dg-final { scan-file dir-only-2_b.i {import "[^\n]*/dir-only-2_a.H";\nimport "[^\n]*/dir-only-2_a.H";\nX} } }
+// { dg-final { scan-file dir-only-2_b.i {export module bob;\n\nexport import q;} } }
+// { dg-final { scan-file dir-only-2_b.i {import sing;\n\n\n// comment} } }
diff --git a/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H b/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H
index 50b27ef..872ebf3 100644
--- a/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H
+++ b/gcc/testsuite/g++.dg/modules/inc-xlate-1_b.H
@@ -18,4 +18,4 @@ extern "C" {
#endif
#endif
-// { dg-final { scan-file inc-xlate-1_b.i {import "[^\n]*inc-xlate-1_a.H" \[\[__translated\]\];\n} } }
+// { dg-final { scan-file inc-xlate-1_b.i {import "[^\n]*inc-xlate-1_a.H" \[\[__translated\]\];\n} } }
diff --git a/gcc/testsuite/g++.dg/modules/legacy-3_b.H b/gcc/testsuite/g++.dg/modules/legacy-3_b.H
index 3bf819d..47ed31c 100644
--- a/gcc/testsuite/g++.dg/modules/legacy-3_b.H
+++ b/gcc/testsuite/g++.dg/modules/legacy-3_b.H
@@ -12,5 +12,5 @@ int move (int X = __LINE__); // Capture __LINE__ in a non-definition
// this should not be diverted
#include "legacy-3.h"
-// { dg-final { scan-file legacy-3_b.i {\n# 9 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 10\);\n} } }
+// { dg-final { scan-file legacy-3_b.i {\n# 9 "[^\n]*legacy-3_b.H"\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nint move \(int X = 10\);\n} } }
diff --git a/gcc/testsuite/g++.dg/modules/legacy-3_c.H b/gcc/testsuite/g++.dg/modules/legacy-3_c.H
index 56b8172..63c9bcf 100644
--- a/gcc/testsuite/g++.dg/modules/legacy-3_c.H
+++ b/gcc/testsuite/g++.dg/modules/legacy-3_c.H
@@ -17,7 +17,7 @@ MARK3 __LINE__
// this should not be translated
#include "legacy-3.h"
-// { dg-final { scan-file legacy-3_c.i {MARK1 8\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nMARK2 10\n} } }
+// { dg-final { scan-file legacy-3_c.i {MARK1 8\nimport "[^\n]*legacy-3_a.H" \[\[__translated\]\];\nMARK2 10\n} } }
// We should have stopped.
// { dg-final { scan-file legacy-3_c.i {move} } }
// { dg-final { scan-file legacy-3_c.i {MARK2 13\n\nMARK3 15\n} } }
diff --git a/gcc/testsuite/g++.dg/modules/pr99050_b.C b/gcc/testsuite/g++.dg/modules/pr99050_b.C
index 439e216..f2c9563 100644
--- a/gcc/testsuite/g++.dg/modules/pr99050_b.C
+++ b/gcc/testsuite/g++.dg/modules/pr99050_b.C
@@ -4,4 +4,4 @@
int main () {}
-// { dg-final { scan-file pr99050_b.i {import "[^\n]*99050_a.H" \[\[__translated\]\];\n} } }
+// { dg-final { scan-file pr99050_b.i {import "[^\n]*99050_a.H" \[\[__translated\]\];\n} } }