Go to file
Jason Merrill a37e8ce3b6 c++: layout of aggregate base with DMI [PR103681]
C++14 changed the definition of 'aggregate' to allow default member
initializers, but such classes still need to be considered "non-POD for the
purpose of layout" for ABI compatibility with C++11 code.  It seems rare to
derive from such a class, as evidenced by how long this bug has
survived (since r216750 in 2014), but it's certainly worth fixing.

We only warn when we were failing to allocate another field into the
tail padding of the newly aggregate class; this is the only ABI impact.

This also changes end_of_class to consider all data members, not just empty
data members; that used to be an additional flag, removed in r9-5710, but I
don't see any reason not to always include them.  This makes the result of
the function correspond to the ABI nvsize term and its nameless counterpart
that does include virtual bases.

When looking closely at other users of end_of_class, I realized that we were
assuming that the latter corresponded to the ABI dsize term, but it doesn't
if the class ends with an empty virtual base (in the rare case that the
empty base can't be assigned offset 0), and this matters for layout of
[[no_unique_address]].  So I added another mode that returns the desired
value for that case.  I'm not adding a warning for this ABI fix because it's
a C++20 feature.

	PR c++/103681

gcc/ChangeLog:

	* common.opt (fabi-version): Add v17.

gcc/cp/ChangeLog:

	* cp-tree.h (struct lang_type): Add non_pod_aggregate.
	(CLASSTYPE_NON_POD_AGGREGATE): New.
	* class.c (check_field_decls): Set it.
	(check_bases_and_members): Check it.
	(check_non_pod_aggregate): New.
	(enum eoc_mode): New.
	(end_of_class): Always include non-empty fields.
	Add eoc_nv_or_dsize mode.
	(include_empty_classes, layout_class_type): Adjust.

gcc/c-family/ChangeLog:

	* c-opts.c (c_common_post_options): Update defaults.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/macro0.C: Update value.
	* g++.dg/abi/no_unique_address6.C: New test.
	* g++.dg/abi/nsdmi-aggr1.C: New test.
	* g++.dg/abi/nsdmi-aggr1a.C: New test.
2021-12-16 22:27:10 -05:00
c++tools
config Daily bump. 2021-12-17 00:16:20 +00:00
contrib Daily bump. 2021-12-17 00:16:20 +00:00
fixincludes Daily bump. 2021-11-24 00:16:29 +00:00
gcc c++: layout of aggregate base with DMI [PR103681] 2021-12-16 22:27:10 -05:00
gnattools
gotools
include Daily bump. 2021-12-13 00:16:28 +00:00
INSTALL
intl Daily bump. 2021-11-30 00:16:44 +00:00
libada
libatomic
libbacktrace Daily bump. 2021-11-13 00:16:39 +00:00
libcc1 Daily bump. 2021-12-17 00:16:20 +00:00
libcody
libcpp Daily bump. 2021-12-05 00:16:28 +00:00
libdecnumber
libffi Daily bump. 2021-11-16 00:16:31 +00:00
libgcc Daily bump. 2021-12-14 00:16:25 +00:00
libgfortran Daily bump. 2021-12-17 00:16:20 +00:00
libgo
libgomp Daily bump. 2021-12-14 00:16:25 +00:00
libiberty Daily bump. 2021-12-17 00:16:20 +00:00
libitm Daily bump. 2021-11-27 00:16:19 +00:00
libobjc
liboffloadmic
libphobos Daily bump. 2021-12-16 00:16:28 +00:00
libquadmath
libsanitizer Daily bump. 2021-12-07 00:16:23 +00:00
libssp
libstdc++-v3 Daily bump. 2021-12-16 00:16:28 +00:00
libvtv
lto-plugin Daily bump. 2021-12-03 00:17:04 +00:00
maintainer-scripts
zlib Daily bump. 2021-12-17 00:16:20 +00:00
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2021-12-17 00:16:20 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub Fixed typo 2021-12-16 17:54:45 +01:00
configure Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
configure.ac Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Add myself to write after approval 2021-12-14 15:59:29 +01:00
Makefile.def d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1) 2021-11-30 16:53:28 +01:00
Makefile.in Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
Makefile.tpl Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB" 2021-12-15 20:45:58 -08:00
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.