-
- Downloads
c++ modules: enum TYPE_MIN/MAX_VALUE streaming [PR106848]
In the frontend, the TYPE_MIN/MAX_VALUE of ENUMERAL_TYPE is the same as that of the enum's underlying type (see start_enum). And the underlying type of an enum is always known, even for an opaque enum that lacks a definition. But currently, we stream TYPE_MIN/MAX_VALUE of an enum only as part of its definition. So if the enum is declared but never defined, the ENUMERAL_TYPE we stream in will have empty TYPE_MIN/MAX_VALUE fields despite these fields being non-empty on stream out. And even if the enum is defined, read_enum_def updates these fields only on the main variant of the enum type, so for other variants (that we may have streamed in earlier) these fields remain empty. That these fields are unexpectedly empty for some ENUMERAL_TYPEs is ultimately the cause of the below two PRs. This patch fixes this by making us stream TYPE_MIN/MAX_VALUE directly for each ENUMERAL_TYPE rather than as part of the enum's definition, so that we naturally also stream these fields for opaque enums (and each enum type variant). PR c++/106848 PR c++/102600 gcc/cp/ChangeLog: * module.cc (trees_out::core_vals): Stream TYPE_MAX_VALUE and TYPE_MIN_VALUE of ENUMERAL_TYPE. (trees_in::core_vals): Likewise. (trees_out::write_enum_def): Don't stream them here. (trees_in::read_enum_def): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/enum-9_a.H: New test. * g++.dg/modules/enum-9_b.C: New test. * g++.dg/modules/enum-10_a.H: New test. * g++.dg/modules/enum-10_b.C: New test. * g++.dg/modules/enum-11_a.H: New test. * g++.dg/modules/enum-11_b.C: New test.
Showing
- gcc/cp/module.cc 24 additions, 15 deletionsgcc/cp/module.cc
- gcc/testsuite/g++.dg/modules/enum-10_a.H 5 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-10_a.H
- gcc/testsuite/g++.dg/modules/enum-10_b.C 6 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-10_b.C
- gcc/testsuite/g++.dg/modules/enum-11_a.H 5 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-11_a.H
- gcc/testsuite/g++.dg/modules/enum-11_b.C 8 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-11_b.C
- gcc/testsuite/g++.dg/modules/enum-9_a.H 13 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-9_a.H
- gcc/testsuite/g++.dg/modules/enum-9_b.C 6 additions, 0 deletionsgcc/testsuite/g++.dg/modules/enum-9_b.C
Loading
Please register or sign in to comment