]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/ipa-devirt.c
ipa-devirt: check precision mismatch of enum values [PR101396]
authorXi Ruoyao <xry111@mengyan1223.wang>
Sat, 10 Jul 2021 09:46:29 +0000 (17:46 +0800)
committerXi Ruoyao <xry111@mengyan1223.wang>
Fri, 30 Jul 2021 07:43:38 +0000 (15:43 +0800)
commit291416d3782e12e983483a3f7b2154a3dbfc9e1f
tree5c434a2b48ab252e5f65bcfeb7b1e028aa839353
parente41ba804ba5f5ca433e09238d561b1b4c8b10985
ipa-devirt: check precision mismatch of enum values [PR101396]

We are comparing enum values (in wide_int) to check ODR violation.
However, if we compare two wide_int values with different precision,
we'll trigger an assert, leading to ICE.  With enum-base introduced
in C++11, it's easy to sink into this situation.

To fix the issue, we need to explicitly check this kind of mismatch,
and emit a proper warning message if there is such one.

gcc/

PR ipa/101396
* ipa-devirt.c (ipa_odr_read_section): Compare the precision of
  enum values, and emit a warning if they mismatch.

gcc/testsuite/

PR ipa/101396
* g++.dg/lto/pr101396_0.C: New test.
* g++.dg/lto/pr101396_1.C: New test.
gcc/ipa-devirt.c
gcc/testsuite/g++.dg/lto/pr101396_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr101396_1.C [new file with mode: 0644]