Go to file
David Malcolm fa92642b26 analyzer: bitfield fixes [PR99212]
This patch verifies the previous fix for bitfield sizes by implementing
enough support for bitfields in the analyzer to get the test cases to pass.

The patch implements support in the analyzer for reading from a
BIT_FIELD_REF, and support for folding BIT_AND_EXPR of a mask, to handle
the cases generated in tests.

The existing bitfields tests in data-model-1.c turned out to rely on
undefined behavior, in that they were assigning values to a signed
bitfield that were outside of the valid range of values.  I believe that
that's why we were seeing target-specific differences in the test
results (PR analyzer/99212).  The patch updates the test to remove the
undefined behaviors.

gcc/analyzer/ChangeLog:
	PR analyzer/99212
	* region-model-manager.cc
	(region_model_manager::maybe_fold_binop): Add support for folding
	BIT_AND_EXPR of compound_svalue and a mask constant.
	* region-model.cc (region_model::get_rvalue_1): Implement
	BIT_FIELD_REF in terms of...
	(region_model::get_rvalue_for_bits): New function.
	* region-model.h (region_model::get_rvalue_for_bits): New decl.
	* store.cc (bit_range::from_mask): New function.
	(selftest::test_bit_range_intersects_p): New selftest.
	(selftest::assert_bit_range_from_mask_eq): New.
	(ASSERT_BIT_RANGE_FROM_MASK_EQ): New macro.
	(selftest::assert_no_bit_range_from_mask_eq): New.
	(ASSERT_NO_BIT_RANGE_FROM_MASK): New macro.
	(selftest::test_bit_range_from_mask): New selftest.
	(selftest::analyzer_store_cc_tests): Call the new selftests.
	* store.h (bit_range::intersects_p): New.
	(bit_range::from_mask): New decl.
	(concrete_binding::get_bit_range): New accessor.
	(store_manager::get_concrete_binding): New overload taking
	const bit_range &.

gcc/testsuite/ChangeLog:
	PR analyzer/99212
	* gcc.dg/analyzer/bitfields-1.c: New test.
	* gcc.dg/analyzer/data-model-1.c (struct sbits): Make bitfields
	explicitly signed.
	(test_44): Update test values assigned to the bits to ones that
	fit in the range of the bitfield type.  Remove xfails.
	(test_45): Remove xfails.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2021-07-02 15:19:45 -04:00
c++tools Daily bump. 2021-06-01 00:18:21 +00:00
config Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
contrib Daily bump. 2021-06-24 00:18:21 +00:00
fixincludes Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
gcc analyzer: bitfield fixes [PR99212] 2021-07-02 15:19:45 -04:00
gnattools Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
gotools Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
include Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
INSTALL
intl Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libada Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libatomic Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libbacktrace Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libcc1 Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libcody Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libcpp Daily bump. 2021-06-17 00:18:41 +00:00
libdecnumber Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libffi Daily bump. 2021-06-18 00:18:48 +00:00
libgcc Daily bump. 2021-06-30 00:18:23 +00:00
libgfortran Daily bump. 2021-06-25 00:18:34 +00:00
libgo libgo: update to Go1.16.5 release 2021-06-10 14:42:37 -07:00
libgomp Daily bump. 2021-06-24 00:18:21 +00:00
libhsail-rt Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libiberty Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libitm Daily bump. 2021-06-19 00:18:23 +00:00
libobjc Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
liboffloadmic Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libphobos Daily bump. 2021-06-12 00:18:14 +00:00
libquadmath Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libsanitizer Daily bump. 2021-05-22 00:18:07 +00:00
libssp Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
libstdc++-v3 Daily bump. 2021-06-23 00:18:00 +00:00
libvtv Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
lto-plugin Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
maintainer-scripts Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
zlib Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Update ChangeLog and version files for release 2021-04-27 09:23:56 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.