Commit f5db79b
committed
c++/modules: Complain on imported GMF TU-local entities in instantiation [PR121574]
An unfortunate side effect of the previous patch is that even with
-pedantic-errors, unless the user specifies -Wtemplate-names-tu-local
when building the module interface there will be no diagnostic at all
from instantiating a template that exposes global TU-local entities,
either when building the module or its importer.
This patch solves this by recognising imported TU-local dependencies,
even if they weren't streamed as TU_LOCAL_ENTITY nodes. The warnings
here are deliberately conservative for when we can be sure this was
actually an imported TU-local entity; in particular, we bail on any
TU-local entity that originated from a header module, without attempting
to determine if the entity came via a named module first.
PR c++/121574
gcc/cp/ChangeLog:
* cp-tree.h (instantiating_tu_local_entity): Declare.
* module.cc (is_tu_local_entity): Extract from depset::hash.
(is_tu_local_value): Likewise.
(has_tu_local_tmpl_arg): Likewise.
(depset::hash::is_tu_local_entity): Remove.
(depset::hash::has_tu_local_tmpl_arg): Remove.
(depset::hash::is_tu_local_value): Remove.
(instantiating_tu_local_entity): New function.
(depset::hash::add_binding_entity): No longer go through
depset::hash to check is_tu_local_entity.
* pt.cc (complain_about_tu_local_entity): Remove.
(tsubst): Use instantiating_tu_local_entity.
(tsubst_expr): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/internal-17_b.C: Check for diagnostics when
instantiating imported TU-local entities.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>1 parent 99c2ed7 commit f5db79b
File tree
4 files changed
+84
-42
lines changed- gcc
- cp
- testsuite/g++.dg/modules
4 files changed
+84
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7745 | 7745 | | |
7746 | 7746 | | |
7747 | 7747 | | |
| 7748 | + | |
| 7749 | + | |
7748 | 7750 | | |
7749 | 7751 | | |
7750 | 7752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2663 | 2663 | | |
2664 | 2664 | | |
2665 | 2665 | | |
2666 | | - | |
2667 | | - | |
2668 | | - | |
2669 | | - | |
2670 | | - | |
2671 | 2666 | | |
2672 | 2667 | | |
2673 | 2668 | | |
| |||
13934 | 13929 | | |
13935 | 13930 | | |
13936 | 13931 | | |
| 13932 | + | |
| 13933 | + | |
| 13934 | + | |
| 13935 | + | |
13937 | 13936 | | |
13938 | 13937 | | |
13939 | 13938 | | |
13940 | | - | |
13941 | | - | |
| 13939 | + | |
| 13940 | + | |
13942 | 13941 | | |
13943 | 13942 | | |
13944 | 13943 | | |
| |||
14104 | 14103 | | |
14105 | 14104 | | |
14106 | 14105 | | |
14107 | | - | |
14108 | | - | |
| 14106 | + | |
| 14107 | + | |
14109 | 14108 | | |
14110 | 14109 | | |
14111 | 14110 | | |
| |||
14154 | 14153 | | |
14155 | 14154 | | |
14156 | 14155 | | |
14157 | | - | |
14158 | | - | |
| 14156 | + | |
| 14157 | + | |
14159 | 14158 | | |
14160 | 14159 | | |
14161 | 14160 | | |
| |||
14208 | 14207 | | |
14209 | 14208 | | |
14210 | 14209 | | |
| 14210 | + | |
| 14211 | + | |
| 14212 | + | |
| 14213 | + | |
| 14214 | + | |
| 14215 | + | |
| 14216 | + | |
| 14217 | + | |
| 14218 | + | |
| 14219 | + | |
| 14220 | + | |
| 14221 | + | |
| 14222 | + | |
| 14223 | + | |
| 14224 | + | |
| 14225 | + | |
| 14226 | + | |
| 14227 | + | |
| 14228 | + | |
| 14229 | + | |
| 14230 | + | |
| 14231 | + | |
| 14232 | + | |
| 14233 | + | |
| 14234 | + | |
| 14235 | + | |
| 14236 | + | |
| 14237 | + | |
| 14238 | + | |
| 14239 | + | |
| 14240 | + | |
| 14241 | + | |
| 14242 | + | |
| 14243 | + | |
| 14244 | + | |
| 14245 | + | |
| 14246 | + | |
| 14247 | + | |
| 14248 | + | |
| 14249 | + | |
| 14250 | + | |
| 14251 | + | |
| 14252 | + | |
| 14253 | + | |
| 14254 | + | |
| 14255 | + | |
| 14256 | + | |
| 14257 | + | |
| 14258 | + | |
| 14259 | + | |
| 14260 | + | |
| 14261 | + | |
| 14262 | + | |
| 14263 | + | |
| 14264 | + | |
| 14265 | + | |
| 14266 | + | |
14211 | 14267 | | |
14212 | 14268 | | |
14213 | 14269 | | |
| |||
14624 | 14680 | | |
14625 | 14681 | | |
14626 | 14682 | | |
14627 | | - | |
| 14683 | + | |
14628 | 14684 | | |
14629 | 14685 | | |
14630 | 14686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9941 | 9941 | | |
9942 | 9942 | | |
9943 | 9943 | | |
9944 | | - | |
9945 | | - | |
9946 | | - | |
9947 | | - | |
9948 | | - | |
9949 | | - | |
9950 | | - | |
9951 | | - | |
9952 | | - | |
9953 | | - | |
9954 | | - | |
9955 | 9944 | | |
9956 | 9945 | | |
9957 | 9946 | | |
| |||
16614 | 16603 | | |
16615 | 16604 | | |
16616 | 16605 | | |
16617 | | - | |
16618 | | - | |
16619 | | - | |
16620 | | - | |
16621 | | - | |
16622 | | - | |
| 16606 | + | |
| 16607 | + | |
| 16608 | + | |
16623 | 16609 | | |
16624 | 16610 | | |
16625 | 16611 | | |
| |||
20865 | 20851 | | |
20866 | 20852 | | |
20867 | 20853 | | |
| 20854 | + | |
| 20855 | + | |
| 20856 | + | |
20868 | 20857 | | |
20869 | 20858 | | |
20870 | 20859 | | |
| |||
22507 | 22496 | | |
22508 | 22497 | | |
22509 | 22498 | | |
22510 | | - | |
22511 | | - | |
22512 | | - | |
22513 | | - | |
22514 | | - | |
| 22499 | + | |
| 22500 | + | |
22515 | 22501 | | |
22516 | 22502 | | |
22517 | 22503 | | |
| |||
22791 | 22777 | | |
22792 | 22778 | | |
22793 | 22779 | | |
22794 | | - | |
22795 | | - | |
22796 | | - | |
22797 | | - | |
22798 | 22780 | | |
22799 | 22781 | | |
22800 | 22782 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
0 commit comments