aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/lang-specs.h6
-rw-r--r--gcc/doc/invoke.texi20
-rw-r--r--gcc/testsuite/g++.dg/modules/dep-1_a.C4
-rw-r--r--gcc/testsuite/g++.dg/modules/dep-1_b.C8
-rw-r--r--gcc/testsuite/g++.dg/modules/dep-2.C4
-rw-r--r--libcpp/mkdeps.cc13
6 files changed, 30 insertions, 25 deletions
diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h
index 7a7f5ff..e565156 100644
--- a/gcc/cp/lang-specs.h
+++ b/gcc/cp/lang-specs.h
@@ -39,6 +39,12 @@ along with GCC; see the file COPYING3. If not see
{".HPP", "@c++-header", 0, 0, 0},
{".tcc", "@c++-header", 0, 0, 0},
{".hh", "@c++-header", 0, 0, 0},
+ /* Module interface unit. Should there also be a .C counterpart? */
+ {".ixx", "@c++", 0, 0, 0}, /* MSVC */
+ {".cppm", "@c++", 0, 0, 0}, /* Clang/libc++ */
+ {".cxxm", "@c++", 0, 0, 0},
+ {".c++m", "@c++", 0, 0, 0},
+ {".ccm", "@c++", 0, 0, 0},
{"@c++-header",
"%{E|M|MM:cc1plus -E %{fmodules-ts:-fdirectives-only -fmodule-header}"
" %(cpp_options) %2 %(cpp_debug_options)}"
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2cba380..517a782 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2317,9 +2317,12 @@ other language.
C++ source files conventionally use one of the suffixes @samp{.C},
@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
-@samp{.H}, or (for shared template code) @samp{.tcc}; and
-preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
-files with these names and compiles them as C++ programs even if you
+@samp{.H}, or (for shared template code) @samp{.tcc};
+preprocessed C++ files use the suffix @samp{.ii}; and C++20 module interface
+units sometimes use @samp{.ixx}, @samp{.cppm}, @samp{.cxxm}, @samp{.c++m},
+or @samp{.ccm}.
+
+GCC recognizes files with these names and compiles them as C++ programs even if you
call the compiler the same way as for compiling C programs (usually
with the name @command{gcc}).
@@ -37705,13 +37708,10 @@ Modular compilation is @emph{not} enabled with just the
version selected, although in pre-C++20 versions, it is of course an
extension.
-No new source file suffixes are required or supported. If you wish to
-use a non-standard suffix (@pxref{Overall Options}), you also need
-to provide a @option{-x c++} option too.@footnote{Some users like to
-distinguish module interface files with a new suffix, such as naming
-the source @code{module.cppm}, which involves
-teaching all tools about the new suffix. A different scheme, such as
-naming @code{module-m.cpp} would be less invasive.}
+No new source file suffixes are required. A few suffixes preferred
+for module interface units by other compilers (e.g. @samp{.ixx},
+@samp{.cppm}) are supported, but files with these suffixes are treated
+the same as any other C++ source file.
Compiling a module interface unit produces an additional output (to
the assembly or object file), called a Compiled Module Interface
diff --git a/gcc/testsuite/g++.dg/modules/dep-1_a.C b/gcc/testsuite/g++.dg/modules/dep-1_a.C
index 5ec5dd3..3e92eea 100644
--- a/gcc/testsuite/g++.dg/modules/dep-1_a.C
+++ b/gcc/testsuite/g++.dg/modules/dep-1_a.C
@@ -4,6 +4,6 @@ export module m:part;
// { dg-module-cmi m:part }
// All The Backslashes!
-// { dg-final { scan-file dep-1_a.d {\nm:part\.c\+\+m: gcm.cache/m-part\.gcm} } }
+// { dg-final { scan-file dep-1_a.d {\nm:part\.c\+\+-module: gcm.cache/m-part\.gcm} } }
// { dg-final { scan-file dep-1_a.d {\ngcm.cache/m-part\.gcm:| dep-1_a\.o} } }
-// { dg-final { scan-file dep-1_a.d {\n\.PHONY: m:part\.c\+\+m} } }
+// { dg-final { scan-file dep-1_a.d {\n\.PHONY: m:part\.c\+\+-module} } }
diff --git a/gcc/testsuite/g++.dg/modules/dep-1_b.C b/gcc/testsuite/g++.dg/modules/dep-1_b.C
index 7a0794e..265ebfc 100644
--- a/gcc/testsuite/g++.dg/modules/dep-1_b.C
+++ b/gcc/testsuite/g++.dg/modules/dep-1_b.C
@@ -3,8 +3,8 @@ export module m;
// { dg-module-cmi m }
export import :part;
-// { dg-final { scan-file dep-1_b.d {\ndep-1_b\.s gcm.cache/m\.gcm: m:part\.c\+\+m} } }
-// { dg-final { scan-file dep-1_b.d {\nm\.c\+\+m: gcm.cache/m\.gcm} } }
-// { dg-final { scan-file dep-1_b.d {\n\.PHONY: m\.c\+\+m} } }
+// { dg-final { scan-file dep-1_b.d {\ndep-1_b\.s gcm.cache/m\.gcm: m:part\.c\+\+-module} } }
+// { dg-final { scan-file dep-1_b.d {\nm\.c\+\+-module: gcm.cache/m\.gcm} } }
+// { dg-final { scan-file dep-1_b.d {\n\.PHONY: m\.c\+\+-module} } }
// { dg-final { scan-file dep-1_b.d {\ngcm.cache/m\.gcm:| dep-1_b.o} } }
-// { dg-final { scan-file dep-1_b.d {\nCXX_IMPORTS \+= m:part\.c\+\+m} } }
+// { dg-final { scan-file dep-1_b.d {\nCXX_IMPORTS \+= m:part\.c\+\+-module} } }
diff --git a/gcc/testsuite/g++.dg/modules/dep-2.C b/gcc/testsuite/g++.dg/modules/dep-2.C
index 0962430..2dccab3 100644
--- a/gcc/testsuite/g++.dg/modules/dep-2.C
+++ b/gcc/testsuite/g++.dg/modules/dep-2.C
@@ -5,8 +5,8 @@ module m:part;
// { dg-module-cmi !m:part }
// All The Backslashes!
-// { dg-final { scan-file dep-2.d {\nm:part\.c\+\+m: gcm.cache/m-part\.gcm} } }
+// { dg-final { scan-file dep-2.d {\nm:part\.c\+\+-module: gcm.cache/m-part\.gcm} } }
// { 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\+\+m} } }
+// { dg-final { scan-file dep-2.d {\n\.PHONY: m:part\.c\+\+-module} } }
// { dg-final { scan-file dep-2.i {\nmodule m:part;\n} } }
diff --git a/libcpp/mkdeps.cc b/libcpp/mkdeps.cc
index 4cf0cf0..622d0dc 100644
--- a/libcpp/mkdeps.cc
+++ b/libcpp/mkdeps.cc
@@ -411,8 +411,7 @@ make_write_vec (const mkdeps::vec<const char *> &vec, FILE *fp,
return col;
}
-/* Write the dependencies to a Makefile. If PHONY is true, add
- .PHONY targets for all the dependencies too. */
+/* Write the dependencies to a Makefile. */
static void
make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
@@ -453,7 +452,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
column = make_write_name (d->cmi_name, fp, column, colmax);
fputs (":", fp);
column++;
- column = make_write_vec (d->modules, fp, column, colmax, 0, ".c++m");
+ column = make_write_vec (d->modules, fp, column, colmax, 0, ".c++-module");
fputs ("\n", fp);
}
@@ -463,7 +462,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
{
/* module-name : cmi-name */
column = make_write_name (d->module_name, fp, 0, colmax,
- true, ".c++m");
+ true, ".c++-module");
fputs (":", fp);
column++;
column = make_write_name (d->cmi_name, fp, column, colmax);
@@ -471,7 +470,7 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
column = fprintf (fp, ".PHONY:");
column = make_write_name (d->module_name, fp, column, colmax,
- true, ".c++m");
+ true, ".c++-module");
fputs ("\n", fp);
}
@@ -488,11 +487,11 @@ make_write (const cpp_reader *pfile, FILE *fp, unsigned int colmax)
fputs ("\n", fp);
}
}
-
+
if (d->modules.size ())
{
column = fprintf (fp, "CXX_IMPORTS +=");
- make_write_vec (d->modules, fp, column, colmax, 0, ".c++m");
+ make_write_vec (d->modules, fp, column, colmax, 0, ".c++-module");
fputs ("\n", fp);
}
}