Go to file
Jakub Jelinek bd35a92f8d c++: Implement C++26 P0609R3 - Attributes for Structured Bindings [PR114456]
The following patch implements the P0609R3 paper; we build the
VAR_DECLs for the structured binding identifiers early, so all we need
IMHO is just to parse the attributed identifier list and pass the attributes
to the VAR_DECL creation.

The paper mentions maybe_unused and gnu::nonstring attributes as examples
where they can be useful.  Not sure about either of them.
For maybe_unused, the thing is that both GCC and clang already don't
diagnose maybe unused for the structured binding identifiers, because it
would be a false positive too often; and there is no easy way to find out
if a structured binding has been written with the P0609R3 paper in mind or
not (maybe we could turn it on if in the structured binding is any
attribute, even if just [[]] and record that as a flag on the whole
underlying decl, so that we'd diagnose
  auto [a, b, c[[]]] = d;
  // use a, c but not b
but not
  auto [e, f, g] = d;
  // use a, c but not b
).  For gnu::nonstring, the issue is that we currently don't allow the
attribute on references to char * or references to char[], just on
char */char[].  I've filed a PR for that.

The first testcase in the patch tests it on [[]] and [[maybe_unused]],
just whether it is parsed properly, second on gnu::deprecated, which
works.  Haven't used deprecated attribute because the paper said that
attribute is for further investigation.

2024-04-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/114456
gcc/c-family/
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine
	__cpp_structured_bindings for C++26 to 202403L rather than
	201606L.
gcc/cp/
	* parser.cc (cp_parser_decomposition_declaration): Implement C++26
	P0609R3 - Attributes for Structured Bindings.  Parse attributed
	identifier lists for structured binding declarations, pass the
	attributes to start_decl.
gcc/testsuite/
	* g++.dg/cpp26/decomp1.C: New test.
	* g++.dg/cpp26/decomp2.C: New test.
	* g++.dg/cpp26/feat-cxx26.C (__cpp_structured_bindings): Expect
	202403 rather than 201606.
2024-04-30 08:57:15 +02:00
.github
c++tools
config
contrib Daily bump. 2024-04-27 00:18:05 +00:00
fixincludes
gcc c++: Implement C++26 P0609R3 - Attributes for Structured Bindings [PR114456] 2024-04-30 08:57:15 +02:00
gnattools
gotools
include
INSTALL
libada
libatomic Daily bump. 2024-04-27 00:18:05 +00:00
libbacktrace Daily bump. 2024-04-29 00:17:54 +00:00
libcc1
libcody
libcpp
libdecnumber
libffi
libgcc Daily bump. 2024-04-26 00:16:42 +00:00
libgfortran Daily bump. 2024-04-30 00:17:28 +00:00
libgm2
libgo runtime: dump registers on Solaris 2024-04-29 11:39:58 -07:00
libgomp Daily bump. 2024-04-27 00:18:05 +00:00
libgrust
libiberty
libitm
libobjc
libphobos
libquadmath
libsanitizer
libssp
libstdc++-v3 Daily bump. 2024-04-30 00:17:28 +00:00
libvtv
lto-plugin
maintainer-scripts Daily bump. 2024-04-27 00:18:05 +00:00
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog
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
SECURITY.txt
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.