]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Track all static class variables [PR122421]
authorNathaniel Shead <nathanieloshead@gmail.com>
Sun, 26 Oct 2025 11:27:33 +0000 (22:27 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sun, 2 Nov 2025 13:45:19 +0000 (00:45 +1100)
commitfd5c057c2d01346d69119f88ca94debf27842e4e
tree1ed7192e2e6354446fe2f232ef0bf65683bdaf24
parentad8de026441c3e57c4761b1c595ace92ed21c254
c++/modules: Track all static class variables [PR122421]

The linker error in the PR is caused because when a static is defined
out of the class body, it doesn't yet have a definition and so
read_var_def (which would otherwise have noted it) never gets called.

This instead moves the responsibility for noting class-scope variables
to read_class_def.

PR c++/122421

gcc/cp/ChangeLog:

* module.cc (trees_in::read_var_def): Don't handle class-scope
variables anymore.
(trees_in::read_class_def): Handle them here instead.

gcc/testsuite/ChangeLog:

* g++.dg/modules/inst-6_a.C: New test.
* g++.dg/modules/inst-6_b.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/inst-6_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/inst-6_b.C [new file with mode: 0644]