]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Catch exposures of TU-local values through inline references [PR119996]
authorNathaniel Shead <nathanieloshead@gmail.com>
Tue, 29 Apr 2025 07:31:55 +0000 (17:31 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 30 Apr 2025 23:50:20 +0000 (09:50 +1000)
commit22ccaded63e96e5a42f4e3676dbbb57aa05b36f9
treebe5968436bbd57075b1bc594a34888bacd4ea22e
parent299d48ff4a34c00a6ef964b694fb9b1312683049
c++/modules: Catch exposures of TU-local values through inline references [PR119996]

In r15-9136-g0210bedf481a9f we started erroring for inline variables
that exposed TU-local entities in their definition, as such variables
would need to have their definitions emitted in importers but would not
know about the TU-local entities they referenced.

A case we mised was potentially-constant references, which disable
streaming of their definitions in make_dependency so as to comply with
[expr.const] p9.2.  This meant that we didn't see the definition
referencing a TU-local entity, leading to nonsensical results.

PR c++/119551
PR c++/119996

gcc/cp/ChangeLog:

* module.cc (depset::hash::make_dependency): Also mark inline
variables referencing TU-local values as exposures here.
(depset::hash::finalize_dependencies): Add error message for
inline variables.

gcc/testsuite/ChangeLog:

* g++.dg/modules/internal-13.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/internal-13.C [new file with mode: 0644]