diff options
author | Alexandre Oliva <oliva@adacore.com> | 2023-11-30 03:40:51 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-11-30 03:40:51 -0300 |
commit | 792936a0669c00982d4325e0113903a75b71a9c7 (patch) | |
tree | fd2fbec80d870c141e79a275d39bc3afadc2c65b /gcc | |
parent | 8315f9986592803bbce32f37d8f197a8c945e4c5 (diff) | |
download | gcc-792936a0669c00982d4325e0113903a75b71a9c7.zip gcc-792936a0669c00982d4325e0113903a75b71a9c7.tar.gz gcc-792936a0669c00982d4325e0113903a75b71a9c7.tar.bz2 |
c++: mark short-enums as packed
Unlike C, C++ doesn't mark enums shortened by -fshort-enums as packed.
This makes for undesirable warning differences between C and C++,
e.g. c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early*.c
triggers a warning about a type cast from a pointer to enum that, when
packed, might not be sufficiently aligned.
This change is not enough for that warning to trigger. The tree
expression generated by the C++ front-end is also a little too
complicated for us get to the base pointer. A separate patch takes
care of that.
for gcc/cp/ChangeLog
* decl.cc (finish_enum_value_list): Set TYPE_PACKED if
use_short_enum, and propagate it to variants.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/decl.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index bce8068..2f2dbb8 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -16913,6 +16913,12 @@ finish_enum_value_list (tree enumtype) /* If -fstrict-enums, still constrain TYPE_MIN/MAX_VALUE. */ if (flag_strict_enums) set_min_and_max_values_for_integral_type (enumtype, precision, sgn); + + if (use_short_enum) + { + TYPE_PACKED (enumtype) = use_short_enum; + fixup_attribute_variants (enumtype); + } } else underlying_type = ENUM_UNDERLYING_TYPE (enumtype); |