diff options
author | Nathan Sidwell <nathan@acm.org> | 2021-03-01 05:41:10 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2021-03-01 05:57:53 -0800 |
commit | 2e0bb9eec2d455840bc4773391b3313a320b3c23 (patch) | |
tree | 5ab3d5239b505ddc775a421efbf05eee0b80e852 /gcc/cp/module.cc | |
parent | 150bde36c119eff4b8a74667c9d728d6a8a5e8a1 (diff) | |
download | gcc-2e0bb9eec2d455840bc4773391b3313a320b3c23.zip gcc-2e0bb9eec2d455840bc4773391b3313a320b3c23.tar.gz gcc-2e0bb9eec2d455840bc4773391b3313a320b3c23.tar.bz2 |
c++: Completeness of typedef structs [PR 99294]
When we read in a class definition, we use fixup_type_variants to
propagate the now-completed fields of the class's TYPE to other
variants. Unfortunately that doesn't propagate all of them, and in
this case we had a typedef to an (incomplete) instantiation. That
typedef ended up with a VOIDmode, which blew up gimple expansion as
the type itself isn't VOID. Without modules, that information is
propagated in finalize_type_size when laying out the class. But that
doesn't happen with stream-in -- we already know the layout. There is
already some overlap between the two functions, now there's a bit
more. In fixup_type_variants, I pay attention to the TYPE_NAME to
decide whether to override a user's TYPE_ALIGN -- variants of the
main-variant typedef just copy the main-variant. Other variants
recalculate. Overaligning is still permitted.
I also added a TYPE_ALIGN_RAW accessor, and fixed a bug in the
alignment streaming I noticed. I did not refactor TYPE_ALIGN beyond
using the new accessor. (It could be written as ((1 << align_raw) >>
1), rather than use the conditional.)
PR c++/99294
gcc/
* tree.h (TYPE_ALIGN_RAW): New accessor.
(TYPE_ALIGN): Use it.
gcc/cp/
* class.c (fixup_type_variants): Propagate mode, precision,
alignment & emptiness.
* module.cc (trees_out::type_node): Use TYPE_ALIGN_RAW.
(trees_in::tree_node): Rematerialize alignment here.
gcc/testsuite/
* g++.dg/modules/pr99294.h: New.
* g++.dg/modules/pr99294_a.C: New.
* g++.dg/modules/pr99294_b.C: New.
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r-- | gcc/cp/module.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 0cb5bd9..369a026 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -8714,7 +8714,7 @@ trees_out::type_node (tree type) else { if (TYPE_USER_ALIGN (type)) - flags = exact_log2 (TYPE_ALIGN (type)); + flags = TYPE_ALIGN_RAW (type); } if (streaming_p ()) @@ -9510,7 +9510,7 @@ trees_in::tree_node (bool is_use) } else { - res = build_aligned_type (res, 1u << flags); + res = build_aligned_type (res, (1u << flags) >> 1); TYPE_USER_ALIGN (res) = true; } |