]> 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>
Thu, 1 May 2025 03:38:01 +0000 (13:38 +1000)
commit3042862fbdba809473e3ea4ddc1697692b233d5f
tree91c9dae4171d1428629b2f26896f795852617d97
parent25db5966e9cc649deb85df4d89e6cad95f523f6d
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>
(cherry picked from commit 22ccaded63e96e5a42f4e3676dbbb57aa05b36f9)
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/internal-13.C [new file with mode: 0644]