]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Check module attachment instead of just purview when necessary [PR112631]
authorNathaniel Shead <nathanieloshead@gmail.com>
Tue, 12 Mar 2024 12:24:27 +0000 (23:24 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 16 Mar 2024 11:18:19 +0000 (22:18 +1100)
commitead3075406ece9daaad65a01ae539150aee43f5a
tree08fbd5f63ae2356d4629bd54da890e309b3cc353
parent5213047b1d50af63dfabb5e5649821a6cb157e33
c++: Check module attachment instead of just purview when necessary [PR112631]

Block-scope declarations of functions or extern values are not allowed
when attached to a named module. Similarly, class member functions are
not inline if attached to a named module. However, in both these cases
we currently only check if the declaration is within the module purview;
it is possible for such a declaration to occur within the module purview
but not be attached to a named module (e.g. in an 'extern "C++"' block).
This patch makes the required adjustments.

PR c++/112631

gcc/cp/ChangeLog:

* cp-tree.h (named_module_attach_p): New function.
* decl.cc (start_decl): Check for attachment not purview.
(grokmethod): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/block-decl-1_a.C: New test.
* g++.dg/modules/block-decl-1_b.C: New test.
* g++.dg/modules/block-decl-2.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/testsuite/g++.dg/modules/block-decl-1_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/block-decl-1_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/block-decl-2.C [new file with mode: 0644]