]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: modules don't require preprocessor output
authorJason Merrill <jason@redhat.com>
Fri, 4 Oct 2024 14:33:16 +0000 (10:33 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 7 Oct 2024 15:52:41 +0000 (11:52 -0400)
commitc877a27f04f648e53c27daa252ca46d47e49b3a1
tree3e178d36d781722b0072d5fd7ee29543a5a00660
parent5fb1ab539e3315175d2e843f4ce40bde6dd7c520
c++: modules don't require preprocessor output

init_modules has rejected -M -fmodules-ts on the premise that module
dependency analysis requires macro expansion, but this is no longer
accurate; P1857 prohibited module directives produced by macro expansion.
They can still be dependent on #if directives, but those are still handled
with -fdirectives-only.

What wasn't working was -M or -dM, because cpp_scan_nooutput never called
module_token_pre to implement the import.  The simplest fix is to use the
-fdirectives-only scan when modules are enabled and teach directives_only_cb
about flag_no_output.

gcc/cp/ChangeLog:

* module.cc (init_modules): Don't warn about -M.

gcc/c-family/ChangeLog:

* c-ppoutput.cc (preprocess_file): For modules,
use directives-only scan even with flag_no_output.
(directives_only_cb): Respect flag_no_output.

gcc/ChangeLog:

* doc/invoke.texi (C++ Module Preprocessing): Allow -M,
refer to -fdeps.

gcc/testsuite/ChangeLog:

* g++.dg/modules/macro-8_a.H: New test.
* g++.dg/modules/macro-8_b.C: New test.
* g++.dg/modules/macro-8_c.C: New test.
* g++.dg/modules/macro-8_d.C: New test.
gcc/c-family/c-ppoutput.cc
gcc/cp/module.cc
gcc/doc/invoke.texi
gcc/testsuite/g++.dg/modules/macro-8_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/macro-8_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/macro-8_c.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/macro-8_d.C [new file with mode: 0644]