aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--MAINTAINERS6
-rw-r--r--contrib/ChangeLog8
-rwxr-xr-xcontrib/download_prerequisites6
-rw-r--r--contrib/prerequisites.md56
-rw-r--r--contrib/prerequisites.sha5126
-rw-r--r--gcc/ChangeLog599
-rw-r--r--gcc/DATESTAMP2
-rw-r--r--gcc/Makefile.in1
-rw-r--r--gcc/c-family/ChangeLog28
-rw-r--r--gcc/c-family/c-common.h2
-rw-r--r--gcc/c-family/c-cppbuiltin.cc2
-rw-r--r--gcc/c-family/c-indentation.cc2
-rw-r--r--gcc/c-family/c-opts.cc11
-rw-r--r--gcc/c-family/c.opt4
-rw-r--r--gcc/c-family/c.opt.urls3
-rw-r--r--gcc/c/ChangeLog48
-rw-r--r--gcc/c/c-decl.cc23
-rw-r--r--gcc/cobol/ChangeLog10
-rw-r--r--gcc/cobol/cbldiag.h4
-rw-r--r--gcc/cobol/parse.y4
-rw-r--r--gcc/cobol/scan.l2
-rw-r--r--gcc/cobol/scan_ante.h2
-rw-r--r--gcc/cobol/show_parse.h2
-rw-r--r--gcc/cobol/util.cc4
-rw-r--r--gcc/common.opt12
-rw-r--r--gcc/common.opt.urls9
-rw-r--r--gcc/config/aarch64/aarch64-sve-builtins.cc5
-rw-r--r--gcc/config/aarch64/aarch64-sve.md64
-rw-r--r--gcc/config/aarch64/aarch64-sve2.md16
-rw-r--r--gcc/config/aarch64/aarch64.cc37
-rw-r--r--gcc/config/aarch64/iterators.md6
-rw-r--r--gcc/config/arm/arm.cc5
-rw-r--r--gcc/config/arm/arm.md13
-rw-r--r--gcc/config/arm/thumb1.md9
-rw-r--r--gcc/config/arm/thumb2.md21
-rw-r--r--gcc/config/darwin.cc38
-rw-r--r--gcc/config/darwin.h2
-rw-r--r--gcc/config/s390/s390.cc37
-rw-r--r--gcc/config/xtensa/constraints.md2
-rw-r--r--gcc/cp/ChangeLog75
-rw-r--r--gcc/cp/call.cc22
-rw-r--r--gcc/cp/constexpr.cc8
-rw-r--r--gcc/cp/decl.cc241
-rw-r--r--gcc/cp/error.cc4
-rw-r--r--gcc/cp/lex.cc60
-rw-r--r--gcc/cp/parser.cc81
-rw-r--r--gcc/cp/pt.cc117
-rw-r--r--gcc/d/ChangeLog4
-rw-r--r--gcc/diagnostic.h3
-rw-r--r--gcc/diagnostics/buffering.cc5
-rw-r--r--gcc/diagnostics/column-options.h44
-rw-r--r--gcc/diagnostics/context.cc127
-rw-r--r--gcc/diagnostics/context.h31
-rw-r--r--gcc/diagnostics/dumping.cc102
-rw-r--r--gcc/diagnostics/dumping.h50
-rw-r--r--gcc/diagnostics/file-cache.cc49
-rw-r--r--gcc/diagnostics/html-sink.cc40
-rw-r--r--gcc/diagnostics/html-sink.h2
-rw-r--r--gcc/diagnostics/metadata.h2
-rw-r--r--gcc/diagnostics/output-spec.cc14
-rw-r--r--gcc/diagnostics/sarif-sink.cc81
-rw-r--r--gcc/diagnostics/sarif-sink.h4
-rw-r--r--gcc/diagnostics/sink.h3
-rw-r--r--gcc/diagnostics/source-printing.cc8
-rw-r--r--gcc/diagnostics/text-sink.cc26
-rw-r--r--gcc/diagnostics/text-sink.h8
-rw-r--r--gcc/doc/invoke.texi65
-rw-r--r--gcc/doc/tm.texi10
-rw-r--r--gcc/doc/tm.texi.in10
-rw-r--r--gcc/fortran/ChangeLog17
-rw-r--r--gcc/fortran/decl.cc313
-rw-r--r--gcc/fortran/parse.cc6
-rw-r--r--gcc/libgdiagnostics.cc3
-rw-r--r--gcc/lto-wrapper.cc9
-rw-r--r--gcc/opts-common.cc3
-rw-r--r--gcc/opts.cc22
-rw-r--r--gcc/pretty-print.cc49
-rw-r--r--gcc/simplify-rtx.cc12
-rw-r--r--gcc/testsuite/ChangeLog293
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr121389-1.c23
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr121389-2.c37
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr121389-3.c130
-rw-r--r--gcc/testsuite/c-c++-common/asan/pr121389-4.c6
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2575.C51
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2576.C47
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2577-1.C40
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2577-2.C13
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2577-2.h1
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2577-3.C7
-rw-r--r--gcc/testsuite/g++.dg/DRs/dr2577-3.h1
-rw-r--r--gcc/testsuite/g++.dg/concepts/nested-diagnostics-1-truncated.C2
-rw-r--r--gcc/testsuite/g++.dg/concepts/nested-diagnostics-1.C2
-rw-r--r--gcc/testsuite/g++.dg/concepts/nested-diagnostics-2.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp26/constexpr-new3.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp13.C52
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp14.C474
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp15.C474
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp16.C240
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp17.C28
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp18.C109
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp19.C46
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp20.C53
-rw-r--r--gcc/testsuite/g++.dg/cpp26/decomp21.C103
-rw-r--r--gcc/testsuite/g++.dg/cpp26/feat-cxx26.C4
-rw-r--r--gcc/testsuite/g++.dg/modules/atom-preamble-3.C2
-rw-r--r--gcc/testsuite/g++.dg/modules/class-11_a.H1
-rw-r--r--gcc/testsuite/g++.dg/modules/class-11_b.C1
-rw-r--r--gcc/testsuite/g++.dg/opt/pr82577.C8
-rw-r--r--gcc/testsuite/g++.dg/template/sfinae17.C6
-rw-r--r--gcc/testsuite/g++.dg/torture/noncall-eh-1.C26
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-1.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-10.C23
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-2.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-3.C7
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-4.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-5.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-6.C7
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-7.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-8.C112
-rw-r--r--gcc/testsuite/g++.dg/warn/Wkeyword-macro-9.C22
-rw-r--r--gcc/testsuite/g++.target/aarch64/sve/pr121449.C44
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-1.c62
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-3.c62
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-5.c47
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-6.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-7.c47
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-8.c4
-rw-r--r--gcc/testsuite/gcc.dg/Wkeyword-macro-9.c15
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-4.c7
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-6.c10
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c9
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c24
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/plugin.exp2
-rw-r--r--gcc/testsuite/gcc.dg/pr118946-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/torture/hardbool-ai.c1
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-2.c36
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c29
-rw-r--r--gcc/testsuite/gcc.target/aarch64/pr120986-1.c10
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sme/pr121414_1.c27
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr120718.c12
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11.c20
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11_run.c27
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12.c21
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12_run.c29
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13.c24
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13_run.c15
-rw-r--r--gcc/testsuite/gcc.target/aarch64/torture/pr120986-2.c7
-rw-r--r--gcc/testsuite/gcc.target/arm/cmse/cmse-18.c7
-rw-r--r--gcc/testsuite/gcc.target/arm/cmse/cmse-19.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/asm-hard-reg-2.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/pr90579.c9
-rw-r--r--gcc/testsuite/gcc.target/s390/bitint-1.c83
-rw-r--r--gcc/testsuite/gcc.target/s390/bitint-2.c32
-rw-r--r--gcc/testsuite/gcc.target/s390/bitint-3.c28
-rw-r--r--gcc/testsuite/gcc.target/s390/bitint-4.c71
-rw-r--r--gcc/testsuite/gfortran.dg/generic_stmt_1.f90194
-rw-r--r--gcc/testsuite/gfortran.dg/generic_stmt_2.f9087
-rw-r--r--gcc/testsuite/gfortran.dg/generic_stmt_3.f9096
-rw-r--r--gcc/testsuite/gfortran.dg/generic_stmt_4.f9043
-rw-r--r--gcc/testsuite/lib/multiline.exp3
-rw-r--r--gcc/toplev.cc6
-rw-r--r--gcc/tree-diagnostic.cc2
-rw-r--r--gcc/tree-ssa-forwprop.cc421
-rw-r--r--gcc/tree-ssa-sccvn.cc31
-rw-r--r--gcc/tree-tailcall.cc207
-rw-r--r--gcc/tree-vect-data-refs.cc61
-rw-r--r--gcc/tree-vect-loop-manip.cc71
-rw-r--r--gcc/tree-vect-loop.cc193
-rw-r--r--gcc/tree-vect-stmts.cc135
-rw-r--r--gcc/tree-vectorizer.h9
-rw-r--r--libcpp/ChangeLog12
-rw-r--r--libcpp/directives.cc21
-rw-r--r--libcpp/include/cpplib.h17
-rw-r--r--libcpp/macro.cc33
-rw-r--r--libgcc/ChangeLog28
-rw-r--r--libgcc/Makefile.in1
-rw-r--r--libgcc/config.host2
-rw-r--r--libgcc/config/aarch64/t-aarch642
-rw-r--r--libgcc/config/s390/libgcc-glibc.ver14
-rw-r--r--libgcc/config/s390/sfp-exceptions.c61
-rw-r--r--libgcc/config/s390/sfp-machine.h89
-rw-r--r--libgcc/config/s390/t-softfp2
-rwxr-xr-xlibgcc/configure19
-rw-r--r--libgcc/configure.ac14
-rw-r--r--libgcobol/ChangeLog19
-rw-r--r--libgcobol/Makefile.am1
-rw-r--r--libgcobol/Makefile.in4
-rw-r--r--libgcobol/libgcobol.cc138
-rw-r--r--libgcobol/stringbin.cc477
-rw-r--r--libgcobol/stringbin.h47
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgomp/ChangeLog20
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/doc/html/manual/appendix_porting.html2
-rw-r--r--libstdc++-v3/doc/xml/manual/build_hacking.xml2
206 files changed, 8305 insertions, 1031 deletions
diff --git a/ChangeLog b/ChangeLog
index f7f3d99..fc1be55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-08-08 Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+
+ * MAINTAINERS (Andrew Pinski): Update email address.
+
+2025-08-07 Pengfei Li <Pengfei.Li2@arm.com>
+
+ * MAINTAINERS: Add myself.
+
2025-08-05 Thomas Schwinge <tschwinge@baylibre.com>
* .gitignore: Remove 'libgrust/*/target/'.
diff --git a/MAINTAINERS b/MAINTAINERS
index 6148ce0..dd31eed 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -276,7 +276,7 @@ check in changes outside of the parts of the compiler they maintain.
Reviewers
aarch64 port Alex Coplan <alex.coplan@arm.com>
-aarch64 port Andrew Pinski <pinskia@gmail.com>
+aarch64 port Andrew Pinski <andrew.pinski@oss.qualcomm.com>
arm port (MVE) Christophe Lyon <christophe.lyon@arm.com>
callgraph Martin Jambor <mjambor@suse.cz>
C front end Marek Polacek <polacek@redhat.com>
@@ -628,6 +628,7 @@ James Lemke jwlemke <jim@lemke.org>
Ilya Leoshkevich iii <iii@linux.ibm.com>
Kriang Lerdsuwanakij lerdsuwa <lerdsuwa@users.sourceforge.net>
Pan Li - <pan2.li@intel.com>
+Pengfei Li pfustc <pengfei.li2@arm.com>
Renlin Li renlin <renlin.li@arm.com>
Xinliang David Li davidxl <davidxl@google.com>
Kewen Lin linkw <linkw@gcc.gnu.org>
@@ -733,7 +734,7 @@ Sebastian Peryt speryt <sebastian.peryt@intel.com>
Johannes Pfau jpfau <johannespfau@gmail.com>
Gerald Pfeifer gerald <gerald@pfeifer.com>
Kaushik Phatak kaushikp <kaushik.phatak@kpitcummins.com>
-Andrew Pinski pinskia <pinskia@gmail.com>
+Andrew Pinski pinskia <andrew.pinski@qualcomm.com>
Nicolas Pitre nico <nico@cam.org>
Michael Ploujnikov plouj <michael.ploujnikov@oracle.com>
Paul Pluzhnikov ppluzhnikov <ppluzhnikov@google.com>
@@ -958,6 +959,7 @@ Immad Mir <mir@sourceware.org>
Gaius Mulley <gaiusmod2@gmail.com>
Szabolcs Nagy <nsz@gcc.gnu.org>
Andrew Pinski <quic_apinski@quicinc.com>
+Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Siddhesh Poyarekar <siddhesh@gotplt.org>
Ramana Radhakrishnan <ramanara@nvidia.com>
Navid Rahimi <navidr@gcc.gnu.org>
diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index f4f48e5..5370de6 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,11 @@
+2025-08-07 Tobias Burnus <tburnus@baylibre.com>
+
+ PR other/120237
+ * download_prerequisites: Update to download GMP 6.3.0 (before 6.2.1),
+ MPFR 4.2.2 (before 4.1.0), and MPC 1.3.1 (before 1.2.1).
+ * prerequisites.md5: Update hash.
+ * prerequisites.sha512: Likewise.
+
2025-07-28 David Malcolm <dmalcolm@redhat.com>
* gcc-changelog/git_commit.py: Add "diagnostics" to bug
diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
index b83fcc9..a6d756c 100755
--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -27,9 +27,9 @@ version='(unversioned)'
# remember to also update the files `contrib/prerequisites.sha512` and
# `contrib/prerequisites.md5` with the new checksums.
-gmp='gmp-6.2.1.tar.bz2'
-mpfr='mpfr-4.1.0.tar.bz2'
-mpc='mpc-1.2.1.tar.gz'
+gmp='gmp-6.3.0.tar.bz2'
+mpfr='mpfr-4.2.2.tar.bz2'
+mpc='mpc-1.3.1.tar.gz'
isl='isl-0.24.tar.bz2'
gettext='gettext-0.22.tar.gz'
diff --git a/contrib/prerequisites.md5 b/contrib/prerequisites.md5
index 716a9ff..96b9802 100644
--- a/contrib/prerequisites.md5
+++ b/contrib/prerequisites.md5
@@ -1,5 +1,5 @@
-28971fc21cf028042d4897f02fd355ea gmp-6.2.1.tar.bz2
-44b892bc5a45bafb4294d134e13aad1d mpfr-4.1.0.tar.bz2
-9f16c976c25bb0f76b50be749cd7a3a8 mpc-1.2.1.tar.gz
+c1cd6ef33085e9cb818b9b08371f9000 gmp-6.3.0.tar.bz2
+afe8268360bc8702fbc8297d351c8b5e mpfr-4.2.2.tar.bz2
+5c9bc658c9fd0f940e8e3e0f09530c62 mpc-1.3.1.tar.gz
dd2f7b78e118c25bd96134a52aae7f4d isl-0.24.tar.bz2
c092102240f8f66134d22718421d5115 gettext-0.22.tar.gz
diff --git a/contrib/prerequisites.sha512 b/contrib/prerequisites.sha512
index f71398b..7a3e9c2 100644
--- a/contrib/prerequisites.sha512
+++ b/contrib/prerequisites.sha512
@@ -1,5 +1,5 @@
-8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9 gmp-6.2.1.tar.bz2
-410208ee0d48474c1c10d3d4a59decd2dfa187064183b09358ec4c4666e34d74383128436b404123b831e585d81a9176b24c7ced9d913967c5fce35d4040a0b4 mpfr-4.1.0.tar.bz2
-3279f813ab37f47fdcc800e4ac5f306417d07f539593ca715876e43e04896e1d5bceccfb288ef2908a3f24b760747d0dbd0392a24b9b341bc3e12082e5c836ee mpc-1.2.1.tar.gz
+3b684c9bcb9ede2b7e54d0ba4c9764bfa17c20d4f3000017c553b6f1e135b536949580ff37341680c25dc236cfe0ba1db8cfdfe619ce013656189ef0871b89f8 gmp-6.3.0.tar.bz2
+0176e50808dcc07afbf5bc3e38bf9b7b21918e5f194aa0bfd860d99b00c470630aef149776c4be814a61c44269c3a5b9a4b0b1c0fcd4c9feb1459d8466452da8 mpfr-4.2.2.tar.bz2
+4bab4ef6076f8c5dfdc99d810b51108ced61ea2942ba0c1c932d624360a5473df20d32b300fc76f2ba4aa2a97e1f275c9fd494a1ba9f07c4cb2ad7ceaeb1ae97 mpc-1.3.1.tar.gz
aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95 isl-0.24.tar.bz2
e2a58dde1cae3e6b79c03e7ef3d888f7577c1f4cba283b3b0f31123ceea8c33d7c9700e83de57104644de23e5f5c374868caa0e091f9c45edbbe87b98ee51c04 gettext-0.22.tar.gz
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d975768..535eb24 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,602 @@
+2025-08-09 Iain Sandoe <iain@sandoe.co.uk>
+
+ * config/darwin.cc (darwin_encode_section_info): Do not
+ make anchored symbols linker-visible.
+ (darwin_use_anchors_for_symbol_p): Disallow anchoring on
+ symbols that must be linker-visible (or external), even
+ if the definitions are in this TU.
+
+2025-08-09 Iain Sandoe <iain@sandoe.co.uk>
+
+ * config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): New
+ entry for LANCHOR.
+
+2025-08-09 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostics/context.cc (context::dump): Bulletproof against
+ m_reference_printer being null.
+ * diagnostics/dumping.cc (emit_field<const char *>): Replace
+ with...
+ (emit_string_field): ...this.
+ (emit_field<char *>): Eliminate.
+ (emit_field<bool>): Replace with...
+ (emit_bool_field): ...this.
+ (emit_field<size_t>): Replace with...
+ (emit_size_t_field): ...this, and use HOST_SIZE_T_PRINT_DEC rather
+ than %zi in fprintf call.
+ (emit_field<int>): Replace with...
+ (emit_int_field): ...this.
+ (emit_field<unsigned>): Replace with...
+ (emit_unsigned_field): ...this.
+ * diagnostics/dumping.h (emit_field): Replace this template decl
+ with...
+ (emit_string_field): ...this,
+ (emit_bool_field): ...this,
+ (emit_size_t_field): ...this,
+ (emit_int_field): ...this,
+ (emit_unsigned_field): ... and this.
+ (DIAGNOSTICS_DUMPING_EMIT_FIELD): Rename to...
+ (DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD): ...this and update for
+ above change.
+ * diagnostics/file-cache.cc (file_cache_slot::dump): Replace
+ emit_field calls with calls that explicitly state the type. Fix
+ type of dump of m_missing_trailing_newline to use bool.
+ (file_cache_slot::dump): Use HOST_SIZE_T_PRINT_DEC rather than
+ %zi in fprintf call.
+ * diagnostics/html-sink.cc (html_generation_options::dump): Update
+ for macro renaming.
+ * diagnostics/sarif-sink.cc
+ (sarif_serialization_format_json::dump): Likewise.
+ (sarif_generation_options::dump): Likewise, and for function
+ renaming.
+ * diagnostics/text-sink.cc (text_sink::dump): Update for macro
+ renaming.
+ * libgdiagnostics.cc (diagnostic_manager_debug_dump_file): Use
+ HOST_SIZE_T_PRINT_DEC rather than %zi in fprintf call.
+ * pretty-print.cc: Include "diagnostics/dumping.h".
+ (pp_formatted_chunks::dump): Use it.
+ (get_url_format_as_string): New.
+ (pretty_printer::dump): Use diagnostics::dumping. Bulletproof
+ against m_buffer being null.
+
+2025-08-09 Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
+
+ * config/xtensa/constraints.md (T):
+ Change define_memory_constraint to define_special_memory_constraint.
+
+2025-08-08 Andrew Pinski <quic_apinski@quicinc.com>
+
+ PR tree-optimization/120599
+ * tree-ssa-forwprop.cc (optimize_agr_copyprop): Don't try to copy
+ from statements that throw.
+
+2025-08-08 Andrew Pinski <quic_apinski@quicinc.com>
+
+ PR tree-optimization/118946
+ PR tree-optimization/121422
+ * tree-ssa-forwprop.cc (optimize_memcpy_to_memset): Remove.
+ (optimize_aggr_zeroprop_1): New function.
+ (optimize_aggr_zeroprop): New function.
+ (simplify_builtin_call): Don't call optimize_memcpy_to_memset
+ for memcpy but call optimize_aggr_zeroprop for memset.
+ (pass_forwprop::execute): Don't call optimize_memcpy_to_memset
+ for aggregate copies but rather call optimize_aggr_zeroprop
+ for aggregate stores.
+
+2025-08-08 Andrew Pinski <quic_apinski@quicinc.com>
+
+ * tree-ssa-forwprop.cc (optimize_agr_copyprop): Change into a
+ forward looking (looking at vdef's uses) instead of a back
+ looking (vuse's def).
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ PR diagnostics/116253
+ * common.opt (fdiagnostics-show-nesting): New option.
+ (fdiagnostics-show-nesting-locations): New option.
+ (fdiagnostics-show-nesting-levels): New option.
+ * common.opt.urls: Regenerate.
+ * diagnostics/context.cc (context::set_show_nesting): New.
+ (context::set_show_nesting_locations): New.
+ (context::set_show_nesting_levels): New.
+ * diagnostics/context.h (context::set_show_nesting): New decl.
+ (context::set_show_nesting_locations): New decl.
+ (context::set_show_nesting_levels): New decl.
+ * diagnostics/html-sink.cc: Tweak comment.
+ * diagnostics/output-spec.cc (text_scheme_handler::make_sink):
+ Rename "experimental-nesting" to "show-nesting" and enable by
+ default. Rename "experimental-nesting-show-locations" to
+ "show-nesting-locations". Rename
+ "experimental-nesting-show-levels" to "show-nesting-levels".
+ * diagnostics/sink.h (sink::dyn_cast_text_sink): New.
+ * diagnostics/text-sink.h (text_sink::dyn_cast_text_sink): New.
+ * doc/invoke.texi: Add -fdiagnostics-show-nesting,
+ -fdiagnostics-show-nesting-locations, and
+ -fdiagnostics-show-nesting-levels. Update for changes to
+ output-spec.cc above.
+ * lto-wrapper.cc (merge_and_complain): Ignore
+ OPT_fdiagnostics_show_nesting,
+ OPT_fdiagnostics_show_nesting_locations, and
+ OPT_fdiagnostics_show_nesting_levels.
+ (append_compiler_options): Likewise.
+ (append_diag_options): Likewise.
+ * opts-common.cc (decode_cmdline_options_to_array): Add
+ "-fno-diagnostics-show-nesting" to -fdiagnostics-plain-output.
+ * opts.cc (common_handle_option): Handle the new options.
+ (gen_command_line_string): Ignore the new options.
+ * toplev.cc (general_init): Call set_show_nesting,
+ set_show_nesting_locations, and set_show_nesting_levels on
+ global_dc.
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * Makefile.in (OBJS-libcommon): Add diagnostics/dumping.o.
+ * diagnostics/buffering.cc: Include "diagnostics/dumping.h".
+ (buffer::dump): Reimplement using diagnostics::dumping.
+ * diagnostics/context.cc: Include "diagnostics/dumping.h".
+ (context::dump): Reimplement using diagnostics::dumping.
+ Use sink::dump_kind when listing the sinks.
+ (sink::dump): Reimplement using diagnostics::dumping.
+ (counters::dump): Likewise.
+ * diagnostics/dumping.cc: New file.
+ * diagnostics/dumping.h: New file.
+ * diagnostics/file-cache.cc: Include "diagnostics/dumping.h".
+ (file_cache::dump): Reimplement using diagnostics::dumping.
+ (file_cache_slot::dump): Likewise.
+ * diagnostics/html-sink.cc: Include "diagnostics/dumping.h".
+ (html_generation_options::dump): New.
+ (html_sink_buffer::dump): Reimplement using diagnostics::dumping.
+ (html_builder::dump): New.
+ (html_sink::dump): Reimplement using diagnostics::dumping.
+ Add dump of the html_builder.
+ (html_file_sink::dump): Replace with...
+ (html_file_sink::dump_kind): ...this.
+ (html_buffered_sink::dump_kind): New.
+ * diagnostics/html-sink.h (html_generation_options::dump): New
+ decl.
+ * diagnostics/sarif-sink.cc: Include "diagnostics/dumping.h".
+ (sarif_serialization_format_json::dump): New.
+ (sarif_builder::dump): New.
+ (sarif_sink_buffer::dump): Reimplement using diagnostics::dumping.
+ (sarif_sink::dump): Likewise. Add dump of the sarif_builder.
+ (sarif_stream_sink::dump_kind): New.
+ (sarif_file_sink::dump): Replace with...
+ (sarif_file_sink::dump_kind): ...this.
+ (get_dump_string_for_sarif_version): New.
+ (sarif_generation_options::dump): New.
+ (class buffered_sink): Rename to...
+ (class sarif_buffered_sink): ...this.
+ (sarif_buffered_sink::dump_kind): New.
+ * diagnostics/sarif-sink.h (sarif_serialization_format::dump):
+ New.
+ (sarif_serialization_format_json::dump): New decl.
+ (sarif_generation_options::dump): New decl.
+ * diagnostics/sink.h (sink::dump_kind): New.
+ * diagnostics/text-sink.cc: Include "diagnostics/dumping.h".
+ (text_sink_buffer::dump): Reimplement using diagnostics::dumping.
+ (text_sink::dump): Likewise. Emit fields m_show_nesting,
+ m_show_locations_in_nesting, and m_show_nesting_levels.
+ * diagnostics/text-sink.h (text_sink::dump_kind): New.
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostic.h (diagnostics::get_cwe_url): Move decl to
+ diagnostics/metadata.h.
+ (diagnostics::maybe_line_and_column): Move into
+ diagnostics::text_sink.
+ * diagnostics/context.cc: Update for maybe_line_and_column
+ becoming a static member of text_sink.
+ * diagnostics/metadata.h (diagnostics::get_cwe_url): Move decl
+ here from diagnostic.h.
+ * diagnostics/text-sink.cc (maybe_line_and_column): Convert to...
+ (text_sink::maybe_line_and_column): ...this.
+ * diagnostics/text-sink.h (text_sink::maybe_line_and_column): Move
+ here from diagnostic.h.
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostics/context.cc (context::get_any_inlining_info): Convert
+ "context" arg of m_set_locations_cb from ptr to const &.
+ (context::report_diagnostic): Convert "context" arg of
+ m_adjust_diagnostic_info from ptr to const &.
+ * diagnostics/context.h (context::set_locations_callback_t):
+ Likewise.
+ (context::set_adjust_diagnostic_info_callback): Likewise.
+ (context::m_adjust_diagnostic_info): Likewise.
+ * tree-diagnostic.cc (set_inlining_locations): Likewise.
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * diagnostics/column-options.h: New file, adding struct
+ diagnostics::column_options, taken from fields in
+ diagnostics::context and diagnostics::column_policy.
+ * diagnostics/context.cc (context::initialize): Update for moving
+ fields of diagnostics::context into diagnostics::column_options.
+ (column_policy::column_policy): Likewise.
+ (column_policy::converted_column): Move implementation to...
+ (column_options::convert_column): ...this new function.
+ (context::report_diagnostic): Update for moving fields of
+ diagnostics::context into diagnostics::column_options.
+ (assert_location_text): Likewise.
+ * diagnostics/context.h: Include "diagnostics/column-options.h".
+ (class column_policy): Replace fields m_column_unit,
+ m_column_origin, and m_tabstop with m_column_options.
+ (context::get_column_options): New accessors.
+ (context::m_column_unit): Move to struct column_options and
+ replace with m_column_options.
+ (context::m_column_origin): Likewise.
+ (context::m_tabstop): Likewise.
+ * diagnostics/sarif-sink.cc (sarif_builder::sarif_builder): Update
+ for moving fields of diagnostics::context into
+ diagnostics::column_options.
+ * diagnostics/source-printing.cc: Likewise.
+ * opts.cc (common_handle_option): Likewise.
+
+2025-08-08 Christophe Lyon <christophe.lyon@linaro.org>
+
+ PR target/120977
+ * config/arm/arm.md (call): Move unspec parameter to parallel.
+ (nonsecure_call_internal): Likewise.
+ (call_value): Likewise.
+ (nonsecure_call_value_internal): Likewise.
+ * config/arm/thumb1.md (nonsecure_call_reg_thumb1_v5): Likewise.
+ (nonsecure_call_value_reg_thumb1_v5): Likewise.
+ * config/arm/thumb2.md (nonsecure_call_reg_thumb2_fpcxt):
+ Likewise.
+ (nonsecure_call_reg_thumb2): Likewise.
+ (nonsecure_call_value_reg_thumb2_fpcxt): Likewise.
+ (nonsecure_call_value_reg_thumb2): Likewise.
+ * config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
+ Likewise.
+
+2025-08-08 Pengfei Li <Pengfei.Li2@arm.com>
+
+ PR target/121449
+ * config/aarch64/aarch64-sve.md
+ (mask_gather_load<mode><v_int_container>): Use vg<Vesize>
+ constraints for alternatives with immediate offset.
+ (mask_scatter_store<mode><v_int_container>): Likewise.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ * doc/tm.texi.in: Add Vectorization and OpenMP and OpenACC
+ sub-sections to the list of target macros and functions.
+ * doc/tm.texi: Re-generate.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-loop.cc (vect_determine_vectype_for_stmt_1): Remove.
+ (vect_determine_vectype_for_stmt): Likewise.
+ (vect_set_stmts_vectype): Likewise.
+ (vect_analyze_loop_2): Do not call vect_set_stmts_vectype.
+ * tree-vect-stmts.cc (vect_mark_stmts_to_be_vectorized): Detect
+ irregular stmts early here.
+
+2025-08-08 Alex Coplan <alex.coplan@arm.com>
+
+ PR target/120986
+ * config/aarch64/aarch64-sve-builtins.cc
+ (function_expander::expand): Relax fpm_t assert to allow
+ modeless const_ints.
+
+2025-08-08 Alex Coplan <alex.coplan@arm.com>
+
+ PR target/120986
+ * config/aarch64/aarch64-sve2.md (@aarch64_sve_dot<mode>):
+ Switch mode iterator from SVE_FULL_HSF to new iterator;
+ remove insn predicate as this is now taken care of by conditions
+ in the mode iterator.
+ (@aarch64_sve_dot_lane<mode>): Likewise.
+ * config/aarch64/iterators.md (SVE_FULL_HSF_FP8_FDOT): New.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/121454
+ * tree-ssa-sccvn.cc (visit_nary_op): Avoid unexpected
+ BIT_FIELD_REFs.
+
+2025-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/121389
+ * tree-tailcall.cc (find_tail_calls): For finally_tmp.N
+ handle not just GIMPLE_CONDs with EQ_EXPR/NE_EXPR and only
+ values 0 and 1, but arbitrary non-negative values, arbitrary
+ comparisons in conditions and also GIMPLE_SWITCH next to
+ GIMPLE_CONDs.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): Get
+ the SLP node rather than the stmt_info.
+ (vectorizable_lane_reducing): Adjust, pass SLP node to costing.
+ (vect_transform_reduction): Adjust.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-stmts.cc (vect_model_promotion_demotion_cost): Pass
+ in SLP node and drop unused dr argument. Use SLP node for
+ costing, drop costing of constant/external operands.
+ (vectorizable_conversion): Adjust.
+
+2025-08-08 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-stmts.cc (vectorizable_store): Apply SLP_TREE_VECTYPE
+ to slp_node rather than stmt_info.
+
+2025-08-07 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR target/121414
+ * config/aarch64/aarch64.cc (aarch64_is_variant_pcs): New function,
+ split out from...
+ (aarch64_asm_output_variant_pcs): ...here. Handle various types
+ of SME function type.
+
+2025-08-07 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR rtl-optimization/120718
+ * simplify-rtx.cc (simplify_context::simplify_gen_subreg):
+ Remove MODE_COMPOSITE_P condition.
+
+2025-08-07 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/121405
+ * tree-ssa-sccvn.cc (visit_nary_op): Handle BIT_FIELD_REF
+ with reference def by looking up a combination of both.
+
+2025-08-07 Pengfei Li <Pengfei.Li2@arm.com>
+
+ * tree-vect-data-refs.cc (vect_compute_data_ref_alignment):
+ Allow DR target alignment to be a poly_int.
+ (vect_enhance_data_refs_alignment): Support peeling and
+ versioning for VLA modes.
+ * tree-vect-loop-manip.cc (get_misalign_in_elems): Remove
+ power-of-two rounding in peeling.
+ (vect_create_cond_for_align_checks): Update alignment check
+ logic for poly_int mask.
+ (vect_create_cond_for_vla_spec_read): New runtime checks.
+ (vect_loop_versioning): Support new runtime checks.
+ * tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): Add a new
+ loop_vinfo field.
+ (vectorizable_induction): Fix wrong IV offset issue.
+ * tree-vect-stmts.cc (get_load_store_type): Refactor
+ vectorizable checks for speculative loads.
+ * tree-vectorizer.h (LOOP_VINFO_MAX_SPEC_READ_AMOUNT): New
+ macro for new runtime checks.
+ (LOOP_REQUIRES_VERSIONING_FOR_SPEC_READ): Likewise
+ (LOOP_REQUIRES_VERSIONING): Update macro for new runtime checks.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * doc/invoke.texi (Wkeyword-macro): Document.
+
+2025-08-07 Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
+
+ * config/s390/s390.cc (print_operand): Allow arbitrary wide_int
+ constants for _BitInt.
+ (s390_bitint_type_info): Implement target hook
+ TARGET_C_BITINT_TYPE_INFO.
+
+2025-08-06 Uros Bizjak <ubizjak@gmail.com>
+
+ PR target/96226
+ * config/i386/predicates.md (and_operator): New operator.
+ * config/i386/i386.md (splitter after *<rotate_insn><mode>3_mask):
+ Use and_operator to match AND RTX and use its mode
+ in the split pattern.
+
+2025-08-06 Gerald Pfeifer <gerald@pfeifer.com>
+
+ PR target/69374
+ * doc/install.texi (Prerequisites): Replace bzip2 by xz.
+
+2025-08-06 Yangyu Chen <cyy@cyyself.name>
+
+ * config/i386/i386.h (PTA_BDVER1):
+ Add missing PTA_POPCNT and PTA_LZCNT with PTA_ABM.
+ (PTA_ZNVER1): Ditto.
+ (PTA_BTVER1): Ditto.
+ (PTA_LUJIAZUI): Ditto.
+ (PTA_YONGFENG): Do not include extra PTA_LZCNT.
+
+2025-08-06 Sam James <sam@gentoo.org>
+
+ PR libstdc++/29286
+ * Makefile.in (ALIASING_FLAGS): Drop.
+ * configure: Regenerate.
+ * configure.ac: Drop -fno-strict-aliasing workaround for < GCC 4.3.
+
+2025-08-06 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-data-refs.cc (vect_supportable_dr_alignment):
+ Prune dead code.
+
+2025-08-06 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/121231
+ PR c++/119688
+ PR c++/94511
+ * common.opt: Document additional ABI version 21 change.
+ * doc/invoke.texi: Likewise.
+
+2025-08-06 Richard Biener <rguenther@suse.de>
+
+ * tree-vectorizer.h (_slp_tree::gs_scale): New.
+ (_slp_tree::gs_base): Likewise.
+ (SLP_TREE_GS_SCALE): Likewise.
+ (SLP_TREE_GS_BASE): Likewise.
+ (vect_describe_gather_scatter_call): Declare.
+ * tree-vect-slp.cc (_slp_tree::_slp_tree): Initialize
+ new members.
+ (vect_build_slp_tree_2): Record gather/scatter base and scale.
+ (vect_get_and_check_slp_defs): For gather/scatter IFNs
+ describe the call to first_gs_info.
+ * tree-vect-data-refs.cc (vect_gather_scatter_fn_p): Add
+ mode of operation with fixed offset vector type.
+ (vect_describe_gather_scatter_call): Export.
+ * tree-vect-stmts.cc (get_load_store_type): Do not call
+ vect_check_gather_scatter to fill gs_info, instead populate
+ from the SLP tree. Check which of, IFN, decl or fallback
+ is supported and record that decision.
+
+2025-08-06 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-stmts.cc (vectorizable_store): Build proper
+ alias + align pointer value for gather/scatter and SLP
+ and use it.
+ (vectorizable_load): Likewise.
+
+2025-08-06 Richard Biener <rguenther@suse.de>
+
+ * tree-vect-stmts.cc (check_load_store_for_partial_vectors):
+ Remove redundant gather/scatter target support check, instead
+ check the recorded ifns. Also allow legacy gather/scatter
+ with loop masking.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/121413
+ * gimple-lower-bitint.cc (gimple_lower_bitint): Fix up last
+ commit, cast limb_prec to unsigned before comparison.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * match.pd: Preserve conversion to _BitInt before a VCE
+ if the _BitInt is extended.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * gimple-lower-bitint.cc (bitint_large_huge::lower_mergeable_stmt):
+ Zero-extend the partial limb of any unsigned _BitInt LHS assigned
+ with a widening sign-extension.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * gimple-lower-bitint.cc (bitint_large_huge::limb_access):
+ Add a parameter abi_load_p. If set, load a limb directly
+ in its actual precision without casting from m_limb_type.
+ (struct bitint_large_huge): Same.
+ (bitint_large_huge::handle_load): Use.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/121413
+ * gimple-lower-bitint.cc (abi_limb_prec): New variable
+ (bitint_precision_kind): Initialize it.
+ (gimple_lower_bitint): Clear it at the start. For
+ min_prec > limb_prec descreased precision vars for
+ INTEGER_CST PHI arguments ensure min_prec is either
+ prec or multiple of abi_limb_prec.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/121127
+ * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr): For
+ uninitialized SSA_NAME, set *prec_stored to 0 rather than *prec.
+ Handle that case in narrowing casts. If prec_stored is non-NULL,
+ set *prec_stored to prec_stored_val.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR bootstrap/121386
+ * Makefile.in (gengtype-lex.cc): Append #define FLEX_SCANNER,
+ #include "system.h" and #undef FLEX_SCANNER to the prepended lines.
+ * gengtype-lex.l: Remove inclusion of config.h or bconfig.h, system.h
+ and definition of malloc/realloc from %{} section.
+
+2025-08-06 Kito Cheng <kito.cheng@sifive.com>
+
+ * config/riscv/arch-canonicalize: Read extension data from
+ riscv-ext*.def and adding unittest.
+
+2025-08-06 Kito Cheng <kito.cheng@sifive.com>
+
+ * common/config/riscv/riscv-common.cc (riscv_expand_arch):
+ Ignore `unset`.
+ * config/riscv/riscv.h (OPTION_DEFAULT_SPECS): Handle
+ `-march=unset`.
+ (ARCH_UNSET_CLEANUP_SPECS): New.
+ (DRIVER_SELF_SPECS): Handle -march=unset.
+ * doc/invoke.texi (RISC-V Options): Update documentation for
+ `-march=unset`.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * gimplify.cc (remove_unused_omp_iterator_vars): Display unused
+ variable warning for 'to' and 'from' clauses.
+ (gimplify_scan_omp_clauses): Add argument for iterator loop sequence.
+ Gimplify the clause decl and size into the iterator loop if iterators
+ are used.
+ (gimplify_omp_workshare): Add argument for iterator loops sequence
+ in call to gimplify_scan_omp_clauses.
+ (gimplify_omp_target_update): Call remove_unused_omp_iterator_vars and
+ build_omp_iterators_loops. Add loop sequence as argument when calling
+ gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses and building
+ the Gimple statement.
+ * tree-pretty-print.cc (dump_omp_clause): Call dump_omp_iterators
+ for to/from clauses with iterators.
+ * tree.cc (omp_clause_num_ops): Add extra operand for OMP_CLAUSE_FROM
+ and OMP_CLAUSE_TO.
+ * tree.h (OMP_CLAUSE_HAS_ITERATORS): Add check for OMP_CLAUSE_TO and
+ OMP_CLAUSE_FROM.
+ (OMP_CLAUSE_ITERATORS): Likewise.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+ Andrew Stubbs <ams@baylibre.com>
+
+ * gimple-pretty-print.cc (dump_gimple_omp_target): Print expanded
+ iterator loops.
+ * gimple.cc (gimple_build_omp_target): Add argument for iterator
+ loops sequence. Initialize iterator loops field.
+ * gimple.def (GIMPLE_OMP_TARGET): Set GSS symbol to GSS_OMP_TARGET.
+ * gimple.h (gomp_target): Set GSS symbol to GSS_OMP_TARGET. Add extra
+ field for iterator loops.
+ (gimple_build_omp_target): Add argument for iterator loops sequence.
+ (gimple_omp_target_iterator_loops): New.
+ (gimple_omp_target_iterator_loops_ptr): New.
+ (gimple_omp_target_set_iterator_loops): New.
+ * gimplify.cc (find_var_decl): New.
+ (copy_omp_iterator): New.
+ (remap_omp_iterator_var_1): New.
+ (remap_omp_iterator_var): New.
+ (remove_unused_omp_iterator_vars): New.
+ (struct iterator_loop_info_t): New type.
+ (iterator_loop_info_map_t): New type.
+ (build_omp_iterators_loops): New.
+ (enter_omp_iterator_loop_context_1): New.
+ (enter_omp_iterator_loop_context): New.
+ (enter_omp_iterator_loop_context): New.
+ (exit_omp_iterator_loop_context): New.
+ (gimplify_adjust_omp_clauses): Add argument for iterator loop
+ sequence. Gimplify the clause decl and size into the iterator
+ loop if iterators are used.
+ (gimplify_omp_workshare): Call remove_unused_omp_iterator_vars and
+ build_omp_iterators_loops for OpenMP target expressions. Add
+ loop sequence as argument when calling gimplify_adjust_omp_clauses
+ and building the Gimple statement.
+ * gimplify.h (enter_omp_iterator_loop_context): New prototype.
+ (exit_omp_iterator_loop_context): New prototype.
+ * gsstruct.def (GSS_OMP_TARGET): New.
+ * omp-low.cc (lower_omp_map_iterator_expr): New.
+ (lower_omp_map_iterator_size): New.
+ (finish_omp_map_iterators): New.
+ (lower_omp_target): Add sorry if iterators used with deep mapping.
+ Call lower_omp_map_iterator_expr before assigning to sender ref.
+ Call lower_omp_map_iterator_size before setting the size. Insert
+ iterator loop sequence before the statements for the target clause.
+ * tree-nested.cc (convert_nonlocal_reference_stmt): Walk the iterator
+ loop sequence of OpenMP target statements.
+ (convert_local_reference_stmt): Likewise.
+ (convert_tramp_reference_stmt): Likewise.
+ * tree-pretty-print.cc (dump_omp_iterators): Dump extra iterator
+ information if present.
+ (dump_omp_clause): Call dump_omp_iterators for iterators in map
+ clauses.
+ * tree.cc (omp_clause_num_ops): Add operand for OMP_CLAUSE_MAP.
+ (walk_tree_1): Do not walk last operand of OMP_CLAUSE_MAP.
+ * tree.h (OMP_CLAUSE_HAS_ITERATORS): New.
+ (OMP_CLAUSE_ITERATORS): New.
+
2025-08-05 H.J. Lu <hjl.tools@gmail.com>
PR target/121410
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cf43af9..c740198 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250806
+20250810
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index cc79595..f21d692 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1856,6 +1856,7 @@ OBJS-libcommon = \
diagnostics/color.o \
diagnostics/context.o \
diagnostics/digraphs.o \
+ diagnostics/dumping.o \
diagnostics/file-cache.o \
diagnostics/output-spec.o \
diagnostics/html-sink.o \
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index c9ab153..d766c28 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,31 @@
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * c-indentation.cc (should_warn_for_misleading_indentation):
+ Update for moving diagnostics::context::m_tabstop into
+ diagnostics::column_options.
+ * c-opts.cc (c_common_post_options): Likewise.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/117783
+ * c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_structured_bindings
+ predefined value for C++26 from 202403L to 202411L.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * c.opt (Wkeyword-macro): New option.
+ * c.opt.urls: Regenerate.
+ * c-common.h (cxx_dialect): Comment formatting fix.
+ * c-opts.cc (c_common_post_options): Default to
+ -Wkeyword-macro for C++26 if pedantic.
+
+2025-08-06 Alexandre Oliva <oliva@adacore.com>
+
+ * c-attribs.cc (handle_hardbool_attribute): Create distinct
+ enumeration types, with structural equality. Handle
+ base type qualifiers.
+
2025-08-02 Martin Uecker <uecker@tugraz.at>
* c-attribs.cc (handle_argspec_attribute): Update.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 7c7e21d..009c8ef 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -747,7 +747,7 @@ enum cxx_dialect {
cxx26
};
-/* The C++ dialect being used. C++98 is the default. */
+/* The C++ dialect being used. C++17 is the default. */
extern enum cxx_dialect cxx_dialect;
/* Maximum template instantiation depth. This limit is rather
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 4aea902..5476d10 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1090,7 +1090,7 @@ c_cpp_builtins (cpp_reader *pfile)
cpp_define (pfile, "__cpp_constexpr_exceptions=202411L");
cpp_define (pfile, "__cpp_static_assert=202306L");
cpp_define (pfile, "__cpp_placeholder_variables=202306L");
- cpp_define (pfile, "__cpp_structured_bindings=202403L");
+ cpp_define (pfile, "__cpp_structured_bindings=202411L");
cpp_define (pfile, "__cpp_deleted_function=202403L");
cpp_define (pfile, "__cpp_variadic_friend=202403L");
cpp_define (pfile, "__cpp_pack_indexing=202311L");
diff --git a/gcc/c-family/c-indentation.cc b/gcc/c-family/c-indentation.cc
index bb214fc..d378464 100644
--- a/gcc/c-family/c-indentation.cc
+++ b/gcc/c-family/c-indentation.cc
@@ -330,7 +330,7 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
if (guard_loc == body_loc || body_loc == next_stmt_loc)
return false;
- const unsigned int tab_width = global_dc->m_tabstop;
+ const unsigned int tab_width = global_dc->get_column_options ().m_tabstop;
/* They must be in the same file. */
if (next_stmt_exploc.file != body_exploc.file)
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index c652e82..0ec30e8 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -959,6 +959,15 @@ c_common_post_options (const char **pfilename)
if (warn_enum_compare == -1)
warn_enum_compare = c_dialect_cxx () ? 1 : 0;
+ /* For C++26 default to -Wkeyword-macro if -Wpedantic. */
+ if (cxx_dialect >= cxx26 && pedantic)
+ {
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ warn_keyword_macro, 1);
+ if (warn_keyword_macro)
+ cpp_opts->cpp_warn_keyword_macro = warn_keyword_macro;
+ }
+
/* -Wpacked-bitfield-compat is on by default for the C languages. The
warning is issued in stor-layout.cc which is not part of the front-end so
we need to selectively turn it on here. */
@@ -1191,7 +1200,7 @@ c_common_post_options (const char **pfilename)
flag_char8_t = (cxx_dialect >= cxx20) || flag_isoc23;
cpp_opts->unsigned_utf8char = flag_char8_t ? 1 : cpp_opts->unsigned_char;
- cpp_opts->cpp_tabstop = global_dc->m_tabstop;
+ cpp_opts->cpp_tabstop = global_dc->get_column_options ().m_tabstop;
if (flag_extern_tls_init)
{
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 12877eb..0ee2c30 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -964,6 +964,10 @@ Enum(warn_leading_whitespace_kind) String(tabs) Value(2)
EnumValue
Enum(warn_leading_whitespace_kind) String(blanks) Value(3)
+Wkeyword-macro
+C ObjC C++ ObjC++ CPP(cpp_warn_keyword_macro) CppReason(CPP_W_KEYWORD_MACRO) Var(warn_keyword_macro) Init(0) Warning
+Warn about defining or undefining macros with identifiers equal to keywords (or for C++ conditional keywords or standard attribute names).
+
Wleading-whitespace=
C ObjC C++ ObjC++ CPP(cpp_warn_leading_whitespace) CppReason(CPP_W_LEADING_WHITESPACE) Enum(warn_leading_whitespace_kind) Joined RejectNegative Var(warn_leading_whitespace) Init(0) Warning
Warn about leading whitespace style issues on lines except when in raw string literals.
diff --git a/gcc/c-family/c.opt.urls b/gcc/c-family/c.opt.urls
index 5c97593..6eb1178 100644
--- a/gcc/c-family/c.opt.urls
+++ b/gcc/c-family/c.opt.urls
@@ -508,6 +508,9 @@ UrlSuffix(gcc/Warning-Options.html#index-Winvalid-utf8)
Wjump-misses-init
UrlSuffix(gcc/Warning-Options.html#index-Wjump-misses-init)
+Wkeyword-macro
+UrlSuffix(gcc/Warning-Options.html#index-Wkeyword-macro)
+
Wleading-whitespace=
UrlSuffix(gcc/Warning-Options.html#index-Wleading-whitespace_003d)
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 464e5a1..87a18c9 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,51 @@
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * c-decl.cc (c_init_decl_processing): Mark cpp nodes corresponding
+ to keywords as NODE_WARN if warn_keyword_macro.
+
+2025-08-06 Alexandre Oliva <oliva@adacore.com>
+
+ * c-tree.h (C_BOOLEAN_TYPE_P): Cover hardbools as well.
+ * c-typeck.cc (convert_lvalue_to_rvalue): New overload and
+ wrapper.
+ (build_atomic_assign, build_modify_expr): Use it.
+ (build_asm_expr, handle_omp-array_sections_1): Simplify with
+ it.
+ (build_unary_op): Handle hardbools.
+
+2025-08-06 Martin Uecker <uecker@tugraz.at>
+
+ PR c/108931
+ * c-typeck.cc (composite_type_cond): Renamed from
+ composite_type with argument for condition
+ (composite_type): New function.
+ (composite_type_internal): Implement new logic.
+ (build_conditional_expr): Pass condition.
+ (common_pointer_type): Adapt.
+ (pointer_diff): Adapt.
+ (build_binary_op): Adapt.
+
+2025-08-06 Martin Uecker <uecker@tugraz.at>
+
+ PR c/121217
+ * c-typeck.cc (tagged_types_tu_compatible_p): Add check.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * c-parser.cc (c_parser_omp_clause_from_to): Parse 'iterator' modifier.
+ * c-typeck.cc (c_finish_omp_clauses): Finish iterators for to/from
+ clauses.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+ Andrew Stubbs <ams@baylibre.com>
+
+ * c-parser.cc (c_parser_omp_variable_list): Use location of the
+ map expression as the clause location.
+ (c_parser_omp_clause_map): Parse 'iterator' modifier.
+ * c-typeck.cc (c_finish_omp_clauses): Finish iterators. Apply
+ iterators to generated clauses.
+
2025-08-02 Martin Uecker <uecker@tugraz.at>
* c-decl.cc (get_parm_array_spec): Remove.
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 7850365..8e8bac6 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -4825,6 +4825,29 @@ c_init_decl_processing (void)
make_fname_decl = c_make_fname_decl;
start_fname_decls ();
+
+ if (warn_keyword_macro)
+ {
+ for (unsigned int i = 0; i < num_c_common_reswords; ++i)
+ /* For C register keywords which don't start with underscore
+ or start with just single underscore. Don't complain about
+ ObjC or Transactional Memory keywords. */
+ if (c_common_reswords[i].word[0] == '_'
+ && c_common_reswords[i].word[1] == '_')
+ continue;
+ else if (c_common_reswords[i].disable
+ & (D_TRANSMEM | D_OBJC | D_CXX_OBJC))
+ continue;
+ else
+ {
+ tree id = get_identifier (c_common_reswords[i].word);
+ if (C_IS_RESERVED_WORD (id)
+ && C_RID_CODE (id) != RID_CXX_COMPAT_WARN)
+ cpp_lookup (parse_in,
+ (const unsigned char *) IDENTIFIER_POINTER (id),
+ IDENTIFIER_LENGTH (id))->flags |= NODE_WARN;
+ }
+ }
}
/* Create the VAR_DECL at LOC for __FUNCTION__ etc. ID is the name to
diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog
index 35d645c..8c47213 100644
--- a/gcc/cobol/ChangeLog
+++ b/gcc/cobol/ChangeLog
@@ -1,3 +1,13 @@
+2025-08-07 Robert Dubner <rdubner@symas.com>
+
+ * cbldiag.h (location_dump): Source code formatting.
+ * parse.y: error_msg formatting.
+ * scan.l: Remove UTF-8 character from regex pattern.
+ * scan_ante.h (numstr_of): error_msg formatting.
+ * show_parse.h (class ANALYZE): Suppress cppcheck error.
+ * util.cc (cbl_field_t::report_invalid_initial_value):
+ error_msg formatting.
+
2025-08-02 Jakub Jelinek <jakub@redhat.com>
* parse.y (intrinsic): Use %td format specifier with no cast on
diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h
index dd16190..2554deb 100644
--- a/gcc/cobol/cbldiag.h
+++ b/gcc/cobol/cbldiag.h
@@ -122,8 +122,8 @@ static void
location_dump( const char func[], int line, const char tag[], const LOC& loc) {
extern int yy_flex_debug; // cppcheck-suppress shadowVariable
if( yy_flex_debug ) {
- const char *detail = gcobol_getenv("update_location"); // cppcheck-suppress knownConditionTrueFalse
- if( detail ) {
+ const char *detail = gcobol_getenv("update_location");
+ if( detail ) { // cppcheck-suppress knownConditionTrueFalse
fprintf(stderr, "%s:%d: %s location (%d,%d) to (%d,%d)\n",
func, line, tag,
loc.first_line, loc.first_column, loc.last_line, loc.last_column);
diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index fae96ed..59cc64d 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -10336,8 +10336,8 @@ intrinsic: function_udf
if( p != NULL ) {
auto loc = symbol_field_location(field_index(p->field));
error_msg(loc, "FUNCTION %qs has "
- "inconsistent parameter type %td (%qs)",
- keyword_str($1), p - args.data(), name_of(p->field) );
+ "inconsistent parameter type %ld (%qs)",
+ keyword_str($1), (long)(p - args.data()), name_of(p->field) );
YYERROR;
}
$$ = is_numeric(args[0].field)?
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index ba4c044..5773f09 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -123,7 +123,7 @@ NUMEDCHAR [BPVZ90/,]+{COUNT}?
NUMEDCHARS {NUMEDCHAR}([.]?{NUMEDCHAR})*
NUMED ([+-]{NUMEDCHARS}+)|({NUMEDCHARS}+[+-])
CURRENCY [A-Zfhijklmoqtuwy\x80-\xFF]{-}[ABCDEGNPRSVXZ]
-NUMEDCUR (([.]?[-$0B/Z*+,P9()V+–]|{CURRENCY}+|{COUNT})+([.][$0B/Z*+P9()V+\–])*)+
+NUMEDCUR (([.]?[$0B/Z*+,P9()V+-]|{CURRENCY}+|{COUNT})+([.][$0B/Z*+P9()V+-])*)+
NUMEDITED {NUMED}|{NUMEDCUR}
EDITED {ALPHED}|{NUMED}|{NUMEDCUR}
diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h
index 31093a6..c00826d 100644
--- a/gcc/cobol/scan_ante.h
+++ b/gcc/cobol/scan_ante.h
@@ -149,7 +149,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) {
}
auto nx = std::count_if(input, p, fisdigit);
if( 36 < nx ) {
- error_msg(yylloc, "significand of %s has more than 36 digits (%td)", input, nx);
+ error_msg(yylloc, "significand of %s has more than 36 digits (%ld)", input, (long)nx);
return NO_CONDITION;
}
diff --git a/gcc/cobol/show_parse.h b/gcc/cobol/show_parse.h
index bd0e16f..e1a8cb2 100644
--- a/gcc/cobol/show_parse.h
+++ b/gcc/cobol/show_parse.h
@@ -500,7 +500,7 @@ class ANALYZE
int level;
inline static int analyze_level=1;
public:
- ANALYZE(const char *func_) : func(func_)
+ ANALYZE(const char *func_) : func(func_) // cppcheck-suppress noExplicitConstructor
{
level = 0;
if( getenv("Analyze") )
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index aed9483..2a7bf2b 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -1049,8 +1049,8 @@ cbl_field_t::report_invalid_initial_value(const YYLTYPE& loc) const {
return TOUPPER(ch) == 'E';
} );
if( !has_exponent && data.precision() < pend - p ) {
- error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%td)",
- name, data.initial, '.', pend - p);
+ error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%ld)",
+ name, data.initial, '.', (long)(pend - p));
}
}
}
diff --git a/gcc/common.opt b/gcc/common.opt
index bf38f60..c58ac13 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1620,6 +1620,18 @@ fdiagnostics-minimum-margin-width=
Common Joined UInteger Var(diagnostics_minimum_margin_width) Init(6)
Set minimum width of left margin of source code when showing source.
+fdiagnostics-show-nesting
+Common Var(flag_diagnostics_show_nesting) Init(1)
+Use indentation to show nesting of diagnostics in text output.
+
+fdiagnostics-show-nesting-locations
+Common Var(flag_diagnostics_show_nesting_locations) Init(1)
+Show location information when showing nested diagnostics.
+
+fdiagnostics-show-nesting-levels
+Common Var(flag_diagnostics_show_nesting_levels) Init(0)
+Show nesting levels as numbers when showing nested diagnostics.
+
fdisable-
Common Joined RejectNegative Var(common_deferred_options) Defer
-fdisable-[tree|rtl|ipa]-<pass>=range1+range2 Disable an optimization pass.
diff --git a/gcc/common.opt.urls b/gcc/common.opt.urls
index 38dd9d3..0bc36c4 100644
--- a/gcc/common.opt.urls
+++ b/gcc/common.opt.urls
@@ -640,6 +640,15 @@ UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-text
fdiagnostics-minimum-margin-width=
UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-minimum-margin-width)
+fdiagnostics-show-nesting
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting)
+
+fdiagnostics-show-nesting-locations
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting-locations)
+
+fdiagnostics-show-nesting-levels
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting-levels)
+
fdisable-
UrlSuffix(gcc/Developer-Options.html#index-fdisable-)
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index e394c9a..1764cf8 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -4590,8 +4590,9 @@ function_expander::expand ()
{
/* The last element of these functions is always an fpm_t that must be
written to FPMR before the call to the instruction itself. */
- gcc_assert (args.last ()->mode == DImode);
- emit_move_insn (gen_rtx_REG (DImode, FPM_REGNUM), args.last ());
+ rtx fpm = args.last ();
+ gcc_assert (CONST_INT_P (fpm) || GET_MODE (fpm) == DImode);
+ emit_move_insn (gen_rtx_REG (DImode, FPM_REGNUM), fpm);
}
rtx result = base->expand (*this);
if (function_returns_void_p ())
diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md
index 88d323a..51e2d7d 100644
--- a/gcc/config/aarch64/aarch64-sve.md
+++ b/gcc/config/aarch64/aarch64-sve.md
@@ -1542,18 +1542,18 @@
UNSPEC_LD1_GATHER))]
"TARGET_SVE && TARGET_NON_STREAMING"
{@ [cons: =0, 1, 2, 3, 4, 5 ]
- [&w, Z, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%2.s]
- [?w, Z, 0, Ui1, Ui1, Upl] ^
- [&w, vgw, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%2.s, #%1]
- [?w, vgw, 0, Ui1, Ui1, Upl] ^
- [&w, rk, w, Z, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, sxtw]
- [?w, rk, 0, Z, Ui1, Upl] ^
- [&w, rk, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, uxtw]
- [?w, rk, 0, Ui1, Ui1, Upl] ^
- [&w, rk, w, Z, i, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, sxtw %p4]
- [?w, rk, 0, Z, i, Upl] ^
- [&w, rk, w, Ui1, i, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, uxtw %p4]
- [?w, rk, 0, Ui1, i, Upl] ^
+ [&w, Z, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%2.s]
+ [?w, Z, 0, Ui1, Ui1, Upl] ^
+ [&w, vg<Vesize>, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%2.s, #%1]
+ [?w, vg<Vesize>, 0, Ui1, Ui1, Upl] ^
+ [&w, rk, w, Z, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, sxtw]
+ [?w, rk, 0, Z, Ui1, Upl] ^
+ [&w, rk, w, Ui1, Ui1, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, uxtw]
+ [?w, rk, 0, Ui1, Ui1, Upl] ^
+ [&w, rk, w, Z, i, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, sxtw %p4]
+ [?w, rk, 0, Z, i, Upl] ^
+ [&w, rk, w, Ui1, i, Upl] ld1<Vesize>\t%0.s, %5/z, [%1, %2.s, uxtw %p4]
+ [?w, rk, 0, Ui1, i, Upl] ^
}
)
@@ -1572,14 +1572,14 @@
UNSPEC_LD1_GATHER))]
"TARGET_SVE && TARGET_NON_STREAMING"
{@ [cons: =0, 1, 2, 3, 4, 5]
- [&w, Z, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%2.d]
- [?w, Z, 0, i, Ui1, Upl] ^
- [&w, vgd, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%2.d, #%1]
- [?w, vgd, 0, i, Ui1, Upl] ^
- [&w, rk, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%1, %2.d]
- [?w, rk, 0, i, Ui1, Upl] ^
- [&w, rk, w, i, i, Upl] ld1<Vesize>\t%0.d, %5/z, [%1, %2.d, lsl %p4]
- [?w, rk, 0, i, i, Upl] ^
+ [&w, Z, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%2.d]
+ [?w, Z, 0, i, Ui1, Upl] ^
+ [&w, vg<Vesize>, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%2.d, #%1]
+ [?w, vg<Vesize>, 0, i, Ui1, Upl] ^
+ [&w, rk, w, i, Ui1, Upl] ld1<Vesize>\t%0.d, %5/z, [%1, %2.d]
+ [?w, rk, 0, i, Ui1, Upl] ^
+ [&w, rk, w, i, i, Upl] ld1<Vesize>\t%0.d, %5/z, [%1, %2.d, lsl %p4]
+ [?w, rk, 0, i, i, Upl] ^
}
)
@@ -2488,13 +2488,13 @@
(match_operand:SVE_4 4 "register_operand")]
UNSPEC_ST1_SCATTER))]
"TARGET_SVE && TARGET_NON_STREAMING"
- {@ [ cons: 0 , 1 , 2 , 3 , 4 , 5 ]
- [ Z , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%1.s]
- [ vgw , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%1.s, #%0]
- [ rk , w , Z , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, sxtw]
- [ rk , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, uxtw]
- [ rk , w , Z , i , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, sxtw %p3]
- [ rk , w , Ui1 , i , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, uxtw %p3]
+ {@ [ cons: 0 , 1 , 2 , 3 , 4 , 5 ]
+ [ Z , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%1.s]
+ [ vg<Vesize> , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%1.s, #%0]
+ [ rk , w , Z , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, sxtw]
+ [ rk , w , Ui1 , Ui1 , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, uxtw]
+ [ rk , w , Z , i , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, sxtw %p3]
+ [ rk , w , Ui1 , i , w , Upl ] st1<Vesize>\t%4.s, %5, [%0, %1.s, uxtw %p3]
}
)
@@ -2511,11 +2511,11 @@
(match_operand:SVE_2 4 "register_operand")]
UNSPEC_ST1_SCATTER))]
"TARGET_SVE && TARGET_NON_STREAMING"
- {@ [ cons: 0 , 1 , 3 , 4 , 5 ]
- [ Z , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%1.d]
- [ vgd , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%1.d, #%0]
- [ rk , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%0, %1.d]
- [ rk , w , i , w , Upl ] st1<Vesize>\t%4.d, %5, [%0, %1.d, lsl %p3]
+ {@ [ cons: 0 , 1 , 3 , 4 , 5 ]
+ [ Z , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%1.d]
+ [ vg<Vesize> , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%1.d, #%0]
+ [ rk , w , Ui1 , w , Upl ] st1<Vesize>\t%4.d, %5, [%0, %1.d]
+ [ rk , w , i , w , Upl ] st1<Vesize>\t%4.d, %5, [%0, %1.d, lsl %p3]
}
)
diff --git a/gcc/config/aarch64/aarch64-sve2.md b/gcc/config/aarch64/aarch64-sve2.md
index a4c3257..a3cbbce 100644
--- a/gcc/config/aarch64/aarch64-sve2.md
+++ b/gcc/config/aarch64/aarch64-sve2.md
@@ -2211,14 +2211,14 @@
;; - FDOT (2-way, indexed) (FP8DOT2)
;; -------------------------------------------------------------------------
(define_insn "@aarch64_sve_dot<mode>"
- [(set (match_operand:SVE_FULL_HSF 0 "register_operand")
- (unspec:SVE_FULL_HSF
- [(match_operand:SVE_FULL_HSF 1 "register_operand")
+ [(set (match_operand:SVE_FULL_HSF_FP8_FDOT 0 "register_operand")
+ (unspec:SVE_FULL_HSF_FP8_FDOT
+ [(match_operand:SVE_FULL_HSF_FP8_FDOT 1 "register_operand")
(match_operand:VNx16QI 2 "register_operand")
(match_operand:VNx16QI 3 "register_operand")
(reg:DI FPM_REGNUM)]
UNSPEC_DOT_FP8))]
- "TARGET_SSVE_FP8DOT4 && !(<MODE>mode == VNx8HFmode && !TARGET_SSVE_FP8DOT2)"
+ ""
{@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
[ w , 0 , w , w ; * ] fdot\t%0.<Vetype>, %2.b, %3.b
[ ?&w , w , w , w ; yes ] movprfx\t%0, %1\;fdot\t%0.<Vetype>, %2.b, %3.b
@@ -2226,15 +2226,15 @@
)
(define_insn "@aarch64_sve_dot_lane<mode>"
- [(set (match_operand:SVE_FULL_HSF 0 "register_operand")
- (unspec:SVE_FULL_HSF
- [(match_operand:SVE_FULL_HSF 1 "register_operand")
+ [(set (match_operand:SVE_FULL_HSF_FP8_FDOT 0 "register_operand")
+ (unspec:SVE_FULL_HSF_FP8_FDOT
+ [(match_operand:SVE_FULL_HSF_FP8_FDOT 1 "register_operand")
(match_operand:VNx16QI 2 "register_operand")
(match_operand:VNx16QI 3 "register_operand")
(match_operand:SI 4 "const_int_operand")
(reg:DI FPM_REGNUM)]
UNSPEC_DOT_LANE_FP8))]
- "TARGET_SSVE_FP8DOT4 && !(<MODE>mode == VNx8HFmode && !TARGET_SSVE_FP8DOT2)"
+ ""
{@ [ cons: =0 , 1 , 2 , 3 ; attrs: movprfx ]
[ w , 0 , w , y ; * ] fdot\t%0.<Vetype>, %2.b, %3.b[%4]
[ ?&w , w , w , y ; yes ] movprfx\t%0, %1\;fdot\t%0.<Vetype>, %2.b, %3.b[%4]
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index d30c9c7..2dbaf4a 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -25435,20 +25435,41 @@ aarch64_asm_preferred_eh_data_format (int code ATTRIBUTE_UNUSED, int global)
return (global ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | type;
}
+/* Return true if function declaration FNDECL needs to be marked as
+ having a variant PCS. */
+
+static bool
+aarch64_is_variant_pcs (tree fndecl)
+{
+ /* Check for ABIs that preserve more registers than usual. */
+ arm_pcs pcs = (arm_pcs) fndecl_abi (fndecl).id ();
+ if (pcs == ARM_PCS_SIMD || pcs == ARM_PCS_SVE)
+ return true;
+
+ /* Check for ABIs that allow PSTATE.SM to be 1 on entry. */
+ tree fntype = TREE_TYPE (fndecl);
+ if (aarch64_fntype_pstate_sm (fntype) != AARCH64_ISA_MODE_SM_OFF)
+ return true;
+
+ /* Check for ABIs that require PSTATE.ZA to be 1 on entry, either because
+ of ZA or ZT0. */
+ if (aarch64_fntype_pstate_za (fntype) != 0)
+ return true;
+
+ return false;
+}
+
/* Output .variant_pcs for aarch64_vector_pcs function symbols. */
static void
aarch64_asm_output_variant_pcs (FILE *stream, const tree decl, const char* name)
{
- if (TREE_CODE (decl) == FUNCTION_DECL)
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && aarch64_is_variant_pcs (decl))
{
- arm_pcs pcs = (arm_pcs) fndecl_abi (decl).id ();
- if (pcs == ARM_PCS_SIMD || pcs == ARM_PCS_SVE)
- {
- fprintf (stream, "\t.variant_pcs\t");
- assemble_name (stream, name);
- fprintf (stream, "\n");
- }
+ fprintf (stream, "\t.variant_pcs\t");
+ assemble_name (stream, name);
+ fprintf (stream, "\n");
}
}
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index 8f8237e..68b080d 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -543,6 +543,12 @@
;; elements.
(define_mode_iterator SVE_FULL_HSF [VNx8HF VNx4SF])
+;; Like SVE_FULL_HSF, but selectively enables those modes that are valid
+;; for the variant of the SVE2 FP8 FDOT instruction associated with that
+;; mode.
+(define_mode_iterator SVE_FULL_HSF_FP8_FDOT [(VNx4SF "TARGET_SSVE_FP8DOT4")
+ (VNx8HF "TARGET_SSVE_FP8DOT2")])
+
;; Partial SVE floating-point vector modes that have 16-bit or 32-bit
;; elements.
(define_mode_iterator SVE_PARTIAL_HSF [VNx2HF VNx4HF VNx2SF])
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 29b45ae..8b951f3 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -18983,7 +18983,8 @@ cmse_nonsecure_call_inline_register_clear (void)
call = SET_SRC (call);
/* Check if it is a cmse_nonsecure_call. */
- unspec = XEXP (call, 0);
+ unspec = XVECEXP (pat, 0, 2);
+
if (GET_CODE (unspec) != UNSPEC
|| XINT (unspec, 1) != UNSPEC_NONSECURE_MEM)
continue;
@@ -19010,7 +19011,7 @@ cmse_nonsecure_call_inline_register_clear (void)
/* Make sure the register used to hold the function address is not
cleared. */
- address = RTVEC_ELT (XVEC (unspec, 0), 0);
+ address = XEXP (call, 0);
gcc_assert (MEM_P (address));
gcc_assert (REG_P (XEXP (address, 0)));
address_regnum = REGNO (XEXP (address, 0));
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 5e5e112..537a3e2 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -8623,7 +8623,7 @@
if (detect_cmse_nonsecure_call (addr))
{
pat = gen_nonsecure_call_internal (operands[0], operands[1],
- operands[2]);
+ operands[2], const0_rtx);
emit_call_insn (pat);
}
else
@@ -8665,10 +8665,10 @@
(clobber (reg:SI LR_REGNUM))])])
(define_expand "nonsecure_call_internal"
- [(parallel [(call (unspec:SI [(match_operand 0 "memory_operand")]
- UNSPEC_NONSECURE_MEM)
+ [(parallel [(call (match_operand 0 "memory_operand")
(match_operand 1 "general_operand"))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))])]
"use_cmse"
{
@@ -8745,7 +8745,8 @@
if (detect_cmse_nonsecure_call (addr))
{
pat = gen_nonsecure_call_value_internal (operands[0], operands[1],
- operands[2], operands[3]);
+ operands[2], operands[3],
+ const0_rtx);
emit_call_insn (pat);
}
else
@@ -8779,10 +8780,10 @@
(define_expand "nonsecure_call_value_internal"
[(parallel [(set (match_operand 0 "" "")
- (call (unspec:SI [(match_operand 1 "memory_operand")]
- UNSPEC_NONSECURE_MEM)
+ (call (match_operand 1 "memory_operand")
(match_operand 2 "general_operand")))
(use (match_operand 3 "" ""))
+ (unspec:SI [(match_operand 4)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))])]
"use_cmse"
"
diff --git a/gcc/config/arm/thumb1.md b/gcc/config/arm/thumb1.md
index f9e89e9..4da0086 100644
--- a/gcc/config/arm/thumb1.md
+++ b/gcc/config/arm/thumb1.md
@@ -1874,10 +1874,10 @@
)
(define_insn "*nonsecure_call_reg_thumb1_v5"
- [(call (unspec:SI [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (reg:SI R4_REGNUM))
(match_operand 0 "" ""))
(use (match_operand 1 "" ""))
+ (unspec:SI [(match_operand 2)]UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB1 && use_cmse && !SIBLING_CALL_P (insn)"
"bl\\t__gnu_cmse_nonsecure_call"
@@ -1919,11 +1919,10 @@
(define_insn "*nonsecure_call_value_reg_thumb1_v5"
[(set (match_operand 0 "" "")
- (call (unspec:SI
- [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ (call (mem:SI (reg:SI R4_REGNUM))
(match_operand 1 "" "")))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB1 && use_cmse"
"bl\\t__gnu_cmse_nonsecure_call"
diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
index 019f9d4..2c2026b 100644
--- a/gcc/config/arm/thumb2.md
+++ b/gcc/config/arm/thumb2.md
@@ -537,10 +537,10 @@
)
(define_insn "*nonsecure_call_reg_thumb2_fpcxt"
- [(call (unspec:SI [(mem:SI (match_operand:SI 0 "s_register_operand" "l*r"))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (match_operand:SI 0 "s_register_operand" "l*r"))
(match_operand 1 "" ""))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && TARGET_HAVE_FPCXT_CMSE"
"blxns\\t%0"
@@ -549,10 +549,10 @@
)
(define_insn "*nonsecure_call_reg_thumb2"
- [(call (unspec:SI [(mem:SI (reg:SI R4_REGNUM))]
- UNSPEC_NONSECURE_MEM)
+ [(call (mem:SI (reg:SI R4_REGNUM))
(match_operand 0 "" ""))
(use (match_operand 1 "" ""))
+ (unspec:SI [(match_operand 2)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && !TARGET_HAVE_FPCXT_CMSE"
"bl\\t__gnu_cmse_nonsecure_call"
@@ -573,11 +573,10 @@
(define_insn "*nonsecure_call_value_reg_thumb2_fpcxt"
[(set (match_operand 0 "" "")
- (call
- (unspec:SI [(mem:SI (match_operand:SI 1 "register_operand" "l*r"))]
- UNSPEC_NONSECURE_MEM)
- (match_operand 2 "" "")))
+ (call (mem:SI (match_operand:SI 1 "register_operand" "l*r"))
+ (match_operand 2 "" "")))
(use (match_operand 3 "" ""))
+ (unspec:SI [(match_operand 4)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && TARGET_HAVE_FPCXT_CMSE"
"blxns\\t%1"
@@ -587,10 +586,10 @@
(define_insn "*nonsecure_call_value_reg_thumb2"
[(set (match_operand 0 "" "")
- (call
- (unspec:SI [(mem:SI (reg:SI R4_REGNUM))] UNSPEC_NONSECURE_MEM)
- (match_operand 1 "" "")))
+ (call (mem:SI (reg:SI R4_REGNUM))
+ (match_operand 1 "" "")))
(use (match_operand 2 "" ""))
+ (unspec:SI [(match_operand 3)] UNSPEC_NONSECURE_MEM)
(clobber (reg:SI LR_REGNUM))]
"TARGET_THUMB2 && use_cmse && !TARGET_HAVE_FPCXT_CMSE"
"bl\\t__gnu_cmse_nonsecure_call"
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index be2daed..1724084 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -1298,6 +1298,29 @@ darwin_encode_section_info (tree decl, rtx rtl, int first)
SYMBOL_FLAG_EXTERNAL. */
default_encode_section_info (decl, rtl, first);
+ if (CONSTANT_CLASS_P (decl))
+ {
+ bool is_str = TREE_CODE (decl) == STRING_CST;
+ rtx sym_ref = XEXP (rtl, 0);
+
+ /* If this is a string cst or not anchored we have nothing to do. */
+ if (is_str || !SYMBOL_REF_HAS_BLOCK_INFO_P (sym_ref))
+ return;
+
+ tree sym_decl = SYMBOL_REF_DECL (sym_ref);
+ const char *name = XSTR (sym_ref, 0);
+ gcc_checking_assert (strncmp ("*lC", name, 3) == 0);
+
+ char *buf;
+ /* Lets identify anchored constants with a different prefix, for the
+ sake of inspection only. */
+ buf = xasprintf ("*LaC%s", &name[3]);
+ if (sym_decl)
+ DECL_NAME (sym_decl) = get_identifier (buf);
+ XSTR (sym_ref, 0) = ggc_strdup (buf);
+ free (buf);
+ }
+
if (! VAR_OR_FUNCTION_DECL_P (decl))
return;
@@ -3297,11 +3320,16 @@ darwin_use_anchors_for_symbol_p (const_rtx symbol)
{
if (DARWIN_SECTION_ANCHORS && flag_section_anchors)
{
- section *sect;
- /* If the section contains a zero-sized object it's ineligible. */
- sect = SYMBOL_REF_BLOCK (symbol)->sect;
- /* This should have the effect of disabling anchors for vars that follow
- any zero-sized one, in a given section. */
+ tree decl = SYMBOL_REF_DECL (symbol);
+ /* If the symbol would be linker-visible, then it can split at that
+ so we must disallow. This is more strict than the default impl.
+ TODO: add other cases. */
+ if (decl && DECL_P (decl)
+ && (TREE_PUBLIC (decl) || !DECL_ARTIFICIAL (decl)))
+ return false;
+
+ /* We mark sections containing unsuitable entries. */
+ section *sect = SYMBOL_REF_BLOCK (symbol)->sect;
if (sect->common.flags & SECTION_NO_ANCHOR)
return false;
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 9b9a3fe..ccfe01e 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1005,6 +1005,8 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
else if (strcmp ("LTRAMP", PREFIX) == 0) \
sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\
+ else if (strncmp ("LANCHOR", PREFIX, 7) == 0) \
+ sprintf (LABEL, "*%s%ld", "lANCHOR", (long)(NUM));\
else \
sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \
} while (0)
diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 012b6db..d044f9a 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -9239,15 +9239,12 @@ print_operand (FILE *file, rtx x, int code)
else if (code == 'h')
fprintf (file, HOST_WIDE_INT_PRINT_DEC,
((CONST_WIDE_INT_ELT (x, 0) & 0xffff) ^ 0x8000) - 0x8000);
+ /* Support arbitrary _BitInt constants in asm statements. */
+ else if (code == 0)
+ output_addr_const (file, x);
else
- {
- if (code == 0)
- output_operand_lossage ("invalid constant - try using "
- "an output modifier");
- else
- output_operand_lossage ("invalid constant for output modifier '%c'",
- code);
- }
+ output_operand_lossage ("invalid constant for output modifier '%c'",
+ code);
break;
case CONST_VECTOR:
switch (code)
@@ -18768,6 +18765,27 @@ s390_c_mode_for_floating_type (enum tree_index ti)
return default_mode_for_floating_type (ti);
}
+/* Return true if _BitInt(N) is supported and fill its details into *INFO. */
+
+bool
+s390_bitint_type_info (int n, struct bitint_info *info)
+{
+ if (!TARGET_64BIT)
+ return false;
+ if (n <= 8)
+ info->limb_mode = QImode;
+ else if (n <= 16)
+ info->limb_mode = HImode;
+ else if (n <= 32)
+ info->limb_mode = SImode;
+ else
+ info->limb_mode = DImode;
+ info->abi_limb_mode = info->limb_mode;
+ info->big_endian = true;
+ info->extended = true;
+ return true;
+}
+
/* Initialize GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -19089,6 +19107,9 @@ s390_c_mode_for_floating_type (enum tree_index ti)
#undef TARGET_DOCUMENTATION_NAME
#define TARGET_DOCUMENTATION_NAME "S/390"
+#undef TARGET_C_BITINT_TYPE_INFO
+#define TARGET_C_BITINT_TYPE_INFO s390_bitint_type_info
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-s390.h"
diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md
index 77c9571..727ec1e 100644
--- a/gcc/config/xtensa/constraints.md
+++ b/gcc/config/xtensa/constraints.md
@@ -130,7 +130,7 @@
(and (match_code "mem")
(match_test "smalloffset_mem_p (op)")))
-(define_memory_constraint "T"
+(define_special_memory_constraint "T"
"Memory in a literal pool (addressable with an L32R instruction)."
(and (match_code "mem")
(match_test "!TARGET_CONST16 && constantpool_mem_p (op)")))
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cb4ff09..b85f527 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,78 @@
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ * error.cc (cp_adjust_diagnostic_info): Convert "context" arg from
+ ptr to const &.
+
+2025-08-07 Patrick Palka <ppalka@redhat.com>
+
+ * call.cc (extract_call_expr): Remove handling of C++20
+ rewritten comparison operators.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/117783
+ * parser.cc: Implement C++26 P1061R10 - Structured Bindings can
+ introduce a Pack.
+ (cp_parser_range_for): Also handle TREE_VEC as DECL_VALUE_EXPR
+ instead of ARRAY_REF.
+ (cp_parser_decomposition_declaration): Use sb-identifier-list instead
+ of identifier-list in comments. Parse structured bindings with
+ structured binding pack. Don't emit pedwarn about structured
+ binding attributes in structured bindings inside of a condition.
+ (cp_convert_omp_range_for): Also handle TREE_VEC as DECL_VALUE_EXPR
+ instead of ARRAY_REF.
+ * decl.cc (get_tuple_element_type): Change i argument type from
+ unsigned to unsigned HOST_WIDE_INT.
+ (get_tuple_decomp_init): Likewise.
+ (set_sb_pack_name): New function.
+ (cp_finish_decomp): Handle structured binding packs.
+ * pt.cc (tsubst_pack_expansion): Handle structured binding packs
+ and capture proxies for them. Formatting fixes.
+ (tsubst_decl): For structured binding packs don't tsubst TREE_TYPE
+ first, instead recreate the type after r is created.
+ (tsubst_omp_for_iterator): Also handle TREE_VEC as DECL_VALUE_EXPR
+ instead of ARRAY_REF.
+ (tsubst_expr): Handle sizeof... on non-dependent structure binding
+ packs.
+ (value_dependent_expression_p): Return false for sizeof... on
+ non-dependent structure binding packs.
+ (instantiation_dependent_r): Don't recurse on sizeof... on
+ non-dependent structure binding packs.
+ * constexpr.cc (potential_constant_expression_1): Also handle
+ TREE_VEC on DECL_VALUE_EXPR of structure binding packs.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * lex.cc (cxx_init): Mark cpp nodes corresponding
+ to keywords, identifiers with special meaning and standard
+ attribute identifiers as NODE_WARN if warn_keyword_macro.
+
+2025-08-06 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/121231
+ PR c++/119688
+ PR c++/94511
+ * mangle.cc (write_expression): Write out implicit non-trailing
+ zeroes of a CONSTRUCTOR when the ABI version is at least 21.
+
+2025-08-06 Jason Merrill <jason@redhat.com>
+
+ * constexpr.cc (cxx_eval_indirect_ref): Improve diagnostic.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * parser.cc (cp_parser_omp_clause_from_to): Parse 'iterator' modifier.
+ * semantics.cc (finish_omp_clauses): Finish iterators for to/from
+ clauses.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+ Andrew Stubbs <ams@baylibre.com>
+
+ * parser.cc (cp_parser_omp_clause_map): Parse 'iterator' modifier.
+ * semantics.cc (finish_omp_clauses): Finish iterators. Apply
+ iterators to generated clauses.
+
2025-08-05 Jason Merrill <jason@redhat.com>
PR c++/121068
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 9283d97..63cad2a 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -7904,28 +7904,6 @@ extract_call_expr (tree call)
call = TREE_OPERAND (call, 0);
if (TREE_CODE (call) == TARGET_EXPR)
call = TARGET_EXPR_INITIAL (call);
- if (cxx_dialect >= cxx20)
- switch (TREE_CODE (call))
- {
- /* C++20 rewritten comparison operators. */
- case TRUTH_NOT_EXPR:
- call = TREE_OPERAND (call, 0);
- break;
- case LT_EXPR:
- case LE_EXPR:
- case GT_EXPR:
- case GE_EXPR:
- case SPACESHIP_EXPR:
- {
- tree op0 = TREE_OPERAND (call, 0);
- if (integer_zerop (op0))
- call = TREE_OPERAND (call, 1);
- else
- call = op0;
- }
- break;
- default:;
- }
if (TREE_CODE (call) != CALL_EXPR
&& TREE_CODE (call) != AGGR_INIT_EXPR
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index b8ac454..eabf7f8 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -11615,12 +11615,14 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
}
return false;
}
+ tree ve = DECL_VALUE_EXPR (t);
/* Treat __PRETTY_FUNCTION__ inside a template function as
potentially-constant. */
- else if (DECL_PRETTY_FUNCTION_P (t)
- && DECL_VALUE_EXPR (t) == error_mark_node)
+ if (DECL_PRETTY_FUNCTION_P (t) && ve == error_mark_node)
return true;
- return RECUR (DECL_VALUE_EXPR (t), rval);
+ if (DECL_DECOMPOSITION_P (t) && TREE_CODE (ve) == TREE_VEC)
+ return RECUR (TREE_VEC_ELT (ve, 0), rval);
+ return RECUR (ve, rval);
}
if (want_rval
&& (now || !var_in_maybe_constexpr_fn (t))
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 8122fca..ab5b0c9 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -9748,7 +9748,7 @@ get_tuple_size (tree type)
/* Return std::tuple_element<I,TYPE>::type. */
static tree
-get_tuple_element_type (tree type, unsigned i)
+get_tuple_element_type (tree type, unsigned HOST_WIDE_INT i)
{
tree args = make_tree_vec (2);
TREE_VEC_ELT (args, 0) = build_int_cst (integer_type_node, i);
@@ -9764,7 +9764,7 @@ get_tuple_element_type (tree type, unsigned i)
/* Return e.get<i>() or get<i>(e). */
static tree
-get_tuple_decomp_init (tree decl, unsigned i)
+get_tuple_decomp_init (tree decl, unsigned HOST_WIDE_INT i)
{
tree targs = make_tree_vec (1);
TREE_VEC_ELT (targs, 0) = build_int_cst (integer_type_node, i);
@@ -9870,6 +9870,19 @@ cp_maybe_mangle_decomp (tree decl, cp_decomp *decomp)
}
}
+/* Append #i to DECL_NAME (decl). */
+
+static void
+set_sb_pack_name (tree decl, unsigned HOST_WIDE_INT i)
+{
+ tree name = DECL_NAME (decl);
+ size_t len = IDENTIFIER_LENGTH (name) + 22;
+ char *n = XALLOCAVEC (char, len);
+ snprintf (n, len, "%s#" HOST_WIDE_INT_PRINT_UNSIGNED,
+ IDENTIFIER_POINTER (name), i);
+ DECL_NAME (decl) = get_identifier (n);
+}
+
/* Finish a decomposition declaration. DECL is the underlying declaration
"e", FIRST is the head of a chain of decls for the individual identifiers
chained through DECL_CHAIN in reverse order and COUNT is the number of
@@ -9926,10 +9939,13 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
auto_vec<tree, 16> v;
v.safe_grow (count, true);
tree d = first;
+ int pack = -1;
for (unsigned int i = 0; i < count; i++, d = DECL_CHAIN (d))
{
v[count - i - 1] = d;
fit_decomposition_lang_decl (d, decl);
+ if (DECL_PACK_P (d))
+ pack = count - i - 1;
}
tree type = TREE_TYPE (decl);
@@ -9951,6 +9967,14 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
tree eltype = NULL_TREE;
unsigned HOST_WIDE_INT eltscnt = 0;
+ /* Structured binding packs when initializer is non-dependent should
+ have their DECL_VALUE_EXPR set to a TREE_VEC. First two elements
+ of that TREE_VEC are the base and index, what is normally represented
+ as DECL_VALUE_EXPR ARRAY_REF <base, index> where index is the index
+ of the pack first element. The remaining elements of the TREE_VEC
+ are VAR_DECLs for the pack elements. */
+ tree packv = NULL_TREE;
+
if (TREE_CODE (type) == ARRAY_TYPE)
{
tree nelts;
@@ -9969,7 +9993,7 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
goto error_out;
}
eltscnt = tree_to_uhwi (nelts);
- if (count != eltscnt)
+ if (pack != -1 ? count - 1 > eltscnt : count != eltscnt)
{
cnt_mismatch:
auto_diagnostic_group d;
@@ -9990,12 +10014,37 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
eltype = TREE_TYPE (type);
for (unsigned int i = 0; i < count; i++)
{
+ if ((unsigned) pack == i)
+ {
+ packv = make_tree_vec (eltscnt - count + 3);
+ for (unsigned HOST_WIDE_INT j = 0; j < eltscnt - count + 1; ++j)
+ {
+ tree t;
+ TREE_VEC_ELT (packv, j + 2) = t = copy_node (v[pack]);
+ set_sb_pack_name (t, j);
+ maybe_push_decl (t);
+ TREE_TYPE (t) = eltype;
+ layout_decl (t, 0);
+ if (!processing_template_decl)
+ {
+ tree a = unshare_expr (dexp);
+ a = build4 (ARRAY_REF, eltype, a, size_int (j + pack),
+ NULL_TREE, NULL_TREE);
+ SET_DECL_VALUE_EXPR (t, a);
+ DECL_HAS_VALUE_EXPR_P (t) = 1;
+ }
+ }
+ continue;
+ }
TREE_TYPE (v[i]) = eltype;
layout_decl (v[i], 0);
if (processing_template_decl)
continue;
tree t = unshare_expr (dexp);
- t = build4 (ARRAY_REF, eltype, t, size_int (i), NULL_TREE, NULL_TREE);
+ unsigned HOST_WIDE_INT j = i;
+ if (pack != -1 && (unsigned) pack < i)
+ j = i + eltscnt - count;
+ t = build4 (ARRAY_REF, eltype, t, size_int (j), NULL_TREE, NULL_TREE);
SET_DECL_VALUE_EXPR (v[i], t);
DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
}
@@ -10004,17 +10053,41 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
else if (TREE_CODE (type) == COMPLEX_TYPE)
{
eltscnt = 2;
- if (count != eltscnt)
+ if (pack != -1 ? count - 1 > eltscnt : count != eltscnt)
goto cnt_mismatch;
eltype = cp_build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
for (unsigned int i = 0; i < count; i++)
{
+ if ((unsigned) pack == i)
+ {
+ packv = make_tree_vec (eltscnt - count + 3);
+ for (unsigned HOST_WIDE_INT j = 0; j < eltscnt - count + 1; ++j)
+ {
+ tree t;
+ TREE_VEC_ELT (packv, j + 2) = t = copy_node (v[pack]);
+ set_sb_pack_name (t, j);
+ maybe_push_decl (t);
+ TREE_TYPE (t) = eltype;
+ layout_decl (t, 0);
+ if (!processing_template_decl)
+ {
+ tree a = build1 (pack + j ? IMAGPART_EXPR : REALPART_EXPR, eltype,
+ unshare_expr (dexp));
+ SET_DECL_VALUE_EXPR (t, a);
+ DECL_HAS_VALUE_EXPR_P (t) = 1;
+ }
+ }
+ continue;
+ }
TREE_TYPE (v[i]) = eltype;
layout_decl (v[i], 0);
if (processing_template_decl)
continue;
tree t = unshare_expr (dexp);
- t = build1 (i ? IMAGPART_EXPR : REALPART_EXPR, eltype, t);
+ unsigned HOST_WIDE_INT j = i;
+ if (pack != -1 && (unsigned) pack < i)
+ j = i + eltscnt - count;
+ t = build1 (j ? IMAGPART_EXPR : REALPART_EXPR, eltype, t);
SET_DECL_VALUE_EXPR (v[i], t);
DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
}
@@ -10026,19 +10099,47 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
error_at (loc, "cannot decompose variable length vector %qT", type);
goto error_out;
}
- if (count != eltscnt)
+ if (pack != -1 ? count - 1 > eltscnt : count != eltscnt)
goto cnt_mismatch;
eltype = cp_build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
for (unsigned int i = 0; i < count; i++)
{
+ if ((unsigned) pack == i)
+ {
+ packv = make_tree_vec (eltscnt - count + 3);
+ for (unsigned HOST_WIDE_INT j = 0; j < eltscnt - count + 1; ++j)
+ {
+ tree t;
+ TREE_VEC_ELT (packv, j + 2) = t = copy_node (v[pack]);
+ set_sb_pack_name (t, j);
+ maybe_push_decl (t);
+ TREE_TYPE (t) = eltype;
+ layout_decl (t, 0);
+ if (!processing_template_decl)
+ {
+ tree a = unshare_expr (dexp);
+ location_t loc = DECL_SOURCE_LOCATION (t);
+ tree s = size_int (j + pack);
+ convert_vector_to_array_for_subscript (loc, &a, s);
+ a = build4 (ARRAY_REF, eltype, a, s,
+ NULL_TREE, NULL_TREE);
+ SET_DECL_VALUE_EXPR (t, a);
+ DECL_HAS_VALUE_EXPR_P (t) = 1;
+ }
+ }
+ continue;
+ }
TREE_TYPE (v[i]) = eltype;
layout_decl (v[i], 0);
if (processing_template_decl)
continue;
tree t = unshare_expr (dexp);
+ unsigned HOST_WIDE_INT j = i;
+ if (pack != -1 && (unsigned) pack < i)
+ j = i + eltscnt - count;
convert_vector_to_array_for_subscript (DECL_SOURCE_LOCATION (v[i]),
- &t, size_int (i));
- t = build4 (ARRAY_REF, eltype, t, size_int (i), NULL_TREE, NULL_TREE);
+ &t, size_int (j));
+ t = build4 (ARRAY_REF, eltype, t, size_int (j), NULL_TREE, NULL_TREE);
SET_DECL_VALUE_EXPR (v[i], t);
DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
}
@@ -10062,11 +10163,11 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
goto error_out;
}
eltscnt = tree_to_uhwi (tsize);
- if (count != eltscnt)
+ if (pack != -1 ? count - 1 > eltscnt : count != eltscnt)
goto cnt_mismatch;
- if (test_p)
+ if (test_p && eltscnt)
return true;
- if (!processing_template_decl && DECL_DECOMP_BASE (decl))
+ if (!processing_template_decl && DECL_DECOMP_BASE (decl) && eltscnt)
{
/* For structured bindings used in conditions we need to evaluate
the conversion of decl (aka e in the standard) to bool or
@@ -10096,16 +10197,70 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
location_t sloc = input_location;
location_t dloc = DECL_SOURCE_LOCATION (v[i]);
+ if ((unsigned) pack == i)
+ {
+ packv = make_tree_vec (eltscnt - count + 3);
+ for (unsigned HOST_WIDE_INT j = 0; j < eltscnt - count + 1; ++j)
+ {
+ tree t;
+ TREE_VEC_ELT (packv, j + 2) = t = copy_node (v[pack]);
+ set_sb_pack_name (t, j);
+ input_location = dloc;
+ tree init = get_tuple_decomp_init (decl, j + pack);
+ tree eltype = (init == error_mark_node ? error_mark_node
+ : get_tuple_element_type (type, j + pack));
+ input_location = sloc;
+
+ if (VOID_TYPE_P (eltype))
+ {
+ error ("%<std::tuple_element<%wu, %T>::type%> is "
+ "%<void%>", j + pack, type);
+ eltype = error_mark_node;
+ }
+ if (init == error_mark_node || eltype == error_mark_node)
+ {
+ inform (dloc, "in initialization of structured binding "
+ "pack %qD", v[pack]);
+ goto error_out;
+ }
+ if (j == 0
+ && !processing_template_decl
+ && TREE_STATIC (decl))
+ {
+ sorry_at (dloc, "mangling of structured binding pack "
+ "elements not implemented yet");
+ goto error_out;
+ }
+ maybe_push_decl (t);
+ /* Save the decltype away before reference collapse. */
+ hash_map_safe_put<hm_ggc> (decomp_type_table, t, eltype);
+ eltype = cp_build_reference_type (eltype, !lvalue_p (init));
+ TREE_TYPE (t) = eltype;
+ layout_decl (t, 0);
+ DECL_HAS_VALUE_EXPR_P (t) = 0;
+ if (!processing_template_decl)
+ {
+ copy_linkage (t, decl);
+ cp_finish_decl (t, init, /*constexpr*/false,
+ /*asm*/NULL_TREE, LOOKUP_NORMAL);
+ }
+ }
+ continue;
+ }
+
+ unsigned HOST_WIDE_INT j = i;
+ if (pack != -1 && (unsigned) pack < i)
+ j = i + eltscnt - count;
input_location = dloc;
- tree init = get_tuple_decomp_init (decl, i);
+ tree init = get_tuple_decomp_init (decl, j);
tree eltype = (init == error_mark_node ? error_mark_node
- : get_tuple_element_type (type, i));
+ : get_tuple_element_type (type, j));
input_location = sloc;
if (VOID_TYPE_P (eltype))
{
- error ("%<std::tuple_element<%u, %T>::type%> is %<void%>",
- i, type);
+ error ("%<std::tuple_element<%wu, %T>::type%> is %<void%>",
+ j, type);
eltype = error_mark_node;
}
if (init == error_mark_node || eltype == error_mark_node)
@@ -10159,6 +10314,12 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
goto error_out;
else if (btype == NULL_TREE)
{
+ if (pack == 0 && count == 1)
+ {
+ eltscnt = 0;
+ packv = make_tree_vec (2);
+ goto done;
+ }
error_at (loc, "cannot decompose class type %qT without non-static "
"data members", type);
goto error_out;
@@ -10170,7 +10331,7 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
continue;
else
eltscnt++;
- if (count != eltscnt)
+ if (pack != -1 ? count - 1 > eltscnt : count != eltscnt)
goto cnt_mismatch;
tree t = dexp;
if (type != btype)
@@ -10179,6 +10340,7 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
/*nonnull*/false, tf_warning_or_error);
type = btype;
}
+ unsigned HOST_WIDE_INT j = 0;
unsigned int i = 0;
for (tree field = TYPE_FIELDS (btype); field; field = TREE_CHAIN (field))
if (TREE_CODE (field) != FIELD_DECL
@@ -10191,6 +10353,32 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
NULL_TREE);
if (REFERENCE_REF_P (tt))
tt = TREE_OPERAND (tt, 0);
+ if (pack != -1 && j >= (unsigned) pack)
+ {
+ if (j == (unsigned) pack)
+ {
+ packv = make_tree_vec (eltscnt - count + 3);
+ i++;
+ }
+ if (j < (unsigned) pack + eltscnt - (count - 1))
+ {
+ tree t;
+ TREE_VEC_ELT (packv, j + 3 - i) = t = copy_node (v[pack]);
+ set_sb_pack_name (t, j + 1 - i);
+ maybe_push_decl (t);
+ TREE_TYPE (t) = TREE_TYPE (tt);
+ layout_decl (t, 0);
+ if (!processing_template_decl)
+ {
+ SET_DECL_VALUE_EXPR (t, tt);
+ DECL_HAS_VALUE_EXPR_P (t) = 1;
+ }
+ else
+ DECL_HAS_VALUE_EXPR_P (t) = 0;
+ j++;
+ continue;
+ }
+ }
TREE_TYPE (v[i]) = TREE_TYPE (tt);
layout_decl (v[i], 0);
if (!processing_template_decl)
@@ -10199,7 +10387,26 @@ cp_finish_decomp (tree decl, cp_decomp *decomp, bool test_p)
DECL_HAS_VALUE_EXPR_P (v[i]) = 1;
}
i++;
+ j++;
}
+ if (pack != -1 && j == (unsigned) pack)
+ {
+ gcc_checking_assert (eltscnt == count - 1);
+ packv = make_tree_vec (2);
+ }
+ }
+ done:
+ if (packv)
+ {
+ gcc_checking_assert (pack != -1);
+ TREE_VEC_ELT (packv, 0) = decl;
+ TREE_VEC_ELT (packv, 1) = size_int (pack);
+ SET_DECL_VALUE_EXPR (v[pack], packv);
+ DECL_HAS_VALUE_EXPR_P (v[pack]) = 1;
+ DECL_IGNORED_P (v[pack]) = 1;
+ if (!processing_template_decl)
+ for (unsigned int i = 0; i < TREE_VEC_LENGTH (packv) - 2U; ++i)
+ pushdecl (TREE_VEC_ELT (packv, 2 + i));
}
if (processing_template_decl)
{
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index c427163..cd35c7a 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -250,7 +250,7 @@ erroneous_templates_t *erroneous_templates;
issue an error if we later need to instantiate the template. */
static void
-cp_adjust_diagnostic_info (diagnostics::context *context,
+cp_adjust_diagnostic_info (const diagnostics::context &context,
diagnostics::diagnostic_info *diagnostic)
{
if (diagnostic->m_kind == diagnostics::kind::error)
@@ -258,7 +258,7 @@ cp_adjust_diagnostic_info (diagnostics::context *context,
{
diagnostic->m_option_id = OPT_Wtemplate_body;
- if (context->m_permissive)
+ if (context.m_permissive)
diagnostic->m_kind = diagnostics::kind::warning;
bool existed;
diff --git a/gcc/cp/lex.cc b/gcc/cp/lex.cc
index 08a6348..b7d2ac6 100644
--- a/gcc/cp/lex.cc
+++ b/gcc/cp/lex.cc
@@ -368,6 +368,66 @@ cxx_init (void)
cxx_init_decl_processing ();
+ if (warn_keyword_macro)
+ {
+ for (unsigned int i = 0; i < num_c_common_reswords; ++i)
+ /* For C++ none of the keywords in [lex.key] starts with underscore,
+ don't register anything like that. Don't complain about
+ ObjC or Transactional Memory keywords. */
+ if (c_common_reswords[i].word[0] == '_')
+ continue;
+ else if (c_common_reswords[i].disable & (D_TRANSMEM | D_OBJC))
+ continue;
+ else
+ {
+ tree id = get_identifier (c_common_reswords[i].word);
+ if (IDENTIFIER_KEYWORD_P (id)
+ /* Don't register keywords with spaces. */
+ && IDENTIFIER_POINTER (id)[IDENTIFIER_LENGTH (id) - 1] != ' ')
+ cpp_lookup (parse_in,
+ (const unsigned char *) IDENTIFIER_POINTER (id),
+ IDENTIFIER_LENGTH (id))->flags |= NODE_WARN;
+ }
+ auto warn_on = [] (const char *name) {
+ cpp_lookup (parse_in, (const unsigned char *) name,
+ strlen (name))->flags |= NODE_WARN;
+ };
+ if (cxx_dialect >= cxx11)
+ {
+ warn_on ("final");
+ warn_on ("override");
+ warn_on ("noreturn");
+ if (cxx_dialect < cxx26)
+ warn_on ("carries_dependency");
+ }
+ if (cxx_dialect >= cxx14)
+ warn_on ("deprecated");
+ if (cxx_dialect >= cxx17)
+ {
+ warn_on ("fallthrough");
+ warn_on ("maybe_unused");
+ warn_on ("nodiscard");
+ }
+ if (cxx_dialect >= cxx20)
+ {
+ warn_on ("likely");
+ warn_on ("unlikely");
+ warn_on ("no_unique_address");
+ }
+ if (flag_modules)
+ {
+ warn_on ("import");
+ warn_on ("module");
+ }
+ if (cxx_dialect >= cxx23)
+ warn_on ("assume");
+ if (cxx_dialect >= cxx26)
+ {
+ warn_on ("replaceable_if_eligible");
+ warn_on ("trivially_relocatable_if_eligible");
+ }
+ }
+
if (c_common_init () == false)
{
input_location = saved_loc;
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index a8c54c7..743fd74 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -14672,13 +14672,23 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
tree v = DECL_VALUE_EXPR (range_decl);
/* For decomposition declaration get all of the corresponding
declarations out of the way. */
- if (TREE_CODE (v) == ARRAY_REF
- && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ if ((TREE_CODE (v) == ARRAY_REF
+ && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ || (TREE_CODE (v) == TREE_VEC
+ && DECL_DECOMPOSITION_P (TREE_VEC_ELT (v, 0))))
{
tree d = range_decl;
- range_decl = TREE_OPERAND (v, 0);
decomp = &decomp_d;
- decomp->count = tree_to_uhwi (TREE_OPERAND (v, 1)) + 1;
+ if (TREE_CODE (v) == ARRAY_REF)
+ {
+ range_decl = TREE_OPERAND (v, 0);
+ decomp->count = tree_to_uhwi (TREE_OPERAND (v, 1)) + 1;
+ }
+ else
+ {
+ range_decl = TREE_VEC_ELT (v, 0);
+ decomp->count = tree_to_uhwi (TREE_VEC_ELT (v, 1)) + 1;
+ }
decomp->decl = d;
bool seen_name_independent_decl = false;
for (unsigned int i = 0; i < decomp->count;
@@ -16843,7 +16853,7 @@ cp_parser_simple_declaration (cp_parser* parser,
}
/* Helper of cp_parser_simple_declaration, parse a decomposition declaration.
- decl-specifier-seq ref-qualifier [opt] [ identifier-list ]
+ decl-specifier-seq ref-qualifier [opt] [ sb-identifier-list ]
initializer ; */
static tree
@@ -16856,21 +16866,45 @@ cp_parser_decomposition_declaration (cp_parser *parser,
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require (parser, CPP_OPEN_SQUARE, RT_OPEN_SQUARE);
- /* Parse the identifier-list. */
+ /* Parse the sb-identifier-list. */
auto_vec<cp_expr, 10> v;
bool attr_diagnosed = false;
int first_attr = -1;
+ int pack = -1;
unsigned int cnt = 0;
if (!cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_SQUARE))
while (true)
{
+ if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
+ {
+ location_t elloc = cp_lexer_peek_token (parser->lexer)->location;
+ if (!processing_template_decl)
+ error_at (elloc, "structured binding pack outside of template");
+ else if (pack != -1)
+ error_at (elloc,
+ "multiple packs in structured binding declaration");
+ else
+ {
+ if (keyword == RID_MAX
+ && cxx_dialect >= cxx17
+ && cxx_dialect < cxx26)
+ pedwarn (elloc, OPT_Wc__26_extensions,
+ "structured binding packs only available with "
+ "%<-std=c++2c%> or %<-std=gnu++2c%>");
+ pack = cnt;
+ }
+ cp_lexer_consume_token (parser->lexer);
+ }
cp_expr e = cp_parser_identifier (parser);
if (e.get_value () == error_mark_node)
break;
tree attr = NULL_TREE;
if (cp_next_tokens_can_be_std_attribute_p (parser))
{
- if (cxx_dialect >= cxx17 && cxx_dialect < cxx26 && !attr_diagnosed)
+ if (keyword == RID_MAX
+ && cxx_dialect >= cxx17
+ && cxx_dialect < cxx26
+ && !attr_diagnosed)
{
pedwarn (cp_lexer_peek_token (parser->lexer)->location,
OPT_Wc__26_extensions,
@@ -16931,7 +16965,7 @@ cp_parser_decomposition_declaration (cp_parser *parser,
&pushed_scope);
tree orig_decl = decl;
- unsigned int i;
+ unsigned int i, j;
cp_expr e;
cp_decl_specifier_seq decl_specs;
clear_decl_specs (&decl_specs);
@@ -16939,6 +16973,7 @@ cp_parser_decomposition_declaration (cp_parser *parser,
if (decl_specifiers->storage_class == sc_static)
decl_specs.storage_class = sc_static;
tree prev = decl;
+ j = 0;
FOR_EACH_VEC_ELT (v, i, e)
{
if (i == 0)
@@ -16969,9 +17004,22 @@ cp_parser_decomposition_declaration (cp_parser *parser,
prev = decl2;
DECL_DECLARED_CONSTEXPR_P (decl2) = DECL_DECLARED_CONSTEXPR_P (decl);
DECL_DECLARED_CONSTINIT_P (decl2) = DECL_DECLARED_CONSTINIT_P (decl);
+ if (j == (unsigned) pack)
+ {
+ tree dtype = cxx_make_type (DECLTYPE_TYPE);
+ DECLTYPE_TYPE_EXPR (dtype) = decl2;
+ DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (dtype) = 1;
+ SET_TYPE_STRUCTURAL_EQUALITY (dtype);
+ tree type = cxx_make_type (TYPE_PACK_EXPANSION);
+ PACK_EXPANSION_PATTERN (type) = dtype;
+ SET_TYPE_STRUCTURAL_EQUALITY (type);
+ PACK_EXPANSION_PARAMETER_PACKS (type) = decl2;
+ TREE_TYPE (decl2) = type;
+ }
}
if (elt_pushed_scope)
pop_scope (elt_pushed_scope);
+ ++j;
}
if (v.is_empty ())
@@ -46300,6 +46348,14 @@ cp_convert_omp_range_for (tree &this_pre_body, tree &sl,
decomp->count = tree_to_uhwi (TREE_OPERAND (v, 1)) + 1;
decomp->decl = decl;
}
+ else if (TREE_CODE (v) == TREE_VEC
+ && DECL_DECOMPOSITION_P (TREE_VEC_ELT (v, 0)))
+ {
+ d = TREE_VEC_ELT (v, 0);
+ decomp = &decomp_d;
+ decomp->count = tree_to_uhwi (TREE_VEC_ELT (v, 1)) + 1;
+ decomp->decl = decl;
+ }
}
do_range_for_auto_deduction (d, init, decomp);
}
@@ -46423,6 +46479,15 @@ cp_convert_omp_range_for (tree &this_pre_body, tree &sl,
decomp->count = tree_to_uhwi (TREE_OPERAND (v, 1)) + 1;
decomp->decl = d;
}
+ else if (TREE_CODE (v) == TREE_VEC
+ && DECL_DECOMPOSITION_P (TREE_VEC_ELT (v, 0)))
+ {
+ tree d = orig_decl;
+ orig_decl = TREE_VEC_ELT (v, 0);
+ decomp = &decomp_d;
+ decomp->count = tree_to_uhwi (TREE_VEC_ELT (v, 1)) + 1;
+ decomp->decl = d;
+ }
}
tree auto_node = type_uses_auto (TREE_TYPE (orig_decl));
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index acfeb81..b6b13ed 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -13981,9 +13981,30 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
else if (is_capture_proxy (parm_pack))
{
arg_pack = retrieve_local_specialization (parm_pack);
+ if (DECL_DECOMPOSITION_P (arg_pack))
+ {
+ orig_arg = arg_pack;
+ goto expand_sb_pack;
+ }
if (DECL_PACK_P (arg_pack))
arg_pack = NULL_TREE;
}
+ else if (DECL_DECOMPOSITION_P (parm_pack))
+ {
+ orig_arg = retrieve_local_specialization (parm_pack);
+ expand_sb_pack:
+ gcc_assert (DECL_DECOMPOSITION_P (orig_arg));
+ if (TREE_TYPE (orig_arg) == error_mark_node)
+ return error_mark_node;
+ gcc_assert (DECL_HAS_VALUE_EXPR_P (orig_arg));
+ arg_pack = DECL_VALUE_EXPR (orig_arg);
+ tree vec = make_tree_vec (TREE_VEC_LENGTH (arg_pack) - 2);
+ if (TREE_VEC_LENGTH (vec))
+ memcpy (TREE_VEC_BEGIN (vec), &TREE_VEC_ELT (arg_pack, 2),
+ TREE_VEC_LENGTH (vec) * sizeof (tree));
+ arg_pack = make_node (NONTYPE_ARGUMENT_PACK);
+ ARGUMENT_PACK_ARGS (arg_pack) = vec;
+ }
else
{
int idx;
@@ -13996,7 +14017,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
arg_pack = NULL_TREE;
}
- orig_arg = arg_pack;
+ if (orig_arg == NULL_TREE)
+ orig_arg = arg_pack;
if (arg_pack && TREE_CODE (arg_pack) == ARGUMENT_PACK_SELECT)
arg_pack = ARGUMENT_PACK_SELECT_FROM_PACK (arg_pack);
@@ -14011,8 +14033,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
if (arg_pack)
{
- int my_len =
- TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg_pack));
+ int my_len
+ = TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg_pack));
/* Don't bother trying to do a partial substitution with
incomplete packs; we'll try again after deduction. */
@@ -14176,8 +14198,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
/* Update the corresponding argument. */
if (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (args))
- TREE_VEC_ELT (TREE_VEC_ELT (args, level -1 ), idx) =
- TREE_TYPE (pack);
+ TREE_VEC_ELT (TREE_VEC_ELT (args, level -1 ), idx)
+ = TREE_TYPE (pack);
else
TREE_VEC_ELT (args, idx) = TREE_TYPE (pack);
}
@@ -15921,7 +15943,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain,
tsubst_flags_t tcomplain = complain;
if (VAR_P (t))
tcomplain |= tf_tst_ok;
- type = tsubst (type, args, tcomplain, in_decl);
+ if (DECL_DECOMPOSITION_P (t) && DECL_PACK_P (t))
+ type = NULL_TREE;
+ else
+ type = tsubst (type, args, tcomplain, in_decl);
/* Substituting the type might have recursively instantiated this
same alias (c++/86171). */
if (use_spec_table && gen_tmpl && DECL_ALIAS_TEMPLATE_P (gen_tmpl)
@@ -15938,6 +15963,17 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain,
{
DECL_INITIALIZED_P (r) = 0;
DECL_TEMPLATE_INSTANTIATED (r) = 0;
+ if (DECL_DECOMPOSITION_P (t) && DECL_PACK_P (t))
+ {
+ tree dtype = cxx_make_type (DECLTYPE_TYPE);
+ DECLTYPE_TYPE_EXPR (dtype) = r;
+ DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (dtype) = 1;
+ SET_TYPE_STRUCTURAL_EQUALITY (dtype);
+ type = cxx_make_type (TYPE_PACK_EXPANSION);
+ PACK_EXPANSION_PATTERN (type) = dtype;
+ SET_TYPE_STRUCTURAL_EQUALITY (type);
+ PACK_EXPANSION_PARAMETER_PACKS (type) = r;
+ }
if (TREE_CODE (type) == FUNCTION_TYPE)
{
/* It may seem that this case cannot occur, since:
@@ -18555,13 +18591,17 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree &orig_declv,
if (decl != error_mark_node && DECL_HAS_VALUE_EXPR_P (decl))
{
tree v = DECL_VALUE_EXPR (decl);
- if (TREE_CODE (v) == ARRAY_REF
- && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ if ((TREE_CODE (v) == ARRAY_REF
+ && DECL_DECOMPOSITION_P (TREE_OPERAND (v, 0)))
+ || (TREE_CODE (v) == TREE_VEC
+ && DECL_DECOMPOSITION_P (TREE_VEC_ELT (v, 0))))
{
+ v = (TREE_CODE (v) == ARRAY_REF
+ ? TREE_OPERAND (v, 0) : TREE_VEC_ELT (v, 0));
cp_decomp decomp_d = { NULL_TREE, 0 };
- tree d = tsubst_decl (TREE_OPERAND (v, 0), args, complain);
+ tree d = tsubst_decl (v, args, complain);
maybe_push_decl (d);
- d = tsubst_decomp_names (d, TREE_OPERAND (v, 0), args, complain,
+ d = tsubst_decomp_names (d, v, args, complain,
in_decl, &decomp_d);
decomp = true;
if (d == error_mark_node)
@@ -21220,7 +21260,28 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
++c_inhibit_evaluation_warnings;
/* We only want to compute the number of arguments. */
if (PACK_EXPANSION_P (op))
- expanded = tsubst_pack_expansion (op, args, complain, in_decl);
+ {
+ expanded = NULL_TREE;
+ if (DECL_DECOMPOSITION_P (PACK_EXPANSION_PATTERN (op)))
+ {
+ tree d = PACK_EXPANSION_PATTERN (op);
+ if (DECL_HAS_VALUE_EXPR_P (d))
+ {
+ d = DECL_VALUE_EXPR (d);
+ if (TREE_CODE (d) == TREE_VEC)
+ {
+ tree b = TREE_VEC_ELT (d, 0);
+ if (!type_dependent_expression_p_push (b))
+ {
+ expanded = void_node;
+ len = TREE_VEC_LENGTH (d) - 2;
+ }
+ }
+ }
+ }
+ if (!expanded)
+ expanded = tsubst_pack_expansion (op, args, complain, in_decl);
+ }
else
expanded = tsubst_template_args (ARGUMENT_PACK_ARGS (op),
args, complain, in_decl);
@@ -29050,6 +29111,24 @@ value_dependent_expression_p (tree expression)
case SIZEOF_EXPR:
if (SIZEOF_EXPR_TYPE_P (expression))
return dependent_type_p (TREE_TYPE (TREE_OPERAND (expression, 0)));
+ if (tree p = TREE_OPERAND (expression, 0))
+ if (PACK_EXPANSION_P (p)
+ && DECL_DECOMPOSITION_P (PACK_EXPANSION_PATTERN (p)))
+ {
+ tree d = PACK_EXPANSION_PATTERN (p);
+ if (DECL_HAS_VALUE_EXPR_P (d))
+ {
+ d = DECL_VALUE_EXPR (d);
+ /* [temp.dep.constexpr]/4:
+ Expressions of the following form are value-dependent:
+ sizeof ... ( identifier )
+ unless the identifier is a structured binding pack whose
+ initializer is not dependent. */
+ if (TREE_CODE (d) == TREE_VEC
+ && !type_dependent_expression_p (TREE_VEC_ELT (d, 0)))
+ return false;
+ }
+ }
/* FALLTHRU */
case ALIGNOF_EXPR:
case TYPEID_EXPR:
@@ -29563,6 +29642,22 @@ instantiation_dependent_r (tree *tp, int *walk_subtrees,
tree op = TREE_OPERAND (*tp, 0);
if (code == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (*tp))
op = TREE_TYPE (op);
+ else if (code == SIZEOF_EXPR
+ && PACK_EXPANSION_P (op)
+ && DECL_DECOMPOSITION_P (PACK_EXPANSION_PATTERN (op)))
+ {
+ tree d = PACK_EXPANSION_PATTERN (op);
+ if (DECL_HAS_VALUE_EXPR_P (d))
+ {
+ d = DECL_VALUE_EXPR (d);
+ if (TREE_CODE (d) == TREE_VEC
+ && !type_dependent_expression_p (TREE_VEC_ELT (d, 0)))
+ {
+ *walk_subtrees = 0;
+ return NULL_TREE;
+ }
+ }
+ }
if (TYPE_P (op))
{
if (dependent_type_p (op))
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 4fe6418..1217b5d 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,7 @@
+2025-08-06 Sam James <sam@gentoo.org>
+
+ * Make-lang.in (ALL_DFLAGS): Don't use ALIASING_FLAGS.
+
2025-07-25 David Malcolm <dmalcolm@redhat.com>
* d-diagnostic.cc: Likewise.
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 7572e04..7d73046 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -277,9 +277,6 @@ namespace diagnostics {
/* Compute the number of digits in the decimal representation of an integer. */
extern int num_digits (int);
-extern char *get_cwe_url (int cwe);
-extern const char *maybe_line_and_column (int line, int col);
-
} // namespace diagnostics
#endif /* ! GCC_DIAGNOSTIC_H */
diff --git a/gcc/diagnostics/buffering.cc b/gcc/diagnostics/buffering.cc
index 29f039f..a7747b5 100644
--- a/gcc/diagnostics/buffering.cc
+++ b/gcc/diagnostics/buffering.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "diagnostics/buffering.h"
#include "diagnostics/sink.h"
+#include "diagnostics/dumping.h"
namespace diagnostics {
@@ -122,12 +123,12 @@ void
buffer::dump (FILE *out, int indent) const
{
m_diagnostic_counters.dump (out, indent + 2);
- fprintf (out, "%*sm_per_sink_buffers:\n", indent, "");
+ dumping::emit_heading (out, indent, "m_per_sink_buffers");
if (m_per_sink_buffers)
for (auto per_sink_buffer_ : *m_per_sink_buffers)
per_sink_buffer_->dump (out, indent + 2);
else
- fprintf (out, "%*s(none)\n", indent + 2, "");
+ dumping::emit_none (out, indent + 2);
}
bool
diff --git a/gcc/diagnostics/column-options.h b/gcc/diagnostics/column-options.h
new file mode 100644
index 0000000..86296e9
--- /dev/null
+++ b/gcc/diagnostics/column-options.h
@@ -0,0 +1,44 @@
+/* Options relating to the meaning of column numbers.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_DIAGNOSTICS_COLUMN_OPTIONS_H
+#define GCC_DIAGNOSTICS_COLUMN_OPTIONS_H
+
+namespace diagnostics {
+
+/* A bundle of options relating to the meaning of column numbers. */
+
+struct column_options
+{
+ int convert_column (file_cache &fc,
+ expanded_location s) const;
+
+ /* What units to use when outputting the column number. */
+ enum diagnostics_column_unit m_column_unit;
+
+ /* The origin for the column number (1-based or 0-based typically). */
+ int m_column_origin;
+
+ /* The size of the tabstop for tab expansion. */
+ int m_tabstop;
+};
+
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_COLUMN_OPTIONS_H */
diff --git a/gcc/diagnostics/context.cc b/gcc/diagnostics/context.cc
index a1441ca..3668958 100644
--- a/gcc/diagnostics/context.cc
+++ b/gcc/diagnostics/context.cc
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/logical-locations.h"
#include "diagnostics/buffering.h"
#include "diagnostics/file-cache.h"
+#include "diagnostics/dumping.h"
#ifdef HAVE_TERMIOS_H
# include <termios.h>
@@ -176,12 +177,18 @@ context::initialize (int n_opts)
m_client_aux_data = nullptr;
m_lock = 0;
m_inhibit_notes_p = false;
+
m_source_printing.colorize_source_p = false;
m_source_printing.show_labels_p = false;
m_source_printing.show_line_numbers_p = false;
m_source_printing.min_margin_width = 0;
m_source_printing.show_ruler_p = false;
m_source_printing.show_event_links_p = false;
+
+ m_column_options.m_column_unit = DIAGNOSTICS_COLUMN_UNIT_DISPLAY;
+ m_column_options.m_column_origin = 1;
+ m_column_options.m_tabstop = 8;
+
m_report_bug = false;
m_extra_output_kind = EXTRA_DIAGNOSTIC_OUTPUT_none;
if (const char *var = getenv ("GCC_EXTRA_DIAGNOSTIC_OUTPUT"))
@@ -192,9 +199,6 @@ context::initialize (int n_opts)
m_extra_output_kind = EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2;
/* Silently ignore unrecognized values. */
}
- m_column_unit = DIAGNOSTICS_COLUMN_UNIT_DISPLAY;
- m_column_origin = 1;
- m_tabstop = 8;
m_escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
m_fixits_change_set = nullptr;
m_diagnostic_groups.m_group_nesting_depth = 0;
@@ -284,6 +288,33 @@ context::urls_init (int value)
(m_reference_printer->get_url_format ());
}
+void
+context::set_show_nesting (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_nesting (val);
+}
+
+void
+context::set_show_nesting_locations (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_locations_in_nesting (val);
+}
+
+void
+context::set_show_nesting_levels (bool val)
+{
+ for (auto sink_ : m_sinks)
+ if (sink_->follows_reference_printer_p ())
+ if (auto text_sink_ = sink_->dyn_cast_text_sink ())
+ text_sink_->set_show_nesting_levels (val);
+}
+
/* Create the file_cache, if not already created, and tell it how to
translate files on input. */
void
@@ -355,33 +386,40 @@ context::finish ()
/* Dump state of this diagnostics::context to OUT, for debugging. */
void
-context::dump (FILE *out) const
+context::dump (FILE *outfile) const
{
- fprintf (out, "diagnostics::context:\n");
- m_diagnostic_counters.dump (out, 2);
- fprintf (out, " reference printer:\n");
- m_reference_printer->dump (out, 4);
- fprintf (out, " output sinks:\n");
+ dumping::emit_heading (outfile, 0, "diagnostics::context");
+ m_diagnostic_counters.dump (outfile, 2);
+ dumping::emit_heading (outfile, 2, "reference printer");
+ if (m_reference_printer)
+ m_reference_printer->dump (outfile, 4);
+ else
+ dumping::emit_none (outfile, 4);
+ dumping::emit_heading (outfile, 2, "output sinks");
if (m_sinks.length () > 0)
{
for (unsigned i = 0; i < m_sinks.length (); ++i)
{
- fprintf (out, " sink %i:\n", i);
- m_sinks[i]->dump (out, 4);
+ dumping::emit_indent (outfile, 4);
+ const sink *s = m_sinks[i];
+ fprintf (outfile, "sink %i (", i);
+ s->dump_kind (outfile);
+ fprintf (outfile, "):\n");
+ s->dump (outfile, 6);
}
}
else
- fprintf (out, " (none):\n");
- fprintf (out, " diagnostic buffer:\n");
+ dumping::emit_none (outfile, 4);
+ dumping::emit_heading (outfile, 2, "diagnostic buffer");
if (m_diagnostic_buffer)
- m_diagnostic_buffer->dump (out, 4);
+ m_diagnostic_buffer->dump (outfile, 4);
else
- fprintf (out, " (none):\n");
- fprintf (out, " file cache:\n");
+ dumping::emit_none (outfile, 4);
+ dumping::emit_heading (outfile, 2, "file cache");
if (m_file_cache)
- m_file_cache->dump (out, 4);
+ m_file_cache->dump (outfile, 4);
else
- fprintf (out, " (none):\n");
+ dumping::emit_none (outfile, 4);
}
/* Return true if sufficiently severe diagnostics have been seen that
@@ -671,11 +709,22 @@ convert_column_unit (file_cache &fc,
}
}
+/* Given an expanded_location, convert the column (which is in 1-based bytes)
+ to the requested units and origin. Return -1 if the column is
+ invalid (<= 0). */
+int
+column_options::convert_column (file_cache &fc,
+ expanded_location s) const
+{
+ int one_based_col = convert_column_unit (fc, m_column_unit, m_tabstop, s);
+ if (one_based_col <= 0)
+ return -1;
+ return one_based_col + (m_column_origin - 1);
+}
+
column_policy::column_policy (const context &dc)
: m_file_cache (dc.get_file_cache ()),
- m_column_unit (dc.m_column_unit),
- m_column_origin (dc.m_column_origin),
- m_tabstop (dc.m_tabstop)
+ m_column_options (dc.get_column_options ())
{
}
@@ -685,11 +734,7 @@ column_policy::column_policy (const context &dc)
int
column_policy::converted_column (expanded_location s) const
{
- int one_based_col = convert_column_unit (m_file_cache,
- m_column_unit, m_tabstop, s);
- if (one_based_col <= 0)
- return -1;
- return one_based_col + (m_column_origin - 1);
+ return m_column_options.convert_column (m_file_cache, s);
}
/* Return a string describing a location e.g. "foo.c:42:10". */
@@ -711,7 +756,7 @@ column_policy::get_location_text (const expanded_location &s,
col = converted_column (s);
}
- const char *line_col = maybe_line_and_column (line, col);
+ const char *line_col = text_sink::maybe_line_and_column (line, col);
return label_text::take (build_message_string ("%s%s%s:%s", locus_cs, file,
line_col, locus_ce));
}
@@ -1098,7 +1143,7 @@ context::get_any_inlining_info (diagnostic_info *diagnostic)
/* Retrieve the locations into which the expression about to be
diagnosed has been inlined, including those of all the callers
all the way down the inlining stack. */
- m_set_locations_cb (this, diagnostic);
+ m_set_locations_cb (*this, diagnostic);
else
{
/* When there's no callback use just the one location provided
@@ -1249,7 +1294,7 @@ context::report_diagnostic (diagnostic_info *diagnostic)
}
if (m_adjust_diagnostic_info)
- m_adjust_diagnostic_info (this, diagnostic);
+ m_adjust_diagnostic_info (*this, diagnostic);
if (diagnostic->m_kind == kind::pedwarn)
{
@@ -1385,6 +1430,8 @@ context::report_diagnostic (diagnostic_info *diagnostic)
sink_->on_report_diagnostic (*diagnostic, orig_diag_kind);
}
+ const int tabstop = get_column_options ().m_tabstop;
+
switch (m_extra_output_kind)
{
default:
@@ -1393,14 +1440,14 @@ context::report_diagnostic (diagnostic_info *diagnostic)
print_parseable_fixits (get_file_cache (),
m_reference_printer, diagnostic->m_richloc,
DIAGNOSTICS_COLUMN_UNIT_BYTE,
- m_tabstop);
+ tabstop);
pp_flush (m_reference_printer);
break;
case EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2:
print_parseable_fixits (get_file_cache (),
m_reference_printer, diagnostic->m_richloc,
DIAGNOSTICS_COLUMN_UNIT_DISPLAY,
- m_tabstop);
+ tabstop);
pp_flush (m_reference_printer);
break;
}
@@ -1690,7 +1737,7 @@ context::set_nesting_level (int new_level)
void
sink::dump (FILE *out, int indent) const
{
- fprintf (out, "%*sprinter:\n", indent, "");
+ dumping::emit_heading (out, indent, "printer");
m_printer->dump (out, indent + 2);
}
@@ -1777,19 +1824,19 @@ counters::counters ()
void
counters::dump (FILE *out, int indent) const
{
- fprintf (out, "%*scounts:\n", indent, "");
+ dumping::emit_heading (out, indent, "counts");
bool none = true;
for (int i = 0; i < static_cast<int> (kind::last_diagnostic_kind); i++)
if (m_count_for_kind[i] > 0)
{
- fprintf (out, "%*s%s%i\n",
- indent + 2, "",
+ dumping::emit_indent (out, indent + 2);
+ fprintf (out, "%s%i\n",
get_text_for_kind (static_cast<enum kind> (i)),
m_count_for_kind[i]);
none = false;
}
if (none)
- fprintf (out, "%*s(none)\n", indent + 2, "");
+ dumping::emit_none (out, indent + 2);
}
void
@@ -2015,8 +2062,8 @@ assert_location_text (const char *expected_loc_text,
= DIAGNOSTICS_COLUMN_UNIT_BYTE)
{
diagnostics::selftest::test_context dc;
- dc.m_column_unit = column_unit;
- dc.m_column_origin = origin;
+ dc.get_column_options ().m_column_unit = column_unit;
+ dc.get_column_options ().m_column_origin = origin;
expanded_location xloc;
xloc.file = filename;
@@ -2052,8 +2099,8 @@ test_get_location_text ()
assert_location_text ("foo.c:42:", "foo.c", 42, 10, false);
assert_location_text ("foo.c:", "foo.c", 0, 10, false);
- diagnostics::maybe_line_and_column (INT_MAX, INT_MAX);
- diagnostics::maybe_line_and_column (INT_MIN, INT_MIN);
+ diagnostics::text_sink::maybe_line_and_column (INT_MAX, INT_MAX);
+ diagnostics::text_sink::maybe_line_and_column (INT_MIN, INT_MIN);
{
/* In order to test display columns vs byte columns, we need to create a
diff --git a/gcc/diagnostics/context.h b/gcc/diagnostics/context.h
index b6ec85c..dea4588 100644
--- a/gcc/diagnostics/context.h
+++ b/gcc/diagnostics/context.h
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/option-id-manager.h"
#include "diagnostics/context-options.h"
#include "diagnostics/source-printing-options.h"
+#include "diagnostics/column-options.h"
#include "diagnostics/counters.h"
namespace diagnostics {
@@ -99,13 +100,11 @@ public:
bool show_column,
bool colorize) const;
- int get_tabstop () const { return m_tabstop; }
+ int get_tabstop () const { return m_column_options.m_tabstop; }
private:
file_cache &m_file_cache;
- enum diagnostics_column_unit m_column_unit;
- int m_column_origin;
- int m_tabstop;
+ column_options m_column_options;
};
/* A bundle of state for printing locations within diagnostics
@@ -265,7 +264,7 @@ public:
friend class text_sink;
friend class buffer;
- typedef void (*set_locations_callback_t) (context *,
+ typedef void (*set_locations_callback_t) (const context &,
diagnostic_info *);
void initialize (int n_opts);
@@ -393,6 +392,9 @@ public:
}
void set_show_path_depths (bool val) { m_show_path_depths = val; }
void set_show_option_requested (bool val) { m_show_option_requested = val; }
+ void set_show_nesting (bool val);
+ void set_show_nesting_locations (bool val);
+ void set_show_nesting_levels (bool val);
void set_max_errors (int val) { m_max_errors = val; }
void set_escape_format (enum diagnostics_escape_format val)
{
@@ -572,7 +574,7 @@ public:
}
void
- set_adjust_diagnostic_info_callback (void (*cb) (context *,
+ set_adjust_diagnostic_info_callback (void (*cb) (const context &,
diagnostic_info *))
{
m_adjust_diagnostic_info = cb;
@@ -592,6 +594,9 @@ public:
return m_source_printing;
}
+ column_options &get_column_options () { return m_column_options; }
+ const column_options &get_column_options () const { return m_column_options; }
+
void set_caret_max_width (int value);
private:
@@ -708,7 +713,7 @@ private:
/* Client hook to adjust properties of the given diagnostic that we're
about to issue, such as its kind. */
- void (*m_adjust_diagnostic_info)(context *, diagnostic_info *);
+ void (*m_adjust_diagnostic_info)(const context &, diagnostic_info *);
/* Owned by the context; this would be a std::unique_ptr if
context had a proper ctor. */
@@ -739,6 +744,7 @@ private:
bool m_inhibit_notes_p;
source_printing_options m_source_printing;
+ column_options m_column_options;
/* True if -freport-bug option is used. */
bool m_report_bug;
@@ -748,17 +754,6 @@ private:
-fdiagnostics-parseable-fixits and GCC_EXTRA_DIAGNOSTIC_OUTPUT. */
enum diagnostics_extra_output_kind m_extra_output_kind;
-public:
- /* What units to use when outputting the column number. */
- enum diagnostics_column_unit m_column_unit;
-
- /* The origin for the column number (1-based or 0-based typically). */
- int m_column_origin;
-
- /* The size of the tabstop for tab expansion. */
- int m_tabstop;
-
-private:
/* How should non-ASCII/non-printable bytes be escaped when
a diagnostic suggests escaping the source code on output. */
enum diagnostics_escape_format m_escape_format;
diff --git a/gcc/diagnostics/dumping.cc b/gcc/diagnostics/dumping.cc
new file mode 100644
index 0000000..1dbecf4
--- /dev/null
+++ b/gcc/diagnostics/dumping.cc
@@ -0,0 +1,102 @@
+/* Utilities for implementing "dump" functions for the diagnostics subsystem.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "diagnostics/dumping.h"
+
+namespace diagnostics {
+namespace dumping {
+
+/* Emit indentation to OUTFILE for the start of a dump line. */
+
+void
+emit_indent (FILE *outfile, int indent)
+{
+ fprintf (outfile, "%*s", indent, "");
+}
+
+/* Emit an indented line to OUTFILE showing a heading. */
+
+void
+emit_heading (FILE *outfile, int indent,
+ const char *text)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "%s:\n", text);
+}
+
+/* Various functions that emit an indented line to OUTFILE
+ showing "label: value". */
+
+void
+emit_string_field (FILE *outfile, int indent,
+ const char *label, const char *value)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "%s: %s\n", label, value);
+}
+
+void
+emit_bool_field (FILE *outfile, int indent,
+ const char *label, bool value)
+{
+ emit_string_field (outfile, indent, label,
+ value ? "true" : "false");
+}
+
+void
+emit_size_t_field (FILE *outfile, int indent,
+ const char *label, size_t value)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "%s: " HOST_SIZE_T_PRINT_DEC "\n", label, value);
+}
+
+void
+emit_int_field (FILE *outfile, int indent,
+ const char *label, int value)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "%s: %i\n", label, value);
+}
+
+void
+emit_unsigned_field (FILE *outfile, int indent,
+ const char *label, unsigned value)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "%s: %u\n", label, value);
+}
+
+/* Emit an indented line to OUTFILE reading "(none)". */
+
+void
+emit_none (FILE *outfile, int indent)
+{
+ emit_indent (outfile, indent);
+ fprintf (outfile, "(none)\n");
+}
+
+
+} // namespace dumping {
+} // namespace diagnostics
diff --git a/gcc/diagnostics/dumping.h b/gcc/diagnostics/dumping.h
new file mode 100644
index 0000000..02f6485
--- /dev/null
+++ b/gcc/diagnostics/dumping.h
@@ -0,0 +1,50 @@
+/* Utilities for implementing "dump" functions for the diagnostics subsystem.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_DIAGNOSTICS_DUMP_H
+#define GCC_DIAGNOSTICS_DUMP_H
+
+namespace diagnostics {
+namespace dumping {
+
+extern void emit_indent (FILE *outfile, int indent);
+extern void emit_heading (FILE *outfile, int indent,
+ const char *text);
+
+extern void emit_string_field (FILE *outfile, int indent,
+ const char *label, const char *value);
+extern void emit_bool_field (FILE *outfile, int indent,
+ const char *label, bool value);
+extern void emit_size_t_field (FILE *outfile, int indent,
+ const char *label, size_t value);
+extern void emit_int_field (FILE *outfile, int indent,
+ const char *label, int value);
+extern void emit_unsigned_field (FILE *outfile, int indent,
+ const char *label, unsigned value);
+
+extern void emit_none (FILE *outfile, int indent);
+
+#define DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD(FLAG) \
+ dumping::emit_bool_field (outfile, indent, #FLAG, FLAG)
+
+} // namespace dumping
+} // namespace diagnostics
+
+#endif /* ! GCC_DIAGNOSTICS_DUMP_H */
diff --git a/gcc/diagnostics/file-cache.cc b/gcc/diagnostics/file-cache.cc
index febeb03..0ec0679 100644
--- a/gcc/diagnostics/file-cache.cc
+++ b/gcc/diagnostics/file-cache.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "cpplib.h"
#include "diagnostics/file-cache.h"
+#include "diagnostics/dumping.h"
#include "selftest.h"
#ifndef HAVE_ICONV
@@ -473,7 +474,8 @@ file_cache::dump (FILE *out, int indent) const
{
for (size_t i = 0; i < m_num_file_slots; ++i)
{
- fprintf (out, "%*sslot[%i]:\n", indent, "", (int)i);
+ dumping::emit_indent (out, indent);
+ fprintf (out, "slot[%i]:\n", (int)i);
m_file_slots[i].dump (out, indent + 2);
}
}
@@ -541,27 +543,38 @@ file_cache_slot::dump (FILE *out, int indent) const
{
if (!m_file_path)
{
- fprintf (out, "%*s(unused)\n", indent, "");
+ dumping::emit_indent (out, indent);
+ fprintf (out, "(unused)\n");
return;
}
- fprintf (out, "%*sfile_path: %s\n", indent, "", m_file_path);
- fprintf (out, "%*sfp: %p\n", indent, "", (void *)m_fp);
- fprintf (out, "%*sneeds_read_p: %i\n", indent, "", (int)needs_read_p ());
- fprintf (out, "%*sneeds_grow_p: %i\n", indent, "", (int)needs_grow_p ());
- fprintf (out, "%*suse_count: %i\n", indent, "", m_use_count);
- fprintf (out, "%*ssize: %zi\n", indent, "", m_size);
- fprintf (out, "%*snb_read: %zi\n", indent, "", m_nb_read);
- fprintf (out, "%*sstart_line_idx: %zi\n", indent, "", m_line_start_idx);
- fprintf (out, "%*sline_num: %zi\n", indent, "", m_line_num);
- fprintf (out, "%*smissing_trailing_newline: %i\n",
- indent, "", (int)m_missing_trailing_newline);
- fprintf (out, "%*sline records (%i):\n",
- indent, "", m_line_record.length ());
+ dumping::emit_string_field (out, indent, "file_path", m_file_path);
+ {
+ dumping::emit_indent (out, indent);
+ fprintf (out, "fp: %p\n", (void *)m_fp);
+ }
+ dumping::emit_bool_field (out, indent, "needs_read_p", needs_read_p ());
+ dumping::emit_bool_field (out, indent, "needs_grow_p", needs_grow_p ());
+ dumping::emit_unsigned_field (out, indent, "use_count", m_use_count);
+ dumping::emit_size_t_field (out, indent, "size", m_size);
+ dumping::emit_size_t_field (out, indent, "nb_read", m_nb_read);
+ dumping::emit_size_t_field (out, indent, "start_line_idx", m_line_start_idx);
+ dumping::emit_size_t_field (out, indent, "line_num", m_line_num);
+ dumping::emit_bool_field (out, indent, "missing_trailing_newline",
+ m_missing_trailing_newline);
+ {
+ dumping::emit_indent (out, indent);
+ fprintf (out, "line records (%i):\n", m_line_record.length ());
+ }
int idx = 0;
for (auto &line : m_line_record)
- fprintf (out, "%*s[%i]: line %zi: byte offsets: %zi-%zi\n",
- indent + 2, "",
- idx++, line.line_num, line.start_pos, line.end_pos);
+ {
+ dumping::emit_indent (out, indent);
+ fprintf (out, ("[%i]:"
+ " line " HOST_SIZE_T_PRINT_DEC ":"
+ " byte offsets: " HOST_SIZE_T_PRINT_DEC
+ "-" HOST_SIZE_T_PRINT_DEC "\n"),
+ idx++, line.line_num, line.start_pos, line.end_pos);
+ }
}
/* Returns TRUE iff the cache would need to be filled with data coming
diff --git a/gcc/diagnostics/html-sink.cc b/gcc/diagnostics/html-sink.cc
index 934d8e2..1fd317a 100644
--- a/gcc/diagnostics/html-sink.cc
+++ b/gcc/diagnostics/html-sink.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/output-file.h"
#include "diagnostics/buffering.h"
#include "diagnostics/paths.h"
+#include "diagnostics/dumping.h"
#include "diagnostics/client-data-hooks.h"
#include "selftest.h"
#include "diagnostics/selftest-context.h"
@@ -61,6 +62,16 @@ html_generation_options::html_generation_options ()
{
}
+void
+html_generation_options::dump (FILE *outfile, int indent) const
+{
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_css);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_javascript);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_state_diagrams);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_state_diagrams_sarif);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_state_diagrams_dot_src);
+}
+
class html_builder;
/* Concrete buffering implementation subclass for HTML output. */
@@ -116,6 +127,8 @@ public:
const line_maps *line_maps,
const html_generation_options &html_gen_opts);
+ void dump (FILE *out, int indent) const;
+
void
set_main_input_filename (const char *name);
@@ -223,11 +236,12 @@ make_span (std::string class_)
void
html_sink_buffer::dump (FILE *out, int indent) const
{
- fprintf (out, "%*shtml_sink_buffer:\n", indent, "");
+ dumping::emit_heading (out, indent, "html_sink_buffer");
int idx = 0;
for (auto &result : m_results)
{
- fprintf (out, "%*sresult[%i]:\n", indent + 2, "", idx);
+ dumping::emit_indent (out, indent + 2);
+ fprintf (out, "result[%i]:\n", idx);
result->dump (out);
fprintf (out, "\n");
++idx;
@@ -470,6 +484,13 @@ html_builder::html_builder (context &dc,
}
void
+html_builder::dump (FILE *out, int indent) const
+{
+ dumping::emit_heading (out, indent, "HTML generation options");
+ m_html_gen_opts.dump (out, indent + 2);
+}
+
+void
html_builder::set_main_input_filename (const char *name)
{
gcc_assert (m_title_element);
@@ -539,7 +560,7 @@ html_builder::on_report_diagnostic (const diagnostic_info &diagnostic,
}
}
-// For ease of comparison with experimental-nesting-show-levels=yes
+// For ease of comparison with show-nesting-levels=yes
static void
add_nesting_level_attr (xml::element &element,
@@ -1333,8 +1354,9 @@ public:
void dump (FILE *out, int indent) const override
{
- fprintf (out, "%*shtml_sink\n", indent, "");
sink::dump (out, indent);
+ dumping::emit_heading (out, indent, "html_builder");
+ m_builder.dump (out, indent + 2);
}
void
@@ -1439,12 +1461,10 @@ public:
{
m_builder.flush_to_file (m_output_file.get_open_file ());
}
- void dump (FILE *out, int indent) const override
+ void dump_kind (FILE *out) const override
{
- fprintf (out, "%*shtml_file_sink: %s\n",
- indent, "",
+ fprintf (out, "html_file_sink: %s",
m_output_file.get_filename ());
- sink::dump (out, indent);
}
bool machine_readable_stderr_p () const final override
{
@@ -1607,6 +1627,10 @@ private:
: html_sink (dc, line_maps, html_gen_opts)
{
}
+ void dump_kind (FILE *out) const final override
+ {
+ fprintf (out, "html_buffered_sink");
+ }
bool machine_readable_stderr_p () const final override
{
return true;
diff --git a/gcc/diagnostics/html-sink.h b/gcc/diagnostics/html-sink.h
index d86bde8..d25ceea 100644
--- a/gcc/diagnostics/html-sink.h
+++ b/gcc/diagnostics/html-sink.h
@@ -30,6 +30,8 @@ struct html_generation_options
{
html_generation_options ();
+ void dump (FILE *out, int indent) const;
+
bool m_css;
bool m_javascript;
diff --git a/gcc/diagnostics/metadata.h b/gcc/diagnostics/metadata.h
index c28f982..39291ec 100644
--- a/gcc/diagnostics/metadata.h
+++ b/gcc/diagnostics/metadata.h
@@ -119,6 +119,8 @@ class metadata
const lazy_digraphs *m_lazy_digraphs;
};
+extern char *get_cwe_url (int cwe);
+
} // namespace diagnostics
#endif /* ! GCC_DIAGNOSTICS_METADATA_H */
diff --git a/gcc/diagnostics/output-spec.cc b/gcc/diagnostics/output-spec.cc
index 83f128c..13565f9 100644
--- a/gcc/diagnostics/output-spec.cc
+++ b/gcc/diagnostics/output-spec.cc
@@ -368,7 +368,7 @@ text_scheme_handler::make_sink (const context &ctxt,
const scheme_name_and_params &parsed_arg) const
{
bool show_color = pp_show_color (dc.get_reference_printer ());
- bool show_nesting = false;
+ bool show_nesting = true;
bool show_locations_in_nesting = true;
bool show_levels = false;
for (auto& iter : parsed_arg.m_kvs)
@@ -381,21 +381,21 @@ text_scheme_handler::make_sink (const context &ctxt,
return nullptr;
continue;
}
- if (key == "experimental-nesting")
+ if (key == "show-nesting")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value,
show_nesting))
return nullptr;
continue;
}
- if (key == "experimental-nesting-show-locations")
+ if (key == "show-nesting-locations")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value,
show_locations_in_nesting))
return nullptr;
continue;
}
- if (key == "experimental-nesting-show-levels")
+ if (key == "show-nesting-levels")
{
if (!parse_bool_value (ctxt, unparsed_arg, key, value, show_levels))
return nullptr;
@@ -405,9 +405,9 @@ text_scheme_handler::make_sink (const context &ctxt,
/* Key not found. */
auto_vec<const char *> known_keys;
known_keys.safe_push ("color");
- known_keys.safe_push ("experimental-nesting");
- known_keys.safe_push ("experimental-nesting-show-locations");
- known_keys.safe_push ("experimental-nesting-show-levels");
+ known_keys.safe_push ("show-nesting");
+ known_keys.safe_push ("show-nesting-locations");
+ known_keys.safe_push ("show-nesting-levels");
ctxt.report_unknown_key (unparsed_arg, key, get_scheme_name (),
known_keys);
return nullptr;
diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc
index 4738ae9..7526c16 100644
--- a/gcc/diagnostics/sarif-sink.cc
+++ b/gcc/diagnostics/sarif-sink.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/paths.h"
#include "diagnostics/sink.h"
#include "diagnostics/buffering.h"
+#include "diagnostics/dumping.h"
#include "json.h"
#include "cpplib.h"
#include "diagnostics/logical-locations.h"
@@ -704,6 +705,14 @@ sarif_serialization_format_json::write_to_file (FILE *outf,
fprintf (outf, "\n");
}
+void
+sarif_serialization_format_json::dump (FILE *outfile, int indent) const
+{
+ dumping::emit_indent (outfile, indent);
+ fprintf (outfile, "json\n");
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_formatted);
+}
+
/* A class for managing SARIF output (for -fdiagnostics-format=sarif-stderr
and -fdiagnostics-format=sarif-file).
@@ -760,6 +769,8 @@ public:
const sarif_generation_options &sarif_gen_opts);
~sarif_builder ();
+ void dump (FILE *out, int indent) const;
+
void set_printer (pretty_printer &printer)
{
m_printer = &printer;
@@ -1674,7 +1685,7 @@ sarif_builder::sarif_builder (diagnostics::context &dc,
(std::make_unique<sarif_array_of_unique<sarif_logical_location>> ()),
m_run_graphs
(std::make_unique<sarif_array_of_unique<sarif_graph>> ()),
- m_tabstop (dc.m_tabstop),
+ m_tabstop (dc.get_column_options ().m_tabstop),
m_serialization_format (std::move (serialization_format)),
m_sarif_gen_opts (sarif_gen_opts),
m_next_result_idx (0),
@@ -1699,6 +1710,15 @@ sarif_builder::~sarif_builder ()
}
}
+void
+sarif_builder::dump (FILE *out, int indent) const
+{
+ dumping::emit_heading (out, indent, "serialization format");
+ m_serialization_format->dump (out, indent + 2);
+ dumping::emit_heading (out, indent, "SARIF generation options");
+ m_sarif_gen_opts.dump (out, indent + 2);
+}
+
/* Functions at which to stop the backtrace print. It's not
particularly helpful to print the callers of these functions. */
@@ -3803,11 +3823,12 @@ sarif_builder::make_artifact_content_object (const char *text) const
void
sarif_sink_buffer::dump (FILE *out, int indent) const
{
- fprintf (out, "%*ssarif_sink_buffer:\n", indent, "");
+ dumping::emit_heading (out, indent, "sarif_sink_buffer");
int idx = 0;
for (auto &result : m_results)
{
- fprintf (out, "%*sresult[%i]:\n", indent + 2, "", idx);
+ dumping::emit_indent (out, indent + 2);
+ fprintf (out, "result[%i]:\n", idx);
result->dump (out, true);
fprintf (out, "\n");
++idx;
@@ -3862,8 +3883,9 @@ public:
void dump (FILE *out, int indent) const override
{
- fprintf (out, "%*ssarif_sink\n", indent, "");
sink::dump (out, indent);
+ dumping::emit_heading (out, indent, "sarif_builder");
+ m_builder.dump (out, indent + 2);
}
void
@@ -3973,6 +3995,10 @@ public:
{
m_builder.flush_to_file (m_stream);
}
+ void dump_kind (FILE *out) const override
+ {
+ fprintf (out, "sarif_stream_sink");
+ }
bool machine_readable_stderr_p () const final override
{
return m_stream == stderr;
@@ -4001,12 +4027,10 @@ public:
{
m_builder.flush_to_file (m_output_file.get_open_file ());
}
- void dump (FILE *out, int indent) const override
+ void dump_kind (FILE *out) const override
{
- fprintf (out, "%*ssarif_file_sink: %s\n",
- indent, "",
+ fprintf (out, "sarif_file_sink: %s",
m_output_file.get_filename ());
- sink::dump (out, indent);
}
bool machine_readable_stderr_p () const final override
{
@@ -4319,6 +4343,29 @@ sarif_generation_options::sarif_generation_options ()
{
}
+static const char *
+get_dump_string_for_sarif_version (enum sarif_version version)
+{
+ switch (version)
+ {
+ default:
+ gcc_unreachable ();
+ case sarif_version::v2_1_0:
+ return "v2_1_0";
+ case sarif_version::v2_2_prerelease_2024_08_08:
+ return "v2_2_prerelease_2024_08_08";
+ }
+}
+
+void
+sarif_generation_options::dump (FILE *outfile, int indent) const
+{
+ dumping::emit_string_field (outfile, indent,
+ "m_version",
+ get_dump_string_for_sarif_version (m_version));
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_state_graph);
+}
+
#if CHECKING_P
namespace selftest {
@@ -4406,10 +4453,10 @@ public:
test_sarif_diagnostic_context (const char *main_input_filename,
const sarif_generation_options &sarif_gen_opts)
{
- auto sink_ = std::make_unique<buffered_sink> (*this,
- line_table,
- true,
- sarif_gen_opts);
+ auto sink_ = std::make_unique<sarif_buffered_sink> (*this,
+ line_table,
+ true,
+ sarif_gen_opts);
m_sink = sink_.get (); // borrowed
init_sarif_sink (*this, std::move (sink_));
m_sink->set_main_input_filename (main_input_filename);
@@ -4424,10 +4471,10 @@ public:
sarif_result &get_result (size_t idx) { return m_sink->get_result (idx); }
private:
- class buffered_sink : public sarif_sink
+ class sarif_buffered_sink : public sarif_sink
{
public:
- buffered_sink (context &dc,
+ sarif_buffered_sink (context &dc,
const line_maps *line_maps,
bool formatted,
const sarif_generation_options &sarif_gen_opts)
@@ -4436,6 +4483,10 @@ private:
sarif_gen_opts)
{
}
+ void dump_kind (FILE *out) const final override
+ {
+ fprintf (out, "sarif_buffered_sink");
+ }
bool machine_readable_stderr_p () const final override
{
return false;
@@ -4446,7 +4497,7 @@ private:
}
};
- buffered_sink *m_sink; // borrowed
+ sarif_buffered_sink *m_sink; // borrowed
};
/* Test making a sarif_location for a complex rich_location
diff --git a/gcc/diagnostics/sarif-sink.h b/gcc/diagnostics/sarif-sink.h
index 9f8a73f..e6f897b 100644
--- a/gcc/diagnostics/sarif-sink.h
+++ b/gcc/diagnostics/sarif-sink.h
@@ -73,6 +73,7 @@ public:
virtual ~sarif_serialization_format () {}
virtual void write_to_file (FILE *outf,
const json::value &top) = 0;
+ virtual void dump (FILE *out, int indent) const = 0;
};
/* Concrete subclass for serializing SARIF as JSON. */
@@ -85,6 +86,7 @@ public:
{
}
void write_to_file (FILE *outf, const json::value &top) final override;
+ void dump (FILE *out, int indent) const final override;
private:
bool m_formatted;
@@ -108,6 +110,8 @@ struct sarif_generation_options
{
sarif_generation_options ();
+ void dump (FILE *out, int indent) const;
+
enum sarif_version m_version;
bool m_state_graph;
};
diff --git a/gcc/diagnostics/sink.h b/gcc/diagnostics/sink.h
index ac4e0fb64..24eb707 100644
--- a/gcc/diagnostics/sink.h
+++ b/gcc/diagnostics/sink.h
@@ -36,6 +36,9 @@ class sink
public:
virtual ~sink () {}
+ virtual text_sink *dyn_cast_text_sink () { return nullptr; }
+
+ virtual void dump_kind (FILE *out) const = 0;
virtual void dump (FILE *out, int indent) const;
/* Vfunc for notifying this format what the primary input file is,
diff --git a/gcc/diagnostics/source-printing.cc b/gcc/diagnostics/source-printing.cc
index 94b1c2d..aeda9ad 100644
--- a/gcc/diagnostics/source-printing.cc
+++ b/gcc/diagnostics/source-printing.cc
@@ -4412,7 +4412,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
for (int tabstop = 1; tabstop != num_tabstops; ++tabstop)
{
test_context dc;
- dc.m_tabstop = tabstop;
+ dc.get_column_options ().m_tabstop = tabstop;
diagnostics::source_print_policy policy (dc);
layout test_layout (policy, richloc, nullptr);
colorizer col (*dc.get_reference_printer (),
@@ -4436,7 +4436,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_)
for (int tabstop = 1; tabstop != num_tabstops; ++tabstop)
{
test_context dc;
- dc.m_tabstop = tabstop;
+ dc.get_column_options ().m_tabstop = tabstop;
static const int small_width = 24;
auto &source_printing_opts = dc.get_source_printing_options ();
source_printing_opts.max_width = small_width - 4;
@@ -6833,7 +6833,7 @@ test_tab_expansion (const line_table_case &case_)
everything too. */
{
test_context dc;
- dc.m_tabstop = tabstop;
+ dc.get_column_options ().m_tabstop = tabstop;
rich_location richloc (line_table,
linemap_position_for_column (line_table,
first_non_ws_byte_col));
@@ -6846,7 +6846,7 @@ test_tab_expansion (const line_table_case &case_)
as well. */
{
test_context dc;
- dc.m_tabstop = tabstop;
+ dc.get_column_options ().m_tabstop = tabstop;
rich_location richloc (line_table,
linemap_position_for_column (line_table,
right_quote_byte_col));
diff --git a/gcc/diagnostics/text-sink.cc b/gcc/diagnostics/text-sink.cc
index bcf91cf..48b369c 100644
--- a/gcc/diagnostics/text-sink.cc
+++ b/gcc/diagnostics/text-sink.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostics/diagram.h"
#include "diagnostics/text-sink.h"
#include "diagnostics/buffering.h"
+#include "diagnostics/dumping.h"
#include "text-art/theme.h"
/* Disable warnings about quoting issues in the pp_xxx calls below
@@ -76,7 +77,7 @@ text_sink_buffer::text_sink_buffer (sink &sink_)
void
text_sink_buffer::dump (FILE *out, int indent) const
{
- fprintf (out, "%*stext_sink_buffer:\n", indent, "");
+ dumping::emit_heading (out, indent, "text_sink_buffer");
m_output_buffer.dump (out, indent + 2);
}
@@ -156,18 +157,19 @@ text_sink::~text_sink ()
}
void
-text_sink::dump (FILE *out, int indent) const
-{
- fprintf (out, "%*stext_sink\n", indent, "");
- fprintf (out, "%*sm_follows_reference_printer: %s\n",
- indent, "",
- m_follows_reference_printer ? "true" : "false");
- sink::dump (out, indent);
- fprintf (out, "%*ssaved_output_buffer:\n", indent + 2, "");
+text_sink::dump (FILE *outfile, int indent) const
+{
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_follows_reference_printer);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_nesting);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_locations_in_nesting);
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_nesting_levels);
+
+ sink::dump (outfile, indent);
+ dumping::emit_heading (outfile, indent, "saved_output_buffer");
if (m_saved_output_buffer)
- m_saved_output_buffer->dump (out, indent + 4);
+ m_saved_output_buffer->dump (outfile, indent + 2);
else
- fprintf (out, "%*s(none):\n", indent + 4, "");
+ dumping::emit_none (outfile, indent + 2);
}
void
@@ -612,7 +614,7 @@ text_sink::get_location_text (const expanded_location &s) const
The result is a statically allocated buffer. */
const char *
-maybe_line_and_column (int line, int col)
+text_sink::maybe_line_and_column (int line, int col)
{
static char result[32];
diff --git a/gcc/diagnostics/text-sink.h b/gcc/diagnostics/text-sink.h
index 5c60976..f280e72 100644
--- a/gcc/diagnostics/text-sink.h
+++ b/gcc/diagnostics/text-sink.h
@@ -51,6 +51,12 @@ public:
{}
~text_sink ();
+ text_sink *dyn_cast_text_sink () final override { return this; }
+
+ void dump_kind (FILE *out) const override
+ {
+ fprintf (out, "text_sink");
+ }
void dump (FILE *out, int indent) const override;
std::unique_ptr<per_sink_buffer>
@@ -127,6 +133,8 @@ public:
return m_source_printing;
}
+ static const char *maybe_line_and_column (int line, int col);
+
protected:
void print_any_cwe (const diagnostic_info &diagnostic);
void print_any_rules (const diagnostic_info &diagnostic);
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 00468a7..28466c4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -322,6 +322,9 @@ Objective-C and Objective-C++ Dialects}.
-fno-diagnostics-show-cwe
-fno-diagnostics-show-rules
-fno-diagnostics-show-highlight-colors
+-fno-diagnostics-show-nesting
+-fno-diagnostics-show-nesting-locations
+-fdiagnostics-show-nesting-levels
-fdiagnostics-minimum-margin-width=@var{width}
-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
-fdiagnostics-show-template-tree -fno-elide-type
@@ -388,6 +391,7 @@ Objective-C and Objective-C++ Dialects}.
-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
-Wno-int-to-pointer-cast -Wno-invalid-memory-model
-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
+-Wkeyword-macro
-Wlarger-than=@var{byte-size} -Wleading-whitespace=@var{kind}
-Wlogical-not-parentheses -Wlogical-op
-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
@@ -5428,7 +5432,8 @@ options:
-fdiagnostics-urls=never
-fdiagnostics-path-format=separate-events
-fdiagnostics-text-art-charset=none
--fno-diagnostics-show-event-links}
+-fno-diagnostics-show-event-links
+-fno-diagnostics-show-nesting}
In the future, if GCC changes the default appearance of its diagnostics, the
corresponding option to disable the new behavior will be added to this list.
@@ -6050,6 +6055,40 @@ emoji variant of the character).
The default is @samp{emoji}, except when the environment variable @env{LANG}
is set to @samp{C}, in which case the default is @samp{ascii}.
+@opindex fno-diagnostics-show-nesting
+@opindex fdiagnostics-show-nesting
+@item -fno-diagnostics-show-nesting
+Some GCC diagnostics have an internal tree-like structure of nested
+sub-diagnostics, such as for problems when instantiating C++ templates.
+
+By default GCC uses indentation and bullet points in its text output to
+show the nesting structure of these diagnostics, moves location
+information to separate lines to make the structure clearer, and
+eliminates redundant repeated information.
+
+Selecting @option{-fno-diagnostics-show-nesting} suppresses this
+indentation, reformatting, and elision, restoring an older `look'' for the
+diagnostics.
+
+@opindex fno-diagnostics-show-nesting-locations
+@opindex fdiagnostics-show-nesting-locations
+@item -fno-diagnostics-show-nesting-locations
+
+When @option{fdiagnostics-show-nesting} is enabled, file names and
+line- and column- numbers are displayed on separate lines from the
+messages. This location information can be disabled altogether with
+@option{-fno-diagnostics-show-nesting-locations}.
+This option exists for use by GCC developers, for writing DejaGnu test cases.
+
+@opindex fdiagnostics-show-nesting-levels
+@opindex fno-diagnostics-show-nesting-levels
+@item -fdiagnostics-show-nesting-levels
+When @option{fdiagnostics-show-nesting} is enabled, use
+@option{fdiagnostics-show-nesting-levels} to also display numbers
+showing the depth of the nesting.
+This option exists for use by GCC developers for debugging nested
+diagnostics, but may be of use to plugin authors.
+
@opindex fdiagnostics-format
@item -fdiagnostics-format=@var{FORMAT}
Select a different format for printing diagnostics.
@@ -6098,18 +6137,18 @@ Supported keys are:
Override colorization settings from @option{-fdiagnostics-color} for this
text output.
-@item experimental-nesting=@r{[}yes@r{|}no@r{]}
-Enable an experimental mode that emphasizes hierarchical relationships
-within diagnostics messages, displaying location information on separate
-lines.
+@item show-nesting=@r{[}yes@r{|}no@r{]}
+Enable a mode that emphasizes hierarchical relationships
+within diagnostics messages, as per @option{-fdiagnostics-show-nesting}.
+Defaults to @code{yes}.
-@item experimental-nesting-show-locations=@r{[}yes@r{|}no@r{]}
-If @code{experimental-nesting=yes}, then by default locations are
+@item show-nesting-locations=@r{[}yes@r{|}no@r{]}
+If @code{show-nesting=yes}, then by default locations are
shown; set this key to @code{no} to disable printing such locations.
This exists for use by GCC developers, for writing DejaGnu test cases.
-@item experimental-nesting-show-levels=@r{[}yes@r{|}no@r{]}
-This is a debugging option for use with @code{experimental-nesting=yes}.
+@item show-nesting-levels=@r{[}yes@r{|}no@r{]}
+This is a debugging option for use with @code{show-nesting=yes}.
Set this key to @code{yes} to print explicit nesting levels in the output.
This exists for use by GCC developers.
@@ -10399,6 +10438,14 @@ Do not warn if certain built-in macros are redefined. This suppresses
warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
+@opindex Wkeyword-macro
+@opindex Wno-keyword-macro
+@item -Wkeyword-macro
+Warn if a keyword is defined as a macro or undefined.
+For C++ identifiers with special meaning or standard attribute identifiers
+are diagnosed as well. This warning is enabled by default for C++26
+if @code{-Wpedantic} and emits a pedwarn in that case.
+
@opindex Wfree-labels
@opindex Wno-free-labels
@item -Wfree-labels @r{(C and Objective-C only)}
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4d4e676..4c338c3 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -37,6 +37,8 @@ through the macros defined in the @file{.h} file.
* Trampolines:: Code set up at run time to enter a nested function.
* Library Calls:: Controlling how library routines are implicitly called.
* Addressing Modes:: Defining addressing modes valid for memory operands.
+* Vectorization:: Controlling how the vectorizer operates.
+* OpenMP and OpenACC:: Defining how OpenMP and OpenACC features should work.
* Anchored Addresses:: Defining how @option{-fsection-anchors} should work.
* Condition Code:: Defining how insns update the condition code.
* Costs:: Defining relative costs of different operations.
@@ -6282,6 +6284,10 @@ reciprocal of the machine-specific builtin function @var{fndecl}, or
@code{NULL_TREE} if such a function is not available.
@end deftypefn
+@node Vectorization
+@section Vectorization
+@cindex Vectorization
+
@deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD (void)
This hook should return the DECL of a function @var{f} that given an
address @var{addr} as an argument returns a mask @var{m} that can be
@@ -6522,6 +6528,10 @@ number of scalar elements in each scalar loop iteration that are to be
combined into the vector.
@end deftypefn
+@node OpenMP and OpenACC
+@section OpenMP and OpenACC
+@cindex OpenMP and OpenACC
+
@deftypefn {Target Hook} int TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN (struct cgraph_node *@var{}, struct cgraph_simd_clone *@var{}, @var{tree}, @var{int}, @var{bool})
This hook should set @var{vecsize_mangle}, @var{vecsize_int}, @var{vecsize_float}
fields in @var{simd_clone} structure pointed by @var{clone_info} argument and also
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 1a51ad5..12b8ed6 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -37,6 +37,8 @@ through the macros defined in the @file{.h} file.
* Trampolines:: Code set up at run time to enter a nested function.
* Library Calls:: Controlling how library routines are implicitly called.
* Addressing Modes:: Defining addressing modes valid for memory operands.
+* Vectorization:: Controlling how the vectorizer operates.
+* OpenMP and OpenACC:: Defining how OpenMP and OpenACC features should work.
* Anchored Addresses:: Defining how @option{-fsection-anchors} should work.
* Condition Code:: Defining how insns update the condition code.
* Costs:: Defining relative costs of different operations.
@@ -4273,6 +4275,10 @@ address; but often a machine-dependent strategy can generate better code.
@hook TARGET_BUILTIN_RECIPROCAL
+@node Vectorization
+@section Vectorization
+@cindex Vectorization
+
@hook TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD
@hook TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST
@@ -4313,6 +4319,10 @@ address; but often a machine-dependent strategy can generate better code.
@hook TARGET_VECTORIZE_PREFER_GATHER_SCATTER
+@node OpenMP and OpenACC
+@section OpenMP and OpenACC
+@cindex OpenMP and OpenACC
+
@hook TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN
@hook TARGET_SIMD_CLONE_ADJUST
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 20e4a76..c203356 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,18 @@
+2025-08-09 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/121182
+ * decl.cc (match_generic_stmt): New function based on original
+ gfc_match_generic but feeding namespace rather than typebound
+ generics.
+ (match_typebound_generic): Renamed original gfc_match_generic.
+ (gfc_match_generic): New function that selects between type
+ bound generic and other generic statements and calls one of the
+ above two functions as appropriate.
+ * parse.cc (decode_specification_statement): Allow generic
+ statements.
+ (parse_spec): Accept a generic statement in a specification
+ block.
+
2025-08-05 Mikael Morin <morin-mikael@orange.fr>
* trans-stmt.cc (trans_associate_var): Remove overwrite of
@@ -285,7 +300,7 @@
2025-07-11 Paul Thomas <pault@gcc.gnu.org>
- PR fortran/106135
+ PR fortran/106035
* decl.cc (build_sym): Emit an error if a symbol associated by
an IMPORT, ONLY or IMPORT, all statement is being redeclared.
(gfc_match_import): Parse and check the F2018 versions of the
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index af42575..5146731 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -11710,10 +11710,308 @@ syntax:
}
+/* Match a GENERIC statement.
+F2018 15.4.3.3 GENERIC statement
+
+A GENERIC statement specifies a generic identifier for one or more specific
+procedures, in the same way as a generic interface block that does not contain
+interface bodies.
+
+R1510 generic-stmt is:
+GENERIC [ , access-spec ] :: generic-spec => specific-procedure-list
+
+C1510 (R1510) A specific-procedure in a GENERIC statement shall not specify a
+procedure that was specified previously in any accessible interface with the
+same generic identifier.
+
+If access-spec appears, it specifies the accessibility (8.5.2) of generic-spec.
+
+For GENERIC statements outside of a derived type, use is made of the existing,
+typebound matching functions to obtain access-spec and generic-spec. After
+this the standard INTERFACE machinery is used. */
+
+static match
+match_generic_stmt (void)
+{
+ char name[GFC_MAX_SYMBOL_LEN + 1];
+ /* Allow space for OPERATOR(...). */
+ char generic_spec_name[GFC_MAX_SYMBOL_LEN + 16];
+ /* Generics other than uops */
+ gfc_symbol* generic_spec = NULL;
+ /* Generic uops */
+ gfc_user_op *generic_uop = NULL;
+ /* For the matching calls */
+ gfc_typebound_proc tbattr;
+ gfc_namespace* ns = gfc_current_ns;
+ interface_type op_type;
+ gfc_intrinsic_op op;
+ match m;
+ gfc_symtree* st;
+ /* The specific-procedure-list */
+ gfc_interface *generic = NULL;
+ /* The head of the specific-procedure-list */
+ gfc_interface **generic_tail = NULL;
+
+ memset (&tbattr, 0, sizeof (tbattr));
+ tbattr.where = gfc_current_locus;
+
+ /* See if we get an access-specifier. */
+ m = match_binding_attributes (&tbattr, true, false);
+ tbattr.where = gfc_current_locus;
+ if (m == MATCH_ERROR)
+ goto error;
+
+ /* Now the colons, those are required. */
+ if (gfc_match (" ::") != MATCH_YES)
+ {
+ gfc_error ("Expected %<::%> at %C");
+ goto error;
+ }
+
+ /* Match the generic-spec name; depending on type (operator / generic) format
+ it for future error messages in 'generic_spec_name'. */
+ m = gfc_match_generic_spec (&op_type, name, &op);
+ if (m == MATCH_ERROR)
+ return MATCH_ERROR;
+ if (m == MATCH_NO)
+ {
+ gfc_error ("Expected generic name or operator descriptor at %C");
+ goto error;
+ }
+
+ switch (op_type)
+ {
+ case INTERFACE_GENERIC:
+ case INTERFACE_DTIO:
+ snprintf (generic_spec_name, sizeof (generic_spec_name), "%s", name);
+ break;
+
+ case INTERFACE_USER_OP:
+ snprintf (generic_spec_name, sizeof (generic_spec_name), "OPERATOR(.%s.)", name);
+ break;
+
+ case INTERFACE_INTRINSIC_OP:
+ snprintf (generic_spec_name, sizeof (generic_spec_name), "OPERATOR(%s)",
+ gfc_op2string (op));
+ break;
+
+ case INTERFACE_NAMELESS:
+ gfc_error ("Malformed GENERIC statement at %C");
+ goto error;
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+
+ /* Match the required =>. */
+ if (gfc_match (" =>") != MATCH_YES)
+ {
+ gfc_error ("Expected %<=>%> at %C");
+ goto error;
+ }
+
+
+ if (gfc_current_state () != COMP_MODULE && tbattr.access != ACCESS_UNKNOWN)
+ {
+ gfc_error ("The access specification at %L not in a module",
+ &tbattr.where);
+ goto error;
+ }
+
+ /* Try to find existing generic-spec with this name for this operator;
+ if there is something, check that it is another generic-spec and then
+ extend it rather than building a new symbol. Otherwise, create a new
+ one with the right attributes. */
+
+ switch (op_type)
+ {
+ case INTERFACE_DTIO:
+ case INTERFACE_GENERIC:
+ st = gfc_find_symtree (ns->sym_root, name);
+ generic_spec = st ? st->n.sym : NULL;
+ if (generic_spec)
+ {
+ if (generic_spec->attr.flavor != FL_PROCEDURE
+ && generic_spec->attr.flavor != FL_UNKNOWN)
+ {
+ gfc_error ("The generic-spec name %qs at %C clashes with the "
+ "name of an entity declared at %L that is not a "
+ "procedure", name, &generic_spec->declared_at);
+ goto error;
+ }
+
+ if (op_type == INTERFACE_GENERIC && !generic_spec->attr.generic
+ && generic_spec->attr.flavor != FL_UNKNOWN)
+ {
+ gfc_error ("There's already a non-generic procedure with "
+ "name %qs at %C", generic_spec->name);
+ goto error;
+ }
+
+ if (tbattr.access != ACCESS_UNKNOWN)
+ {
+ if (generic_spec->attr.access != tbattr.access)
+ {
+ gfc_error ("The access specification at %L conflicts with "
+ "that already given to %qs", &tbattr.where,
+ generic_spec->name);
+ goto error;
+ }
+ else
+ {
+ gfc_error ("The access specification at %L repeats that "
+ "already given to %qs", &tbattr.where,
+ generic_spec->name);
+ goto error;
+ }
+ }
+
+ if (generic_spec->ts.type != BT_UNKNOWN)
+ {
+ gfc_error ("The generic-spec in the generic statement at %C "
+ "has a type from the declaration at %L",
+ &generic_spec->declared_at);
+ goto error;
+ }
+ }
+
+ /* Now create the generic_spec if it doesn't already exist and provide
+ is with the appropriate attributes. */
+ if (!generic_spec || generic_spec->attr.flavor != FL_PROCEDURE)
+ {
+ if (!generic_spec)
+ {
+ gfc_get_symbol (name, ns, &generic_spec, &gfc_current_locus);
+ gfc_set_sym_referenced (generic_spec);
+ generic_spec->attr.access = tbattr.access;
+ }
+ else if (generic_spec->attr.access == ACCESS_UNKNOWN)
+ generic_spec->attr.access = tbattr.access;
+ generic_spec->refs++;
+ generic_spec->attr.generic = 1;
+ generic_spec->attr.flavor = FL_PROCEDURE;
+
+ generic_spec->declared_at = gfc_current_locus;
+ }
+
+ /* Prepare to add the specific procedures. */
+ generic = generic_spec->generic;
+ generic_tail = &generic_spec->generic;
+ break;
+
+ case INTERFACE_USER_OP:
+ st = gfc_find_symtree (ns->uop_root, name);
+ generic_uop = st ? st->n.uop : NULL;
+ if (generic_uop)
+ {
+ if (generic_uop->access != ACCESS_UNKNOWN
+ && tbattr.access != ACCESS_UNKNOWN)
+ {
+ if (generic_uop->access != tbattr.access)
+ {
+ gfc_error ("The user operator at %L must have the same "
+ "access specification as already defined user "
+ "operator %qs", &tbattr.where, generic_spec_name);
+ goto error;
+ }
+ else
+ {
+ gfc_error ("The user operator at %L repeats the access "
+ "specification of already defined user operator " "%qs", &tbattr.where, generic_spec_name);
+ goto error;
+ }
+ }
+ else if (generic_uop->access == ACCESS_UNKNOWN)
+ generic_uop->access = tbattr.access;
+ }
+ else
+ {
+ generic_uop = gfc_get_uop (name);
+ generic_uop->access = tbattr.access;
+ }
+
+ /* Prepare to add the specific procedures. */
+ generic = generic_uop->op;
+ generic_tail = &generic_uop->op;
+ break;
+
+ case INTERFACE_INTRINSIC_OP:
+ generic = ns->op[op];
+ generic_tail = &ns->op[op];
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+
+ /* Now, match all following names in the specific-procedure-list. */
+ do
+ {
+ m = gfc_match_name (name);
+ if (m == MATCH_ERROR)
+ goto error;
+ if (m == MATCH_NO)
+ {
+ gfc_error ("Expected specific procedure name at %C");
+ goto error;
+ }
+
+ if (op_type == INTERFACE_GENERIC
+ && !strcmp (generic_spec->name, name))
+ {
+ gfc_error ("The name %qs of the specific procedure at %C conflicts "
+ "with that of the generic-spec", name);
+ goto error;
+ }
+
+ generic = *generic_tail;
+ for (; generic; generic = generic->next)
+ {
+ if (!strcmp (generic->sym->name, name))
+ {
+ gfc_error ("%qs already defined as a specific procedure for the"
+ " generic %qs at %C", name, generic_spec->name);
+ goto error;
+ }
+ }
+
+ gfc_find_sym_tree (name, ns, 1, &st);
+ if (!st)
+ {
+ /* This might be a procedure that has not yet been parsed. If
+ so gfc_fixup_sibling_symbols will replace this symbol with
+ that of the procedure. */
+ gfc_get_sym_tree (name, ns, &st, false);
+ st->n.sym->refs++;
+ }
+
+ generic = gfc_get_interface();
+ generic->next = *generic_tail;
+ *generic_tail = generic;
+ generic->where = gfc_current_locus;
+ generic->sym = st->n.sym;
+ }
+ while (gfc_match (" ,") == MATCH_YES);
+
+ if (gfc_match_eos () != MATCH_YES)
+ {
+ gfc_error ("Junk after GENERIC statement at %C");
+ goto error;
+ }
+
+ gfc_commit_symbols ();
+ return MATCH_YES;
+
+error:
+ return MATCH_ERROR;
+}
+
+
/* Match a GENERIC procedure binding inside a derived type. */
-match
-gfc_match_generic (void)
+static match
+match_typebound_generic (void)
{
char name[GFC_MAX_SYMBOL_LEN + 1];
char bind_name[GFC_MAX_SYMBOL_LEN + 16]; /* Allow space for OPERATOR(...). */
@@ -11923,6 +12221,17 @@ error:
}
+match
+gfc_match_generic ()
+{
+ if (gfc_option.allow_std & ~GFC_STD_OPT_F08
+ && gfc_current_state () != COMP_DERIVED_CONTAINS)
+ return match_generic_stmt ();
+ else
+ return match_typebound_generic ();
+}
+
+
/* Match a FINAL declaration inside a derived type. */
match
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index 847ff37..300a7a3 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -242,6 +242,7 @@ decode_specification_statement (void)
break;
case 'g':
+ match ("generic", gfc_match_generic, ST_GENERIC);
break;
case 'i':
@@ -4534,6 +4535,11 @@ declSt:
st = next_statement ();
goto loop;
+ case ST_GENERIC:
+ accept_statement (st);
+ st = next_statement ();
+ goto loop;
+
case ST_ENUM:
accept_statement (st);
parse_enum();
diff --git a/gcc/libgdiagnostics.cc b/gcc/libgdiagnostics.cc
index 784e281..d87dd46 100644
--- a/gcc/libgdiagnostics.cc
+++ b/gcc/libgdiagnostics.cc
@@ -1939,7 +1939,8 @@ diagnostic_manager_debug_dump_file (diagnostic_manager *,
fprintf (out, ", sarif_source_language=\"%s\"",
file->get_sarif_source_language ());
if (const content_buffer *buf = file->get_content ())
- fprintf (out, ", content=(size=%zi)", buf->m_sz);
+ fprintf (out, ", content=(size=" HOST_SIZE_T_PRINT_DEC ")",
+ buf->m_sz);
fprintf (out, ")");
}
else
diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 03fca97..dbe3ad0 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -320,6 +320,9 @@ merge_and_complain (vec<cl_decoded_option> &decoded_options,
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
case OPT_fcommon:
case OPT_fgnu_tm:
@@ -739,6 +742,9 @@ append_compiler_options (obstack *argv_obstack, vec<cl_decoded_option> opts)
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
case OPT_fPIC:
case OPT_fpic:
@@ -801,6 +807,9 @@ append_diag_options (obstack *argv_obstack, vec<cl_decoded_option> opts)
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_location_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fshow_column:
break;
default:
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index e6d7f4d..379402e 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -1096,7 +1096,8 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
"-fdiagnostics-urls=never",
"-fdiagnostics-path-format=separate-events",
"-fdiagnostics-text-art-charset=none",
- "-fno-diagnostics-show-event-links"
+ "-fno-diagnostics-show-event-links",
+ "-fno-diagnostics-show-nesting"
/* We don't put "-fno-diagnostics-show-highlight-colors" here
as -fdiagnostics-color=never makes it redundant. */
};
diff --git a/gcc/opts.cc b/gcc/opts.cc
index b6d25bf..a02d017 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3016,11 +3016,12 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_fdiagnostics_column_unit_:
- dc->m_column_unit = (enum diagnostics_column_unit)value;
+ dc->get_column_options ().m_column_unit
+ = (enum diagnostics_column_unit)value;
break;
case OPT_fdiagnostics_column_origin_:
- dc->m_column_origin = value;
+ dc->get_column_options ().m_column_origin = value;
break;
case OPT_fdiagnostics_escape_format_:
@@ -3051,6 +3052,18 @@ common_handle_option (struct gcc_options *opts,
dc->set_show_option_requested (value);
break;
+ case OPT_fdiagnostics_show_nesting:
+ dc->set_show_nesting (value);
+ break;
+
+ case OPT_fdiagnostics_show_nesting_locations:
+ dc->set_show_nesting_locations (value);
+ break;
+
+ case OPT_fdiagnostics_show_nesting_levels:
+ dc->set_show_nesting_levels (value);
+ break;
+
case OPT_fdiagnostics_minimum_margin_width_:
dc->get_source_printing_options ().min_margin_width = value;
break;
@@ -3408,7 +3421,7 @@ common_handle_option (struct gcc_options *opts,
case OPT_ftabstop_:
/* It is documented that we silently ignore silly values. */
if (value >= 1 && value <= 100)
- dc->m_tabstop = value;
+ dc->get_column_options ().m_tabstop = value;
break;
case OPT_freport_bug:
@@ -3879,6 +3892,9 @@ gen_command_line_string (cl_decoded_option *options,
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_color_:
case OPT_fdiagnostics_format_:
+ case OPT_fdiagnostics_show_nesting:
+ case OPT_fdiagnostics_show_nesting_locations:
+ case OPT_fdiagnostics_show_nesting_levels:
case OPT_fverbose_asm:
case OPT____:
case OPT__sysroot_:
diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc
index 77d40ec..d79a828 100644
--- a/gcc/pretty-print.cc
+++ b/gcc/pretty-print.cc
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "pretty-print-urlifier.h"
#include "diagnostics/color.h"
#include "diagnostics/event-id.h"
+#include "diagnostics/dumping.h"
#include "diagnostic-highlight-colors.h"
#include "auto-obstack.h"
#include "selftest.h"
@@ -1600,9 +1601,8 @@ pp_formatted_chunks::dump (FILE *out, int indent) const
{
for (size_t idx = 0; m_args[idx]; ++idx)
{
- fprintf (out, "%*s%i: ",
- indent, "",
- (int)idx);
+ diagnostics::dumping::emit_indent (out, indent);
+ fprintf (out, "%i: ", (int)idx);
m_args[idx]->dump (out);
}
}
@@ -3100,34 +3100,39 @@ pretty_printer::end_url ()
pp_string (this, get_end_url_string (this));
}
-/* Dump state of this pretty_printer to OUT, for debugging. */
-
-void
-pretty_printer::dump (FILE *out, int indent) const
+static const char *
+get_url_format_as_string (diagnostic_url_format url_format)
{
- fprintf (out, "%*sm_show_color: %s\n",
- indent, "",
- m_show_color ? "true" : "false");
-
- fprintf (out, "%*sm_url_format: ", indent, "");
- switch (m_url_format)
+ switch (url_format)
{
case URL_FORMAT_NONE:
- fprintf (out, "none");
- break;
+ return "none";
case URL_FORMAT_ST:
- fprintf (out, "st");
- break;
+ return "st";
case URL_FORMAT_BEL:
- fprintf (out, "bel");
- break;
+ return "bel";
default:
gcc_unreachable ();
}
- fprintf (out, "\n");
+}
+
+/* Dump state of this pretty_printer to OUT, for debugging. */
- fprintf (out, "%*sm_buffer:\n", indent, "");
- m_buffer->dump (out, indent + 2);
+void
+pretty_printer::dump (FILE *outfile, int indent) const
+{
+ namespace dumping = diagnostics::dumping;
+
+ DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD (m_show_color);
+ dumping::emit_string_field
+ (outfile, indent,
+ "m_url_format",
+ get_url_format_as_string (m_url_format));
+ dumping::emit_heading (outfile, indent, "m_buffer");
+ if (m_buffer)
+ m_buffer->dump (outfile, indent + 2);
+ else
+ dumping::emit_none (outfile, indent + 2);
}
/* class pp_markup::context. */
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index c723a07..ee9c048 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -8460,14 +8460,10 @@ simplify_context::simplify_gen_subreg (machine_mode outermode, rtx op,
if (GET_CODE (op) == SUBREG
|| GET_CODE (op) == CONCAT
- || GET_MODE (op) == VOIDmode)
- return NULL_RTX;
-
- if (MODE_COMPOSITE_P (outermode)
- && (CONST_SCALAR_INT_P (op)
- || CONST_DOUBLE_AS_FLOAT_P (op)
- || CONST_FIXED_P (op)
- || GET_CODE (op) == CONST_VECTOR))
+ || CONST_SCALAR_INT_P (op)
+ || CONST_DOUBLE_AS_FLOAT_P (op)
+ || CONST_FIXED_P (op)
+ || GET_CODE (op) == CONST_VECTOR)
return NULL_RTX;
if (validate_subreg (outermode, innermode, op, byte))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1ac6084..b3ddaf1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,294 @@
+2025-08-09 H.J. Lu <hjl.tools@gmail.com>
+
+ PR testsuite/121205
+ * gcc.target/i386/asm-hard-reg-2.c (z): Use long long for -m32
+ to trigger RA error.
+
+2025-08-09 Dimitar Dimitrov <dimitar@dinux.eu>
+
+ * g++.dg/modules/class-11_a.H: Skip test for effective
+ default_packed targets.
+ * g++.dg/modules/class-11_b.C: Ditto.
+
+2025-08-09 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/121182
+ * gfortran.dg/generic_stmt_1.f90: New test.
+ * gfortran.dg/generic_stmt_2.f90: New test.
+ * gfortran.dg/generic_stmt_3.f90: New test.
+ * gfortran.dg/generic_stmt_4.f90: New test.
+
+2025-08-09 Dimitar Dimitrov <dimitar@dinux.eu>
+
+ * gcc.dg/torture/hardbool-ai.c: Require target that supports
+ atomic operations on int types.
+
+2025-08-08 Andrew Pinski <quic_apinski@quicinc.com>
+
+ PR tree-optimization/120599
+ * g++.dg/torture/noncall-eh-1.C: New test.
+
+2025-08-08 Andrew Pinski <quic_apinski@quicinc.com>
+
+ PR tree-optimization/118946
+ PR tree-optimization/121422
+ * gcc.dg/pr118946-1.c: New test.
+ * gcc.dg/torture/pr121422-1.c: New test.
+ * gcc.dg/torture/pr121422-2.c: New test.
+
+2025-08-08 David Malcolm <dmalcolm@redhat.com>
+
+ PR diagnostics/116253
+ * g++.dg/concepts/nested-diagnostics-1-truncated.C: Update for
+ renamed keys to -fdiagnostics-set-output=text
+ * g++.dg/concepts/nested-diagnostics-1.C: Likewise.
+ * g++.dg/concepts/nested-diagnostics-2.C: Likewise.
+ * gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c: New
+ test.
+ * gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c: New test.
+ * gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c:
+ Update for renamed keys to -fdiagnostics-set-output=text.
+ * gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c:
+ Likewise.
+ * gcc.dg/plugin/diagnostic-test-nesting-text-indented.c: Likewise.
+ * gcc.dg/plugin/plugin.exp: Add the new tests.
+
+2025-08-08 Christophe Lyon <christophe.lyon@linaro.org>
+
+ PR target/120977
+ * gcc.target/arm/cmse/cmse-18.c: Check only the case when FPCXT is
+ not enabled.
+ * gcc.target/arm/cmse/cmse-19.c: New test.
+
+2025-08-08 Pengfei Li <Pengfei.Li2@arm.com>
+
+ PR target/121449
+ * g++.target/aarch64/sve/pr121449.C: New test.
+
+2025-08-08 Alex Coplan <alex.coplan@arm.com>
+
+ PR target/120986
+ * gcc.target/aarch64/torture/pr120986-2.c: New test.
+
+2025-08-08 Alex Coplan <alex.coplan@arm.com>
+
+ PR target/120986
+ * gcc.target/aarch64/pr120986-1.c: New test.
+
+2025-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/121389
+ * c-c++-common/asan/pr121389-1.c: New test.
+ * c-c++-common/asan/pr121389-2.c: New test.
+ * c-c++-common/asan/pr121389-3.c: New test.
+ * c-c++-common/asan/pr121389-4.c: New test.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/117783
+ * g++.dg/cpp26/decomp13.C: New test.
+ * g++.dg/cpp26/decomp14.C: New test.
+ * g++.dg/cpp26/decomp15.C: New test.
+ * g++.dg/cpp26/decomp16.C: New test.
+ * g++.dg/cpp26/decomp17.C: New test.
+ * g++.dg/cpp26/decomp18.C: New test.
+ * g++.dg/cpp26/decomp19.C: New test.
+ * g++.dg/cpp26/decomp20.C: New test.
+ * g++.dg/cpp26/decomp21.C: New test.
+ * g++.dg/cpp26/feat-cxx26.C (__cpp_structured_bindings): Expect
+ 202411 rather than 202403.
+
+2025-08-07 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR target/121414
+ * gcc.target/aarch64/sme/pr121414_1.c: New test.
+
+2025-08-07 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR rtl-optimization/120718
+ * gcc.target/aarch64/sve/acle/general/pr120718.c: New test.
+
+2025-08-07 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/121405
+ * gcc.dg/tree-ssa/ssa-fre-107.c: New testcase.
+ * gcc.target/i386/pr90579.c: Adjust.
+
+2025-08-07 Pengfei Li <Pengfei.Li2@arm.com>
+
+ * gcc.target/aarch64/sve/peel_ind_11.c: New test.
+ * gcc.target/aarch64/sve/peel_ind_11_run.c: New test.
+ * gcc.target/aarch64/sve/peel_ind_12.c: New test.
+ * gcc.target/aarch64/sve/peel_ind_12_run.c: New test.
+ * gcc.target/aarch64/sve/peel_ind_13.c: New test.
+ * gcc.target/aarch64/sve/peel_ind_13_run.c: New test.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * g++.dg/DRs/dr2577-1.C: New test.
+ * g++.dg/DRs/dr2577-2.C: New test.
+ * g++.dg/DRs/dr2577-2.h: New file.
+ * g++.dg/DRs/dr2577-3.C: New test.
+ * g++.dg/DRs/dr2577-3.h: New file.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * g++.dg/DRs/dr2575.C: New test.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * g++.dg/DRs/dr2576.C: New test.
+
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * gcc.dg/Wkeyword-macro-1.c: New test.
+ * gcc.dg/Wkeyword-macro-2.c: New test.
+ * gcc.dg/Wkeyword-macro-3.c: New test.
+ * gcc.dg/Wkeyword-macro-4.c: New test.
+ * gcc.dg/Wkeyword-macro-5.c: New test.
+ * gcc.dg/Wkeyword-macro-6.c: New test.
+ * gcc.dg/Wkeyword-macro-7.c: New test.
+ * gcc.dg/Wkeyword-macro-8.c: New test.
+ * gcc.dg/Wkeyword-macro-9.c: New test.
+ * g++.dg/warn/Wkeyword-macro-1.C: New test.
+ * g++.dg/warn/Wkeyword-macro-2.C: New test.
+ * g++.dg/warn/Wkeyword-macro-3.C: New test.
+ * g++.dg/warn/Wkeyword-macro-4.C: New test.
+ * g++.dg/warn/Wkeyword-macro-5.C: New test.
+ * g++.dg/warn/Wkeyword-macro-6.C: New test.
+ * g++.dg/warn/Wkeyword-macro-7.C: New test.
+ * g++.dg/warn/Wkeyword-macro-8.C: New test.
+ * g++.dg/warn/Wkeyword-macro-9.C: New test.
+ * g++.dg/warn/Wkeyword-macro-10.C: New test.
+ * g++.dg/opt/pr82577.C: Don't #define register to nothing for
+ C++17 and later. Instead define reg macro to nothing for C++17
+ and later or to register and use it instead of register.
+ * g++.dg/modules/atom-preamble-3.C: Add -Wno-keyword-macro to
+ dg-additional-options.
+ * g++.dg/template/sfinae17.C (static_assert): Rename macro to ...
+ (my_static_assert): ... this.
+ (main): Use my_static_assert instead of static_assert.
+
+2025-08-07 Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
+
+ * gcc.target/s390/bitint-1.c: New test.
+ * gcc.target/s390/bitint-2.c: New test.
+ * gcc.target/s390/bitint-3.c: New test.
+ * gcc.target/s390/bitint-4.c: New test.
+
+2025-08-06 Sam James <sam@gentoo.org>
+
+ * g++.dg/cpp26/constexpr-new3.C: Escape '[' and ']'.
+
+2025-08-06 Alexandre Oliva <oliva@adacore.com>
+
+ * gcc.dg/torture/hardbool-ai.c: New.
+ * gcc.dg/torture/hardbool-vi.c: New.
+ * gcc.dg/torture/hardbool.c: Handle NO_BITFIELDS.
+ (add1, preinc, postinc, sub1, predec, postdec): New.
+ (main): Exercise them.
+
+2025-08-06 Martin Uecker <uecker@tugraz.at>
+
+ PR c/108931
+ * gcc.dg/vla-tert-1.c: New test.
+
+2025-08-06 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/121231
+ PR c++/119688
+ PR c++/94511
+ * g++.dg/abi/mangle82.C: New test.
+ * g++.dg/cpp2a/nontype-class73.C: New test.
+
+2025-08-06 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp26/constexpr-new3.C: Tweak diagnostic.
+
+2025-08-06 Richard Biener <rguenther@suse.de>
+
+ * gcc.dg/vect/vect-gather-1.c: Adjust to hide N.
+
+2025-08-06 Tejas Belagod <tejas.belagod@arm.com>
+
+ * gcc.target/aarch64/sve/acle/general/cops.c: Fix test.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * gcc.dg/torture/bitint-84.c: New test.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * gcc.dg/torture/bitint-83.c: New test.
+
+2025-08-06 Yang Yujie <yangyujie@loongson.cn>
+
+ * gcc.dg/bitintext.h (BEXTC1): Define. Convert the copied
+ object back to the original type before comparison.
+ (BEXTC): Use BEXTC1 for both the signed and the unsigned case.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/121413
+ * gcc.dg/torture/bitint-85.c: New test.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/121127
+ * gcc.dg/bitint-125.c: New test.
+
+2025-08-06 Yuao Ma <c8ef@outlook.com>
+
+ * gfortran.dg/c_f_pointer_shape_tests_2.f03: Use the new driver.
+ * gfortran.dg/c_f_pointer_shape_tests_4.f03: Ditto.
+ * gfortran.dg/c_f_pointer_shape_tests_4_driver.c: Removed.
+ * gfortran.dg/c_f_pointer_shape_tests_2_driver.c: Renamed to ...
+ * gfortran.dg/c_f_pointer_shape_tests_driver.c: ... this; format
+ with gcc style.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * c-c++-common/cpp/comment-ff-1.c: New test.
+ * c-c++-common/cpp/comment-vtab-1.c: New test.
+
+2025-08-06 Martin Uecker <uecker@tugraz.at>
+
+ PR c/121217
+ * gcc.dg/pr121217.c: New test.
+
+2025-08-06 Kito Cheng <kito.cheng@sifive.com>
+
+ * gcc.target/riscv/arch-unset-1.c: New test.
+ * gcc.target/riscv/arch-unset-2.c: New test.
+ * gcc.target/riscv/arch-unset-3.c: New test.
+ * gcc.target/riscv/arch-unset-4.c: New test.
+ * gcc.target/riscv/arch-unset-5.c: New test.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * c-c++-common/gomp/target-update-iterators-1.c: New.
+ * c-c++-common/gomp/target-update-iterators-2.c: New.
+ * c-c++-common/gomp/target-update-iterators-3.c: New.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+ Andrew Stubbs <ams@baylibre.com>
+
+ * c-c++-common/gomp/map-6.c (foo): Amend expected error message.
+ * c-c++-common/gomp/target-map-iterators-1.c: New.
+ * c-c++-common/gomp/target-map-iterators-2.c: New.
+ * c-c++-common/gomp/target-map-iterators-3.c: New.
+ * c-c++-common/gomp/target-map-iterators-4.c: New.
+
+2025-08-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/121234
+ * gfortran.dg/pr121234.f90: New test.
+
2025-08-05 Jason Merrill <jason@redhat.com>
PR c++/121068
@@ -2711,7 +3002,7 @@
2025-07-11 Paul Thomas <pault@gcc.gnu.org>
- PR fortran/106135
+ PR fortran/106035
* gfortran.dg/import3.f90: Use -std=f2008 and comment on change
in error message texts with f2018.
* gfortran.dg/import12.f90: New test.
diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-1.c b/gcc/testsuite/c-c++-common/asan/pr121389-1.c
new file mode 100644
index 0000000..0116d7a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr121389-1.c
@@ -0,0 +1,23 @@
+// PR middle-end/121389
+// { dg-do compile { target musttail } }
+// { dg-options "-fsanitize=address" }
+
+int foo (void);
+int bar (void);
+int baz (unsigned *);
+
+int
+bar (void)
+{
+ do
+ {
+ unsigned t;
+ int u = baz (&t);
+ if (u == 42)
+ [[gnu::musttail]] return foo ();
+ if (u == -42)
+ break;
+ }
+ while (1);
+ return 42;
+}
diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-2.c b/gcc/testsuite/c-c++-common/asan/pr121389-2.c
new file mode 100644
index 0000000..02914f8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr121389-2.c
@@ -0,0 +1,37 @@
+// PR middle-end/121389
+// { dg-do compile { target musttail } }
+// { dg-options "-fsanitize=address" }
+
+int foo (void);
+int bar (void);
+int baz (unsigned *);
+
+int
+bar (void)
+{
+ for (int a = 0; a < 420; ++a)
+ {
+ for (int b = 0; b < 420; ++b)
+ {
+ for (int c = 0; c < 420; ++c)
+ {
+ unsigned t;
+ int u = baz (&t);
+ if (u == 42)
+ [[gnu::musttail]] return foo ();
+ if (u == -42)
+ break;
+ if (u == 16)
+ goto l1;
+ if (u == 18)
+ goto l2;
+ if (u == 20)
+ goto l3;
+ }
+ l3:;
+ }
+ l2:;
+ }
+ l1:;
+ return 42;
+}
diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-3.c b/gcc/testsuite/c-c++-common/asan/pr121389-3.c
new file mode 100644
index 0000000..5f71e06
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr121389-3.c
@@ -0,0 +1,130 @@
+// PR middle-end/121389
+// { dg-do compile { target musttail } }
+// { dg-options "-fsanitize=address" }
+
+int foo (void);
+int bar (void);
+int baz (unsigned *);
+
+int
+bar (void)
+{
+ for (int a = 0; a < 420; ++a)
+ {
+ for (int b = 0; b < 420; ++b)
+ {
+ for (int c = 0; c < 420; ++c)
+ {
+ unsigned t;
+ int u = baz (&t);
+ if (u == 42)
+ [[gnu::musttail]] return foo ();
+ if (u == -42)
+ break;
+ if (u == 16)
+ goto l1;
+ if (u == 18)
+ goto l2;
+ if (u == 20)
+ goto l3;
+ switch (u)
+ {
+ case 100: goto l100;
+ case 101: goto l101;
+ case 102: goto l102;
+ case 103: goto l103;
+ case 104: goto l104;
+ case 105: goto l105;
+ case 106: goto l106;
+ case 107: goto l107;
+ case 108: goto l108;
+ case 109: goto l109;
+ case 110: goto l110;
+ case 111: goto l111;
+ case 112: goto l112;
+ case 113: goto l113;
+ case 114: goto l114;
+ case 115: goto l115;
+ case 116: goto l116;
+ case 117: goto l117;
+ case 118: goto l118;
+ case 119: goto l119;
+ case 120: goto l120;
+ case 121: goto l121;
+ case 122: goto l122;
+ case 123: goto l123;
+ case 124: goto l124;
+ case 125: goto l125;
+ case 126: goto l126;
+ case 127: goto l127;
+ case 128: goto l128;
+ case 129: goto l129;
+ }
+ }
+ l3:;
+ foo ();
+ l100:
+ foo ();
+ l101:
+ foo ();
+ l102:
+ foo ();
+ l103:
+ foo ();
+ l104:
+ foo ();
+ l105:
+ foo ();
+ l106:
+ foo ();
+ l107:
+ foo ();
+ l108:
+ foo ();
+ l109:;
+ }
+ l2:;
+ foo ();
+ l110:
+ foo ();
+ l111:
+ foo ();
+ l112:
+ foo ();
+ l113:
+ foo ();
+ l114:
+ foo ();
+ l115:
+ foo ();
+ l116:
+ foo ();
+ l117:
+ foo ();
+ l118:
+ foo ();
+ l119:;
+ }
+ l1:;
+ foo ();
+ l120:
+ foo ();
+ l121:
+ foo ();
+ l122:
+ foo ();
+ l123:
+ foo ();
+ l124:
+ foo ();
+ l125:
+ foo ();
+ l126:
+ foo ();
+ l127:
+ foo ();
+ l128:
+ foo ();
+ l129:;
+ return 42;
+}
diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-4.c b/gcc/testsuite/c-c++-common/asan/pr121389-4.c
new file mode 100644
index 0000000..2f7b410
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr121389-4.c
@@ -0,0 +1,6 @@
+// PR middle-end/121389
+// { dg-do compile { target musttail } }
+// { dg-options "-fsanitize=address -fdisable-tree-switchlower_O0" }
+// { dg-skip-if "" { *-*-* } { "*" } { "-O0" } }
+
+#include "pr121389-3.c"
diff --git a/gcc/testsuite/g++.dg/DRs/dr2575.C b/gcc/testsuite/g++.dg/DRs/dr2575.C
new file mode 100644
index 0000000..f350282
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2575.C
@@ -0,0 +1,51 @@
+// DR 2575 - Undefined behavior when macro-replacing "defined" operator
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#define A defined
+#if !A(A) // { dg-error "this use of 'defined' may not be portable" }
+#error
+#endif
+#if A(B) // { dg-error "this use of 'defined' may not be portable" }
+#error
+#endif
+#if !A A // { dg-error "this use of 'defined' may not be portable" }
+#error
+#endif
+#if A B // { dg-error "this use of 'defined' may not be portable" }
+#error
+#endif
+#if defined A + B
+#else
+#error
+#endif
+#if defined +B // { dg-error "operator 'defined' requires an identifier" }
+#endif // { dg-error "missing binary operator before token 'B'" "" { target *-*-* } .-1 }
+#if defined 1 // { dg-error "operator 'defined' requires an identifier" }
+#endif
+#if defined // { dg-error "operator 'defined' requires an identifier" }
+#endif
+#if defined (A + B) // { dg-error "missing '\\\)' after 'defined'" }
+#endif // { dg-error "missing binary operator before token 'B'" "" { target *-*-* } .-1 }
+#if defined (+B) // { dg-error "operator 'defined' requires an identifier" }
+#endif // { dg-error "missing binary operator before token 'B'" "" { target *-*-* } .-1 }
+#if defined (1) // { dg-error "operator 'defined' requires an identifier" }
+#endif // { dg-error "missing '\\\(' in expression" "" { target *-*-* } .-1 }
+#if defined () // { dg-error "operator 'defined' requires an identifier" }
+#endif
+#if defined A, B // { dg-error "comma operator in operand of #if" }
+#endif
+#if defined (A), B // { dg-error "comma operator in operand of #if" }
+#endif
+#if (defined A), B // { dg-error "comma operator in operand of #if" }
+#endif
+#if defined (A, B) // { dg-error "missing '\\\)' after 'defined'" }
+#endif // { dg-error "missing binary operator before token 'B'" "" { target *-*-* } .-1 }
+#if defined (A) + B
+#else
+#error
+#endif
+#if (defined A) + B
+#else
+#error
+#endif
diff --git a/gcc/testsuite/g++.dg/DRs/dr2576.C b/gcc/testsuite/g++.dg/DRs/dr2576.C
new file mode 100644
index 0000000..ed53a08
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2576.C
@@ -0,0 +1,47 @@
+// DR 2576 - Undefined behavior with macro-expanded #include directives
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#define A <cstddef>
+#include A
+#define B "cstddef"
+#include B
+#define C(x) #x
+#define D(x) C(x)
+#include D(cstddef)
+#include "cstddef" "" // { dg-error "extra tokens at end of '#include' directive" }
+#include "cstddef"".h" // { dg-error "extra tokens at end of '#include' directive" }
+#include // { dg-error "'#include' expects '\"FILENAME\"' or '<FILENAME>'" }
+#include E // { dg-error "'#include' expects '\"FILENAME\"' or '<FILENAME>'" }
+#include <cstddef
+ // { dg-error "missing terminating '>' character" "" { target *-*-* } .-1 }
+#include "cstddef
+ // { dg-error "missing terminating \" character" "" { target *-*-* } .-1 }
+ // { dg-error "'#include' expects '\"FILENAME\"' or '<FILENAME>'" "" { target *-*-* } .-2 }
+#define F cstddef
+#include F // { dg-error "'#include' expects '\"FILENAME\"' or '<FILENAME>'" }
+// There is implementation divergence on the following cases (G H through M N)
+// between e.g. GCC and clang++. clang++ fails on trying to include ' cstddef'
+// and 'cstd def' and 'stddef .h' and 'cstddef ' headers.
+// https://eel.is/c++draft/cpp.include#7.sentence-3 makes the whitespace
+// handling implementation defined and the way GCC handles it can allow
+// certain use cases which aren't otherwise possible. One can still
+// insert spaces into the <> filenames if it is from the same macro.
+#define G <
+#define H cstddef>
+#include G H
+#define I <cstd
+#define J def>
+#include I J
+#define K <stddef
+#define L .h>
+#include K L
+#define M <cstddef
+#define N >
+#include M N
+#define O <cstddef> <cstddef>
+#include O // { dg-error "extra tokens at end of '#include' directive" }
+#define P "cstddef" ""
+#include P // { dg-error "extra tokens at end of '#include' directive" }
+#define Q "cstddef"".h"
+#include Q // { dg-error "extra tokens at end of '#include' directive" }
diff --git a/gcc/testsuite/g++.dg/DRs/dr2577-1.C b/gcc/testsuite/g++.dg/DRs/dr2577-1.C
new file mode 100644
index 0000000..784b6a8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2577-1.C
@@ -0,0 +1,40 @@
+// DR 2577 - Undefined behavior for preprocessing directives in macro arguments
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#define A(x)
+#define B(x, y)
+A(
+#if 1 // { dg-error "embedding a directive within macro arguments is not portable" }
+1
+#else // { dg-error "embedding a directive within macro arguments is not portable" }
+2
+#endif // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+B(1,
+#line 234 // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+#line 18
+A(
+#define C 1 // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+A(
+#undef C // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+B(42,
+# 234 "dr2577-1.C" // { dg-error "embedding a directive within macro arguments is not portable" }
+) // { dg-error "style of line directive is a GCC extension" "" { target *-*-* } .-1 }
+#line 28 "dr2577-1.C"
+B(
+#warning "foobar" // { dg-error "embedding a directive within macro arguments is not portable" }
+, 12) // { dg-error "'#warning' before C\\\+\\\+23 is a GCC extension" "" { target c++20_down } .-1 }
+ // { dg-warning "#warning \"foobar\"" "" { target *-*-* } .-2 }
+A(
+#pragma GCC diagnostics push // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+B(5,
+#pragma GCC diagnostics pop // { dg-error "embedding a directive within macro arguments is not portable" }
+)
+A(
+#error foobar // { dg-error "embedding a directive within macro arguments is not portable" }
+) // { dg-error "#error foobar" "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/g++.dg/DRs/dr2577-2.C b/gcc/testsuite/g++.dg/DRs/dr2577-2.C
new file mode 100644
index 0000000..e54006a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2577-2.C
@@ -0,0 +1,13 @@
+// DR 2577 - Undefined behavior for preprocessing directives in macro arguments
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#define A(x, y, z) x + y + z
+int a = A(
+#include "dr2577-2.h" // { dg-error "embedding a directive within macro arguments is not portable" }
+,
+#include "dr2577-2.h"
+,
+#include "dr2577-2.h"
+);
+// { dg-error "unterminated argument list invoking macro 'A'" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/DRs/dr2577-2.h b/gcc/testsuite/g++.dg/DRs/dr2577-2.h
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2577-2.h
@@ -0,0 +1 @@
+1
diff --git a/gcc/testsuite/g++.dg/DRs/dr2577-3.C b/gcc/testsuite/g++.dg/DRs/dr2577-3.C
new file mode 100644
index 0000000..6ebf419
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2577-3.C
@@ -0,0 +1,7 @@
+// DR 2577 - Undefined behavior for preprocessing directives in macro arguments
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#define A(x) x
+int a = A(
+#include "dr2577-3.h" // { dg-error "embedding a directive within macro arguments is not portable" }
diff --git a/gcc/testsuite/g++.dg/DRs/dr2577-3.h b/gcc/testsuite/g++.dg/DRs/dr2577-3.h
new file mode 100644
index 0000000..5e36ce0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2577-3.h
@@ -0,0 +1 @@
+1)
diff --git a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1-truncated.C b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1-truncated.C
index 0cb1610..5b5e3fe 100644
--- a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1-truncated.C
+++ b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1-truncated.C
@@ -1,6 +1,6 @@
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
struct dog {};
struct cat {};
diff --git a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1.C b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1.C
index e642676..a071b55 100644
--- a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1.C
+++ b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-1.C
@@ -1,6 +1,6 @@
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
// { dg-additional-options "-fconcepts-diagnostics-depth=3" }
struct dog {};
diff --git a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-2.C b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-2.C
index cc15f11..9530bc1 100644
--- a/gcc/testsuite/g++.dg/concepts/nested-diagnostics-2.C
+++ b/gcc/testsuite/g++.dg/concepts/nested-diagnostics-2.C
@@ -1,6 +1,6 @@
// { dg-do compile { target c++17 } }
// { dg-options "-fconcepts" }
-// { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
+// { dg-additional-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-locations=no" }
struct dog{};
struct cat{};
diff --git a/gcc/testsuite/g++.dg/cpp26/constexpr-new3.C b/gcc/testsuite/g++.dg/cpp26/constexpr-new3.C
index 7466199..c79060f 100644
--- a/gcc/testsuite/g++.dg/cpp26/constexpr-new3.C
+++ b/gcc/testsuite/g++.dg/cpp26/constexpr-new3.C
@@ -37,7 +37,7 @@ baz ()
{
std::allocator<int> a;
auto b = a.allocate (2);
- new (b) long (42); // { dg-error "accessing value of 'int [2]' object through a 'long int' glvalue in a constant expression" }
+ new (b) long (42); // { dg-error "accessing value of 'int \\\[2\\\]' object through a 'long int' glvalue in a constant expression" }
a.deallocate (b, 2);
return true;
}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp13.C b/gcc/testsuite/g++.dg/cpp26/decomp13.C
new file mode 100644
index 0000000..d01590f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp13.C
@@ -0,0 +1,52 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+namespace std {
+ template<typename T> struct tuple_size;
+ template<int, typename> struct tuple_element;
+}
+
+struct S { int a, b, c, d; };
+struct T {
+ int a[5];
+ template <int I> int &get () { return a[I]; }
+};
+
+template<> struct std::tuple_size<T> { static const int value = 5; };
+template<int I> struct std::tuple_element<I,T> { using type = int; };
+
+template <int N>
+void
+foo ()
+{
+ auto [a, ...b, c] = S (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ auto [...d] = S (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ auto [...e, f, ...g, h] = S (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-error "multiple packs in structured binding declaration" "" { target *-*-* } .-2 }
+ auto [i, j, k, l, ...m, n] = S (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-error "6 names provided for structured binding" "" { target *-*-* } .-2 }
+ // { dg-message "while 'S' decomposes into 4 elements" "" { target *-*-* } .-3 }
+ auto [o, ...p, q, r, s] = S (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ auto [t, u, v, w, x, ...y, z] = T (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-error "7 names provided for structured binding" "" { target *-*-* } .-2 }
+ // { dg-message "while 'T' decomposes into 5 elements" "" { target *-*-* } .-3 }
+ int aa[] = { 1, 2, 3 };
+ const auto & [ab, ...ac, ad, ae, af] = aa; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-error "5 names provided for structured binding" "" { target *-*-* } .-2 }
+ // { dg-message "while 'const int \\\[3\\\]' decomposes into 3 elements" "" { target *-*-* } .-3 }
+}
+
+void
+bar ()
+{
+ auto [a, ...b, c, d] = S (); // { dg-error "structured binding pack outside of template" }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp14.C b/gcc/testsuite/g++.dg/cpp26/decomp14.C
new file mode 100644
index 0000000..f626ec9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp14.C
@@ -0,0 +1,474 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+struct S {
+ int a; long long b; short c;
+ explicit operator bool () const noexcept { return true; }
+};
+namespace std {
+ template <typename T> struct tuple_size;
+ template <int, typename> struct tuple_element;
+}
+struct T {
+ short c; int a; long long b;
+ template <int I>
+ typename std::tuple_element<I, T>::type &get ();
+ template <int I>
+ typename std::tuple_element<I, const T>::type &get () const;
+ explicit operator bool () const noexcept { return false; }
+};
+template <>
+struct std::tuple_size<T> { static constexpr int value = 3; };
+template <>
+struct std::tuple_element<0, T> { typedef int type; };
+template <>
+struct std::tuple_element<1, T> { typedef long long type; };
+template <>
+struct std::tuple_element<2, T> { typedef short type; };
+template <>
+std::tuple_element<0, T>::type &T::get <0> () { return a; }
+template <>
+std::tuple_element<1, T>::type &T::get <1> () { return b; }
+template <>
+std::tuple_element<2, T>::type &T::get <2> () { return c; }
+template <>
+struct std::tuple_size<const T> { static constexpr int value = 3; };
+template <>
+struct std::tuple_element<0, const T> { typedef const int type; };
+template <>
+struct std::tuple_element<1, const T> { typedef const long long type; };
+template <>
+struct std::tuple_element<2, const T> { typedef const short type; };
+template <>
+std::tuple_element<0, const T>::type &T::get <0> () const { return a; }
+template <>
+std::tuple_element<1, const T>::type &T::get <1> () const { return b; }
+template <>
+std::tuple_element<2, const T>::type &T::get <2> () const { return c; }
+template <typename T, typename U>
+struct same_type { static const bool value = false; };
+template <typename T>
+struct same_type<T, T> { static const bool value = true; };
+
+int
+sum ()
+{
+ return 0;
+}
+
+template <typename T, typename ...A>
+T
+sum (T x, A... y)
+{
+ return x + sum (y...);
+}
+
+template <typename T>
+T
+square (T x)
+{
+ return x * x;
+}
+
+template <typename T>
+T &
+ref (T &x)
+{
+ return x;
+}
+
+using size_t = decltype (sizeof 0);
+
+template <int N>
+size_t
+foo ()
+{
+ S s = S { 1, 2, 3 };
+ auto [sa, sb, sc] = S { 1, 2, 3 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (sa), int>::value, "");
+ static_assert (same_type <decltype (sb), long long>::value, "");
+ static_assert (same_type <decltype (sc), short>::value, "");
+ auto [sd, ...se] = S { 1, 2, 3 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ constexpr size_t ses = sizeof... (se);
+ static_assert (sizeof... (se) == 2, "");
+ static_assert (same_type <decltype (sd), int>::value, "");
+ static_assert (same_type <decltype (se...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (se...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ const auto & [...sf [[]], sg] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sf) == 2, "");
+ static_assert (same_type <decltype (sf...[0]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sf...[1]), const long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sg), const short>::value, "");
+ auto [sh, si, sj [[]], ...sk] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sk) == 0, "");
+ static_assert (same_type <decltype (sh), int>::value, "");
+ static_assert (same_type <decltype (si), long long>::value, "");
+ static_assert (same_type <decltype (sj), short>::value, "");
+ auto && [sl, ...sm [[maybe_unused]], sn] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sm) == 1, "");
+ static_assert (same_type <decltype (sl), int>::value, "");
+ static_assert (same_type <decltype (sm...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sn), short>::value, "");
+ auto [...so] = S { 1, 2, 3 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (so) == 3, "");
+ static_assert (same_type <decltype (so...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (so...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (so...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...sp, sq, sr, ss [[maybe_unused]]] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sp) == 0, "");
+ static_assert (same_type <decltype (sq), int>::value, "");
+ static_assert (same_type <decltype (sr), long long>::value, "");
+ static_assert (same_type <decltype (ss), short>::value, "");
+ auto [st, ...su, sv, sw] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (su) == 0, "");
+ static_assert (same_type <decltype (st), int>::value, "");
+ static_assert (same_type <decltype (sv), long long>::value, "");
+ static_assert (same_type <decltype (sw), short>::value, "");
+ if (sa != 1 || sb != 2 || sc != 3
+ || sd != 1 || se...[0] != 2 || se...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sf...[0] != 1 || sf...[1] != 2 || sg != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sh != 1 || si != 2 || sj != 3
+ || sl != 1 || sm...[0] != 2 || sn != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || so...[0] != 1 || so...[1] != 2 || so...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sq != 1 || sr != 2 || ss != 3
+ || st != 1 || sv != 2 || sw != 3
+ || sum (se...) != 5
+ || sum <decltype (se)...> (se...) != 5
+ || sum (square (square (se))...) != 97
+ || sum (sf...) != 3
+ || sum (sk...) != 0
+ || sum (sm...) != 2
+ || sum (so...) != 6
+ || sum <decltype (so)...> (so...) != 6
+ || sum (square (so)...) != 14
+ || sum (sp...) != 0
+ || sum (su...) != 0
+ || (se + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + sf) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + sk) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (sm + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (so + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (sp + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + su) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ S s2[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
+ int i = 0;
+ for (auto [sx, ...sy [[]]] : s2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sy) == 2, "");
+ static_assert (same_type <decltype (sx), int>::value, "");
+ static_assert (same_type <decltype (sy...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sy...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sx != i * 3 + 1 || sum (sy...) != i * 6 + 5)
+ __builtin_abort ();
+ auto fn1 = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn1 ();
+ auto fn2 = [&sy..., &i] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn2 ();
+ auto fn3 = [&...sy2 = sy, &i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn3 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn4 = [&...sy3 = ref (sy), &i] () { if (sum (sy3...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn4 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn5 = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn5 ();
+ auto fn6 = [sy..., i] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn6 ();
+ auto fn7 = [...sy2 = sy, i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn7 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn8 = [...sy3 = square (sy), i] () { if (sum (sy3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn8 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn9 = [&] () { auto fn = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn9 ();
+ auto fn10 = [&sy..., &i] () { auto fn = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn10 ();
+ auto fn11 = [&] () { auto fn = [&...sy2 = sy, &i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn11 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn12 = [&sy..., &i] () { auto fn = [&...sy3 = ref (sy), &i] () { if (sum (sy3...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn12 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn13 = [=] () { auto fn = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn13 ();
+ auto fn14 = [sy..., i] () { auto fn = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn14 ();
+ auto fn15 = [=] () { auto fn = [...sy2 = sy, i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn15 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn16 = [&sy..., &i] () { auto fn = [...sy3 = square (sy), i] () { if (sum (sy3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn16 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ ++i;
+ }
+ i = 0;
+ for (auto [...sz] : s2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (sz) == 3, "");
+ static_assert (same_type <decltype (sz...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sz...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sz...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (sz...) != i * 9 + 6)
+ __builtin_abort ();
+ auto fn = [=] () { if (sum (sz...) != i * 9 + 6) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn ();
+ ++i;
+ }
+ if (auto [...sx, sy] = s) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ {
+ static_assert (sizeof... (sx) == 2, "");
+ static_assert (same_type <decltype (sx...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sx...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sy), short>::value, "");
+ if (sum (sx...) != 3 || sy != 3)
+ __builtin_abort ();
+ }
+ else
+ __builtin_abort ();
+ T t = T { 3, 1, 2 };
+ auto [ta, tb, tc] = T { 3, 1, 2 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (ta), int>::value, "");
+ static_assert (same_type <decltype (tb), long long>::value, "");
+ static_assert (same_type <decltype (tc), short>::value, "");
+ auto [td [[maybe_unused]], ...te] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (te) == 2, "");
+ static_assert (same_type <decltype (td), int>::value, "");
+ static_assert (same_type <decltype (te...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (te...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...tf [[maybe_unused]], tg] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tf) == 2, "");
+ static_assert (same_type <decltype (tf...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tf...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tg), short>::value, "");
+ const auto & [th, ti, tj, ...tk] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (tk) == 0, "");
+ static_assert (same_type <decltype (th), const int>::value, "");
+ static_assert (same_type <decltype (ti), const long long>::value, "");
+ static_assert (same_type <decltype (tj), const short>::value, "");
+ auto [tl [[]], ...tm [[]], tn [[]]] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tm) == 1, "");
+ static_assert (same_type <decltype (tl), int>::value, "");
+ static_assert (same_type <decltype (tm...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tn), short>::value, "");
+ auto && [...to] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (to) == 3, "");
+ static_assert (same_type <decltype (to...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (to...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (to...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...tp, tq [[]], tr, ts] = T { 3, 1, 2 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tp) == 0, "");
+ static_assert (same_type <decltype (tq), int>::value, "");
+ static_assert (same_type <decltype (tr), long long>::value, "");
+ static_assert (same_type <decltype (ts), short>::value, "");
+ auto [tt, ...tu [[]], tv, tw] = T { 3, 1, 2 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tu) == 0, "");
+ static_assert (same_type <decltype (tt), int>::value, "");
+ static_assert (same_type <decltype (tv), long long>::value, "");
+ static_assert (same_type <decltype (tw), short>::value, "");
+ if (ta != 1 || tb != 2 || tc != 3
+ || td != 1 || te...[0] != 2 || te...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || tf...[0] != 1 || tf...[1] != 2 || tg != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || th != 1 || ti != 2 || tj != 3
+ || tl != 1 || tm...[0] != 2 || tn != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || to...[0] != 1 || to...[1] != 2 || to...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || tq != 1 || tr != 2 || ts != 3
+ || tt != 1 || tv != 2 || tw != 3
+ || sum (te...) != 5
+ || sum <decltype (te)...> (te...) != 5
+ || sum (square (square (te))...) != 97
+ || sum (tf...) != 3
+ || sum (tk...) != 0
+ || sum (tm...) != 2
+ || sum (to...) != 6
+ || sum <decltype (to)...> (to...) != 6
+ || sum (square (to)...) != 14
+ || sum (tp...) != 0
+ || sum (tu...) != 0
+ || (te + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + tf) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + tk) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (tm + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (to + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (tp + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + tu) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ T t2[] = { { 3, 1, 2 }, { 6, 4, 5 }, { 9, 7, 8 } };
+ i = 0;
+ for (auto [tx, ...ty] : t2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ty) == 2, "");
+ static_assert (same_type <decltype (tx), int>::value, "");
+ static_assert (same_type <decltype (ty...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ty...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (tx != i * 3 + 1 || sum (ty...) != i * 6 + 5)
+ __builtin_abort ();
+ auto fn1 = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); };
+ fn1 ();
+ auto fn2 = [&ty..., &i] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn2 ();
+ auto fn3 = [&...ty2 = ty, &i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn3 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn4 = [&...ty3 = ref (ty), &i] () { if (sum (ty3...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn4 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn5 = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); };
+ fn5 ();
+ auto fn6 = [ty..., i] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn6 ();
+ auto fn7 = [...ty2 = ty, i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn7 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn8 = [...ty3 = square (ty), i] () { if (sum (ty3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn8 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn9 = [&] () { auto fn = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); };
+ fn9 ();
+ auto fn10 = [&ty..., &i] () { auto fn = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn10 ();
+ auto fn11 = [&] () { auto fn = [&...ty2 = ty, &i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn11 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn12 = [&ty..., &i] () { auto fn = [&...ty3 = ref (ty), &i] () { if (sum (ty3...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn12 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn13 = [=] () { auto fn = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); };
+ fn13 ();
+ auto fn14 = [ty..., i] () { auto fn = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn14 ();
+ auto fn15 = [=] () { auto fn = [...ty2 = ty, i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn15 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn16 = [&ty..., &i] () { auto fn = [...ty3 = square (ty), i] () { if (sum (ty3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn16 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ ++i;
+ }
+ i = 0;
+ for (auto [...tz] : t2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (tz) == 3, "");
+ static_assert (same_type <decltype (tz...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tz...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tz...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (tz...) != i * 9 + 6)
+ __builtin_abort ();
+ auto fn = [=] () { if (sum (tz...) != i * 9 + 6) __builtin_abort (); };
+ fn ();
+ ++i;
+ }
+ if (auto [...tx [[maybe_unused]], ty] = t) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ __builtin_abort ();
+ else
+ {
+ static_assert (sizeof... (tx) == 2, "");
+ static_assert (same_type <decltype (tx...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tx...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ty), short>::value, "");
+ if (sum (tx...) != 3 || ty != 3)
+ __builtin_abort ();
+ }
+ int a[3] = { 1, 2, 3 };
+ auto [aa, ab, ac] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (aa), int>::value, "");
+ static_assert (same_type <decltype (ab), int>::value, "");
+ static_assert (same_type <decltype (ac), int>::value, "");
+ auto [ad [[maybe_unused]], ...ae [[maybe_unused]]] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ae) == 2, "");
+ static_assert (same_type <decltype (ad), int>::value, "");
+ static_assert (same_type <decltype (ae...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ae...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...af, ag] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (af) == 2, "");
+ static_assert (same_type <decltype (af...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (af...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ag), int>::value, "");
+ auto [ah, ai [[]], aj, ...ak [[]]] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ak) == 0, "");
+ static_assert (same_type <decltype (ah), int>::value, "");
+ static_assert (same_type <decltype (ai), int>::value, "");
+ static_assert (same_type <decltype (aj), int>::value, "");
+ auto [al, ...am [[]], an] = a;// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (am) == 1, "");
+ static_assert (same_type <decltype (al), int>::value, "");
+ static_assert (same_type <decltype (am...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (an), int>::value, "");
+ const auto &[...ao] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ao) == 3, "");
+ static_assert (same_type <decltype (ao...[0]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ao...[1]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ao...[2]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto &&[...ap, aq, ar [[]], as] = a;// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ap) == 0, "");
+ static_assert (same_type <decltype (aq), int>::value, "");
+ static_assert (same_type <decltype (ar), int>::value, "");
+ static_assert (same_type <decltype (as), int>::value, "");
+ auto [at, ...au, av, aw] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (au) == 0, "");
+ static_assert (same_type <decltype (at), int>::value, "");
+ static_assert (same_type <decltype (av), int>::value, "");
+ static_assert (same_type <decltype (aw), int>::value, "");
+ if (aa != 1 || ab != 2 || ac != 3
+ || ad != 1 || ae...[0] != 2 || ae...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || af...[0] != 1 || af...[1] != 2 || ag != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || ah != 1 || ai != 2 || aj != 3
+ || al != 1 || am...[0] != 2 || an != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || ao...[0] != 1 || ao...[1] != 2 || ao...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || aq != 1 || ar != 2 || as != 3
+ || at != 1 || av != 2 || aw != 3
+ || sum (ae...) != 5
+ || sum <decltype (ae)...> (ae...) != 5
+ || sum (square (square (ae))...) != 97
+ || sum (af...) != 3
+ || sum (ak...) != 0
+ || sum (am...) != 2
+ || sum (ao...) != 6
+ || sum <decltype (ao)...> (ao...) != 6
+ || sum (square (ao)...) != 14
+ || sum (ap...) != 0
+ || sum (au...) != 0
+ || (ae + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + af) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + ak) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (am + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (ao + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (ap + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + au) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ return ses;
+}
+
+int
+main ()
+{
+ if (foo <0> () != 2)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp15.C b/gcc/testsuite/g++.dg/cpp26/decomp15.C
new file mode 100644
index 0000000..9bb55b3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp15.C
@@ -0,0 +1,474 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+struct S {
+ int a; long long b; short c;
+ explicit operator bool () const noexcept { return true; }
+};
+namespace std {
+ template <typename T> struct tuple_size;
+ template <int, typename> struct tuple_element;
+}
+struct T {
+ short c; int a; long long b;
+ template <int I>
+ typename std::tuple_element<I, T>::type &get ();
+ template <int I>
+ typename std::tuple_element<I, const T>::type &get () const;
+ explicit operator bool () const noexcept { return false; }
+};
+template <>
+struct std::tuple_size<T> { static constexpr int value = 3; };
+template <>
+struct std::tuple_element<0, T> { typedef int type; };
+template <>
+struct std::tuple_element<1, T> { typedef long long type; };
+template <>
+struct std::tuple_element<2, T> { typedef short type; };
+template <>
+std::tuple_element<0, T>::type &T::get <0> () { return a; }
+template <>
+std::tuple_element<1, T>::type &T::get <1> () { return b; }
+template <>
+std::tuple_element<2, T>::type &T::get <2> () { return c; }
+template <>
+struct std::tuple_size<const T> { static constexpr int value = 3; };
+template <>
+struct std::tuple_element<0, const T> { typedef const int type; };
+template <>
+struct std::tuple_element<1, const T> { typedef const long long type; };
+template <>
+struct std::tuple_element<2, const T> { typedef const short type; };
+template <>
+std::tuple_element<0, const T>::type &T::get <0> () const { return a; }
+template <>
+std::tuple_element<1, const T>::type &T::get <1> () const { return b; }
+template <>
+std::tuple_element<2, const T>::type &T::get <2> () const { return c; }
+template <typename T, typename U>
+struct same_type { static const bool value = false; };
+template <typename T>
+struct same_type<T, T> { static const bool value = true; };
+
+int
+sum ()
+{
+ return 0;
+}
+
+template <typename T, typename ...A>
+T
+sum (T x, A... y)
+{
+ return x + sum (y...);
+}
+
+template <typename T>
+T
+square (T x)
+{
+ return x * x;
+}
+
+template <typename T>
+T &
+ref (T &x)
+{
+ return x;
+}
+
+using size_t = decltype (sizeof 0);
+
+template <typename S, typename T, typename U>
+size_t
+foo ()
+{
+ S s = S { 1, 2, 3 };
+ auto [sa, sb, sc] = S { 1, 2, 3 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (sa), int>::value, "");
+ static_assert (same_type <decltype (sb), long long>::value, "");
+ static_assert (same_type <decltype (sc), short>::value, "");
+ auto [sd, ...se] = S { 1, 2, 3 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (se) == 2, "");
+ static_assert (same_type <decltype (sd), int>::value, "");
+ static_assert (same_type <decltype (se...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (se...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ const auto & [...sf [[]], sg] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sf) == 2, "");
+ static_assert (same_type <decltype (sf...[0]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sf...[1]), const long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sg), const short>::value, "");
+ auto [sh, si, sj [[]], ...sk] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sk) == 0, "");
+ static_assert (same_type <decltype (sh), int>::value, "");
+ static_assert (same_type <decltype (si), long long>::value, "");
+ static_assert (same_type <decltype (sj), short>::value, "");
+ auto && [sl, ...sm [[maybe_unused]], sn] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sm) == 1, "");
+ static_assert (same_type <decltype (sl), int>::value, "");
+ static_assert (same_type <decltype (sm...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sn), short>::value, "");
+ auto [...so] = S { 1, 2, 3 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (so) == 3, "");
+ static_assert (same_type <decltype (so...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (so...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (so...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...sp, sq, sr, ss [[maybe_unused]]] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sp) == 0, "");
+ static_assert (same_type <decltype (sq), int>::value, "");
+ static_assert (same_type <decltype (sr), long long>::value, "");
+ static_assert (same_type <decltype (ss), short>::value, "");
+ auto [st, ...su, sv, sw] = S { 1, 2, 3 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (su) == 0, "");
+ static_assert (same_type <decltype (st), int>::value, "");
+ static_assert (same_type <decltype (sv), long long>::value, "");
+ static_assert (same_type <decltype (sw), short>::value, "");
+ if (sa != 1 || sb != 2 || sc != 3
+ || sd != 1 || se...[0] != 2 || se...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sf...[0] != 1 || sf...[1] != 2 || sg != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sh != 1 || si != 2 || sj != 3
+ || sl != 1 || sm...[0] != 2 || sn != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || so...[0] != 1 || so...[1] != 2 || so...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sq != 1 || sr != 2 || ss != 3
+ || st != 1 || sv != 2 || sw != 3
+ || sum (se...) != 5
+ || sum <decltype (se)...> (se...) != 5
+ || sum (square (square (se))...) != 97
+ || sum (sf...) != 3
+ || sum (sk...) != 0
+ || sum (sm...) != 2
+ || sum (so...) != 6
+ || sum <decltype (so)...> (so...) != 6
+ || sum (square (so)...) != 14
+ || sum (sp...) != 0
+ || sum (su...) != 0
+ || (se + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + sf) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + sk) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (sm + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (so + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (sp + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + su) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ S s2[] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
+ int i = 0;
+ for (auto [sx, ...sy [[]]] : s2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (sy) == 2, "");
+ static_assert (same_type <decltype (sx), int>::value, "");
+ static_assert (same_type <decltype (sy...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sy...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sx != i * 3 + 1 || sum (sy...) != i * 6 + 5)
+ __builtin_abort ();
+ auto fn1 = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn1 ();
+ auto fn2 = [&sy..., &i] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn2 ();
+ auto fn3 = [&...sy2 = sy, &i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn3 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn4 = [&...sy3 = ref (sy), &i] () { if (sum (sy3...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn4 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn5 = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn5 ();
+ auto fn6 = [sy..., i] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn6 ();
+ auto fn7 = [...sy2 = sy, i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn7 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn8 = [...sy3 = square (sy), i] () { if (sum (sy3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn8 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn9 = [&] () { auto fn = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn9 ();
+ auto fn10 = [&sy..., &i] () { auto fn = [&] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn10 ();
+ auto fn11 = [&] () { auto fn = [&...sy2 = sy, &i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn11 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn12 = [&sy..., &i] () { auto fn = [&...sy3 = ref (sy), &i] () { if (sum (sy3...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn12 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn13 = [=] () { auto fn = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn13 ();
+ auto fn14 = [sy..., i] () { auto fn = [=] () { if (sum (sy...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn14 ();
+ auto fn15 = [=] () { auto fn = [...sy2 = sy, i] () { if (sum (sy2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn15 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn16 = [&sy..., &i] () { auto fn = [...sy3 = square (sy), i] () { if (sum (sy3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn16 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ ++i;
+ }
+ i = 0;
+ for (auto [...sz] : s2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (sz) == 3, "");
+ static_assert (same_type <decltype (sz...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sz...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sz...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (sz...) != i * 9 + 6)
+ __builtin_abort ();
+ auto fn = [=] () { if (sum (sz...) != i * 9 + 6) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn ();
+ ++i;
+ }
+ if (auto [...sx, sy] = s) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ {
+ static_assert (sizeof... (sx) == 2, "");
+ static_assert (same_type <decltype (sx...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sx...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (sy), short>::value, "");
+ if (sum (sx...) != 3 || sy != 3)
+ __builtin_abort ();
+ }
+ else
+ __builtin_abort ();
+ T t = T { 3, 1, 2 };
+ auto [ta, tb, tc] = T { 3, 1, 2 }; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (ta), int>::value, "");
+ static_assert (same_type <decltype (tb), long long>::value, "");
+ static_assert (same_type <decltype (tc), short>::value, "");
+ auto [td [[maybe_unused]], ...te] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (te) == 2, "");
+ static_assert (same_type <decltype (td), int>::value, "");
+ static_assert (same_type <decltype (te...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (te...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...tf [[maybe_unused]], tg] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tf) == 2, "");
+ static_assert (same_type <decltype (tf...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tf...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tg), short>::value, "");
+ const auto & [th, ti, tj, ...tk] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (tk) == 0, "");
+ static_assert (same_type <decltype (th), const int>::value, "");
+ static_assert (same_type <decltype (ti), const long long>::value, "");
+ static_assert (same_type <decltype (tj), const short>::value, "");
+ auto [tl [[]], ...tm [[]], tn [[]]] = T { 3, 1, 2 }; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tm) == 1, "");
+ static_assert (same_type <decltype (tl), int>::value, "");
+ static_assert (same_type <decltype (tm...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tn), short>::value, "");
+ auto && [...to] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (to) == 3, "");
+ constexpr size_t tos = sizeof... (to);
+ static_assert (same_type <decltype (to...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (to...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (to...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...tp, tq [[]], tr, ts] = T { 3, 1, 2 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tp) == 0, "");
+ static_assert (same_type <decltype (tq), int>::value, "");
+ static_assert (same_type <decltype (tr), long long>::value, "");
+ static_assert (same_type <decltype (ts), short>::value, "");
+ auto [tt, ...tu [[]], tv, tw] = T { 3, 1, 2 };// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (tu) == 0, "");
+ static_assert (same_type <decltype (tt), int>::value, "");
+ static_assert (same_type <decltype (tv), long long>::value, "");
+ static_assert (same_type <decltype (tw), short>::value, "");
+ if (ta != 1 || tb != 2 || tc != 3
+ || td != 1 || te...[0] != 2 || te...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || tf...[0] != 1 || tf...[1] != 2 || tg != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || th != 1 || ti != 2 || tj != 3
+ || tl != 1 || tm...[0] != 2 || tn != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || to...[0] != 1 || to...[1] != 2 || to...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || tq != 1 || tr != 2 || ts != 3
+ || tt != 1 || tv != 2 || tw != 3
+ || sum (te...) != 5
+ || sum <decltype (te)...> (te...) != 5
+ || sum (square (square (te))...) != 97
+ || sum (tf...) != 3
+ || sum (tk...) != 0
+ || sum (tm...) != 2
+ || sum (to...) != 6
+ || sum <decltype (to)...> (to...) != 6
+ || sum (square (to)...) != 14
+ || sum (tp...) != 0
+ || sum (tu...) != 0
+ || (te + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + tf) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + tk) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (tm + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (to + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (tp + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + tu) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ T t2[] = { { 3, 1, 2 }, { 6, 4, 5 }, { 9, 7, 8 } };
+ i = 0;
+ for (auto [tx, ...ty] : t2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ty) == 2, "");
+ static_assert (same_type <decltype (tx), int>::value, "");
+ static_assert (same_type <decltype (ty...[0]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ty...[1]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (tx != i * 3 + 1 || sum (ty...) != i * 6 + 5)
+ __builtin_abort ();
+ auto fn1 = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); };
+ fn1 ();
+ auto fn2 = [&ty..., &i] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn2 ();
+ auto fn3 = [&...ty2 = ty, &i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn3 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn4 = [&...ty3 = ref (ty), &i] () { if (sum (ty3...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn4 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn5 = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); };
+ fn5 ();
+ auto fn6 = [ty..., i] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn6 ();
+ auto fn7 = [...ty2 = ty, i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn7 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn8 = [...ty3 = square (ty), i] () { if (sum (ty3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn8 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn9 = [&] () { auto fn = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); };
+ fn9 ();
+ auto fn10 = [&ty..., &i] () { auto fn = [&] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn10 ();
+ auto fn11 = [&] () { auto fn = [&...ty2 = ty, &i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn11 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn12 = [&ty..., &i] () { auto fn = [&...ty3 = ref (ty), &i] () { if (sum (ty3...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn12 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ auto fn13 = [=] () { auto fn = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); };
+ fn13 ();
+ auto fn14 = [ty..., i] () { auto fn = [=] () { if (sum (ty...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "captured structured bindings are" "" { target c++17_down } }
+ fn14 ();
+ auto fn15 = [=] () { auto fn = [...ty2 = ty, i] () { if (sum (ty2...) != i * 6 + 5) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn15 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ auto fn16 = [&ty..., &i] () { auto fn = [...ty3 = square (ty), i] () { if (sum (ty3...) != (i * 3 + 2) * (i * 3 + 2) + (i * 3 + 3) * (i * 3 + 3)) __builtin_abort (); }; fn (); }; // { dg-warning "pack init-capture only available with" "" { target c++17_down } }
+ fn16 (); // { dg-warning "lambda capture initializers only available with" "" { target c++11_only } .-1 }
+ // { dg-warning "captured structured bindings are" "" { target c++17_down } .-2 }
+ ++i;
+ }
+ i = 0;
+ for (auto [...tz] : t2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (tz) == 3, "");
+ static_assert (same_type <decltype (tz...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tz...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tz...[2]), short>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (tz...) != i * 9 + 6)
+ __builtin_abort ();
+ auto fn = [=] () { if (sum (tz...) != i * 9 + 6) __builtin_abort (); };
+ fn ();
+ ++i;
+ }
+ if (auto [...tx [[maybe_unused]], ty] = t) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ __builtin_abort ();
+ else
+ {
+ static_assert (sizeof... (tx) == 2, "");
+ static_assert (same_type <decltype (tx...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (tx...[1]), long long>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ty), short>::value, "");
+ if (sum (tx...) != 3 || ty != 3)
+ __builtin_abort ();
+ }
+ U a[3] = { 1, 2, 3 };
+ auto [aa, ab, ac] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ static_assert (same_type <decltype (aa), int>::value, "");
+ static_assert (same_type <decltype (ab), int>::value, "");
+ static_assert (same_type <decltype (ac), int>::value, "");
+ auto [ad [[maybe_unused]], ...ae [[maybe_unused]]] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ae) == 2, "");
+ static_assert (same_type <decltype (ad), int>::value, "");
+ static_assert (same_type <decltype (ae...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ae...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...af, ag] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (af) == 2, "");
+ static_assert (same_type <decltype (af...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (af...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ag), int>::value, "");
+ auto [ah, ai [[]], aj, ...ak [[]]] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ak) == 0, "");
+ static_assert (same_type <decltype (ah), int>::value, "");
+ static_assert (same_type <decltype (ai), int>::value, "");
+ static_assert (same_type <decltype (aj), int>::value, "");
+ auto [al, ...am [[]], an] = a;// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (am) == 1, "");
+ static_assert (same_type <decltype (al), int>::value, "");
+ static_assert (same_type <decltype (am...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (an), int>::value, "");
+ const auto &[...ao] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ao) == 3, "");
+ static_assert (same_type <decltype (ao...[0]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ao...[1]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ao...[2]), const int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto &&[...ap, aq, ar [[]], as] = a;// { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings with attributed identifiers only available with" "" { target { c++17 && c++23_down } } .-2 }
+ static_assert (sizeof... (ap) == 0, "");
+ static_assert (same_type <decltype (aq), int>::value, "");
+ static_assert (same_type <decltype (ar), int>::value, "");
+ static_assert (same_type <decltype (as), int>::value, "");
+ auto [at, ...au, av, aw] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (au) == 0, "");
+ static_assert (same_type <decltype (at), int>::value, "");
+ static_assert (same_type <decltype (av), int>::value, "");
+ static_assert (same_type <decltype (aw), int>::value, "");
+ if (aa != 1 || ab != 2 || ac != 3
+ || ad != 1 || ae...[0] != 2 || ae...[1] != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || af...[0] != 1 || af...[1] != 2 || ag != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || ah != 1 || ai != 2 || aj != 3
+ || al != 1 || am...[0] != 2 || an != 3 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || ao...[0] != 1 || ao...[1] != 2 || ao...[2] != 3// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || aq != 1 || ar != 2 || as != 3
+ || at != 1 || av != 2 || aw != 3
+ || sum (ae...) != 5
+ || sum <decltype (ae)...> (ae...) != 5
+ || sum (square (square (ae))...) != 97
+ || sum (af...) != 3
+ || sum (ak...) != 0
+ || sum (am...) != 2
+ || sum (ao...) != 6
+ || sum <decltype (ao)...> (ao...) != 6
+ || sum (square (ao)...) != 14
+ || sum (ap...) != 0
+ || sum (au...) != 0
+ || (ae + ...) != 5 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + af) != 3 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + ak) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (am + ... + 0) != 2 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (ao + ...) != 6 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (ap + ... + 0) != 0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + au) != 0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ return tos;
+}
+
+int
+main ()
+{
+ if (foo <S, T, int> () != 3)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp16.C b/gcc/testsuite/g++.dg/cpp26/decomp16.C
new file mode 100644
index 0000000..548f9af
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp16.C
@@ -0,0 +1,240 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+int
+sum ()
+{
+ return 0;
+}
+
+template <typename T, typename ...A>
+T
+sum (T x, A... y)
+{
+ return x + sum (y...);
+}
+
+template <typename T>
+T
+square (T x)
+{
+ return x * x;
+}
+
+template <typename T, typename U>
+struct same_type { static const bool value = false; };
+
+template <typename T>
+struct same_type<T, T> { static const bool value = true; };
+
+typedef int V __attribute__((vector_size (16 * sizeof (int))));
+
+template <int N>
+void
+foo ()
+{
+ V v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ auto [...va] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (va) == 16, "");
+ static_assert (same_type <decltype (va...[5]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (va...[13]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [vb, ...vc, vd, ve] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vc) == 13, "");
+ static_assert (same_type <decltype (vb), int>::value, "");
+ static_assert (same_type <decltype (vc...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vc...[12]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vd), int>::value, "");
+ static_assert (same_type <decltype (ve), int>::value, "");
+ auto [vf, vg, vh, vi, ...vj] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vj) == 12, "");
+ static_assert (same_type <decltype (vf), int>::value, "");
+ static_assert (same_type <decltype (vg), int>::value, "");
+ static_assert (same_type <decltype (vh), int>::value, "");
+ static_assert (same_type <decltype (vi), int>::value, "");
+ static_assert (same_type <decltype (vj...[2]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vj...[10]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (va...[13] != 14 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (va...) != 8 * 17
+ || sum (square (va)...) != 1496
+ || vb != 1
+ || vc...[10] != 12 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (vc...) != 15 * 7 - 1
+ || sum <decltype (vc)...> (vc...) != 15 * 7 - 1
+ || vd != 15 || ve != 16
+ || vf != 1 || vg != 2 || vh != 3 || vi != 4
+ || sum (vj...) != 8 * 17 - 10
+ || (va + ...) != 8 * 17 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + vc) != 15 * 7 - 1 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + vj) != 8 * 17 - 10) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ V v2[3] = { v, v + 1, v + 2 };
+ int i = 0;
+ for (auto [vk, ...vl, vm] : v2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vl) == 14, "");
+ static_assert (same_type <decltype (vk), int>::value, "");
+ static_assert (same_type <decltype (vl...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vl...[9]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vm), int>::value, "");
+ if (vk != i + 1 || sum (vl...) != i * 14 + 15 * 8 - 1 || vm != i + 16)
+ __builtin_abort ();
+ ++i;
+ }
+ _Complex double c = 1.0 + 2.0i;
+ auto [...ca] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ca) == 2, "");
+ static_assert (same_type <decltype (ca...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ca...[1]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [cb, ...cc, cd] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cc) == 0, "");
+ static_assert (same_type <decltype (cb), double>::value, "");
+ static_assert (same_type <decltype (cd), double>::value, "");
+ auto [ce, ...cf] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cf) == 1, "");
+ static_assert (same_type <decltype (ce), double>::value, "");
+ static_assert (same_type <decltype (cf...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...cg, ch] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cg) == 1, "");
+ static_assert (same_type <decltype (cg...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ch), double>::value, "");
+ if (ca...[0] != 1.0 || ca...[1] != 2.0// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (ca...) != 3.0
+ || sum <decltype (ca)...> (ca...) != 3.0
+ || sum (square (square (square (ca)))...) != 257.0
+ || cb != 1.0 || cd != 2.0
+ || ce != 1.0 || cf...[0] != 2.0 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (cf...) != 2.0
+ || cg...[0] != 1.0 || ch != 2.0 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (cg...) != 1.0
+ || (ca + ...) != 3.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0.0 + ... + cc) != 0.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + cf) != 2.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (cg + ... + 0.0) != 1.0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ _Complex float c2[3] = { 1.0f + 2.0fi, 2.0f + 3.0fi, 3.0f + 4.0fi };
+ i = 0;
+ for (auto [...ci] : c2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ci) == 2, "");
+ static_assert (same_type <decltype (ci...[0]), float>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ci...[1]), float>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (ci...) != i * 2 + 3.0f)
+ __builtin_abort ();
+ ++i;
+ }
+}
+
+template <typename V, typename C, typename D>
+void
+bar ()
+{
+ V v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ auto [...va] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (va) == 16, "");
+ static_assert (same_type <decltype (va...[5]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (va...[13]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [vb, ...vc, vd, ve] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vc) == 13, "");
+ static_assert (same_type <decltype (vb), int>::value, "");
+ static_assert (same_type <decltype (vc...[0]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vc...[12]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vd), int>::value, "");
+ static_assert (same_type <decltype (ve), int>::value, "");
+ auto [vf, vg, vh, vi, ...vj] = v; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vj) == 12, "");
+ static_assert (same_type <decltype (vf), int>::value, "");
+ static_assert (same_type <decltype (vg), int>::value, "");
+ static_assert (same_type <decltype (vh), int>::value, "");
+ static_assert (same_type <decltype (vi), int>::value, "");
+ static_assert (same_type <decltype (vj...[2]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vj...[10]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (va...[13] != 14 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (va...) != 8 * 17
+ || vb != 1
+ || vc...[10] != 12 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (vc...) != 15 * 7 - 1
+ || sum <decltype (vc)...> (vc...) != 15 * 7 - 1
+ || vd != 15 || ve != 16
+ || vf != 1 || vg != 2 || vh != 3 || vi != 4
+ || sum (vj...) != 8 * 17 - 10
+ || (va + ...) != 8 * 17 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + vc) != 15 * 7 - 1 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0 + ... + vj) != 8 * 17 - 10) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ V v2[3] = { v, v + 1, v + 2 };
+ int i = 0;
+ for (auto [vk, ...vl, vm] : v2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (vl) == 14, "");
+ static_assert (same_type <decltype (vk), int>::value, "");
+ static_assert (same_type <decltype (vl...[1]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vl...[9]), int>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (vm), int>::value, "");
+ if (vk != i + 1 || sum (vl...) != i * 14 + 15 * 8 - 1 || vm != i + 16)
+ __builtin_abort ();
+ ++i;
+ }
+ C c = 1.0 + 2.0i;
+ auto [...ca] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ca) == 2, "");
+ static_assert (same_type <decltype (ca...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ca...[1]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [cb, ...cc, cd] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cc) == 0, "");
+ static_assert (same_type <decltype (cb), double>::value, "");
+ static_assert (same_type <decltype (cd), double>::value, "");
+ auto [ce, ...cf] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cf) == 1, "");
+ static_assert (same_type <decltype (ce), double>::value, "");
+ static_assert (same_type <decltype (cf...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ auto [...cg, ch] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (cg) == 1, "");
+ static_assert (same_type <decltype (cg...[0]), double>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ch), double>::value, "");
+ if (ca...[0] != 1.0 || ca...[1] != 2.0// { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (ca...) != 3.0
+ || sum <decltype (ca)...> (ca...) != 3.0
+ || cb != 1.0 || cd != 2.0
+ || ce != 1.0 || cf...[0] != 2.0 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (cf...) != 2.0
+ || cg...[0] != 1.0 || ch != 2.0 // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ || sum (cg...) != 1.0
+ || (ca + ...) != 3.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (0.0 + ... + cc) != 0.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (... + cf) != 2.0 // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ || (cg + ... + 0.0) != 1.0) // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+ __builtin_abort ();
+ D c2[3] = { 1.0f + 2.0fi, 2.0f + 3.0fi, 3.0f + 4.0fi };
+ i = 0;
+ for (auto [...ci] : c2) // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ { // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ci) == 2, "");
+ static_assert (same_type <decltype (ci...[0]), float>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ static_assert (same_type <decltype (ci...[1]), float>::value, ""); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ if (sum (ci...) != i * 2 + 3.0f)
+ __builtin_abort ();
+ ++i;
+ }
+}
+
+int
+main ()
+{
+ foo <0> ();
+ bar <V, _Complex double, _Complex float> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp17.C b/gcc/testsuite/g++.dg/cpp26/decomp17.C
new file mode 100644
index 0000000..49ad0e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp17.C
@@ -0,0 +1,28 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+typedef int V __attribute__((vector_size (16 * sizeof (int))));
+
+template <int N>
+void
+foo ()
+{
+ V v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ auto [va, vb, vc, vd, ...ve, vf, vg, vh, vi, vj, vk, vl, vm, vn, vo, vp, vq, vr] = v;
+ // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } .-1 }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-2 }
+ // { dg-error "18 names provided for structured binding" "" { target *-*-* } .-3 }
+ // { dg-message "while '__vector\\\(16\\\) int' decomposes into 16 elements" "" { target *-*-* } .-4 }
+ _Complex double c = 1.0 + 2.0i;
+ auto [...ca, cb, cc, cd] = c; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-error "4 names provided for structured binding" "" { target *-*-* } .-2 }
+ // { dg-message "while '__complex__ double' decomposes into 2 elements" "" { target *-*-* } .-3 }
+}
+
+int
+main ()
+{
+ foo <0> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp18.C b/gcc/testsuite/g++.dg/cpp26/decomp18.C
new file mode 100644
index 0000000..86b9bf4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp18.C
@@ -0,0 +1,109 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+struct S { int a, b, c; };
+namespace std {
+ template <typename T> struct tuple_size;
+ template <int, typename> struct tuple_element;
+}
+struct T {
+ int a[3];
+ template <int I>
+ int &get () { return a[2 - I]; }
+};
+template <>
+struct std::tuple_size<T> { static constexpr int value = 3; };
+template <int N>
+struct std::tuple_element<N, T> { typedef int type; };
+
+template <int N>
+inline int
+foo ()
+{
+ static int a[4] = { N, N + 1, N + 2, N + 3 };
+ static auto [...aa] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-2 }
+ aa...[1]++; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ return (... + aa); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+template <int N>
+inline int
+bar ()
+{
+ static S s = { N, N + 1, N + 2 };
+ static auto [...sa] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-2 }
+ sa...[1]++; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ return (sa + ...); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+template <int N>
+inline int
+baz ()
+{
+ static T t = { { N, N + 1, N + 2 } };
+ static auto [ta, ...tb, tc, td] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-2 }
+ tc++;
+ return ((ta + tc + td) + ... + tb); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+template <int N>
+inline int
+qux ()
+{
+ thread_local int a[4] = { N, N + 1, N + 2, N + 3 };
+ thread_local auto [...aa] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-2 }
+ aa...[1]++; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ return (... + aa); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+template <int N>
+inline int
+freddy ()
+{
+ thread_local S s = { N, N + 1, N + 2 };
+ thread_local auto [...sa] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-2 }
+ sa...[1]++; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ return (sa + ...); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+template <int N>
+inline int
+corge ()
+{
+ thread_local T t = { { N, N + 1, N + 2 } };
+ thread_local auto [ta, ...tb, tc, td] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-2 }
+ tc++;
+ return ((ta + tc + td) + ... + tb); // { dg-warning "fold-expressions only available with" "" { target c++14_down } }
+}
+
+int
+main ()
+{
+ if (foo <2> () != 15 || foo <2> () != 16 || foo <2> () != 17
+ || foo <42> () != 175 || foo <42> () != 176
+ || bar <5> () != 19 || bar <5> () != 20 || bar <5> () != 21
+ || bar <18> () != 58 || bar <18> () != 59
+ || baz <3> () != 13 || baz <3> () != 14 || baz <3> () != 15
+ || baz <22> () != 70 || baz <22> () != 71)
+ __builtin_abort ();
+ if (qux <2> () != 15 || qux <2> () != 16 || qux <2> () != 17
+ || qux <42> () != 175 || qux <42> () != 176
+ || freddy <5> () != 19 || freddy <5> () != 20 || freddy <5> () != 21
+ || freddy <18> () != 58 || freddy <18> () != 59
+ || corge <3> () != 13 || corge <3> () != 14 || corge <3> () != 15
+ || corge <22> () != 70 || corge <22> () != 71)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp19.C b/gcc/testsuite/g++.dg/cpp26/decomp19.C
new file mode 100644
index 0000000..b4d97a1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp19.C
@@ -0,0 +1,46 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+namespace std {
+ template <typename T> struct tuple_size;
+ template <int, typename> struct tuple_element;
+}
+struct T {
+ int a[3];
+ template <int I>
+ int &get () { return a[2 - I]; }
+};
+template <>
+struct std::tuple_size<T> { static constexpr int value = 3; };
+template <int N>
+struct std::tuple_element<N, T> { typedef int type; };
+
+template <int N>
+inline void
+foo ()
+{
+ static T t = { { N, N + 1, N + 2 } };
+ static auto [ta, ...tb, tc] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-2 }
+ // { dg-message "mangling of structured binding pack elements not implemented yet" "" { target *-*-* } .-3 }
+}
+
+template <int N>
+inline void
+bar ()
+{
+ thread_local T t = { { N, N + 1, N + 2 } };
+ thread_local auto [...ta] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured binding declaration can be 'thread_local' only in" "" { target c++17_down } .-2 }
+ // { dg-message "mangling of structured binding pack elements not implemented yet" "" { target *-*-* } .-3 }
+}
+
+int
+main ()
+{
+ foo <0> ();
+ bar <0> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp20.C b/gcc/testsuite/g++.dg/cpp26/decomp20.C
new file mode 100644
index 0000000..5091e13
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp20.C
@@ -0,0 +1,53 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct S {
+ explicit operator bool () const noexcept { return true; }
+};
+namespace std {
+ template <typename T> struct tuple_size;
+ template <int, typename> struct tuple_element;
+}
+int x;
+struct T {
+ template <int I>
+ int &get () { return x; }
+ explicit operator bool () const noexcept { return false; }
+};
+template <>
+struct std::tuple_size<T> { static constexpr int value = 0; };
+template <int N>
+struct std::tuple_element<N, T> { typedef int type; };
+
+template <int N>
+void
+foo ()
+{
+ int a[0] = {};
+ auto [...aa] = a; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (aa) == 0, "");
+ S s = {};
+ auto [...sa] = s; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (sa) == 0, "");
+ T t = {};
+ auto [...ta] = t; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (ta) == 0, "");
+ if (auto [...sb] = s) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ static_assert (sizeof... (sb) == 0, "");
+ else
+ __builtin_abort ();
+ if (auto [...tb] = t) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } }
+ __builtin_abort ();
+ else
+ static_assert (sizeof... (tb) == 0, "");
+}
+
+int
+main ()
+{
+ foo <0> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/decomp21.C b/gcc/testsuite/g++.dg/cpp26/decomp21.C
new file mode 100644
index 0000000..6baa8aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/decomp21.C
@@ -0,0 +1,103 @@
+// P1061R10 - Structured Bindings can introduce a Pack
+// { dg-do run { target c++11 } }
+// { dg-options "" }
+
+using size_t = decltype (sizeof 0);
+
+auto g () -> int (&)[4]
+{
+ static int a[4] = { 1, 2, 3, 4 };
+ return a;
+}
+
+template <size_t N>
+void
+h (int (&arr)[N])
+{
+ auto [a, ...b, c] = arr; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (b) == 2, "");
+ auto &[f, ...g, h] = arr; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (g) == 2, "");
+ if (&f != &arr[0] || &h != &arr[3]
+ || &g...[0] != &arr[1] || &g...[1] != &arr[2]) // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ __builtin_abort ();
+ auto &[...e] = arr; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof ... (e) == 4, "");
+ if (&e...[0] != &arr[0] || &e...[3] != &arr[3]) // { dg-warning "pack indexing only available with" "" { target c++23_down } }
+ __builtin_abort ();
+}
+
+struct C { int x, y, z; };
+
+template <class T>
+void
+now_i_know_my ()
+{
+ auto [a, b, c] = C (); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [d, ...e] = C (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (e) == 2, "");
+ auto [...f, g] = C (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (f) == 2, "");
+ auto [h, i, j, ...k] = C (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (k) == 0, "");
+// auto [l, m, n, o, ...p] = C ();
+}
+
+auto foo () -> int (&)[2]
+{
+ static int a[2] = { 1, 2 };
+ return a;
+}
+
+template <class T>
+void
+bar ()
+{
+ auto [...a] = foo (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (a) == 2, "");
+ auto [b, c, ...d] = foo (); // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ static_assert (sizeof... (d) == 0, "");
+}
+
+struct D { };
+
+void
+baz (...)
+{
+ __builtin_abort ();
+}
+
+template <typename T>
+void
+qux ()
+{
+ D arr[1] = {};
+ auto [...e] = arr; // { dg-warning "structured binding packs only available with" "" { target { c++17 && c++23_down } } }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+ baz (e...);
+}
+
+int d;
+
+void
+baz (D)
+{
+ d = 1;
+}
+
+int
+main ()
+{
+ h (g ());
+ now_i_know_my <int> ();
+ bar <int> ();
+ qux <int> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
index cfc5f61..9284bc2 100644
--- a/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
+++ b/gcc/testsuite/g++.dg/cpp26/feat-cxx26.C
@@ -395,8 +395,8 @@
#ifndef __cpp_structured_bindings
# error "__cpp_structured_bindings"
-#elif __cpp_structured_bindings != 202403
-# error "__cpp_structured_bindings != 202403"
+#elif __cpp_structured_bindings != 202411
+# error "__cpp_structured_bindings != 202411"
#endif
#ifndef __cpp_template_template_args
diff --git a/gcc/testsuite/g++.dg/modules/atom-preamble-3.C b/gcc/testsuite/g++.dg/modules/atom-preamble-3.C
index 74dba7d..915fa74 100644
--- a/gcc/testsuite/g++.dg/modules/atom-preamble-3.C
+++ b/gcc/testsuite/g++.dg/modules/atom-preamble-3.C
@@ -1,4 +1,4 @@
-// { dg-additional-options "-fmodules-ts" }
+// { dg-additional-options "-fmodules-ts -Wno-keyword-macro" }
#define import import
import malcolm; // { dg-error "object-like macro" }
// { dg-error "failed to read" "" { target *-*-* } 0 }
diff --git a/gcc/testsuite/g++.dg/modules/class-11_a.H b/gcc/testsuite/g++.dg/modules/class-11_a.H
index 799dbdd..43fddb6 100644
--- a/gcc/testsuite/g++.dg/modules/class-11_a.H
+++ b/gcc/testsuite/g++.dg/modules/class-11_a.H
@@ -1,6 +1,7 @@
// Check for some additional lang_type flags that we'd missed.
// { dg-additional-options "-fmodule-header -fabi-version=21 -Wabi=15" }
// { dg-module-cmi {} }
+// { dg-skip-if "test assumes that structs have padding" { default_packed } }
#if __cpp_trivial_relocatability < 202502L
#define trivially_relocatable_if_eligible __trivially_relocatable_if_eligible
diff --git a/gcc/testsuite/g++.dg/modules/class-11_b.C b/gcc/testsuite/g++.dg/modules/class-11_b.C
index 2450a45..87be71a 100644
--- a/gcc/testsuite/g++.dg/modules/class-11_b.C
+++ b/gcc/testsuite/g++.dg/modules/class-11_b.C
@@ -1,4 +1,5 @@
// { dg-additional-options "-fmodules -fabi-version=21 -Wabi=15" }
+// { dg-skip-if "test assumes that structs have padding" { default_packed } }
import "class-11_a.H";
diff --git a/gcc/testsuite/g++.dg/opt/pr82577.C b/gcc/testsuite/g++.dg/opt/pr82577.C
index 1a06897..8a4f36d 100644
--- a/gcc/testsuite/g++.dg/opt/pr82577.C
+++ b/gcc/testsuite/g++.dg/opt/pr82577.C
@@ -3,7 +3,9 @@
#if __cplusplus > 201500L
// register is no longer a keyword in C++17.
-#define register
+#define reg
+#else
+#define reg register
#endif
class a {
@@ -14,8 +16,8 @@ struct c {
int d;
a e;
} f;
-void fn1(register c *g) {
- register int *h;
+void fn1(reg c *g) {
+ reg int *h;
do
(h) = g->e.b() + (g)->d;
while (&f);
diff --git a/gcc/testsuite/g++.dg/template/sfinae17.C b/gcc/testsuite/g++.dg/template/sfinae17.C
index eb043cb..8628726 100644
--- a/gcc/testsuite/g++.dg/template/sfinae17.C
+++ b/gcc/testsuite/g++.dg/template/sfinae17.C
@@ -1,7 +1,7 @@
// The conversion from D* to B* is ambiguous, but that should not produce
// an error, it should remove the first f overload by SFINAE.
-#define static_assert(TEST,STR) \
+#define my_static_assert(TEST,STR) \
do { int ar[(TEST)?1:-1]; } while (0);
struct B {};
@@ -23,6 +23,6 @@ template <class T>
int main()
{
- static_assert(sizeof f<int>(0) == sizeof(two), "");
- static_assert(sizeof f<B *>(0) == sizeof(two), "");
+ my_static_assert(sizeof f<int>(0) == sizeof(two), "");
+ my_static_assert(sizeof f<B *>(0) == sizeof(two), "");
}
diff --git a/gcc/testsuite/g++.dg/torture/noncall-eh-1.C b/gcc/testsuite/g++.dg/torture/noncall-eh-1.C
new file mode 100644
index 0000000..ea8fd79
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/noncall-eh-1.C
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// For slim LTO there's no optimized dump
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+// { dg-additional-options "-fnon-call-exceptions -fexceptions -fdump-tree-optimized-eh" }
+
+// PR tree-optimization/120599
+// Copying prop for aggregates should not touch `a = *__val` since that statement
+// can throw (internally) so we need to be able to keep the landing pad.
+
+struct RefitOption {
+ char subtype;
+ int string;
+} n;
+void h(RefitOption) __attribute__((nothrow));
+void k(RefitOption *__val, RefitOption a)
+{
+ try {
+ a = *__val;
+ RefitOption __trans_tmp_2 = a;
+ h(__trans_tmp_2);
+ }
+ catch(...){}
+}
+
+// Make sure There is a landing pad for the non-call exception from the aggregate load.
+// { dg-final { scan-tree-dump "LP " "optimized" } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-1.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-1.C
new file mode 100644
index 0000000..f47de7a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-1.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#define alignas 1 // { dg-error "keyword 'alignas' defined as macro" "" { target c++26 } }
+#define alignof 1 // { dg-error "keyword 'alignof' defined as macro" "" { target c++26 } }
+#define asm 1 // { dg-error "keyword 'asm' defined as macro" "" { target c++26 } }
+#define auto 1 // { dg-error "keyword 'auto' defined as macro" "" { target c++26 } }
+#define bool 1 // { dg-error "keyword 'bool' defined as macro" "" { target c++26 } }
+#define break 1 // { dg-error "keyword 'break' defined as macro" "" { target c++26 } }
+#define case 1 // { dg-error "keyword 'case' defined as macro" "" { target c++26 } }
+#define catch 1 // { dg-error "keyword 'catch' defined as macro" "" { target c++26 } }
+#define char 1 // { dg-error "keyword 'char' defined as macro" "" { target c++26 } }
+#define char16_t 1 // { dg-error "keyword 'char16_t' defined as macro" "" { target c++26 } }
+#define char32_t 1 // { dg-error "keyword 'char32_t' defined as macro" "" { target c++26 } }
+#define char8_t 1 // { dg-error "keyword 'char8_t' defined as macro" "" { target c++26 } }
+#define class 1 // { dg-error "keyword 'class' defined as macro" "" { target c++26 } }
+#define co_await 1 // { dg-error "keyword 'co_await' defined as macro" "" { target c++26 } }
+#define concept 1 // { dg-error "keyword 'concept' defined as macro" "" { target c++26 } }
+#define const 1 // { dg-error "keyword 'const' defined as macro" "" { target c++26 } }
+#define const_cast 1 // { dg-error "keyword 'const_cast' defined as macro" "" { target c++26 } }
+#define consteval 1 // { dg-error "keyword 'consteval' defined as macro" "" { target c++26 } }
+#define constexpr 1 // { dg-error "keyword 'constexpr' defined as macro" "" { target c++26 } }
+#define constinit 1 // { dg-error "keyword 'constinit' defined as macro" "" { target c++26 } }
+#define continue 1 // { dg-error "keyword 'continue' defined as macro" "" { target c++26 } }
+#define contract_assert 1
+#define co_return 1 // { dg-error "keyword 'co_return' defined as macro" "" { target c++26 } }
+#define co_yield 1 // { dg-error "keyword 'co_yield' defined as macro" "" { target c++26 } }
+#define decltype 1 // { dg-error "keyword 'decltype' defined as macro" "" { target c++26 } }
+#define default 1 // { dg-error "keyword 'default' defined as macro" "" { target c++26 } }
+#define delete 1 // { dg-error "keyword 'delete' defined as macro" "" { target c++26 } }
+#define do 1 // { dg-error "keyword 'do' defined as macro" "" { target c++26 } }
+#define double 1 // { dg-error "keyword 'double' defined as macro" "" { target c++26 } }
+#define dynamic_cast 1 // { dg-error "keyword 'dynamic_cast' defined as macro" "" { target c++26 } }
+#define else 1 // { dg-error "keyword 'else' defined as macro" "" { target c++26 } }
+#define enum 1 // { dg-error "keyword 'enum' defined as macro" "" { target c++26 } }
+#define explicit 1 // { dg-error "keyword 'explicit' defined as macro" "" { target c++26 } }
+#define export 1 // { dg-error "keyword 'export' defined as macro" "" { target c++26 } }
+#define extern 1 // { dg-error "keyword 'extern' defined as macro" "" { target c++26 } }
+#define false 1 // { dg-error "keyword 'false' defined as macro" "" { target c++26 } }
+#define float 1 // { dg-error "keyword 'float' defined as macro" "" { target c++26 } }
+#define for 1 // { dg-error "keyword 'for' defined as macro" "" { target c++26 } }
+#define friend 1 // { dg-error "keyword 'friend' defined as macro" "" { target c++26 } }
+#define goto 1 // { dg-error "keyword 'goto' defined as macro" "" { target c++26 } }
+#define if 1 // { dg-error "keyword 'if' defined as macro" "" { target c++26 } }
+#define inline 1 // { dg-error "keyword 'inline' defined as macro" "" { target c++26 } }
+#define int 1 // { dg-error "keyword 'int' defined as macro" "" { target c++26 } }
+#define long 1 // { dg-error "keyword 'long' defined as macro" "" { target c++26 } }
+#define mutable 1 // { dg-error "keyword 'mutable' defined as macro" "" { target c++26 } }
+#define namespace 1 // { dg-error "keyword 'namespace' defined as macro" "" { target c++26 } }
+#define new 1 // { dg-error "keyword 'new' defined as macro" "" { target c++26 } }
+#define noexcept 1 // { dg-error "keyword 'noexcept' defined as macro" "" { target c++26 } }
+#define nullptr 1 // { dg-error "keyword 'nullptr' defined as macro" "" { target c++26 } }
+#define operator 1 // { dg-error "keyword 'operator' defined as macro" "" { target c++26 } }
+#define private 1 // { dg-error "keyword 'private' defined as macro" "" { target c++26 } }
+#define protected 1 // { dg-error "keyword 'protected' defined as macro" "" { target c++26 } }
+#define public 1 // { dg-error "keyword 'public' defined as macro" "" { target c++26 } }
+#define register 1 // { dg-error "keyword 'register' defined as macro" "" { target c++26 } }
+#define reinterpret_cast 1 // { dg-error "keyword 'reinterpret_cast' defined as macro" "" { target c++26 } }
+#define requires 1 // { dg-error "keyword 'requires' defined as macro" "" { target c++26 } }
+#define return 1 // { dg-error "keyword 'return' defined as macro" "" { target c++26 } }
+#define short 1 // { dg-error "keyword 'short' defined as macro" "" { target c++26 } }
+#define signed 1 // { dg-error "keyword 'signed' defined as macro" "" { target c++26 } }
+#define sizeof 1 // { dg-error "keyword 'sizeof' defined as macro" "" { target c++26 } }
+#define static 1 // { dg-error "keyword 'static' defined as macro" "" { target c++26 } }
+#define static_assert 1 // { dg-error "keyword 'static_assert' defined as macro" "" { target c++26 } }
+#define static_cast 1 // { dg-error "keyword 'static_cast' defined as macro" "" { target c++26 } }
+#define struct 1 // { dg-error "keyword 'struct' defined as macro" "" { target c++26 } }
+#define switch 1 // { dg-error "keyword 'switch' defined as macro" "" { target c++26 } }
+#define template 1 // { dg-error "keyword 'template' defined as macro" "" { target c++26 } }
+#define this 1 // { dg-error "keyword 'this' defined as macro" "" { target c++26 } }
+#define thread_local 1 // { dg-error "keyword 'thread_local' defined as macro" "" { target c++26 } }
+#define throw 1 // { dg-error "keyword 'throw' defined as macro" "" { target c++26 } }
+#define true 1 // { dg-error "keyword 'true' defined as macro" "" { target c++26 } }
+#define try 1 // { dg-error "keyword 'try' defined as macro" "" { target c++26 } }
+#define typedef 1 // { dg-error "keyword 'typedef' defined as macro" "" { target c++26 } }
+#define typeid 1 // { dg-error "keyword 'typeid' defined as macro" "" { target c++26 } }
+#define typename 1 // { dg-error "keyword 'typename' defined as macro" "" { target c++26 } }
+#define union 1 // { dg-error "keyword 'union' defined as macro" "" { target c++26 } }
+#define unsigned 1 // { dg-error "keyword 'unsigned' defined as macro" "" { target c++26 } }
+#define using 1 // { dg-error "keyword 'using' defined as macro" "" { target c++26 } }
+#define virtual 1 // { dg-error "keyword 'virtual' defined as macro" "" { target c++26 } }
+#define void 1 // { dg-error "keyword 'void' defined as macro" "" { target c++26 } }
+#define volatile 1 // { dg-error "keyword 'volatile' defined as macro" "" { target c++26 } }
+#define wchar_t 1 // { dg-error "keyword 'wchar_t' defined as macro" "" { target c++26 } }
+#define while 1 // { dg-error "keyword 'while' defined as macro" "" { target c++26 } }
+
+// [lex.name]
+#define final 1 // { dg-error "keyword 'final' defined as macro" "" { target c++26 } }
+#define import 1 // { dg-error "keyword 'import' defined as macro" "" { target c++26 } }
+#define module 1 // { dg-error "keyword 'module' defined as macro" "" { target c++26 } }
+#define override 1 // { dg-error "keyword 'override' defined as macro" "" { target c++26 } }
+#define post 1
+#define pre 1
+#define replaceable_if_eligible 1 // { dg-error "keyword 'replaceable_if_eligible' defined as macro" "" { target c++26 } }
+#define trivially_relocatable_if_eligible 1 // { dg-error "keyword 'trivially_relocatable_if_eligible' defined as macro" "" { target c++26 } }
+
+// [dcl.attr]
+#define assume 1 // { dg-error "keyword 'assume' defined as macro" "" { target c++26 } }
+#define carries_dependency 1
+#define deprecated 1 // { dg-error "keyword 'deprecated' defined as macro" "" { target c++26 } }
+#define fallthrough 1 // { dg-error "keyword 'fallthrough' defined as macro" "" { target c++26 } }
+#define indeterminate 1
+#define likely 1 // { dg-error "keyword 'likely' defined as macro" "" { target c++26 } }
+#define maybe_unused 1 // { dg-error "keyword 'maybe_unused' defined as macro" "" { target c++26 } }
+#define nodiscard 1 // { dg-error "keyword 'nodiscard' defined as macro" "" { target c++26 } }
+#define noreturn 1 // { dg-error "keyword 'noreturn' defined as macro" "" { target c++26 } }
+#define no_unique_address 1 // { dg-error "keyword 'no_unique_address' defined as macro" "" { target c++26 } }
+#define unlikely 1 // { dg-error "keyword 'unlikely' defined as macro" "" { target c++26 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-10.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-10.C
new file mode 100644
index 0000000..e6fafcd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-10.C
@@ -0,0 +1,23 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro" }
+
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define for for // { dg-warning "keyword 'for' defined as macro" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while for // { dg-warning "keyword 'while' defined as macro" }
+ // { dg-warning "'while' redefined" "" { target *-*-* } .-1 }
+#undef while // { dg-warning "undefining keyword 'while'" }
+#define while while // { dg-warning "keyword 'while' defined as macro" }
+#define private public // { dg-warning "keyword 'private' defined as macro" }
+#define inline // { dg-warning "keyword 'inline' defined as macro" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#define inline __inline__ __attribute__((__always_inline__)) // { dg-warning "keyword 'inline' defined as macro" }
+#define likely(a) a
+#undef likely // { dg-warning "undefining keyword 'likely'" "" { target c++20 } }
+#define unlikely(a, b, c) a + b + c
+#define unlikely(a, b, c) a + b + c
+#undef unlikely // { dg-warning "undefining keyword 'unlikely'" "" { target c++20 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-2.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-2.C
new file mode 100644
index 0000000..b1a9aa2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-2.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-pedantic" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#define alignas 1 // { dg-warning "keyword 'alignas' defined as macro" "" { target c++26 } }
+#define alignof 1 // { dg-warning "keyword 'alignof' defined as macro" "" { target c++26 } }
+#define asm 1 // { dg-warning "keyword 'asm' defined as macro" "" { target c++26 } }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" "" { target c++26 } }
+#define bool 1 // { dg-warning "keyword 'bool' defined as macro" "" { target c++26 } }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" "" { target c++26 } }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" "" { target c++26 } }
+#define catch 1 // { dg-warning "keyword 'catch' defined as macro" "" { target c++26 } }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" "" { target c++26 } }
+#define char16_t 1 // { dg-warning "keyword 'char16_t' defined as macro" "" { target c++26 } }
+#define char32_t 1 // { dg-warning "keyword 'char32_t' defined as macro" "" { target c++26 } }
+#define char8_t 1 // { dg-warning "keyword 'char8_t' defined as macro" "" { target c++26 } }
+#define class 1 // { dg-warning "keyword 'class' defined as macro" "" { target c++26 } }
+#define co_await 1 // { dg-warning "keyword 'co_await' defined as macro" "" { target c++26 } }
+#define concept 1 // { dg-warning "keyword 'concept' defined as macro" "" { target c++26 } }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" "" { target c++26 } }
+#define const_cast 1 // { dg-warning "keyword 'const_cast' defined as macro" "" { target c++26 } }
+#define consteval 1 // { dg-warning "keyword 'consteval' defined as macro" "" { target c++26 } }
+#define constexpr 1 // { dg-warning "keyword 'constexpr' defined as macro" "" { target c++26 } }
+#define constinit 1 // { dg-warning "keyword 'constinit' defined as macro" "" { target c++26 } }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" "" { target c++26 } }
+#define contract_assert 1
+#define co_return 1 // { dg-warning "keyword 'co_return' defined as macro" "" { target c++26 } }
+#define co_yield 1 // { dg-warning "keyword 'co_yield' defined as macro" "" { target c++26 } }
+#define decltype 1 // { dg-warning "keyword 'decltype' defined as macro" "" { target c++26 } }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" "" { target c++26 } }
+#define delete 1 // { dg-warning "keyword 'delete' defined as macro" "" { target c++26 } }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" "" { target c++26 } }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" "" { target c++26 } }
+#define dynamic_cast 1 // { dg-warning "keyword 'dynamic_cast' defined as macro" "" { target c++26 } }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" "" { target c++26 } }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" "" { target c++26 } }
+#define explicit 1 // { dg-warning "keyword 'explicit' defined as macro" "" { target c++26 } }
+#define export 1 // { dg-warning "keyword 'export' defined as macro" "" { target c++26 } }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" "" { target c++26 } }
+#define false 1 // { dg-warning "keyword 'false' defined as macro" "" { target c++26 } }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" "" { target c++26 } }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" "" { target c++26 } }
+#define friend 1 // { dg-warning "keyword 'friend' defined as macro" "" { target c++26 } }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" "" { target c++26 } }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" "" { target c++26 } }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" "" { target c++26 } }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" "" { target c++26 } }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" "" { target c++26 } }
+#define mutable 1 // { dg-warning "keyword 'mutable' defined as macro" "" { target c++26 } }
+#define namespace 1 // { dg-warning "keyword 'namespace' defined as macro" "" { target c++26 } }
+#define new 1 // { dg-warning "keyword 'new' defined as macro" "" { target c++26 } }
+#define noexcept 1 // { dg-warning "keyword 'noexcept' defined as macro" "" { target c++26 } }
+#define nullptr 1 // { dg-warning "keyword 'nullptr' defined as macro" "" { target c++26 } }
+#define operator 1 // { dg-warning "keyword 'operator' defined as macro" "" { target c++26 } }
+#define private 1 // { dg-warning "keyword 'private' defined as macro" "" { target c++26 } }
+#define protected 1 // { dg-warning "keyword 'protected' defined as macro" "" { target c++26 } }
+#define public 1 // { dg-warning "keyword 'public' defined as macro" "" { target c++26 } }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" "" { target c++26 } }
+#define reinterpret_cast 1 // { dg-warning "keyword 'reinterpret_cast' defined as macro" "" { target c++26 } }
+#define requires 1 // { dg-warning "keyword 'requires' defined as macro" "" { target c++26 } }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" "" { target c++26 } }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" "" { target c++26 } }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" "" { target c++26 } }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" "" { target c++26 } }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" "" { target c++26 } }
+#define static_assert 1 // { dg-warning "keyword 'static_assert' defined as macro" "" { target c++26 } }
+#define static_cast 1 // { dg-warning "keyword 'static_cast' defined as macro" "" { target c++26 } }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" "" { target c++26 } }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" "" { target c++26 } }
+#define template 1 // { dg-warning "keyword 'template' defined as macro" "" { target c++26 } }
+#define this 1 // { dg-warning "keyword 'this' defined as macro" "" { target c++26 } }
+#define thread_local 1 // { dg-warning "keyword 'thread_local' defined as macro" "" { target c++26 } }
+#define throw 1 // { dg-warning "keyword 'throw' defined as macro" "" { target c++26 } }
+#define true 1 // { dg-warning "keyword 'true' defined as macro" "" { target c++26 } }
+#define try 1 // { dg-warning "keyword 'try' defined as macro" "" { target c++26 } }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" "" { target c++26 } }
+#define typeid 1 // { dg-warning "keyword 'typeid' defined as macro" "" { target c++26 } }
+#define typename 1 // { dg-warning "keyword 'typename' defined as macro" "" { target c++26 } }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" "" { target c++26 } }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" "" { target c++26 } }
+#define using 1 // { dg-warning "keyword 'using' defined as macro" "" { target c++26 } }
+#define virtual 1 // { dg-warning "keyword 'virtual' defined as macro" "" { target c++26 } }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" "" { target c++26 } }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" "" { target c++26 } }
+#define wchar_t 1 // { dg-warning "keyword 'wchar_t' defined as macro" "" { target c++26 } }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" "" { target c++26 } }
+
+// [lex.name]
+#define final 1 // { dg-warning "keyword 'final' defined as macro" "" { target c++26 } }
+#define import 1 // { dg-warning "keyword 'import' defined as macro" "" { target c++26 } }
+#define module 1 // { dg-warning "keyword 'module' defined as macro" "" { target c++26 } }
+#define override 1 // { dg-warning "keyword 'override' defined as macro" "" { target c++26 } }
+#define post 1
+#define pre 1
+#define replaceable_if_eligible 1 // { dg-warning "keyword 'replaceable_if_eligible' defined as macro" "" { target c++26 } }
+#define trivially_relocatable_if_eligible 1 // { dg-warning "keyword 'trivially_relocatable_if_eligible' defined as macro" "" { target c++26 } }
+
+// [dcl.attr]
+#define assume 1 // { dg-warning "keyword 'assume' defined as macro" "" { target c++26 } }
+#define carries_dependency 1
+#define deprecated 1 // { dg-warning "keyword 'deprecated' defined as macro" "" { target c++26 } }
+#define fallthrough 1 // { dg-warning "keyword 'fallthrough' defined as macro" "" { target c++26 } }
+#define indeterminate 1
+#define likely 1 // { dg-warning "keyword 'likely' defined as macro" "" { target c++26 } }
+#define maybe_unused 1 // { dg-warning "keyword 'maybe_unused' defined as macro" "" { target c++26 } }
+#define nodiscard 1 // { dg-warning "keyword 'nodiscard' defined as macro" "" { target c++26 } }
+#define noreturn 1 // { dg-warning "keyword 'noreturn' defined as macro" "" { target c++26 } }
+#define no_unique_address 1 // { dg-warning "keyword 'no_unique_address' defined as macro" "" { target c++26 } }
+#define unlikely 1 // { dg-warning "keyword 'unlikely' defined as macro" "" { target c++26 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-3.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-3.C
new file mode 100644
index 0000000..8576b64
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-3.C
@@ -0,0 +1,7 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+#include "Wkeyword-macro-1.C"
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-4.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-4.C
new file mode 100644
index 0000000..9ff974d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-4.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#undef alignas // { dg-error "undefining keyword 'alignas'" "" { target c++26 } }
+#undef alignof // { dg-error "undefining keyword 'alignof'" "" { target c++26 } }
+#undef asm // { dg-error "undefining keyword 'asm'" "" { target c++26 } }
+#undef auto // { dg-error "undefining keyword 'auto'" "" { target c++26 } }
+#undef bool // { dg-error "undefining keyword 'bool'" "" { target c++26 } }
+#undef break // { dg-error "undefining keyword 'break'" "" { target c++26 } }
+#undef case // { dg-error "undefining keyword 'case'" "" { target c++26 } }
+#undef catch // { dg-error "undefining keyword 'catch'" "" { target c++26 } }
+#undef char // { dg-error "undefining keyword 'char'" "" { target c++26 } }
+#undef char16_t // { dg-error "undefining keyword 'char16_t'" "" { target c++26 } }
+#undef char32_t // { dg-error "undefining keyword 'char32_t'" "" { target c++26 } }
+#undef char8_t // { dg-error "undefining keyword 'char8_t'" "" { target c++26 } }
+#undef class // { dg-error "undefining keyword 'class'" "" { target c++26 } }
+#undef co_await // { dg-error "undefining keyword 'co_await'" "" { target c++26 } }
+#undef concept // { dg-error "undefining keyword 'concept'" "" { target c++26 } }
+#undef const // { dg-error "undefining keyword 'const'" "" { target c++26 } }
+#undef const_cast // { dg-error "undefining keyword 'const_cast'" "" { target c++26 } }
+#undef consteval // { dg-error "undefining keyword 'consteval'" "" { target c++26 } }
+#undef constexpr // { dg-error "undefining keyword 'constexpr'" "" { target c++26 } }
+#undef constinit // { dg-error "undefining keyword 'constinit'" "" { target c++26 } }
+#undef continue // { dg-error "undefining keyword 'continue'" "" { target c++26 } }
+#undef contract_assert
+#undef co_return // { dg-error "undefining keyword 'co_return'" "" { target c++26 } }
+#undef co_yield // { dg-error "undefining keyword 'co_yield'" "" { target c++26 } }
+#undef decltype // { dg-error "undefining keyword 'decltype'" "" { target c++26 } }
+#undef default // { dg-error "undefining keyword 'default'" "" { target c++26 } }
+#undef delete // { dg-error "undefining keyword 'delete'" "" { target c++26 } }
+#undef do // { dg-error "undefining keyword 'do'" "" { target c++26 } }
+#undef double // { dg-error "undefining keyword 'double'" "" { target c++26 } }
+#undef dynamic_cast // { dg-error "undefining keyword 'dynamic_cast'" "" { target c++26 } }
+#undef else // { dg-error "undefining keyword 'else'" "" { target c++26 } }
+#undef enum // { dg-error "undefining keyword 'enum'" "" { target c++26 } }
+#undef explicit // { dg-error "undefining keyword 'explicit'" "" { target c++26 } }
+#undef export // { dg-error "undefining keyword 'export'" "" { target c++26 } }
+#undef extern // { dg-error "undefining keyword 'extern'" "" { target c++26 } }
+#undef false // { dg-error "undefining keyword 'false'" "" { target c++26 } }
+#undef float // { dg-error "undefining keyword 'float'" "" { target c++26 } }
+#undef for // { dg-error "undefining keyword 'for'" "" { target c++26 } }
+#undef friend // { dg-error "undefining keyword 'friend'" "" { target c++26 } }
+#undef goto // { dg-error "undefining keyword 'goto'" "" { target c++26 } }
+#undef if // { dg-error "undefining keyword 'if'" "" { target c++26 } }
+#undef inline // { dg-error "undefining keyword 'inline'" "" { target c++26 } }
+#undef int // { dg-error "undefining keyword 'int'" "" { target c++26 } }
+#undef long // { dg-error "undefining keyword 'long'" "" { target c++26 } }
+#undef mutable // { dg-error "undefining keyword 'mutable'" "" { target c++26 } }
+#undef namespace // { dg-error "undefining keyword 'namespace'" "" { target c++26 } }
+#undef new // { dg-error "undefining keyword 'new'" "" { target c++26 } }
+#undef noexcept // { dg-error "undefining keyword 'noexcept'" "" { target c++26 } }
+#undef nullptr // { dg-error "undefining keyword 'nullptr'" "" { target c++26 } }
+#undef operator // { dg-error "undefining keyword 'operator'" "" { target c++26 } }
+#undef private // { dg-error "undefining keyword 'private'" "" { target c++26 } }
+#undef protected // { dg-error "undefining keyword 'protected'" "" { target c++26 } }
+#undef public // { dg-error "undefining keyword 'public'" "" { target c++26 } }
+#undef register // { dg-error "undefining keyword 'register'" "" { target c++26 } }
+#undef reinterpret_cast // { dg-error "undefining keyword 'reinterpret_cast'" "" { target c++26 } }
+#undef requires // { dg-error "undefining keyword 'requires'" "" { target c++26 } }
+#undef return // { dg-error "undefining keyword 'return'" "" { target c++26 } }
+#undef short // { dg-error "undefining keyword 'short'" "" { target c++26 } }
+#undef signed // { dg-error "undefining keyword 'signed'" "" { target c++26 } }
+#undef sizeof // { dg-error "undefining keyword 'sizeof'" "" { target c++26 } }
+#undef static // { dg-error "undefining keyword 'static'" "" { target c++26 } }
+#undef static_assert // { dg-error "undefining keyword 'static_assert'" "" { target c++26 } }
+#undef static_cast // { dg-error "undefining keyword 'static_cast'" "" { target c++26 } }
+#undef struct // { dg-error "undefining keyword 'struct'" "" { target c++26 } }
+#undef switch // { dg-error "undefining keyword 'switch'" "" { target c++26 } }
+#undef template // { dg-error "undefining keyword 'template'" "" { target c++26 } }
+#undef this // { dg-error "undefining keyword 'this'" "" { target c++26 } }
+#undef thread_local // { dg-error "undefining keyword 'thread_local'" "" { target c++26 } }
+#undef throw // { dg-error "undefining keyword 'throw'" "" { target c++26 } }
+#undef true // { dg-error "undefining keyword 'true'" "" { target c++26 } }
+#undef try // { dg-error "undefining keyword 'try'" "" { target c++26 } }
+#undef typedef // { dg-error "undefining keyword 'typedef'" "" { target c++26 } }
+#undef typeid // { dg-error "undefining keyword 'typeid'" "" { target c++26 } }
+#undef typename // { dg-error "undefining keyword 'typename'" "" { target c++26 } }
+#undef union // { dg-error "undefining keyword 'union'" "" { target c++26 } }
+#undef unsigned // { dg-error "undefining keyword 'unsigned'" "" { target c++26 } }
+#undef using // { dg-error "undefining keyword 'using'" "" { target c++26 } }
+#undef virtual // { dg-error "undefining keyword 'virtual'" "" { target c++26 } }
+#undef void // { dg-error "undefining keyword 'void'" "" { target c++26 } }
+#undef volatile // { dg-error "undefining keyword 'volatile'" "" { target c++26 } }
+#undef wchar_t // { dg-error "undefining keyword 'wchar_t'" "" { target c++26 } }
+#undef while // { dg-error "undefining keyword 'while'" "" { target c++26 } }
+
+// [lex.name]
+#undef final // { dg-error "undefining keyword 'final'" "" { target c++26 } }
+#undef import // { dg-error "undefining keyword 'import'" "" { target c++26 } }
+#undef module // { dg-error "undefining keyword 'module'" "" { target c++26 } }
+#undef override // { dg-error "undefining keyword 'override'" "" { target c++26 } }
+#undef post
+#undef pre
+#undef replaceable_if_eligible // { dg-error "undefining keyword 'replaceable_if_eligible'" "" { target c++26 } }
+#undef trivially_relocatable_if_eligible // { dg-error "undefining keyword 'trivially_relocatable_if_eligible'" "" { target c++26 } }
+
+// [dcl.attr]
+#undef assume // { dg-error "undefining keyword 'assume'" "" { target c++26 } }
+#undef carries_dependency
+#undef deprecated // { dg-error "undefining keyword 'deprecated'" "" { target c++26 } }
+#undef fallthrough // { dg-error "undefining keyword 'fallthrough'" "" { target c++26 } }
+#undef indeterminate
+#undef likely // { dg-error "undefining keyword 'likely'" "" { target c++26 } }
+#undef maybe_unused // { dg-error "undefining keyword 'maybe_unused'" "" { target c++26 } }
+#undef nodiscard // { dg-error "undefining keyword 'nodiscard'" "" { target c++26 } }
+#undef noreturn // { dg-error "undefining keyword 'noreturn'" "" { target c++26 } }
+#undef no_unique_address // { dg-error "undefining keyword 'no_unique_address'" "" { target c++26 } }
+#undef unlikely // { dg-error "undefining keyword 'unlikely'" "" { target c++26 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-5.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-5.C
new file mode 100644
index 0000000..657797b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-5.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-pedantic" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#undef alignas // { dg-warning "undefining keyword 'alignas'" "" { target c++26 } }
+#undef alignof // { dg-warning "undefining keyword 'alignof'" "" { target c++26 } }
+#undef asm // { dg-warning "undefining keyword 'asm'" "" { target c++26 } }
+#undef auto // { dg-warning "undefining keyword 'auto'" "" { target c++26 } }
+#undef bool // { dg-warning "undefining keyword 'bool'" "" { target c++26 } }
+#undef break // { dg-warning "undefining keyword 'break'" "" { target c++26 } }
+#undef case // { dg-warning "undefining keyword 'case'" "" { target c++26 } }
+#undef catch // { dg-warning "undefining keyword 'catch'" "" { target c++26 } }
+#undef char // { dg-warning "undefining keyword 'char'" "" { target c++26 } }
+#undef char16_t // { dg-warning "undefining keyword 'char16_t'" "" { target c++26 } }
+#undef char32_t // { dg-warning "undefining keyword 'char32_t'" "" { target c++26 } }
+#undef char8_t // { dg-warning "undefining keyword 'char8_t'" "" { target c++26 } }
+#undef class // { dg-warning "undefining keyword 'class'" "" { target c++26 } }
+#undef co_await // { dg-warning "undefining keyword 'co_await'" "" { target c++26 } }
+#undef concept // { dg-warning "undefining keyword 'concept'" "" { target c++26 } }
+#undef const // { dg-warning "undefining keyword 'const'" "" { target c++26 } }
+#undef const_cast // { dg-warning "undefining keyword 'const_cast'" "" { target c++26 } }
+#undef consteval // { dg-warning "undefining keyword 'consteval'" "" { target c++26 } }
+#undef constexpr // { dg-warning "undefining keyword 'constexpr'" "" { target c++26 } }
+#undef constinit // { dg-warning "undefining keyword 'constinit'" "" { target c++26 } }
+#undef continue // { dg-warning "undefining keyword 'continue'" "" { target c++26 } }
+#undef contract_assert
+#undef co_return // { dg-warning "undefining keyword 'co_return'" "" { target c++26 } }
+#undef co_yield // { dg-warning "undefining keyword 'co_yield'" "" { target c++26 } }
+#undef decltype // { dg-warning "undefining keyword 'decltype'" "" { target c++26 } }
+#undef default // { dg-warning "undefining keyword 'default'" "" { target c++26 } }
+#undef delete // { dg-warning "undefining keyword 'delete'" "" { target c++26 } }
+#undef do // { dg-warning "undefining keyword 'do'" "" { target c++26 } }
+#undef double // { dg-warning "undefining keyword 'double'" "" { target c++26 } }
+#undef dynamic_cast // { dg-warning "undefining keyword 'dynamic_cast'" "" { target c++26 } }
+#undef else // { dg-warning "undefining keyword 'else'" "" { target c++26 } }
+#undef enum // { dg-warning "undefining keyword 'enum'" "" { target c++26 } }
+#undef explicit // { dg-warning "undefining keyword 'explicit'" "" { target c++26 } }
+#undef export // { dg-warning "undefining keyword 'export'" "" { target c++26 } }
+#undef extern // { dg-warning "undefining keyword 'extern'" "" { target c++26 } }
+#undef false // { dg-warning "undefining keyword 'false'" "" { target c++26 } }
+#undef float // { dg-warning "undefining keyword 'float'" "" { target c++26 } }
+#undef for // { dg-warning "undefining keyword 'for'" "" { target c++26 } }
+#undef friend // { dg-warning "undefining keyword 'friend'" "" { target c++26 } }
+#undef goto // { dg-warning "undefining keyword 'goto'" "" { target c++26 } }
+#undef if // { dg-warning "undefining keyword 'if'" "" { target c++26 } }
+#undef inline // { dg-warning "undefining keyword 'inline'" "" { target c++26 } }
+#undef int // { dg-warning "undefining keyword 'int'" "" { target c++26 } }
+#undef long // { dg-warning "undefining keyword 'long'" "" { target c++26 } }
+#undef mutable // { dg-warning "undefining keyword 'mutable'" "" { target c++26 } }
+#undef namespace // { dg-warning "undefining keyword 'namespace'" "" { target c++26 } }
+#undef new // { dg-warning "undefining keyword 'new'" "" { target c++26 } }
+#undef noexcept // { dg-warning "undefining keyword 'noexcept'" "" { target c++26 } }
+#undef nullptr // { dg-warning "undefining keyword 'nullptr'" "" { target c++26 } }
+#undef operator // { dg-warning "undefining keyword 'operator'" "" { target c++26 } }
+#undef private // { dg-warning "undefining keyword 'private'" "" { target c++26 } }
+#undef protected // { dg-warning "undefining keyword 'protected'" "" { target c++26 } }
+#undef public // { dg-warning "undefining keyword 'public'" "" { target c++26 } }
+#undef register // { dg-warning "undefining keyword 'register'" "" { target c++26 } }
+#undef reinterpret_cast // { dg-warning "undefining keyword 'reinterpret_cast'" "" { target c++26 } }
+#undef requires // { dg-warning "undefining keyword 'requires'" "" { target c++26 } }
+#undef return // { dg-warning "undefining keyword 'return'" "" { target c++26 } }
+#undef short // { dg-warning "undefining keyword 'short'" "" { target c++26 } }
+#undef signed // { dg-warning "undefining keyword 'signed'" "" { target c++26 } }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" "" { target c++26 } }
+#undef static // { dg-warning "undefining keyword 'static'" "" { target c++26 } }
+#undef static_assert // { dg-warning "undefining keyword 'static_assert'" "" { target c++26 } }
+#undef static_cast // { dg-warning "undefining keyword 'static_cast'" "" { target c++26 } }
+#undef struct // { dg-warning "undefining keyword 'struct'" "" { target c++26 } }
+#undef switch // { dg-warning "undefining keyword 'switch'" "" { target c++26 } }
+#undef template // { dg-warning "undefining keyword 'template'" "" { target c++26 } }
+#undef this // { dg-warning "undefining keyword 'this'" "" { target c++26 } }
+#undef thread_local // { dg-warning "undefining keyword 'thread_local'" "" { target c++26 } }
+#undef throw // { dg-warning "undefining keyword 'throw'" "" { target c++26 } }
+#undef true // { dg-warning "undefining keyword 'true'" "" { target c++26 } }
+#undef try // { dg-warning "undefining keyword 'try'" "" { target c++26 } }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" "" { target c++26 } }
+#undef typeid // { dg-warning "undefining keyword 'typeid'" "" { target c++26 } }
+#undef typename // { dg-warning "undefining keyword 'typename'" "" { target c++26 } }
+#undef union // { dg-warning "undefining keyword 'union'" "" { target c++26 } }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" "" { target c++26 } }
+#undef using // { dg-warning "undefining keyword 'using'" "" { target c++26 } }
+#undef virtual // { dg-warning "undefining keyword 'virtual'" "" { target c++26 } }
+#undef void // { dg-warning "undefining keyword 'void'" "" { target c++26 } }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" "" { target c++26 } }
+#undef wchar_t // { dg-warning "undefining keyword 'wchar_t'" "" { target c++26 } }
+#undef while // { dg-warning "undefining keyword 'while'" "" { target c++26 } }
+
+// [lex.name]
+#undef final // { dg-warning "undefining keyword 'final'" "" { target c++26 } }
+#undef import // { dg-warning "undefining keyword 'import'" "" { target c++26 } }
+#undef module // { dg-warning "undefining keyword 'module'" "" { target c++26 } }
+#undef override // { dg-warning "undefining keyword 'override'" "" { target c++26 } }
+#undef post
+#undef pre
+#undef replaceable_if_eligible // { dg-warning "undefining keyword 'replaceable_if_eligible'" "" { target c++26 } }
+#undef trivially_relocatable_if_eligible // { dg-warning "undefining keyword 'trivially_relocatable_if_eligible'" "" { target c++26 } }
+
+// [dcl.attr]
+#undef assume // { dg-warning "undefining keyword 'assume'" "" { target c++26 } }
+#undef carries_dependency
+#undef deprecated // { dg-warning "undefining keyword 'deprecated'" "" { target c++26 } }
+#undef fallthrough // { dg-warning "undefining keyword 'fallthrough'" "" { target c++26 } }
+#undef indeterminate
+#undef likely // { dg-warning "undefining keyword 'likely'" "" { target c++26 } }
+#undef maybe_unused // { dg-warning "undefining keyword 'maybe_unused'" "" { target c++26 } }
+#undef nodiscard // { dg-warning "undefining keyword 'nodiscard'" "" { target c++26 } }
+#undef noreturn // { dg-warning "undefining keyword 'noreturn'" "" { target c++26 } }
+#undef no_unique_address // { dg-warning "undefining keyword 'no_unique_address'" "" { target c++26 } }
+#undef unlikely // { dg-warning "undefining keyword 'unlikely'" "" { target c++26 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-6.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-6.C
new file mode 100644
index 0000000..881df8b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-6.C
@@ -0,0 +1,7 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+#include "Wkeyword-macro-4.C"
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-7.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-7.C
new file mode 100644
index 0000000..30a2c8d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-7.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#define alignas 1 // { dg-warning "keyword 'alignas' defined as macro" "" { target c++11 } }
+#define alignof 1 // { dg-warning "keyword 'alignof' defined as macro" "" { target c++11 } }
+#define asm 1 // { dg-warning "keyword 'asm' defined as macro" }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" }
+#define bool 1 // { dg-warning "keyword 'bool' defined as macro" }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" }
+#define catch 1 // { dg-warning "keyword 'catch' defined as macro" }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" }
+#define char16_t 1 // { dg-warning "keyword 'char16_t' defined as macro" "" { target c++11 } }
+#define char32_t 1 // { dg-warning "keyword 'char32_t' defined as macro" "" { target c++11 } }
+#define char8_t 1 // { dg-warning "keyword 'char8_t' defined as macro" "" { target c++20 } }
+#define class 1 // { dg-warning "keyword 'class' defined as macro" }
+#define co_await 1 // { dg-warning "keyword 'co_await' defined as macro" "" { target c++20 } }
+#define concept 1 // { dg-warning "keyword 'concept' defined as macro" "" { target c++20 } }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" }
+#define const_cast 1 // { dg-warning "keyword 'const_cast' defined as macro" }
+#define consteval 1 // { dg-warning "keyword 'consteval' defined as macro" "" { target c++20 } }
+#define constexpr 1 // { dg-warning "keyword 'constexpr' defined as macro" "" { target c++11 } }
+#define constinit 1 // { dg-warning "keyword 'constinit' defined as macro" "" { target c++20 } }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" }
+#define contract_assert 1
+#define co_return 1 // { dg-warning "keyword 'co_return' defined as macro" "" { target c++20 } }
+#define co_yield 1 // { dg-warning "keyword 'co_yield' defined as macro" "" { target c++20 } }
+#define decltype 1 // { dg-warning "keyword 'decltype' defined as macro" "" { target c++11 } }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" }
+#define delete 1 // { dg-warning "keyword 'delete' defined as macro" }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" }
+#define dynamic_cast 1 // { dg-warning "keyword 'dynamic_cast' defined as macro" }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" }
+#define explicit 1 // { dg-warning "keyword 'explicit' defined as macro" }
+#define export 1 // { dg-warning "keyword 'export' defined as macro" }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" }
+#define false 1 // { dg-warning "keyword 'false' defined as macro" }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" }
+#define friend 1 // { dg-warning "keyword 'friend' defined as macro" }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" }
+#define mutable 1 // { dg-warning "keyword 'mutable' defined as macro" }
+#define namespace 1 // { dg-warning "keyword 'namespace' defined as macro" }
+#define new 1 // { dg-warning "keyword 'new' defined as macro" }
+#define noexcept 1 // { dg-warning "keyword 'noexcept' defined as macro" "" { target c++11 } }
+#define nullptr 1 // { dg-warning "keyword 'nullptr' defined as macro" "" { target c++11 } }
+#define operator 1 // { dg-warning "keyword 'operator' defined as macro" }
+#define private 1 // { dg-warning "keyword 'private' defined as macro" }
+#define protected 1 // { dg-warning "keyword 'protected' defined as macro" }
+#define public 1 // { dg-warning "keyword 'public' defined as macro" }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" }
+#define reinterpret_cast 1 // { dg-warning "keyword 'reinterpret_cast' defined as macro" }
+#define requires 1 // { dg-warning "keyword 'requires' defined as macro" "" { target c++20 } }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" }
+#define static_assert 1 // { dg-warning "keyword 'static_assert' defined as macro" "" { target c++11 } }
+#define static_cast 1 // { dg-warning "keyword 'static_cast' defined as macro" }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" }
+#define template 1 // { dg-warning "keyword 'template' defined as macro" }
+#define this 1 // { dg-warning "keyword 'this' defined as macro" }
+#define thread_local 1 // { dg-warning "keyword 'thread_local' defined as macro" "" { target c++11 } }
+#define throw 1 // { dg-warning "keyword 'throw' defined as macro" }
+#define true 1 // { dg-warning "keyword 'true' defined as macro" }
+#define try 1 // { dg-warning "keyword 'try' defined as macro" }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" }
+#define typeid 1 // { dg-warning "keyword 'typeid' defined as macro" }
+#define typename 1 // { dg-warning "keyword 'typename' defined as macro" }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" }
+#define using 1 // { dg-warning "keyword 'using' defined as macro" }
+#define virtual 1 // { dg-warning "keyword 'virtual' defined as macro" }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" }
+#define wchar_t 1 // { dg-warning "keyword 'wchar_t' defined as macro" }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" }
+
+// [lex.name]
+#define final 1 // { dg-warning "keyword 'final' defined as macro" "" { target c++11 } }
+#define import 1 // { dg-warning "keyword 'import' defined as macro" "" { target c++20 } }
+#define module 1 // { dg-warning "keyword 'module' defined as macro" "" { target c++20 } }
+#define override 1 // { dg-warning "keyword 'override' defined as macro" "" { target c++11 } }
+#define post 1
+#define pre 1
+#define replaceable_if_eligible 1 // { dg-warning "keyword 'replaceable_if_eligible' defined as macro" "" { target c++26 } }
+#define trivially_relocatable_if_eligible 1 // { dg-warning "keyword 'trivially_relocatable_if_eligible' defined as macro" "" { target c++26 } }
+
+// [dcl.attr]
+#define assume 1 // { dg-warning "keyword 'assume' defined as macro" "" { target c++23 } }
+#define carries_dependency 1 // { dg-warning "keyword 'carries_dependency' defined as macro" "" { target { c++11 && c++23_down } } }
+#define deprecated 1 // { dg-warning "keyword 'deprecated' defined as macro" "" { target c++14 } }
+#define fallthrough 1 // { dg-warning "keyword 'fallthrough' defined as macro" "" { target c++17 } }
+#define indeterminate 1
+#define likely 1 // { dg-warning "keyword 'likely' defined as macro" "" { target c++20 } }
+#define maybe_unused 1 // { dg-warning "keyword 'maybe_unused' defined as macro" "" { target c++17 } }
+#define nodiscard 1 // { dg-warning "keyword 'nodiscard' defined as macro" "" { target c++17 } }
+#define noreturn 1 // { dg-warning "keyword 'noreturn' defined as macro" "" { target c++11 } }
+#define no_unique_address 1 // { dg-warning "keyword 'no_unique_address' defined as macro" "" { target c++20 } }
+#define unlikely 1 // { dg-warning "keyword 'unlikely' defined as macro" "" { target c++20 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-8.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-8.C
new file mode 100644
index 0000000..7dcc377
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-8.C
@@ -0,0 +1,112 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro" }
+// { dg-additional-options "-fmodules" { target c++20 } }
+
+// [lex.key]
+#undef alignas // { dg-warning "undefining keyword 'alignas'" "" { target c++11 } }
+#undef alignof // { dg-warning "undefining keyword 'alignof'" "" { target c++11 } }
+#undef asm // { dg-warning "undefining keyword 'asm'" }
+#undef auto // { dg-warning "undefining keyword 'auto'" }
+#undef bool // { dg-warning "undefining keyword 'bool'" }
+#undef break // { dg-warning "undefining keyword 'break'" }
+#undef case // { dg-warning "undefining keyword 'case'" }
+#undef catch // { dg-warning "undefining keyword 'catch'" }
+#undef char // { dg-warning "undefining keyword 'char'" }
+#undef char16_t // { dg-warning "undefining keyword 'char16_t'" "" { target c++11 } }
+#undef char32_t // { dg-warning "undefining keyword 'char32_t'" "" { target c++11 } }
+#undef char8_t // { dg-warning "undefining keyword 'char8_t'" "" { target c++20 } }
+#undef class // { dg-warning "undefining keyword 'class'" }
+#undef co_await // { dg-warning "undefining keyword 'co_await'" "" { target c++20 } }
+#undef concept // { dg-warning "undefining keyword 'concept'" "" { target c++20 } }
+#undef const // { dg-warning "undefining keyword 'const'" }
+#undef const_cast // { dg-warning "undefining keyword 'const_cast'" }
+#undef consteval // { dg-warning "undefining keyword 'consteval'" "" { target c++20 } }
+#undef constexpr // { dg-warning "undefining keyword 'constexpr'" "" { target c++11 } }
+#undef constinit // { dg-warning "undefining keyword 'constinit'" "" { target c++20 } }
+#undef continue // { dg-warning "undefining keyword 'continue'" }
+#undef contract_assert
+#undef co_return // { dg-warning "undefining keyword 'co_return'" "" { target c++20 } }
+#undef co_yield // { dg-warning "undefining keyword 'co_yield'" "" { target c++20 } }
+#undef decltype // { dg-warning "undefining keyword 'decltype'" "" { target c++11 } }
+#undef default // { dg-warning "undefining keyword 'default'" }
+#undef delete // { dg-warning "undefining keyword 'delete'" }
+#undef do // { dg-warning "undefining keyword 'do'" }
+#undef double // { dg-warning "undefining keyword 'double'" }
+#undef dynamic_cast // { dg-warning "undefining keyword 'dynamic_cast'" }
+#undef else // { dg-warning "undefining keyword 'else'" }
+#undef enum // { dg-warning "undefining keyword 'enum'" }
+#undef explicit // { dg-warning "undefining keyword 'explicit'" }
+#undef export // { dg-warning "undefining keyword 'export'" }
+#undef extern // { dg-warning "undefining keyword 'extern'" }
+#undef false // { dg-warning "undefining keyword 'false'" }
+#undef float // { dg-warning "undefining keyword 'float'" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#undef friend // { dg-warning "undefining keyword 'friend'" }
+#undef goto // { dg-warning "undefining keyword 'goto'" }
+#undef if // { dg-warning "undefining keyword 'if'" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#undef int // { dg-warning "undefining keyword 'int'" }
+#undef long // { dg-warning "undefining keyword 'long'" }
+#undef mutable // { dg-warning "undefining keyword 'mutable'" }
+#undef namespace // { dg-warning "undefining keyword 'namespace'" }
+#undef new // { dg-warning "undefining keyword 'new'" }
+#undef noexcept // { dg-warning "undefining keyword 'noexcept'" "" { target c++11 } }
+#undef nullptr // { dg-warning "undefining keyword 'nullptr'" "" { target c++11 } }
+#undef operator // { dg-warning "undefining keyword 'operator'" }
+#undef private // { dg-warning "undefining keyword 'private'" }
+#undef protected // { dg-warning "undefining keyword 'protected'" }
+#undef public // { dg-warning "undefining keyword 'public'" }
+#undef register // { dg-warning "undefining keyword 'register'" }
+#undef reinterpret_cast // { dg-warning "undefining keyword 'reinterpret_cast'" }
+#undef requires // { dg-warning "undefining keyword 'requires'" "" { target c++20 } }
+#undef return // { dg-warning "undefining keyword 'return'" }
+#undef short // { dg-warning "undefining keyword 'short'" }
+#undef signed // { dg-warning "undefining keyword 'signed'" }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" }
+#undef static // { dg-warning "undefining keyword 'static'" }
+#undef static_assert // { dg-warning "undefining keyword 'static_assert'" "" { target c++11 } }
+#undef static_cast // { dg-warning "undefining keyword 'static_cast'" }
+#undef struct // { dg-warning "undefining keyword 'struct'" }
+#undef switch // { dg-warning "undefining keyword 'switch'" }
+#undef template // { dg-warning "undefining keyword 'template'" }
+#undef this // { dg-warning "undefining keyword 'this'" }
+#undef thread_local // { dg-warning "undefining keyword 'thread_local'" "" { target c++11 } }
+#undef throw // { dg-warning "undefining keyword 'throw'" }
+#undef true // { dg-warning "undefining keyword 'true'" }
+#undef try // { dg-warning "undefining keyword 'try'" }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" }
+#undef typeid // { dg-warning "undefining keyword 'typeid'" }
+#undef typename // { dg-warning "undefining keyword 'typename'" }
+#undef union // { dg-warning "undefining keyword 'union'" }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" }
+#undef using // { dg-warning "undefining keyword 'using'" }
+#undef virtual // { dg-warning "undefining keyword 'virtual'" }
+#undef void // { dg-warning "undefining keyword 'void'" }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" }
+#undef wchar_t // { dg-warning "undefining keyword 'wchar_t'" }
+#undef while // { dg-warning "undefining keyword 'while'" }
+
+// [lex.name]
+#undef final // { dg-warning "undefining keyword 'final'" "" { target c++11 } }
+#undef import // { dg-warning "undefining keyword 'import'" "" { target c++20 } }
+#undef module // { dg-warning "undefining keyword 'module'" "" { target c++20 } }
+#undef override // { dg-warning "undefining keyword 'override'" "" { target c++11 } }
+#undef post
+#undef pre
+#undef replaceable_if_eligible // { dg-warning "undefining keyword 'replaceable_if_eligible'" "" { target c++26 } }
+#undef trivially_relocatable_if_eligible // { dg-warning "undefining keyword 'trivially_relocatable_if_eligible'" "" { target c++26 } }
+
+// [dcl.attr]
+#undef assume // { dg-warning "undefining keyword 'assume'" "" { target c++23 } }
+#undef carries_dependency // { dg-warning "undefining keyword 'carries_dependency'" "" { target { c++11 && c++23_down } } }
+#undef deprecated // { dg-warning "undefining keyword 'deprecated'" "" { target c++14 } }
+#undef fallthrough // { dg-warning "undefining keyword 'fallthrough'" "" { target c++17 } }
+#undef indeterminate
+#undef likely // { dg-warning "undefining keyword 'likely'" "" { target c++20 } }
+#undef maybe_unused // { dg-warning "undefining keyword 'maybe_unused'" "" { target c++17 } }
+#undef nodiscard // { dg-warning "undefining keyword 'nodiscard'" "" { target c++17 } }
+#undef noreturn // { dg-warning "undefining keyword 'noreturn'" "" { target c++11 } }
+#undef no_unique_address // { dg-warning "undefining keyword 'no_unique_address'" "" { target c++20 } }
+#undef unlikely // { dg-warning "undefining keyword 'unlikely'" "" { target c++20 } }
diff --git a/gcc/testsuite/g++.dg/warn/Wkeyword-macro-9.C b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-9.C
new file mode 100644
index 0000000..741cdee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wkeyword-macro-9.C
@@ -0,0 +1,22 @@
+// C++26 P2843R3 - Preprocessing is never undefined
+// [cpp.replace.general]/9
+// { dg-do preprocess }
+// { dg-options "-pedantic-errors" }
+
+#undef for // { dg-error "undefining keyword 'for'" "" { target c++26 } }
+#define for for // { dg-error "keyword 'for' defined as macro" "" { target c++26 } }
+#undef for // { dg-error "undefining keyword 'for'" "" { target c++26 } }
+#define while do // { dg-error "keyword 'while' defined as macro" "" { target c++26 } }
+#define while do // { dg-error "keyword 'while' defined as macro" "" { target c++26 } }
+#define while for // { dg-error "keyword 'while' defined as macro" "" { target c++26 } }
+ // { dg-error "'while' redefined" "" { target *-*-* } .-1 }
+#undef while // { dg-error "undefining keyword 'while'" "" { target c++26 } }
+#define while while // { dg-error "keyword 'while' defined as macro" "" { target c++26 } }
+#define private public // { dg-error "keyword 'private' defined as macro" "" { target c++26 } }
+#define inline // { dg-error "keyword 'inline' defined as macro" "" { target c++26 } }
+#undef inline // { dg-error "undefining keyword 'inline'" "" { target c++26 } }
+#define inline __inline__ __attribute__((__always_inline__)) // { dg-error "keyword 'inline' defined as macro" "" { target c++26 } }
+#define likely(a) a
+#undef likely // { dg-error "undefining keyword 'likely'" "" { target c++26 } }
+#define unlikely(a, b, c) a + b + c
+#define unlikely(a, b, c) a + b + c
diff --git a/gcc/testsuite/g++.target/aarch64/sve/pr121449.C b/gcc/testsuite/g++.target/aarch64/sve/pr121449.C
new file mode 100644
index 0000000..b2e1376
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/sve/pr121449.C
@@ -0,0 +1,44 @@
+/* PR target/121449 */
+/* { dg-do assemble { target aarch64_asm_sve_ok } } */
+/* { dg-options "-O3 -save-temps" } */
+
+struct example;
+
+struct array {
+ unsigned length();
+ example *operator[](unsigned i) {
+ example **data = reinterpret_cast<example **>(this);
+ return data[i];
+ }
+};
+
+struct example {
+ int a[16];
+ bool is_even;
+ int version;
+ int count() { return is_even ? 2 : 1; }
+ void fun1(int, long);
+ void fun2(unsigned, unsigned);
+ void process(array &, array &);
+};
+
+bool found;
+
+void example::process(array &a, array &b) {
+ for (unsigned i = 1; a.length(); i++) {
+ long total = 0;
+ for (unsigned k = 0; k <= i; k++) {
+ total += a[k]->count();
+ }
+ for (unsigned j = 0; j < i; j++) {
+ int major = b[j]->version;
+ if (found)
+ major += i;
+ fun1(i + 1, total);
+ fun2(j, major);
+ }
+ }
+}
+
+/* { dg-final { scan-assembler-not {\tld1b\t(z[0-9]+)\.d, p[0-7]/z, \[(z[0-9]+)\.d, #64\]} } } */
+
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c
new file mode 100644
index 0000000..0b2d78f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-1.c
@@ -0,0 +1,62 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c23" }
+
+#define _Alignas 1 // { dg-warning "keyword '_Alignas' defined as macro" }
+#define _Alignof 1 // { dg-warning "keyword '_Alignof' defined as macro" }
+#define _Atomic 1 // { dg-warning "keyword '_Atomic' defined as macro" }
+#define _BitInt 1 // { dg-warning "keyword '_BitInt' defined as macro" }
+#define _Bool 1 // { dg-warning "keyword '_Bool' defined as macro" }
+#define _Complex 1 // { dg-warning "keyword '_Complex' defined as macro" }
+#define _Decimal128 1 // { dg-warning "keyword '_Decimal128' defined as macro" }
+#define _Decimal32 1 // { dg-warning "keyword '_Decimal32' defined as macro" }
+#define _Decimal64 1 // { dg-warning "keyword '_Decimal64' defined as macro" }
+#define _Generic 1 // { dg-warning "keyword '_Generic' defined as macro" }
+#define _Imaginary 1 // { dg-warning "keyword '_Imaginary' defined as macro" }
+#define _Noreturn 1 // { dg-warning "keyword '_Noreturn' defined as macro" }
+#define _Static_assert 1 // { dg-warning "keyword '_Static_assert' defined as macro" }
+#define _Thread_local 1 // { dg-warning "keyword '_Thread_local' defined as macro" }
+#define alignas 1 // { dg-warning "keyword 'alignas' defined as macro" }
+#define alignof 1 // { dg-warning "keyword 'alignof' defined as macro" }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" }
+#define bool 1 // { dg-warning "keyword 'bool' defined as macro" }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" }
+#define constexpr 1 // { dg-warning "keyword 'constexpr' defined as macro" }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" }
+#define false 1 // { dg-warning "keyword 'false' defined as macro" }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" }
+#define nullptr 1 // { dg-warning "keyword 'nullptr' defined as macro" }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" }
+#define restrict 1 // { dg-warning "keyword 'restrict' defined as macro" }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" }
+#define static_assert 1 // { dg-warning "keyword 'static_assert' defined as macro" }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" }
+#define thread_local 1 // { dg-warning "keyword 'thread_local' defined as macro" }
+#define true 1 // { dg-warning "keyword 'true' defined as macro" }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" }
+#define typeof 1 // { dg-warning "keyword 'typeof' defined as macro" }
+#define typeof_unqual 1 // { dg-warning "keyword 'typeof_unqual' defined as macro" }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c
new file mode 100644
index 0000000..329a55a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-2.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c23" }
+
+#include "Wkeyword-macro-1.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c
new file mode 100644
index 0000000..f631b8e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-3.c
@@ -0,0 +1,62 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c23" }
+
+#undef _Alignas // { dg-warning "undefining keyword '_Alignas'" }
+#undef _Alignof // { dg-warning "undefining keyword '_Alignof'" }
+#undef _Atomic // { dg-warning "undefining keyword '_Atomic'" }
+#undef _BitInt // { dg-warning "undefining keyword '_BitInt'" }
+#undef _Bool // { dg-warning "undefining keyword '_Bool'" }
+#undef _Complex // { dg-warning "undefining keyword '_Complex'" }
+#undef _Decimal128 // { dg-warning "undefining keyword '_Decimal128'" }
+#undef _Decimal32 // { dg-warning "undefining keyword '_Decimal32'" }
+#undef _Decimal64 // { dg-warning "undefining keyword '_Decimal64'" }
+#undef _Generic // { dg-warning "undefining keyword '_Generic'" }
+#undef _Imaginary // { dg-warning "undefining keyword '_Imaginary'" }
+#undef _Noreturn // { dg-warning "undefining keyword '_Noreturn'" }
+#undef _Static_assert // { dg-warning "undefining keyword '_Static_assert'" }
+#undef _Thread_local // { dg-warning "undefining keyword '_Thread_local'" }
+#undef alignas // { dg-warning "undefining keyword 'alignas'" }
+#undef alignof // { dg-warning "undefining keyword 'alignof'" }
+#undef auto // { dg-warning "undefining keyword 'auto'" }
+#undef bool // { dg-warning "undefining keyword 'bool'" }
+#undef break // { dg-warning "undefining keyword 'break'" }
+#undef case // { dg-warning "undefining keyword 'case'" }
+#undef char // { dg-warning "undefining keyword 'char'" }
+#undef const // { dg-warning "undefining keyword 'const'" }
+#undef constexpr // { dg-warning "undefining keyword 'constexpr'" }
+#undef continue // { dg-warning "undefining keyword 'continue'" }
+#undef default // { dg-warning "undefining keyword 'default'" }
+#undef do // { dg-warning "undefining keyword 'do'" }
+#undef double // { dg-warning "undefining keyword 'double'" }
+#undef else // { dg-warning "undefining keyword 'else'" }
+#undef enum // { dg-warning "undefining keyword 'enum'" }
+#undef extern // { dg-warning "undefining keyword 'extern'" }
+#undef false // { dg-warning "undefining keyword 'false'" }
+#undef float // { dg-warning "undefining keyword 'float'" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#undef goto // { dg-warning "undefining keyword 'goto'" }
+#undef if // { dg-warning "undefining keyword 'if'" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#undef int // { dg-warning "undefining keyword 'int'" }
+#undef long // { dg-warning "undefining keyword 'long'" }
+#undef nullptr // { dg-warning "undefining keyword 'nullptr'" }
+#undef register // { dg-warning "undefining keyword 'register'" }
+#undef restrict // { dg-warning "undefining keyword 'restrict'" }
+#undef return // { dg-warning "undefining keyword 'return'" }
+#undef short // { dg-warning "undefining keyword 'short'" }
+#undef signed // { dg-warning "undefining keyword 'signed'" }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" }
+#undef static // { dg-warning "undefining keyword 'static'" }
+#undef static_assert // { dg-warning "undefining keyword 'static_assert'" }
+#undef struct // { dg-warning "undefining keyword 'struct'" }
+#undef switch // { dg-warning "undefining keyword 'switch'" }
+#undef thread_local // { dg-warning "undefining keyword 'thread_local'" }
+#undef true // { dg-warning "undefining keyword 'true'" }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" }
+#undef typeof // { dg-warning "undefining keyword 'typeof'" }
+#undef typeof_unqual // { dg-warning "undefining keyword 'typeof_unqual'" }
+#undef union // { dg-warning "undefining keyword 'union'" }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" }
+#undef void // { dg-warning "undefining keyword 'void'" }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" }
+#undef while // { dg-warning "undefining keyword 'while'" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c
new file mode 100644
index 0000000..796d654
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-4.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c23" }
+
+#include "Wkeyword-macro-3.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c
new file mode 100644
index 0000000..c61a1ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-5.c
@@ -0,0 +1,47 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c17" }
+
+#define _Alignas 1 // { dg-warning "keyword '_Alignas' defined as macro" }
+#define _Alignof 1 // { dg-warning "keyword '_Alignof' defined as macro" }
+#define _Atomic 1 // { dg-warning "keyword '_Atomic' defined as macro" }
+#define _Bool 1 // { dg-warning "keyword '_Bool' defined as macro" }
+#define _Complex 1 // { dg-warning "keyword '_Complex' defined as macro" }
+#define _Generic 1 // { dg-warning "keyword '_Generic' defined as macro" }
+#define _Imaginary 1 // { dg-warning "keyword '_Imaginary' defined as macro" }
+#define _Noreturn 1 // { dg-warning "keyword '_Noreturn' defined as macro" }
+#define _Static_assert 1 // { dg-warning "keyword '_Static_assert' defined as macro" }
+#define _Thread_local 1 // { dg-warning "keyword '_Thread_local' defined as macro" }
+#define auto 1 // { dg-warning "keyword 'auto' defined as macro" }
+#define break 1 // { dg-warning "keyword 'break' defined as macro" }
+#define case 1 // { dg-warning "keyword 'case' defined as macro" }
+#define char 1 // { dg-warning "keyword 'char' defined as macro" }
+#define const 1 // { dg-warning "keyword 'const' defined as macro" }
+#define continue 1 // { dg-warning "keyword 'continue' defined as macro" }
+#define default 1 // { dg-warning "keyword 'default' defined as macro" }
+#define do 1 // { dg-warning "keyword 'do' defined as macro" }
+#define double 1 // { dg-warning "keyword 'double' defined as macro" }
+#define else 1 // { dg-warning "keyword 'else' defined as macro" }
+#define enum 1 // { dg-warning "keyword 'enum' defined as macro" }
+#define extern 1 // { dg-warning "keyword 'extern' defined as macro" }
+#define float 1 // { dg-warning "keyword 'float' defined as macro" }
+#define for 1 // { dg-warning "keyword 'for' defined as macro" }
+#define goto 1 // { dg-warning "keyword 'goto' defined as macro" }
+#define if 1 // { dg-warning "keyword 'if' defined as macro" }
+#define inline 1 // { dg-warning "keyword 'inline' defined as macro" }
+#define int 1 // { dg-warning "keyword 'int' defined as macro" }
+#define long 1 // { dg-warning "keyword 'long' defined as macro" }
+#define register 1 // { dg-warning "keyword 'register' defined as macro" }
+#define restrict 1 // { dg-warning "keyword 'restrict' defined as macro" }
+#define return 1 // { dg-warning "keyword 'return' defined as macro" }
+#define short 1 // { dg-warning "keyword 'short' defined as macro" }
+#define signed 1 // { dg-warning "keyword 'signed' defined as macro" }
+#define sizeof 1 // { dg-warning "keyword 'sizeof' defined as macro" }
+#define static 1 // { dg-warning "keyword 'static' defined as macro" }
+#define struct 1 // { dg-warning "keyword 'struct' defined as macro" }
+#define switch 1 // { dg-warning "keyword 'switch' defined as macro" }
+#define typedef 1 // { dg-warning "keyword 'typedef' defined as macro" }
+#define union 1 // { dg-warning "keyword 'union' defined as macro" }
+#define unsigned 1 // { dg-warning "keyword 'unsigned' defined as macro" }
+#define void 1 // { dg-warning "keyword 'void' defined as macro" }
+#define volatile 1 // { dg-warning "keyword 'volatile' defined as macro" }
+#define while 1 // { dg-warning "keyword 'while' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c
new file mode 100644
index 0000000..760ece6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-6.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c17" }
+
+#include "Wkeyword-macro-5.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c
new file mode 100644
index 0000000..dc146d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-7.c
@@ -0,0 +1,47 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro -std=c17" }
+
+#undef _Alignas // { dg-warning "undefining keyword '_Alignas'" }
+#undef _Alignof // { dg-warning "undefining keyword '_Alignof'" }
+#undef _Atomic // { dg-warning "undefining keyword '_Atomic'" }
+#undef _Bool // { dg-warning "undefining keyword '_Bool'" }
+#undef _Complex // { dg-warning "undefining keyword '_Complex'" }
+#undef _Generic // { dg-warning "undefining keyword '_Generic'" }
+#undef _Imaginary // { dg-warning "undefining keyword '_Imaginary'" }
+#undef _Noreturn // { dg-warning "undefining keyword '_Noreturn'" }
+#undef _Static_assert // { dg-warning "undefining keyword '_Static_assert'" }
+#undef _Thread_local // { dg-warning "undefining keyword '_Thread_local'" }
+#undef auto // { dg-warning "undefining keyword 'auto'" }
+#undef break // { dg-warning "undefining keyword 'break'" }
+#undef case // { dg-warning "undefining keyword 'case'" }
+#undef char // { dg-warning "undefining keyword 'char'" }
+#undef const // { dg-warning "undefining keyword 'const'" }
+#undef continue // { dg-warning "undefining keyword 'continue'" }
+#undef default // { dg-warning "undefining keyword 'default'" }
+#undef do // { dg-warning "undefining keyword 'do'" }
+#undef double // { dg-warning "undefining keyword 'double'" }
+#undef else // { dg-warning "undefining keyword 'else'" }
+#undef enum // { dg-warning "undefining keyword 'enum'" }
+#undef extern // { dg-warning "undefining keyword 'extern'" }
+#undef float // { dg-warning "undefining keyword 'float'" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#undef goto // { dg-warning "undefining keyword 'goto'" }
+#undef if // { dg-warning "undefining keyword 'if'" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#undef int // { dg-warning "undefining keyword 'int'" }
+#undef long // { dg-warning "undefining keyword 'long'" }
+#undef register // { dg-warning "undefining keyword 'register'" }
+#undef restrict // { dg-warning "undefining keyword 'restrict'" }
+#undef return // { dg-warning "undefining keyword 'return'" }
+#undef short // { dg-warning "undefining keyword 'short'" }
+#undef signed // { dg-warning "undefining keyword 'signed'" }
+#undef sizeof // { dg-warning "undefining keyword 'sizeof'" }
+#undef static // { dg-warning "undefining keyword 'static'" }
+#undef struct // { dg-warning "undefining keyword 'struct'" }
+#undef switch // { dg-warning "undefining keyword 'switch'" }
+#undef typedef // { dg-warning "undefining keyword 'typedef'" }
+#undef union // { dg-warning "undefining keyword 'union'" }
+#undef unsigned // { dg-warning "undefining keyword 'unsigned'" }
+#undef void // { dg-warning "undefining keyword 'void'" }
+#undef volatile // { dg-warning "undefining keyword 'volatile'" }
+#undef while // { dg-warning "undefining keyword 'while'" }
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c
new file mode 100644
index 0000000..b209f40
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-8.c
@@ -0,0 +1,4 @@
+// { dg-do preprocess }
+// { dg-options "-std=c17" }
+
+#include "Wkeyword-macro-7.c"
diff --git a/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c b/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c
new file mode 100644
index 0000000..5d6b650
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wkeyword-macro-9.c
@@ -0,0 +1,15 @@
+// { dg-do preprocess }
+// { dg-options "-Wkeyword-macro" }
+
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define for for // { dg-warning "keyword 'for' defined as macro" }
+#undef for // { dg-warning "undefining keyword 'for'" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while do // { dg-warning "keyword 'while' defined as macro" }
+#define while for // { dg-warning "keyword 'while' defined as macro" }
+ // { dg-warning "'while' redefined" "" { target *-*-* } .-1 }
+#undef while // { dg-warning "undefining keyword 'while'" }
+#define while while // { dg-warning "keyword 'while' defined as macro" }
+#define inline // { dg-warning "keyword 'inline' defined as macro" }
+#undef inline // { dg-warning "undefining keyword 'inline'" }
+#define inline __inline__ __attribute__((__always_inline__)) // { dg-warning "keyword 'inline' defined as macro" }
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
index 6a5a9ad..8cefb6e 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
@@ -22,10 +22,11 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 8 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 4 { target { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } */
#endif
char
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
index 7dabf96..5a60f9b 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
/* { dg-options "-std=c99" } we need long long */
#if defined (__aarch64__)
@@ -15,7 +15,7 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 2 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { i?86-*-* x86_64-*-* } } } } */
#endif
long long
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
index 0134bf0..d319467 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
@@ -1,4 +1,5 @@
-/* { dg-do compile { target aarch64*-*-* arm*-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
#if defined (__aarch64__)
# define FPR "{d5}"
@@ -16,9 +17,9 @@
#elif defined (__s390__)
# define FPR "{f5}"
/* { dg-final { scan-assembler-times "foo\t%f5" 4 { target { s390*-*-* } } } } */
-#elif defined (__x86_64__)
+#elif defined (__i386__) || defined (__x86_64__)
# define FPR "{xmm5}"
-/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { i?86-*-* x86_64-*-* } } } } */
#endif
float
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
index a9e25ce..ea7907a 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
typedef int V __attribute__ ((vector_size (4 * sizeof (int))));
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
index d9b7fae..c87a811 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
@@ -19,8 +19,8 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{ecx}"
-/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { i?86-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { i?86-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
#elif defined (__powerpc__) || defined (__POWERPC__)
# define GPR1 "{r4}"
# define GPR2 "{r5}"
@@ -43,8 +43,10 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%ecx" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%esi\\)" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
#endif
void
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
new file mode 100644
index 0000000..3492899
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-diagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
new file mode 100644
index 0000000..8fc2edb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
+
+/* { dg-begin-multiline-output "" }
+ * child 0
+ * grandchild 0 0
+ * grandchild 0 1
+ * grandchild 0 2
+ * child 1
+ * grandchild 1 0
+ * grandchild 1 1
+ * grandchild 1 2
+ * child 2
+ * grandchild 2 0
+ * grandchild 2 1
+ * grandchild 2 2
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
index f44c8eb..4be52fe 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-levels=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-levels=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
index 39e29f7..c069c3f 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
index e103429..a35254d 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index 3bb6063..c7cc36c 100644
--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
@@ -112,6 +112,8 @@ set plugin_test_list [list \
diagnostic-test-graphs-html.c \
diagnostic-test-graphs-sarif.c } \
{ diagnostic_plugin_test_nesting.cc \
+ diagnostic-test-nesting-show-nesting.c \
+ diagnostic-test-nesting-no-show-nesting.c \
diagnostic-test-nesting-text-plain.c \
diagnostic-test-nesting-text-indented.c \
diagnostic-test-nesting-text-indented-show-levels.c \
diff --git a/gcc/testsuite/gcc.dg/pr118946-1.c b/gcc/testsuite/gcc.dg/pr118946-1.c
new file mode 100644
index 0000000..6cf2661
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118946-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+/* PR tree-optimization/118946 */
+
+void f(char *a)
+{
+ char t[1024] = {};
+ __builtin_memcpy(a, t, 10);
+}
+
+/* We should be able to optimize the memcpy into a memset here. */
+/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1"} } */
+/* { dg-final { scan-tree-dump-times "memset " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "memcpy " "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/hardbool-ai.c b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
index 97569a6..af4e0e1 100644
--- a/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
+++ b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
@@ -1,4 +1,5 @@
/* { dg-do run } */
+/* { dg-require-effective-target sync_int_long } */
#define basetype _Atomic int
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-1.c b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
new file mode 100644
index 0000000..136f80d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ b = (struct s1){};
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3*sizeof(t[0]));
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-2.c b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
new file mode 100644
index 0000000..570559c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ __builtin_memset(&b.a[1], 0, 2);
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3);
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c
new file mode 100644
index 0000000..f80baf3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-107.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+struct vec_char_16
+{
+ unsigned char raw[2];
+};
+
+static inline struct vec_char_16
+Dup128VecFromValues(unsigned char t0, unsigned char t1)
+{
+ struct vec_char_16 result;
+ result.raw[0] = t0;
+ result.raw[1] = t1;
+ return result;
+}
+
+int f(unsigned char t0, unsigned char t1)
+{
+ struct vec_char_16 a = Dup128VecFromValues(t0, t1);
+ struct vec_char_16 b;
+ __builtin_memcpy(&b, &a, sizeof(a));
+ return b.raw[0] + b.raw[1];
+}
+
+/* Ideally we'd optimize this at FRE1 time but we only replace
+ the loads from b.raw[] with BIT_FIELD_REFs which get optimized
+ only later in the next FRE. */
+/* { dg-final { scan-tree-dump-not "MEM" "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr120986-1.c b/gcc/testsuite/gcc.target/aarch64/pr120986-1.c
new file mode 100644
index 0000000..e3bc56c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr120986-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=armv8.2-a+sve2+fp8dot2" } */
+#include <arm_sve.h>
+
+/* This triggered an ICE with an unrecognizable insn due to incorrect gating of
+ the insn in the backend. */
+svfloat16_t foo(svfloat16_t a, svmfloat8_t b, svmfloat8_t c, unsigned long fpm)
+{
+ return svdot_lane_fpm (a, b, c, 0, fpm);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/pr121414_1.c b/gcc/testsuite/gcc.target/aarch64/sme/pr121414_1.c
new file mode 100644
index 0000000..ad8600f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sme/pr121414_1.c
@@ -0,0 +1,27 @@
+#pragma GCC target "+sme2"
+
+void f1() __arm_streaming_compatible {}
+void f2() __arm_streaming {}
+void f3() __arm_in("za") {}
+void f4() __arm_out("za") {}
+void f5() __arm_inout("za") {}
+void f6() __arm_in("zt0") {}
+void f7() __arm_out("zt0") {}
+void f8() __arm_inout("zt0") {}
+
+__arm_locally_streaming void g1() {}
+__arm_new("za") void g2() {}
+__arm_new("zt0") void g3() {}
+
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf1\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf2\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf3\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf4\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf5\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf6\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf7\n} } } */
+/* { dg-final { scan-assembler {\t\.variant_pcs\tf8\n} } } */
+
+/* { dg-final { scan-assembler-not {\t\.variant_pcs\tg1\n} } } */
+/* { dg-final { scan-assembler-not {\t\.variant_pcs\tg2\n} } } */
+/* { dg-final { scan-assembler-not {\t\.variant_pcs\tg3\n} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr120718.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr120718.c
new file mode 100644
index 0000000..9ca0938
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr120718.c
@@ -0,0 +1,12 @@
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+typedef int __attribute__((vector_size(8))) v2si;
+typedef struct { int x; int y; } A;
+void bar(A a);
+void foo()
+{
+ A a;
+ *(v2si *)&a = (v2si){0, (int)svcntd_pat(SV_ALL)};
+ bar(a);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11.c
new file mode 100644
index 0000000..feb7ee7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11.c
@@ -0,0 +1,20 @@
+/* Peeling for alignment with masking in VLA modes. */
+/* { dg-do compile } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only -fdump-tree-vect-details" } */
+
+#define START 3
+#define END 510
+
+int __attribute__((noipa))
+foo (int *a) {
+ for (signed int i = START; i < END; ++i) {
+ if (a[i] != 0)
+ return i;
+ }
+ return -1;
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump "pfa_iv_offset" "vect" } } */
+/* { dg-final { scan-tree-dump "Alignment of access forced using peeling" "vect" } } */
+/* { dg-final { scan-assembler {\tnot\tp[0-7]\.b, p[0-7]/z, p.*\n} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11_run.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11_run.c
new file mode 100644
index 0000000..b4c267f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_11_run.c
@@ -0,0 +1,27 @@
+/* Peeling for alignment with masking in VLA modes. */
+/* { dg-do run { target aarch64_sve_hw } } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only" } */
+
+#include "peel_ind_11.c"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define N 512
+
+int __attribute__ ((optimize (1)))
+main (void)
+{
+ for (int k = 5; k < 30; k++) {
+ int *a = (int *) malloc (sizeof(int) * N);
+
+ /* Set only one non-zero element for test. */
+ for (int i = 5; i < 30; i++)
+ a[i] = (i == k ? 1 : 0);
+
+ int res = foo (a);
+ asm volatile ("");
+ if (res != k) {
+ __builtin_abort ();
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12.c
new file mode 100644
index 0000000..260482a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12.c
@@ -0,0 +1,21 @@
+/* Peeling for alignment with masking together with versioning in VLA modes. */
+/* { dg-do compile } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only -fdump-tree-vect-details" } */
+
+#define START 5
+#define END 509
+
+int __attribute__((noipa))
+foo (int *restrict a, int * restrict b) {
+ for (signed int i = START; i < END; ++i) {
+ if (a[i] != b[i])
+ return i;
+ }
+ return -1;
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump "pfa_iv_offset" "vect" } } */
+/* { dg-final { scan-tree-dump "Both peeling and versioning will be applied" "vect" } } */
+/* { dg-final { scan-assembler {\tnot\tp[0-7]\.b, p[0-7]/z, p.*\n} } } */
+/* { dg-final { scan-assembler {\teor\t.*\n} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12_run.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12_run.c
new file mode 100644
index 0000000..ba978fe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_12_run.c
@@ -0,0 +1,29 @@
+/* Peeling for alignment with masking together with versioning in VLA modes. */
+/* { dg-do run { target aarch64_sve_hw } } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only" } */
+
+#include "peel_ind_12.c"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define N 512
+
+int __attribute__ ((optimize (1)))
+main (void) {
+ for (int k = 5; k < 50; k++) {
+ int *a = (int *) malloc (sizeof(int) * N);
+ int *b = (int *) malloc (sizeof(int) * N);
+
+ /* Set only one place of different values for test. */
+ for (int i = 5; i < 50; i++) {
+ a[i] = (i == k ? 1 : 0);
+ b[i] = 0;
+ }
+
+ int res = foo (a, b);
+ asm volatile ("");
+ if (res != k) {
+ __builtin_abort ();
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13.c
new file mode 100644
index 0000000..730e33e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13.c
@@ -0,0 +1,24 @@
+/* Known inbounds DR in VLA modes. */
+/* { dg-do compile } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only -fdump-tree-vect-details" } */
+
+#define N 512
+#define START 5
+#define END 509
+
+int x[N] __attribute__((aligned(32)));
+
+int __attribute__((noipa))
+foo (void)
+{
+ for (signed int i = START; i < END; ++i)
+ {
+ if (x[i] == 0)
+ return i;
+ }
+ return -1;
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump-not "pfa_iv_offset" "vect" } } */
+/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13_run.c b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13_run.c
new file mode 100644
index 0000000..83352a8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/peel_ind_13_run.c
@@ -0,0 +1,15 @@
+/* Known inbounds DR in VLA modes. */
+/* { dg-do run { target aarch64_sve_hw } } */
+/* { dg-options "-Ofast -msve-vector-bits=scalable --param aarch64-autovec-preference=sve-only" } */
+
+#include "peel_ind_13.c"
+
+int __attribute__ ((optimize (1)))
+main (void)
+{
+ int res = foo ();
+ asm volatile ("");
+ if (res != START)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/torture/pr120986-2.c b/gcc/testsuite/gcc.target/aarch64/torture/pr120986-2.c
new file mode 100644
index 0000000..1218dea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/torture/pr120986-2.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv8.2-a+sve2+fp8dot2" } */
+#include <arm_sve.h>
+svfloat16_t foo(svfloat16_t a, svmfloat8_t b, svmfloat8_t c)
+{
+ return svdot_lane_fpm (a, b, c, 0, 0);
+}
diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c
index db7d975..eb8a358 100644
--- a/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c
+++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-18.c
@@ -1,5 +1,6 @@
/* { dg-do compile } */
-/* { dg-options "-mcmse -fdump-rtl-final-slim" } */
+/* Make sure FPCXT is not enabled. */
+/* { dg-options "-mcmse -fdump-rtl-final -march=armv8-m.main+fp" } */
typedef void (*f)(int) __attribute__((cmse_nonsecure_call));
@@ -8,5 +9,5 @@ void bar(f func, int a)
func(a);
}
-/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r4:SI\\\]\\\]" "final" { target { ! arm_v8_1m_mve_ok } } } } */
-/* { dg-final { scan-rtl-dump "call unspec\\\[\\\[r\[0-7\]:SI\\\]\\\]" "final" { target { arm_v8_1m_mve_ok } } } } */
+/* { dg-final { scan-rtl-dump "call \\\(mem:SI \\\(reg:SI 4 r4" "final" } } */
+/* { dg-final { scan-rtl-dump "UNSPEC_NONSECURE_MEM" "final" } } */
diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-19.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-19.c
new file mode 100644
index 0000000..ae075c3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-19.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* This is a duplicate of cmse-18.c, targetting arm_v8_1m_mve, to make sure
+ FPCXT is enabled. */
+/* { dg-options "-mcmse -fdump-rtl-final -march=armv8.1-m.main+mve" } */
+
+typedef void (*f)(int) __attribute__((cmse_nonsecure_call));
+
+void bar(f func, int a)
+{
+ func(a);
+}
+
+/* { dg-final { scan-rtl-dump "call \\\(mem:SI \\\(reg/f:SI \[0-7] r\[0-7\]" "final" } } */
+/* { dg-final { scan-rtl-dump "UNSPEC_NONSECURE_MEM" "final" } } */
diff --git a/gcc/testsuite/gcc.target/i386/asm-hard-reg-2.c b/gcc/testsuite/gcc.target/i386/asm-hard-reg-2.c
index b35cf53..756f6f8 100644
--- a/gcc/testsuite/gcc.target/i386/asm-hard-reg-2.c
+++ b/gcc/testsuite/gcc.target/i386/asm-hard-reg-2.c
@@ -8,7 +8,7 @@ test (void)
#ifdef __x86_64__
int z __attribute__ ((mode (TI)));
#else
- long z;
+ long long z;
#endif
__asm__ __volatile__ ("" : "=A" (z), "={rbx}" (y));
diff --git a/gcc/testsuite/gcc.target/i386/pr90579.c b/gcc/testsuite/gcc.target/i386/pr90579.c
index ab48a44..e8c6bad3 100644
--- a/gcc/testsuite/gcc.target/i386/pr90579.c
+++ b/gcc/testsuite/gcc.target/i386/pr90579.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O3 -mavx2 -mfpmath=sse" } */
+/* { dg-options "-O3 -mavx2 -mfpmath=sse -fno-pie" } */
extern double r[6];
extern double a[];
@@ -16,8 +16,5 @@ loop (int k, double x)
return t;
}
-/* Verify we end up with scalar loads from r for the final sum. */
-/* { dg-final { scan-assembler "vaddsd\tr\\\+40" } } */
-/* { dg-final { scan-assembler "vaddsd\tr\\\+32" } } */
-/* { dg-final { scan-assembler "vaddsd\tr\\\+24" } } */
-/* { dg-final { scan-assembler "vaddsd\tr\\\+16" } } */
+/* Verify we end up with no loads from r. */
+/* { dg-final { scan-assembler-not "v\[ma\]\[^\t \]+\tr" } } */
diff --git a/gcc/testsuite/gcc.target/s390/bitint-1.c b/gcc/testsuite/gcc.target/s390/bitint-1.c
new file mode 100644
index 0000000..8bdf2ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/bitint-1.c
@@ -0,0 +1,83 @@
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -march=z9-109" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/* Verify calling convention. */
+
+static_assert (sizeof (_BitInt(5)) == 1);
+static_assert (sizeof (_BitInt(9)) == 2);
+static_assert (sizeof (_BitInt(17)) == 4);
+static_assert (sizeof (_BitInt(33)) == 8);
+
+/*
+** bitint5_zero_extend_call:
+** lghi %r2,22
+** jg bitint5_zero_extend@PLT
+*/
+
+void bitint5_zero_extend (unsigned _BitInt(5) x);
+void bitint5_zero_extend_call (void) { bitint5_zero_extend (22wbu); }
+
+/*
+** bitint5_sign_extend_call:
+** lghi %r2,-10
+** jg bitint5_sign_extend@PLT
+*/
+
+void bitint5_sign_extend (_BitInt(5) x);
+void bitint5_sign_extend_call (void) { bitint5_sign_extend (-10wb); }
+
+/*
+** bitint9_zero_extend_call:
+** lghi %r2,422
+** jg bitint9_zero_extend@PLT
+*/
+
+void bitint9_zero_extend (unsigned _BitInt(9) x);
+void bitint9_zero_extend_call (void) { bitint9_zero_extend (422wbu); }
+
+/*
+** bitint9_sign_extend_call:
+** lghi %r2,-90
+** jg bitint9_sign_extend@PLT
+*/
+
+void bitint9_sign_extend (_BitInt(9) x);
+void bitint9_sign_extend_call (void) { bitint9_sign_extend (-90wb); }
+
+/*
+** bitint17_zero_extend_call:
+** lgfi %r2,108198
+** jg bitint17_zero_extend@PLT
+*/
+
+void bitint17_zero_extend (unsigned _BitInt(17) x);
+void bitint17_zero_extend_call (void) { bitint17_zero_extend (108198wbu); }
+
+/*
+** bitint17_sign_extend_call:
+** lghi %r2,-22874
+** jg bitint17_sign_extend@PLT
+*/
+
+void bitint17_sign_extend (_BitInt(17) x);
+void bitint17_sign_extend_call (void) { bitint17_sign_extend (-22874wb); }
+
+/*
+** bitint33_zero_extend_call:
+** llihl %r2,1
+** oilf %r2,2795939494
+** jg bitint33_zero_extend@PLT
+*/
+
+void bitint33_zero_extend (unsigned _BitInt(33) x);
+void bitint33_zero_extend_call (void) { bitint33_zero_extend (7090906790wbu); }
+
+/*
+** bitint33_sign_extend_call:
+** lgfi %r2,-1499027802
+** jg bitint33_sign_extend@PLT
+*/
+
+void bitint33_sign_extend (_BitInt(33) x);
+void bitint33_sign_extend_call (void) { bitint33_sign_extend (-1499027802wb); }
diff --git a/gcc/testsuite/gcc.target/s390/bitint-2.c b/gcc/testsuite/gcc.target/s390/bitint-2.c
new file mode 100644
index 0000000..9b0e6b9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/bitint-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23" } */
+
+/* Verify calling convention. */
+
+static_assert (sizeof (_BitInt(65)) == 16);
+
+[[gnu::noipa]] void
+bitint65_zero_extend (unsigned _BitInt(65) x)
+{
+ static const char y[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0xBA, 0xDC, 0x0F, 0xFE, 0xE0, 0xDD, 0xF0, 0x0D};
+ if (__builtin_memcmp (&x, y, 16) != 0)
+ __builtin_abort ();
+}
+
+[[gnu::noipa]] void
+bitint65_sign_extend (signed _BitInt(65) x)
+{
+ static const char y[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xBA, 0xDC, 0x0F, 0xFE, 0xE0, 0xDD, 0xF0, 0x0D};
+ if (__builtin_memcmp (&x, y, 16) != 0)
+ __builtin_abort ();
+}
+
+int
+main (void)
+{
+ bitint65_zero_extend (0x1BADC0FFEE0DDF00Dwbu);
+ bitint65_sign_extend (0x1BADC0FFEE0DDF00Dwb);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/s390/bitint-3.c b/gcc/testsuite/gcc.target/s390/bitint-3.c
new file mode 100644
index 0000000..9132028
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/bitint-3.c
@@ -0,0 +1,28 @@
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-march=z9-109 -fdump-rtl-expand" } */
+
+/* Verify calling convention. */
+
+/* { dg-final { scan-rtl-dump-times "zero_extend:DI.*reg:QI" 1 "expand" } } */
+void bitint5_zero_extend (unsigned _BitInt(5) x);
+void bitint5_zero_extend_call (unsigned _BitInt(5) x) { bitint5_zero_extend (x + 1); }
+
+/* { dg-final { scan-rtl-dump-times "sign_extend:DI.*reg:QI" 1 "expand" } } */
+void bitint5_sign_extend (_BitInt(5) x);
+void bitint5_sign_extend_call (_BitInt(5) x) { bitint5_sign_extend (x + 1); }
+
+/* { dg-final { scan-rtl-dump-times "zero_extend:DI.*reg:HI" 1 "expand" } } */
+void bitint9_zero_extend (unsigned _BitInt(9) x);
+void bitint9_zero_extend_call (unsigned _BitInt(9) x) { bitint9_zero_extend (x + 1); }
+
+/* { dg-final { scan-rtl-dump-times "sign_extend:DI.*reg:HI" 1 "expand" } } */
+void bitint9_sign_extend (_BitInt(9) x);
+void bitint9_sign_extend_call (_BitInt(9) x) { bitint9_sign_extend (x + 1); }
+
+/* { dg-final { scan-rtl-dump-times "zero_extend:DI.*reg:SI" 1 "expand" } } */
+void bitint17_zero_extend (unsigned _BitInt(17) x);
+void bitint17_zero_extend_call (unsigned _BitInt(17) x) { bitint17_zero_extend (x + 1); }
+
+/* { dg-final { scan-rtl-dump-times "sign_extend:DI.*reg:SI" 1 "expand" } } */
+void bitint17_sign_extend (_BitInt(17) x);
+void bitint17_sign_extend_call (_BitInt(17) x) { bitint17_sign_extend (x + 1); }
diff --git a/gcc/testsuite/gcc.target/s390/bitint-4.c b/gcc/testsuite/gcc.target/s390/bitint-4.c
new file mode 100644
index 0000000..dce72d8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/bitint-4.c
@@ -0,0 +1,71 @@
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-march=z9-109 -O2" } */
+/* { dg-final { check-function-bodies "**" "" "" } } */
+
+/* Verify calling convention. */
+
+struct s_bitint5 {
+ short a;
+ unsigned _BitInt(5) b;
+ char c;
+};
+
+static_assert (sizeof (struct s_bitint5) == 4);
+
+/*
+** s_bitint5_call:
+** iilf %r2,2758168
+** jg s_bitint5@PLT
+*/
+
+void s_bitint5 (struct s_bitint5 x);
+void s_bitint5_call (void) { s_bitint5 ((struct s_bitint5){42, 22wbu, 24}); }
+
+struct s_bitint9 {
+ short a;
+ unsigned _BitInt(9) b;
+};
+
+static_assert (sizeof (struct s_bitint9) == 4);
+
+/*
+** s_bitint9_call:
+** iilf %r2,2752934
+** jg s_bitint9@PLT
+*/
+
+void s_bitint9 (struct s_bitint9 x);
+void s_bitint9_call (void) { s_bitint9 ((struct s_bitint9){42, 422wbu}); }
+
+struct s_bitint17 {
+ int a;
+ unsigned _BitInt(17) b;
+};
+
+static_assert (sizeof (struct s_bitint17) == 8);
+
+/*
+** s_bitint17_call:
+** llihl %r2,42
+** oilf %r2,108198
+** jg s_bitint17@PLT
+*/
+
+void s_bitint17 (struct s_bitint17 x);
+void s_bitint17_call (void) { s_bitint17 ((struct s_bitint17){42, 108198wbu}); }
+
+struct s_bitint33 {
+ unsigned _BitInt(33) b;
+};
+
+static_assert (sizeof (struct s_bitint33) == 8);
+
+/*
+** s_bitint33_call:
+** llihl %r2,1
+** oilf %r2,2795939494
+** jg s_bitint33@PLT
+*/
+
+void s_bitint33 (struct s_bitint33 x);
+void s_bitint33_call (void) { s_bitint33 ((struct s_bitint33){7090906790wbu}); }
diff --git a/gcc/testsuite/gfortran.dg/generic_stmt_1.f90 b/gcc/testsuite/gfortran.dg/generic_stmt_1.f90
new file mode 100644
index 0000000..57d0aba
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/generic_stmt_1.f90
@@ -0,0 +1,194 @@
+! { dg-do run }
+!
+! Test the F2018 generic statement
+!
+function cg (arg1, arg2)
+ complex :: cg
+ complex, intent(in) :: arg1, arg2
+ cg = arg1 + arg2
+end
+
+module m
+ implicit none
+
+ type :: t
+ integer :: i
+ end type
+ integer :: tsum = 0
+
+ public g
+ interface g ! Check generic statement + generic interface works
+ module procedure tg
+ end interface g
+
+ generic :: g => ig, rg
+ generic :: operator(.plus.) => ig, rg
+ generic, private :: h => ig, rg
+ generic :: WRITE(FORMATTED) => wtarray
+
+ interface g ! Check generic statement + generic interface works
+ function cg (arg1, arg2)
+ complex :: cg
+ complex, intent(in) :: arg1, arg2
+ end
+ end interface g
+
+! Subroutines
+ generic, public :: sg => sig, srg
+
+! Check that we can mix with submodule procedures
+ interface
+ real module function realg (arg1, arg2)
+ real, intent(in) :: arg1, arg2
+ end function
+ end interface
+ generic, public :: subg => ig, realg
+
+contains
+
+ function rg (arg1, arg2)
+ real :: rg
+ real, intent(in) :: arg1, arg2
+ rg = arg1 + arg2
+ end
+ function ig (arg1, arg2)
+ integer :: ig
+ integer, intent(in) :: arg1, arg2
+ ig = arg1 + arg2
+ end
+ function tg (arg1, arg2) result(res)
+ type(t) :: res
+ type(t), intent(in) :: arg1, arg2
+ res%i = arg1%i + arg2%i
+ end
+ subroutine srg (arg1, arg2, arg3)
+ real :: arg3
+ real, intent(in) :: arg1, arg2
+ arg3 = arg1 + arg2
+ end
+ subroutine sig (arg1, arg2, arg3)
+ integer :: arg3
+ integer, intent(in) :: arg1, arg2
+ arg3 = arg1 + arg2
+ end
+
+ SUBROUTINE wtarray (dtv, unit, iotype, v_list, iostat, iomsg)
+ CLASS(t), INTENT(IN) :: dtv
+ INTEGER, INTENT(IN) :: unit
+ CHARACTER(*), INTENT(IN) :: iotype
+ INTEGER, INTENT(IN) :: v_list (:)
+ INTEGER, INTENT(OUT) :: iostat
+ CHARACTER(*), INTENT(INOUT) :: iomsg
+ WRITE (unit, FMT=*, iostat=iostat, iomsg=iomsg) dtv%i
+ END SUBROUTINE wtarray
+
+ subroutine foo
+ real :: a = 1.0, b = 2.0, r
+ integer :: c = 3, d = 4
+ type(t) :: tres
+ generic :: operator(+) => tg
+! private in foo
+ r = h(a,b)
+ if (r /= rg(a,b)) stop 1
+ if (h(c,d) /= ig(c,d)) stop 2
+! operator in foo
+ r = a.plus.b
+ if (r /= rg(a,b)) stop 3
+ if ((c.plus.(2*d)) /= ig(c,2*d)) stop 4
+! check intrinsic operator
+ tres = t(21) + t(21)
+ if (tres%i /= 42) stop 5
+ end
+end module m
+
+submodule (m) subm
+contains
+ real module function realg (arg1, arg2)
+ real, intent(in) :: arg1, arg2
+ realg = arg1 + arg2
+ end
+end
+
+program p
+ use m
+ implicit none
+ integer :: i, rv
+
+ generic :: operator(.minus.) => pig, prg
+ generic :: operator(*) => times
+ generic :: j => ig, rg
+ generic :: j => mg
+
+ real :: a = 1.0, b = 2.0, s3
+ integer :: c = 3, d = 4, si
+ type(t) :: t1 = t(2), t2 = t(3), tres
+ type(t) :: tarray(5) = [t(5), t(4), t(3), t(2), t(1)]
+
+! module generic in p
+ if (g(2.0*a,2.0*b) /= rg(2.0*a,2.0*b)) stop 6
+ if (g(c,d) /= ig(c,d)) stop 7
+! local generic in p
+ if (j(a,b) /= rg(a,b)) stop 8
+ if (j(c,d) /= ig (c,d)) stop 9
+! local generic in p with different number of arguments
+ if (j(c,d,-1) /= mg(c,d,-1)) stop 10
+! module operator in p
+ if (7*int(a.plus.b) /= 3*(c.plus.d)) stop 11
+! local operator in p
+ if ((a.minus.b) /= prg(a,b)) stop 12
+ if ((c.minus.d) /= pig(c,d)) stop 13
+! local operator in block
+ block
+ generic :: operator(.bminus.) => pig, prg
+ if ((a.bminus.b) /= prg(a,b)) stop 14
+ if ((c.bminus.d) /= pig(c,d)) stop 15
+ end block
+! intrinsic operator in p
+ tres = t1 * t2
+ if (tres%i /= 6) stop 16
+! test private interface in module
+ call foo
+! test mixture of GENERIC statement and generic INTERFACE
+ if (g((1.0,1.0),(2.0,2.0)) /= cg((1.0,1.0),(2.0,2.0))) stop 17
+ tres = g(t1,t2)
+ if (tres%i /= 5) stop 18
+! subroutines
+ call sg(10.0*a, b, s3)
+ if (int(s3) /= 12) stop 19
+ call sg(5*c, d, si)
+ if (si /= 19) stop 20
+! submodule procedures
+ if (subg(20.0*a,2.0*b) /= realg(20.0*a,2.0*b)) stop 21
+! check DTIO
+ open (10,status='scratch')
+ WRITE(10, '(DT)') tarray
+ rewind(10)
+ do i = 1,5
+ read(10, *) rv
+ tsum = tsum + rv
+ end do
+ close(10)
+ if (tsum /= 15) stop 22
+contains
+
+ function pig (arg1, arg2)
+ integer :: pig
+ integer, intent(in) :: arg1, arg2
+ pig = arg1 - arg2
+ end
+ function prg (arg1, arg2)
+ real :: prg
+ real, intent(in) :: arg1, arg2
+ prg = arg1 - arg2
+ end
+ function times (arg1, arg2) result(res)
+ type(t) :: res
+ type(t), intent(in) :: arg1, arg2
+ res%i = arg1%i * arg2%i
+ end
+ function mg (arg1, arg2, arg3)
+ integer :: mg
+ integer, intent(in) :: arg1, arg2, arg3
+ mg = arg1 - arg2 * arg3
+ end
+end
diff --git a/gcc/testsuite/gfortran.dg/generic_stmt_2.f90 b/gcc/testsuite/gfortran.dg/generic_stmt_2.f90
new file mode 100644
index 0000000..f698012
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/generic_stmt_2.f90
@@ -0,0 +1,87 @@
+! { dg-do compile }
+!
+! Test the F2018 generic statement error reporting using the module from
+! generic_stmt_1.f90
+!
+function cg (arg1, arg2)
+ complex :: cg
+ complex, intent(in) :: arg1, arg2
+ cg = arg1 + arg2
+end
+
+module m1
+ implicit none
+
+ type :: t
+ integer :: i
+ end type
+
+ public g
+ interface g ! Check generic statement + generic interface works
+ module procedure tg
+ end interface g
+
+ generic, public :: g => ig ! { dg-error "repeats that already given" }
+ generic, private :: g => rg ! { dg-error "conflicts with that already" }
+ generic :: operator(.plus.) => ig, rg, gg ! { dg-error "did you mean|must be a FUNCTION" }
+ generic, private :: h => ig, rg
+ generic :: => ig, rg ! { dg-error "Malformed GENERIC statement" }
+ generic :: wron ng => ig, rg ! { dg-error "Expected .=>." }
+ generic :: #!& => ig, rg ! { dg-error "Malformed GENERIC statement" }
+ generic, private :: operator(.plusplus.) => ig
+ generic, private :: operator(.plusplus.) => rg ! { dg-error "repeats the access specification" }
+ generic, PUBLIC :: operator(.plusplus.) => tg ! { dg-error "must have the same access" }
+
+ interface g ! Check generic statement + generic interface works
+ function cg (arg1, arg2)
+ complex :: cg
+ complex, intent(in) :: arg1, arg2
+ end
+ end interface g
+
+ generic, public :: sg => sig, srg
+ generic, public :: sg2 => sig, srg, rg ! Error appears at 'srg' declaration
+
+
+contains
+
+ function rg (arg1, arg2)
+ real :: rg
+ real, intent(in) :: arg1, arg2
+ rg = arg1 + arg2
+ end
+ function ig (arg1, arg2)
+ integer :: ig
+ integer, intent(in) :: arg1, arg2
+ ig = arg1 + arg2
+ end
+ function tg (arg1, arg2) result(res)
+ type(t) :: res
+ type(t), intent(in) :: arg1, arg2
+ res%i = arg1%i + arg2%i
+ end
+ subroutine srg (arg1, arg2, arg3) ! { dg-error "procedures must be either all SUBROUTINEs" }
+ real :: arg3
+ real, intent(in) :: arg1, arg2
+ arg3 = arg1 + arg2
+ end
+ subroutine sig (arg1, arg2, arg3)
+ integer :: arg3
+ integer, intent(in) :: arg1, arg2
+ arg3 = arg1 + arg2
+ end
+ subroutine foo
+ real :: a = 1.0, b = 2.0, r
+ integer :: c = 3, d = 4
+ generic, public :: sg => sig, srg ! { dg-error "not in a module" }
+ generic :: operator(+) => rg ! { dg-error "conflicts with intrinsic interface" }
+ r = h(a,d) ! { dg-error "There is no specific function" }
+ if (r /= rg(a,b)) stop 1
+ if (h(c,d) /= ig(c,d)) stop 2
+ generic :: wrong => ig, rg ! { dg-error "Unexpected GENERIC statement" }
+! operator in foo
+ r = c.plus.b ! { dg-error "Unknown operator" }
+ if (r /= rg(a,b)) stop 3
+ if ((c.plus.(2*d)) /= ig(c,2*d)) stop 4
+ end
+end module m1
diff --git a/gcc/testsuite/gfortran.dg/generic_stmt_3.f90 b/gcc/testsuite/gfortran.dg/generic_stmt_3.f90
new file mode 100644
index 0000000..543c63f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/generic_stmt_3.f90
@@ -0,0 +1,96 @@
+! { dg-do compile }
+!
+! Test the F2018 generic statement error reporting of access and name conflicts.
+!
+! Contributed by Steven Kargl <kargls@comcast.net>
+!
+ module foo1
+
+ implicit none
+ private
+
+ public bah
+ generic :: bah => bah, bak ! { dg-error "conflicts with that" }
+
+ public bar
+ generic :: bar => bah, bak ! OK - checked that 'bar' is not a procedure
+
+ contains
+ integer function bah(i)
+ integer, intent(in) :: i
+ bah = i
+ end function bah
+ real function bak(x)
+ real, intent(in) :: x
+ bak = 42.5
+ end function bak
+ end module foo1
+
+ module foo2
+
+ implicit none
+ private
+
+ generic :: bah => bah, bak ! { dg-error "conflicts with that" }
+ public bah
+
+ generic :: bar => bah, bak ! OK - checked that 'bar' is not a procedure
+ public bar
+
+ contains
+ integer function bah(i)
+ integer, intent(in) :: i
+ bah = i
+ end function bah
+ real function bak(x)
+ real, intent(in) :: x
+ bak = 42.5
+ end function bak
+ end module foo2
+
+ module foo3 ! { dg-error "clashes with the name of an entity" }
+
+ implicit none
+ private
+
+ integer :: bar = 10 ! { dg-error "has a type" }
+ generic :: bar => bah, bak ! { dg-error "has a type" }
+
+ generic :: foo3 => bah, bak ! { dg-error "clashes with the name of an entity" }
+
+ contains
+ integer function bah(i)
+ integer, intent(in) :: i
+ bah = i
+ end function bah
+ real function bak(x)
+ real, intent(in) :: x
+ bak = 42.5
+ end function bak
+ end module foo3
+
+ module foo4
+ implicit none
+ private
+ public bak
+
+ generic :: bak => bar, bah
+
+ contains
+ function bar(i)
+ real bar
+ integer, intent(in) :: i
+ bar = i
+ end function bar
+ function bah(x)
+ real bah
+ real, intent(in) :: x
+ bah = x
+ end function bah
+ end module foo4
+
+ program snooze
+ use foo4
+ print *, bak(42) ! Public statement for 'bak' exposes the
+ print *, bak(43.5) ! specific procedures 'bar' and 'bah' here.
+ end program snooze
diff --git a/gcc/testsuite/gfortran.dg/generic_stmt_4.f90 b/gcc/testsuite/gfortran.dg/generic_stmt_4.f90
new file mode 100644
index 0000000..24e814a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/generic_stmt_4.f90
@@ -0,0 +1,43 @@
+! { dg-do run }
+!
+! Test the correct processing of public generic statements and verify that they
+! behave in the same way as public interfaces.
+!
+! Contributed by Steven Kargl <kargls@comcast.net>
+!
+module foo
+
+ implicit none
+
+ private
+ public bak1, bak2
+
+
+ generic :: bak1 => bar, bah
+
+ ! Should be equivalent to above.
+
+ interface bak2
+ module procedure bar
+ module procedure bah
+ end interface bak2
+
+
+ contains
+ function bar(i)
+ real bar
+ integer, intent(in) :: i
+ bar = i
+ end function bar
+ function bah(x)
+ real bah
+ real, intent(in) :: x
+ bah = x
+ end function bah
+end module foo
+
+program snooze
+ use foo
+ if (bak1(42) /= bak2(42)) stop 1
+ if (bak1(43.5) /= bak2(43.5)) stop 2
+end program snooze
diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp
index 08fd969..6865047 100644
--- a/gcc/testsuite/lib/multiline.exp
+++ b/gcc/testsuite/lib/multiline.exp
@@ -153,6 +153,9 @@ proc handle-multiline-outputs { text } {
# If dg-enable-nn-line-numbers was provided, then obscure source-margin
# line numbers by converting them to "NN" form.
set text [maybe-handle-nn-line-numbers $text]
+
+ # Remove Windows .exe suffix
+ regsub -all "(as|cc1|cc1plus|collect2|f951|ld|lto-wrapper)\.exe?:" $text {\1:} text
set index 0
foreach entry $multiline_expected_outputs {
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index d349d83..d264674 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -1094,6 +1094,12 @@ general_init (const char *argv0, bool init_signals, unique_argv original_argv)
= global_options_init.x_flag_show_column;
global_dc->set_show_highlight_colors
(global_options_init.x_flag_diagnostics_show_highlight_colors);
+ global_dc->set_show_nesting
+ (global_options_init.x_flag_diagnostics_show_nesting);
+ global_dc->set_show_nesting_locations
+ (global_options_init.x_flag_diagnostics_show_nesting_locations);
+ global_dc->set_show_nesting_levels
+ (global_options_init.x_flag_diagnostics_show_nesting_levels);
global_dc->set_internal_error_callback (internal_error_function);
const unsigned lang_mask = lang_hooks.option_lang_mask ();
global_dc->set_option_id_manager
diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc
index 3761fc0..20183c8 100644
--- a/gcc/tree-diagnostic.cc
+++ b/gcc/tree-diagnostic.cc
@@ -110,7 +110,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
to the DIAGNOSTIC location. */
static void
-set_inlining_locations (diagnostics::context *,
+set_inlining_locations (const diagnostics::context &,
diagnostics::diagnostic_info *diagnostic)
{
location_t loc = diagnostic_location (diagnostic);
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 43b1c9d..3d38d88 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1190,117 +1190,55 @@ constant_pointer_difference (tree p1, tree p2)
return NULL_TREE;
}
-
-/* Optimize
- a = {};
- b = a;
- into
- a = {};
- b = {};
- Similarly for memset (&a, ..., sizeof (a)); instead of a = {};
- and/or memcpy (&b, &a, sizeof (a)); instead of b = a; */
-
+/* Helper function for optimize_aggr_zeroprop.
+ Props the zeroing (memset, VAL) that was done in DEST+OFFSET:LEN
+ (DEFSTMT) into the STMT. Returns true if the STMT was updated. */
static bool
-optimize_memcpy_to_memset (gimple_stmt_iterator *gsip, tree dest, tree src, tree len)
+optimize_aggr_zeroprop_1 (gimple *defstmt, gimple *stmt,
+ tree dest, poly_int64 offset, tree val,
+ poly_offset_int len)
{
- ao_ref read;
- gimple *stmt = gsi_stmt (*gsip);
- if (gimple_has_volatile_ops (stmt))
- return false;
-
- tree src2 = NULL_TREE, len2 = NULL_TREE;
- poly_int64 offset, offset2;
- tree val = integer_zero_node;
- bool len_was_null = len == NULL_TREE;
- if (len == NULL_TREE)
- len = (TREE_CODE (src) == COMPONENT_REF
- ? DECL_SIZE_UNIT (TREE_OPERAND (src, 1))
- : TYPE_SIZE_UNIT (TREE_TYPE (src)));
- if (len == NULL_TREE
- || !poly_int_tree_p (len))
- return false;
+ tree src2;
+ tree len2 = NULL_TREE;
+ poly_int64 offset2;
- ao_ref_init (&read, src);
- tree vuse = gimple_vuse (stmt);
- gimple *defstmt;
- unsigned limit = param_sccvn_max_alias_queries_per_access;
- do {
- /* If the vuse is the default definition, then there is no stores beforhand. */
- if (SSA_NAME_IS_DEFAULT_DEF (vuse))
- return false;
- defstmt = SSA_NAME_DEF_STMT (vuse);
- if (is_a <gphi*>(defstmt))
- return false;
- if (limit-- == 0)
- return false;
- /* If the len was null, then we can use TBBA. */
- if (stmt_may_clobber_ref_p_1 (defstmt, &read,
- /* tbaa_p = */ len_was_null))
- break;
- vuse = gimple_vuse (defstmt);
- } while (true);
-
- if (gimple_store_p (defstmt)
- && gimple_assign_single_p (defstmt)
- && TREE_CODE (gimple_assign_rhs1 (defstmt)) == STRING_CST
- && !gimple_clobber_p (defstmt))
+ if (gimple_call_builtin_p (stmt, BUILT_IN_MEMCPY)
+ && TREE_CODE (gimple_call_arg (stmt, 1)) == ADDR_EXPR
+ && poly_int_tree_p (gimple_call_arg (stmt, 2)))
{
- tree str = gimple_assign_rhs1 (defstmt);
- src2 = gimple_assign_lhs (defstmt);
- /* The string must contain all null char's for now. */
- for (int i = 0; i < TREE_STRING_LENGTH (str); i++)
- {
- if (TREE_STRING_POINTER (str)[i] != 0)
- {
- src2 = NULL_TREE;
- break;
- }
- }
- }
- else if (gimple_store_p (defstmt)
- && gimple_assign_single_p (defstmt)
- && TREE_CODE (gimple_assign_rhs1 (defstmt)) == CONSTRUCTOR
- && !gimple_clobber_p (defstmt))
- src2 = gimple_assign_lhs (defstmt);
- else if (gimple_call_builtin_p (defstmt, BUILT_IN_MEMSET)
- && TREE_CODE (gimple_call_arg (defstmt, 0)) == ADDR_EXPR
- && TREE_CODE (gimple_call_arg (defstmt, 1)) == INTEGER_CST)
- {
- src2 = TREE_OPERAND (gimple_call_arg (defstmt, 0), 0);
- len2 = gimple_call_arg (defstmt, 2);
- val = gimple_call_arg (defstmt, 1);
- /* For non-0 val, we'd have to transform stmt from assignment
- into memset (only if dest is addressable). */
- if (!integer_zerop (val) && is_gimple_assign (stmt))
- src2 = NULL_TREE;
+ src2 = TREE_OPERAND (gimple_call_arg (stmt, 1), 0);
+ len2 = gimple_call_arg (stmt, 2);
}
+ else if (gimple_assign_load_p (stmt) && gimple_store_p (stmt))
+ {
+ src2 = gimple_assign_rhs1 (stmt);
+ len2 = (TREE_CODE (src2) == COMPONENT_REF
+ ? DECL_SIZE_UNIT (TREE_OPERAND (src2, 1))
+ : TYPE_SIZE_UNIT (TREE_TYPE (src2)));
+ /* Can only handle zero memsets. */
+ if (!integer_zerop (val))
+ return false;
+ }
+ else
+ return false;
- if (src2 == NULL_TREE)
- return false;
-
- if (len2 == NULL_TREE)
- len2 = (TREE_CODE (src2) == COMPONENT_REF
- ? DECL_SIZE_UNIT (TREE_OPERAND (src2, 1))
- : TYPE_SIZE_UNIT (TREE_TYPE (src2)));
if (len2 == NULL_TREE
|| !poly_int_tree_p (len2))
return false;
- src = get_addr_base_and_unit_offset (src, &offset);
src2 = get_addr_base_and_unit_offset (src2, &offset2);
- if (src == NULL_TREE
- || src2 == NULL_TREE
- || maybe_lt (offset, offset2))
+ if (src2 == NULL_TREE
+ || maybe_lt (offset2, offset))
return false;
- if (!operand_equal_p (src, src2, 0))
+ if (!operand_equal_p (dest, src2, 0))
return false;
- /* [ src + offset2, src + offset2 + len2 - 1 ] is set to val.
+ /* [ dest + offset, dest + offset + len - 1 ] is set to val.
Make sure that
- [ src + offset, src + offset + len - 1 ] is a subset of that. */
- if (maybe_gt (wi::to_poly_offset (len) + (offset - offset2),
- wi::to_poly_offset (len2)))
+ [ dest + offset2, dest + offset2 + len2 - 1 ] is a subset of that. */
+ if (maybe_gt (wi::to_poly_offset (len2) + (offset2 - offset),
+ len))
return false;
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1310,7 +1248,7 @@ optimize_memcpy_to_memset (gimple_stmt_iterator *gsip, tree dest, tree src, tree
fprintf (dump_file, "after previous\n ");
print_gimple_stmt (dump_file, defstmt, 0, dump_flags);
}
-
+ gimple *orig_stmt = stmt;
/* For simplicity, don't change the kind of the stmt,
turn dest = src; into dest = {}; and memcpy (&dest, &src, len);
into memset (&dest, val, len);
@@ -1320,8 +1258,10 @@ optimize_memcpy_to_memset (gimple_stmt_iterator *gsip, tree dest, tree src, tree
of dest, dest isn't volatile. */
if (is_gimple_assign (stmt))
{
- tree ctor = build_constructor (TREE_TYPE (dest), NULL);
- gimple_assign_set_rhs_from_tree (gsip, ctor);
+ tree ctor_type = TREE_TYPE (gimple_assign_lhs (stmt));
+ tree ctor = build_constructor (ctor_type, NULL);
+ gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
+ gimple_assign_set_rhs_from_tree (&gsi, ctor);
update_stmt (stmt);
statistics_counter_event (cfun, "copy zeroing propagation of aggregate", 1);
}
@@ -1341,89 +1281,210 @@ optimize_memcpy_to_memset (gimple_stmt_iterator *gsip, tree dest, tree src, tree
fprintf (dump_file, "into\n ");
print_gimple_stmt (dump_file, stmt, 0, dump_flags);
}
+
+ /* Mark the bb for eh cleanup if needed. */
+ if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt))
+ bitmap_set_bit (to_purge, gimple_bb (stmt)->index);
+
return true;
}
-/* Optimizes
- a = c;
+
+/* Optimize
+ a = {}; // DEST = value ;; LEN(nullptr)
b = a;
into
- a = c;
- b = c;
- GSIP is the second statement and SRC is the common
- between the statements.
-*/
+ a = {};
+ b = {};
+ Similarly for memset (&a, ..., sizeof (a)); instead of a = {};
+ and/or memcpy (&b, &a, sizeof (a)); instead of b = a; */
+
static bool
-optimize_agr_copyprop (gimple_stmt_iterator *gsip)
+optimize_aggr_zeroprop (gimple_stmt_iterator *gsip)
{
+ ao_ref read;
gimple *stmt = gsi_stmt (*gsip);
if (gimple_has_volatile_ops (stmt))
return false;
- tree dest = gimple_assign_lhs (stmt);
- tree src = gimple_assign_rhs1 (stmt);
- /* If the statement is `src = src;` then ignore it. */
- if (operand_equal_p (dest, src, 0))
- return false;
+ tree dest = NULL_TREE;
+ tree val = integer_zero_node;
+ tree len = NULL_TREE;
+ bool can_use_tbba = true;
+ bool changed = false;
+
+ if (gimple_call_builtin_p (stmt, BUILT_IN_MEMSET)
+ && TREE_CODE (gimple_call_arg (stmt, 0)) == ADDR_EXPR
+ && TREE_CODE (gimple_call_arg (stmt, 1)) == INTEGER_CST
+ && poly_int_tree_p (gimple_call_arg (stmt, 2)))
+ {
+ dest = TREE_OPERAND (gimple_call_arg (stmt, 0), 0);
+ len = gimple_call_arg (stmt, 2);
+ val = gimple_call_arg (stmt, 1);
+ ao_ref_init_from_ptr_and_size (&read, gimple_call_arg (stmt, 0), len);
+ can_use_tbba = false;
+ }
+ else if (gimple_store_p (stmt)
+ && gimple_assign_single_p (stmt)
+ && TREE_CODE (gimple_assign_rhs1 (stmt)) == STRING_CST)
+ {
+ tree str = gimple_assign_rhs1 (stmt);
+ dest = gimple_assign_lhs (stmt);
+ ao_ref_init (&read, dest);
+ /* The string must contain all null char's for now. */
+ for (int i = 0; i < TREE_STRING_LENGTH (str); i++)
+ {
+ if (TREE_STRING_POINTER (str)[i] != 0)
+ {
+ dest = NULL_TREE;
+ break;
+ }
+ }
+ }
+ else if (gimple_store_p (stmt)
+ && gimple_assign_single_p (stmt)
+ && TREE_CODE (gimple_assign_rhs1 (stmt)) == CONSTRUCTOR
+ && !gimple_clobber_p (stmt))
+ {
+ dest = gimple_assign_lhs (stmt);
+ ao_ref_init (&read, dest);
+ }
- tree vuse = gimple_vuse (stmt);
- /* If the vuse is the default definition, then there is no store beforehand. */
- if (SSA_NAME_IS_DEFAULT_DEF (vuse))
+ if (dest == NULL_TREE)
return false;
- gimple *defstmt = SSA_NAME_DEF_STMT (vuse);
- if (!gimple_assign_load_p (defstmt)
- || !gimple_store_p (defstmt))
+
+ if (len == NULL_TREE)
+ len = (TREE_CODE (dest) == COMPONENT_REF
+ ? DECL_SIZE_UNIT (TREE_OPERAND (dest, 1))
+ : TYPE_SIZE_UNIT (TREE_TYPE (dest)));
+ if (len == NULL_TREE
+ || !poly_int_tree_p (len))
return false;
- if (gimple_has_volatile_ops (defstmt))
+
+ /* This store needs to be on the byte boundary and pointing to an object. */
+ poly_int64 offset;
+ tree dest_base = get_addr_base_and_unit_offset (dest, &offset);
+ if (dest_base == NULL_TREE)
return false;
- tree dest2 = gimple_assign_lhs (defstmt);
- tree src2 = gimple_assign_rhs1 (defstmt);
+ /* Setup the worklist. */
+ auto_vec<std::pair<tree, unsigned>> worklist;
+ unsigned limit = param_sccvn_max_alias_queries_per_access;
+ worklist.safe_push (std::make_pair (gimple_vdef (stmt), limit));
- /* If the original store is `src2 = src2;` skip over it. */
- if (operand_equal_p (src2, dest2, 0))
- return false;
- if (!operand_equal_p (src, dest2, 0))
+ while (!worklist.is_empty ())
+ {
+ std::pair<tree, unsigned> top = worklist.pop ();
+ tree vdef = top.first;
+ limit = top.second;
+ gimple *use_stmt;
+ imm_use_iterator iter;
+ FOR_EACH_IMM_USE_STMT (use_stmt, iter, vdef)
+ {
+ /* Handling PHI nodes might not be worth it so don't. */
+ if (is_a <gphi*> (use_stmt))
+ continue;
+
+ /* If this statement does not clobber add the vdef stmt to the
+ worklist. */
+ if (gimple_vdef (use_stmt)
+ && !stmt_may_clobber_ref_p_1 (use_stmt, &read,
+ /* tbaa_p = */ can_use_tbba)
+ && limit != 0)
+ worklist.safe_push (std::make_pair (gimple_vdef (use_stmt),
+ limit - 1));
+
+ if (optimize_aggr_zeroprop_1 (stmt, use_stmt, dest_base, offset,
+ val, wi::to_poly_offset (len)))
+ changed = true;
+ }
+ }
+
+ return changed;
+}
+/* Optimizes
+ DEST = SRC;
+ DEST2 = DEST; # DEST2 = SRC2;
+ into
+ DEST = SRC;
+ DEST2 = SRC;
+ GSIP is the first statement and SRC is the common
+ between the statements.
+*/
+static bool
+optimize_agr_copyprop (gimple_stmt_iterator *gsip)
+{
+ gimple *stmt = gsi_stmt (*gsip);
+ if (gimple_has_volatile_ops (stmt))
return false;
+ /* Can't prop if the statement could throw. */
+ if (stmt_could_throw_p (cfun, stmt))
+ return false;
- /* For 2 memory refences and using a temporary to do the copy,
- don't remove the temporary as the 2 memory references might overlap.
- Note t does not need to be decl as it could be field.
- See PR 22237 for full details.
- E.g.
- t = *a;
- *b = t;
- Cannot be convert into
- t = *a;
- *b = *a;
- Though the following is allowed to be done:
- t = *a;
- *a = t;
- And convert it into:
- t = *a;
- *a = *a;
- */
- if (!operand_equal_p (src2, dest, 0)
- && !DECL_P (dest) && !DECL_P (src2))
+ tree dest = gimple_assign_lhs (stmt);
+ tree src = gimple_assign_rhs1 (stmt);
+ /* If the statement is `src = src;` then ignore it. */
+ if (operand_equal_p (dest, src, 0))
return false;
- if (dump_file && (dump_flags & TDF_DETAILS))
+ tree vdef = gimple_vdef (stmt);
+ imm_use_iterator iter;
+ gimple *use_stmt;
+ bool changed = false;
+ FOR_EACH_IMM_USE_STMT (use_stmt, iter, vdef)
{
- fprintf (dump_file, "Simplified\n ");
- print_gimple_stmt (dump_file, stmt, 0, dump_flags);
- fprintf (dump_file, "after previous\n ");
- print_gimple_stmt (dump_file, defstmt, 0, dump_flags);
- }
- gimple_assign_set_rhs_from_tree (gsip, unshare_expr (src2));
- update_stmt (stmt);
+ if (!gimple_assign_load_p (use_stmt)
+ || !gimple_store_p (use_stmt))
+ continue;
+ if (gimple_has_volatile_ops (use_stmt))
+ continue;
+ tree dest2 = gimple_assign_lhs (use_stmt);
+ tree src2 = gimple_assign_rhs1 (use_stmt);
+ /* If the new store is `src2 = src2;` skip over it. */
+ if (operand_equal_p (src2, dest2, 0))
+ continue;
+ if (!operand_equal_p (dest, src2, 0))
+ continue;
+ /* For 2 memory refences and using a temporary to do the copy,
+ don't remove the temporary as the 2 memory references might overlap.
+ Note t does not need to be decl as it could be field.
+ See PR 22237 for full details.
+ E.g.
+ t = *a; #DEST = SRC;
+ *b = t; #DEST2 = SRC2;
+ Cannot be convert into
+ t = *a;
+ *b = *a;
+ Though the following is allowed to be done:
+ t = *a;
+ *a = t;
+ And convert it into:
+ t = *a;
+ *a = *a;
+ */
+ if (!operand_equal_p (dest2, src, 0)
+ && !DECL_P (dest2) && !DECL_P (src))
+ continue;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Simplified\n ");
+ print_gimple_stmt (dump_file, use_stmt, 0, dump_flags);
+ fprintf (dump_file, "after previous\n ");
+ print_gimple_stmt (dump_file, stmt, 0, dump_flags);
+ }
+ gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
+ gimple_assign_set_rhs_from_tree (&gsi, unshare_expr (src));
+ update_stmt (use_stmt);
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "into\n ");
- print_gimple_stmt (dump_file, stmt, 0, dump_flags);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "into\n ");
+ print_gimple_stmt (dump_file, use_stmt, 0, dump_flags);
+ }
+ statistics_counter_event (cfun, "copy prop for aggregate", 1);
+ changed = true;
}
- statistics_counter_event (cfun, "copy prop for aggregate", 1);
- return true;
+ return changed;
}
/* *GSI_P is a GIMPLE_CALL to a builtin function.
@@ -1463,22 +1524,6 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
switch (DECL_FUNCTION_CODE (callee2))
{
- case BUILT_IN_MEMCPY:
- if (gimple_call_num_args (stmt2) == 3)
- {
- tree dest = gimple_call_arg (stmt2, 0);
- tree src = gimple_call_arg (stmt2, 1);
- tree len = gimple_call_arg (stmt2, 2);
- /* Try to optimize the memcpy to memset if src
- and dest are addresses. */
- if (TREE_CODE (dest) == ADDR_EXPR
- && TREE_CODE (src) == ADDR_EXPR
- && TREE_CODE (len) == INTEGER_CST
- && optimize_memcpy_to_memset (gsi_p, TREE_OPERAND (dest, 0),
- TREE_OPERAND (src, 0), len))
- return true;
- }
- break;
case BUILT_IN_MEMCHR:
if (gimple_call_num_args (stmt2) == 3
&& (res = gimple_call_lhs (stmt2)) != nullptr
@@ -1540,6 +1585,13 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
break;
case BUILT_IN_MEMSET:
+ if (gimple_call_num_args (stmt2) == 3)
+ {
+ /* Try to prop the zeroing/value of the memset to memcpy
+ if the dest is an address and the value is a constant. */
+ if (optimize_aggr_zeroprop (gsi_p))
+ return true;
+ }
if (gimple_call_num_args (stmt2) != 3
|| gimple_call_lhs (stmt2)
|| CHAR_BIT != 8
@@ -4858,21 +4910,16 @@ pass_forwprop::execute (function *fun)
{
tree rhs1 = gimple_assign_rhs1 (stmt);
enum tree_code code = gimple_assign_rhs_code (stmt);
- if (gimple_assign_load_p (stmt) && gimple_store_p (stmt))
+ if (gimple_store_p (stmt) && optimize_aggr_zeroprop (&gsi))
{
- if (optimize_memcpy_to_memset (&gsi,
- gimple_assign_lhs (stmt),
- gimple_assign_rhs1 (stmt),
- /* len = */NULL_TREE))
- {
- changed = true;
- break;
- }
- if (optimize_agr_copyprop (&gsi))
- {
- changed = true;
- break;
- }
+ changed = true;
+ break;
+ }
+ if (gimple_assign_load_p (stmt) && gimple_store_p (stmt)
+ && optimize_agr_copyprop (&gsi))
+ {
+ changed = true;
+ break;
}
if (TREE_CODE_CLASS (code) == tcc_comparison)
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 00315d1..ccd8080 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -5633,6 +5633,37 @@ visit_nary_op (tree lhs, gassign *stmt)
}
}
break;
+ case BIT_FIELD_REF:
+ if (TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
+ {
+ tree op0 = TREE_OPERAND (rhs1, 0);
+ gassign *ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (op0));
+ if (ass
+ && !gimple_has_volatile_ops (ass)
+ && vn_get_stmt_kind (ass) == VN_REFERENCE)
+ {
+ tree last_vuse = gimple_vuse (ass);
+ tree op = gimple_assign_rhs1 (ass);
+ /* Avoid building invalid and unexpected refs. */
+ if (TREE_CODE (op) != TARGET_MEM_REF
+ && TREE_CODE (op) != BIT_FIELD_REF
+ && TREE_CODE (op) != REALPART_EXPR
+ && TREE_CODE (op) != IMAGPART_EXPR)
+ {
+ tree op = build3 (BIT_FIELD_REF, TREE_TYPE (rhs1),
+ gimple_assign_rhs1 (ass),
+ TREE_OPERAND (rhs1, 1),
+ TREE_OPERAND (rhs1, 2));
+ tree result = vn_reference_lookup (op, gimple_vuse (ass),
+ default_vn_walk_kind,
+ NULL, true, &last_vuse);
+ if (result
+ && useless_type_conversion_p (type, TREE_TYPE (result)))
+ return set_ssa_val_to (lhs, result);
+ }
+ }
+ }
+ break;
case TRUNC_DIV_EXPR:
if (TYPE_UNSIGNED (type))
break;
diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index c80145d..d04394f 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -605,6 +605,12 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
&& (stmt = last_nondebug_stmt (bb))
&& gimple_code (stmt) == GIMPLE_COND)
;
+ else if (esucc
+ && cfun->has_musttail
+ && diag_musttail
+ && (stmt = last_nondebug_stmt (bb))
+ && gimple_code (stmt) == GIMPLE_SWITCH)
+ ;
/* If there is an abnormal edge assume it's the only extra one.
Tolerate that case so that we can give better error messages
for musttail later. */
@@ -668,7 +674,7 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
else
goto <bb 6>; [INV]
When walking backwards, ESUCC is the edge we are coming from,
- depending on its EDGE_TRUE_FLAG, == vs. != for the comparison
+ depending on its EDGE_TRUE_FLAG, comparison code
and value compared against try to find out through which edge
we need to go and which edge should be ignored. The code handles
both INTEGER_CST PHI arguments and SSA_NAMEs set to constants
@@ -677,19 +683,16 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
&& diag_musttail
&& esucc
&& gimple_code (stmt) == GIMPLE_COND
- && (gimple_cond_code (stmt) == EQ_EXPR
- || gimple_cond_code (stmt) == NE_EXPR)
&& TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME
&& TREE_CODE (gimple_cond_rhs (stmt)) == INTEGER_CST
&& INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))
- && (integer_zerop (gimple_cond_rhs (stmt))
- || integer_onep (gimple_cond_rhs (stmt))))
+ && tree_int_cst_sgn (gimple_cond_rhs (stmt)) >= 0)
{
tree lhs = gimple_cond_lhs (stmt);
- bool rhsv = integer_onep (gimple_cond_rhs (stmt));
- if (((esucc->flags & EDGE_TRUE_VALUE) != 0)
- ^ (gimple_cond_code (stmt) == EQ_EXPR))
- rhsv = !rhsv;
+ tree_code ccode = gimple_cond_code (stmt);
+ tree rhsv = gimple_cond_rhs (stmt);
+ if ((esucc->flags & EDGE_FALSE_VALUE) != 0)
+ ccode = invert_tree_comparison (ccode, false);
if (!ignored_edges)
{
ignored_edges = new hash_set<edge>;
@@ -700,8 +703,10 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
&& (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhs))
== INTEGER_CST))
{
- tree rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs));
- if (rhsv ? integer_onep (rhs) : integer_zerop (rhs))
+ tree lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs));
+
+ if (const_binop (ccode, boolean_type_node, lhsv, rhsv)
+ == boolean_true_node)
continue;
}
else if (gimple_code (SSA_NAME_DEF_STMT (lhs)) == GIMPLE_PHI)
@@ -712,15 +717,62 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
edge_iterator ei;
FOR_EACH_EDGE (e, ei, pbb->preds)
{
- tree rhs = gimple_phi_arg_def_from_edge (phi, e);
- if (TREE_CODE (rhs) == SSA_NAME
- && is_gimple_assign (SSA_NAME_DEF_STMT (rhs))
- && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (rhs))
+ tree lhsv = gimple_phi_arg_def_from_edge (phi, e);
+ if (TREE_CODE (lhsv) == SSA_NAME
+ && is_gimple_assign (SSA_NAME_DEF_STMT (lhsv))
+ && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhsv))
== INTEGER_CST))
- rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (rhs));
- if (!(rhsv ? integer_onep (rhs) : integer_zerop (rhs)))
+ lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhsv));
+ if (TREE_CODE (lhsv) != INTEGER_CST
+ || const_binop (ccode, boolean_type_node,
+ lhsv, rhsv) != boolean_true_node)
ignored_edges->add (e);
}
+ continue;
+ }
+ }
+ if (cfun->has_musttail
+ && diag_musttail
+ && esucc
+ && gimple_code (stmt) == GIMPLE_SWITCH
+ && (TREE_CODE (gimple_switch_index (as_a <gswitch *> (stmt)))
+ == SSA_NAME))
+ {
+ gswitch *swtch = as_a <gswitch *> (stmt);
+ tree idx = gimple_switch_index (swtch);
+ if (!ignored_edges)
+ {
+ ignored_edges = new hash_set<edge>;
+ must_see_bbs = new hash_set<basic_block>;
+ delete_ignored_edges = true;
+ }
+ if (is_gimple_assign (SSA_NAME_DEF_STMT (idx))
+ && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (idx))
+ == INTEGER_CST))
+ {
+ tree val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (idx));
+ if (find_taken_edge_switch_expr (swtch, val) == esucc)
+ continue;
+ }
+ else if (gimple_code (SSA_NAME_DEF_STMT (idx)) == GIMPLE_PHI)
+ {
+ gimple *phi = SSA_NAME_DEF_STMT (idx);
+ basic_block pbb = gimple_bb (phi);
+ must_see_bbs->add (pbb);
+ edge_iterator ei;
+ FOR_EACH_EDGE (e, ei, pbb->preds)
+ {
+ tree val = gimple_phi_arg_def_from_edge (phi, e);
+ if (TREE_CODE (val) == SSA_NAME
+ && is_gimple_assign (SSA_NAME_DEF_STMT (val))
+ && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (val))
+ == INTEGER_CST))
+ val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (val));
+ if (TREE_CODE (val) != INTEGER_CST
+ || find_taken_edge_switch_expr (swtch, val) != esucc)
+ ignored_edges->add (e);
+ }
+ continue;
}
}
@@ -1138,47 +1190,67 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
if (ignored_edges)
{
if (is_gimple_assign (stmt)
- && gimple_assign_rhs_code (stmt) == INTEGER_CST)
+ && gimple_assign_rhs_code (stmt) == INTEGER_CST
+ && tree_int_cst_sgn (gimple_assign_rhs1 (stmt)) >= 0)
{
use_operand_p use_p;
- gimple *use_stmt;
- if ((integer_zerop (gimple_assign_rhs1 (stmt))
- || integer_onep (gimple_assign_rhs1 (stmt)))
- && single_imm_use (gimple_assign_lhs (stmt), &use_p,
- &use_stmt))
+ imm_use_iterator imm_iter;
+ bool bad_p = false;
+ FOR_EACH_IMM_USE_FAST (use_p, imm_iter,
+ gimple_assign_lhs (stmt))
{
- if (gimple_code (use_stmt) == GIMPLE_COND)
- continue;
- if (gimple_code (use_stmt) == GIMPLE_PHI
- && single_imm_use (gimple_phi_result (use_stmt),
- &use_p, &use_stmt)
- && gimple_code (use_stmt) == GIMPLE_COND)
+ gimple *use_stmt = USE_STMT (use_p);
+ if (is_gimple_debug (use_stmt)
+ || gimple_code (use_stmt) == GIMPLE_COND
+ || gimple_code (use_stmt) == GIMPLE_SWITCH)
continue;
+ if (gimple_code (use_stmt) == GIMPLE_PHI)
+ {
+ use_operand_p use_p2;
+ imm_use_iterator imm_iter2;
+ FOR_EACH_IMM_USE_FAST (use_p2, imm_iter2,
+ gimple_phi_result (use_stmt))
+ {
+ gimple *use_stmt2 = USE_STMT (use_p2);
+ if (is_gimple_debug (use_stmt2)
+ || gimple_code (use_stmt2) == GIMPLE_COND
+ || gimple_code (use_stmt2) == GIMPLE_SWITCH)
+ continue;
+ bad_p = true;
+ break;
+ }
+ if (bad_p)
+ break;
+ }
+ else
+ {
+ bad_p = true;
+ break;
+ }
}
+ if (!bad_p)
+ continue;
}
if (gimple_code (stmt) == GIMPLE_COND
- && (gimple_cond_code (stmt) == EQ_EXPR
- || gimple_cond_code (stmt) == NE_EXPR)
&& TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME
&& TREE_CODE (gimple_cond_rhs (stmt)) == INTEGER_CST
&& INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))
- && (integer_zerop (gimple_cond_rhs (stmt))
- || integer_onep (gimple_cond_rhs (stmt))))
+ && tree_int_cst_sgn (gimple_cond_rhs (stmt)) >= 0)
{
edge e = NULL, et, ef;
+ enum tree_code ccode = gimple_cond_code (stmt);
tree lhs = gimple_cond_lhs (stmt);
- bool rhsv = integer_onep (gimple_cond_rhs (stmt));
- if (gimple_cond_code (stmt) == NE_EXPR)
- rhsv = !rhsv;
+ tree rhsv = gimple_cond_rhs (stmt);
extract_true_false_edges_from_block (gimple_bb (stmt), &et, &ef);
if (is_gimple_assign (SSA_NAME_DEF_STMT (lhs))
&& (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhs))
== INTEGER_CST))
{
- tree rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs));
- if (rhsv ? integer_onep (rhs) : integer_zerop (rhs))
+ tree lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs));
+ tree r = const_binop (ccode, boolean_type_node, lhsv, rhsv);
+ if (r == boolean_true_node)
e = et;
- else if (rhsv ? integer_zerop (rhs) : integer_onep (rhs))
+ else if (r == boolean_false_node)
e = ef;
}
else if (gimple_code (SSA_NAME_DEF_STMT (lhs)) == GIMPLE_PHI)
@@ -1188,16 +1260,17 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
for (edge e2 : edges)
if (e2->dest == pbb)
{
- tree rhs = gimple_phi_arg_def_from_edge (phi, e2);
- if (TREE_CODE (rhs) == SSA_NAME)
- if (gimple *g = SSA_NAME_DEF_STMT (rhs))
+ tree lhsv = gimple_phi_arg_def_from_edge (phi, e2);
+ if (TREE_CODE (lhsv) == SSA_NAME)
+ if (gimple *g = SSA_NAME_DEF_STMT (lhsv))
if (is_gimple_assign (g)
&& gimple_assign_rhs_code (g) == INTEGER_CST)
- rhs = gimple_assign_rhs1 (g);
- if (rhsv ? integer_onep (rhs) : integer_zerop (rhs))
+ lhsv = gimple_assign_rhs1 (g);
+ tree r = const_binop (ccode, boolean_type_node,
+ lhsv, rhsv);
+ if (r == boolean_true_node)
e = et;
- else if (rhsv ? integer_zerop (rhs)
- : integer_onep (rhs))
+ else if (r == boolean_false_node)
e = ef;
break;
}
@@ -1212,6 +1285,48 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret,
goto new_bb;
}
}
+ if (gimple_code (stmt) == GIMPLE_SWITCH
+ && (TREE_CODE (gimple_switch_index (as_a <gswitch *> (stmt)))
+ == SSA_NAME))
+ {
+ edge e = NULL;
+ gswitch *swtch = as_a <gswitch *> (stmt);
+ tree idx = gimple_switch_index (swtch);
+ if (is_gimple_assign (SSA_NAME_DEF_STMT (idx))
+ && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (idx))
+ == INTEGER_CST))
+ {
+ tree val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (idx));
+ e = find_taken_edge_switch_expr (swtch, val);
+ }
+ else if (gimple_code (SSA_NAME_DEF_STMT (idx)) == GIMPLE_PHI)
+ {
+ gimple *phi = SSA_NAME_DEF_STMT (idx);
+ basic_block pbb = gimple_bb (phi);
+ for (edge e2 : edges)
+ if (e2->dest == pbb)
+ {
+ tree val = gimple_phi_arg_def_from_edge (phi, e2);
+ if (TREE_CODE (val) == SSA_NAME)
+ if (gimple *g = SSA_NAME_DEF_STMT (val))
+ if (is_gimple_assign (g)
+ && gimple_assign_rhs_code (g) == INTEGER_CST)
+ val = gimple_assign_rhs1 (g);
+ if (TREE_CODE (val) == INTEGER_CST)
+ e = find_taken_edge_switch_expr (swtch, val);
+ break;
+ }
+ }
+ if (e)
+ {
+ ass_var = propagate_through_phis (ass_var, e);
+ if (!ass_var || ignored_edges)
+ edges.safe_push (e);
+ abb = e->dest;
+ agsi = gsi_start_bb (abb);
+ goto new_bb;
+ }
+ }
}
if (gimple_code (stmt) != GIMPLE_ASSIGN)
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index a9d4aae..a3d3b3e 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -1448,17 +1448,20 @@ vect_compute_data_ref_alignment (vec_info *vinfo, dr_vec_info *dr_info,
if (loop_vinfo
&& dr_safe_speculative_read_required (stmt_info))
{
- poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
- auto vectype_size
+ /* The required target alignment must be a power-of-2 value and is
+ computed as the product of vector element size, VF and group size.
+ We compute the constant part first as VF may be a variable. For
+ variable VF, the power-of-2 check of VF is deferred to runtime. */
+ auto align_factor_c
= TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
- poly_uint64 new_alignment = vf * vectype_size;
- /* If we have a grouped access we require that the alignment be N * elem. */
if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
- new_alignment *= DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info));
+ align_factor_c *= DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info));
+
+ poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+ poly_uint64 new_alignment = vf * align_factor_c;
- unsigned HOST_WIDE_INT target_alignment;
- if (new_alignment.is_constant (&target_alignment)
- && pow2p_hwi (target_alignment))
+ if ((vf.is_constant () && pow2p_hwi (new_alignment.to_constant ()))
+ || (!vf.is_constant () && pow2p_hwi (align_factor_c)))
{
if (dump_enabled_p ())
{
@@ -1467,7 +1470,7 @@ vect_compute_data_ref_alignment (vec_info *vinfo, dr_vec_info *dr_info,
dump_dec (MSG_NOTE, new_alignment);
dump_printf (MSG_NOTE, " bytes.\n");
}
- vector_alignment = target_alignment;
+ vector_alignment = new_alignment;
}
}
@@ -2438,6 +2441,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
- The cost of peeling (the extra runtime checks, the increase
in code size). */
+ poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
FOR_EACH_VEC_ELT (datarefs, i, dr)
{
dr_vec_info *dr_info = loop_vinfo->lookup_dr (dr);
@@ -2446,9 +2450,18 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
stmt_vec_info stmt_info = dr_info->stmt;
tree vectype = STMT_VINFO_VECTYPE (stmt_info);
- do_peeling
- = vector_alignment_reachable_p (dr_info,
- LOOP_VINFO_VECT_FACTOR (loop_vinfo));
+
+ /* With variable VF, unsafe speculative read can be avoided for known
+ inbounds DRs as long as partial vectors are used. */
+ if (!vf.is_constant ()
+ && dr_safe_speculative_read_required (stmt_info)
+ && DR_SCALAR_KNOWN_BOUNDS (dr_info))
+ {
+ dr_set_safe_speculative_read_required (stmt_info, false);
+ LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P (loop_vinfo) = true;
+ }
+
+ do_peeling = vector_alignment_reachable_p (dr_info, vf);
if (do_peeling)
{
if (known_alignment_for_access_p (dr_info, vectype))
@@ -2488,7 +2501,6 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
poly_uint64 nscalars = npeel_tmp;
if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo)))
{
- poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
unsigned group_size = 1;
if (STMT_SLP_TYPE (stmt_info)
&& STMT_VINFO_GROUPED_ACCESS (stmt_info))
@@ -2911,14 +2923,12 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
2) there is at least one unsupported misaligned data ref with an unknown
misalignment, and
3) all misaligned data refs with a known misalignment are supported, and
- 4) the number of runtime alignment checks is within reason.
- 5) the vectorization factor is a constant. */
+ 4) the number of runtime alignment checks is within reason. */
do_versioning
= (optimize_loop_nest_for_speed_p (loop)
&& !loop->inner /* FORNOW */
- && loop_cost_model (loop) > VECT_COST_MODEL_CHEAP)
- && LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ();
+ && loop_cost_model (loop) > VECT_COST_MODEL_CHEAP);
if (do_versioning)
{
@@ -2965,25 +2975,22 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
?? We could actually unroll the loop to achieve the required
overall step alignment, and forcing the alignment could be
done by doing some iterations of the non-vectorized loop. */
- if (!multiple_p (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
- * DR_STEP_ALIGNMENT (dr),
+ if (!multiple_p (vf * DR_STEP_ALIGNMENT (dr),
DR_TARGET_ALIGNMENT (dr_info)))
{
do_versioning = false;
break;
}
- /* The rightmost bits of an aligned address must be zeros.
- Construct the mask needed for this test. For example,
- GET_MODE_SIZE for the vector mode V4SI is 16 bytes so the
- mask must be 15 = 0xf. */
- gcc_assert (DR_TARGET_ALIGNMENT (dr_info).is_constant ());
- int mask = DR_TARGET_ALIGNMENT (dr_info).to_constant () - 1;
+ /* Use "mask = DR_TARGET_ALIGNMENT - 1" to test rightmost address
+ bits for runtime alignment check. For example, for 16 bytes
+ target alignment the mask is 15 = 0xf. */
+ poly_uint64 mask = DR_TARGET_ALIGNMENT (dr_info) - 1;
/* FORNOW: use the same mask to test all potentially unaligned
references in the loop. */
- if (LOOP_VINFO_PTR_MASK (loop_vinfo)
- && LOOP_VINFO_PTR_MASK (loop_vinfo) != mask)
+ if (maybe_ne (LOOP_VINFO_PTR_MASK (loop_vinfo), 0U)
+ && maybe_ne (LOOP_VINFO_PTR_MASK (loop_vinfo), mask))
{
do_versioning = false;
break;
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 6c1b26a..566308f 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -2454,10 +2454,7 @@ get_misalign_in_elems (gimple **seq, loop_vec_info loop_vinfo)
else
{
tree vla = build_int_cst (type, target_align);
- tree vla_align = fold_build2 (BIT_AND_EXPR, type, vla,
- fold_build2 (MINUS_EXPR, type,
- build_int_cst (type, 0), vla));
- target_align_minus_1 = fold_build2 (MINUS_EXPR, type, vla_align,
+ target_align_minus_1 = fold_build2 (MINUS_EXPR, type, vla,
build_int_cst (type, 1));
}
@@ -3840,7 +3837,7 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo,
const vec<stmt_vec_info> &may_misalign_stmts
= LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo);
stmt_vec_info stmt_info;
- int mask = LOOP_VINFO_PTR_MASK (loop_vinfo);
+ poly_uint64 mask = LOOP_VINFO_PTR_MASK (loop_vinfo);
tree mask_cst;
unsigned int i;
tree int_ptrsize_type;
@@ -3852,9 +3849,7 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo,
tree ptrsize_zero;
tree part_cond_expr;
- /* Check that mask is one less than a power of 2, i.e., mask is
- all zeros followed by all ones. */
- gcc_assert ((mask != 0) && ((mask & (mask+1)) == 0));
+ gcc_assert (known_ne (mask, 0U));
int_ptrsize_type = signed_type_for (ptr_type_node);
@@ -3962,6 +3957,62 @@ vect_create_cond_for_align_checks (loop_vec_info loop_vinfo,
chain_cond_expr (cond_expr, part_cond_expr);
}
+/* Function vect_create_cond_for_vla_spec_read.
+
+ Create a conditional expression that represents the run-time checks with
+ max speculative read amount in VLA modes. We check two things:
+ 1) if the max speculative read amount exceeds the min page size
+ 2) if the VF is power-of-2 - done by checking the max read amount instead
+
+ Input:
+ COND_EXPR - input conditional expression. New conditions will be chained
+ with logical AND operation.
+ LOOP_VINFO - field LOOP_VINFO_MAX_SPEC_READ_AMOUNT contains the max
+ possible speculative read amount in VLA modes.
+
+ Output:
+ COND_EXPR - conditional expression.
+
+ The returned COND_EXPR is the conditional expression to be used in the
+ if statement that controls which version of the loop gets executed at
+ runtime. */
+
+static void
+vect_create_cond_for_vla_spec_read (loop_vec_info loop_vinfo, tree *cond_expr)
+{
+ poly_uint64 read_amount_poly = LOOP_VINFO_MAX_SPEC_READ_AMOUNT (loop_vinfo);
+ tree amount = build_int_cst (long_unsigned_type_node, read_amount_poly);
+
+ /* Both the read amount and the VF must be variants, and the read amount must
+ be a constant power-of-2 multiple of the VF. */
+ unsigned HOST_WIDE_INT multiple;
+ gcc_assert (!read_amount_poly.is_constant ()
+ && !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
+ && constant_multiple_p (read_amount_poly,
+ LOOP_VINFO_VECT_FACTOR (loop_vinfo),
+ &multiple)
+ && pow2p_hwi (multiple));
+
+ tree cst_ul_zero = build_int_cstu (long_unsigned_type_node, 0U);
+ tree cst_ul_one = build_int_cstu (long_unsigned_type_node, 1U);
+ tree cst_ul_pagesize = build_int_cstu (long_unsigned_type_node,
+ (unsigned long) param_min_pagesize);
+
+ /* Create an expression of "amount & (amount - 1) == 0". */
+ tree amount_m1 = fold_build2 (MINUS_EXPR, long_unsigned_type_node,
+ amount, cst_ul_one);
+ tree amount_and_expr = fold_build2 (BIT_AND_EXPR, long_unsigned_type_node,
+ amount, amount_m1);
+ tree powof2_cond_expr = fold_build2 (EQ_EXPR, boolean_type_node,
+ amount_and_expr, cst_ul_zero);
+ chain_cond_expr (cond_expr, powof2_cond_expr);
+
+ /* Create an expression of "amount <= cst_ul_pagesize". */
+ tree pagesize_cond_expr = fold_build2 (LE_EXPR, boolean_type_node,
+ amount, cst_ul_pagesize);
+ chain_cond_expr (cond_expr, pagesize_cond_expr);
+}
+
/* If LOOP_VINFO_CHECK_UNEQUAL_ADDRS contains <A1, B1>, ..., <An, Bn>,
create a tree representation of: (&A1 != &B1) && ... && (&An != &Bn).
Set *COND_EXPR to a tree that is true when both the original *COND_EXPR
@@ -4087,6 +4138,7 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
gimple_seq gimplify_stmt_list = NULL;
tree scalar_loop_iters = LOOP_VINFO_NITERSM1 (loop_vinfo);
bool version_align = LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo);
+ bool version_spec_read = LOOP_REQUIRES_VERSIONING_FOR_SPEC_READ (loop_vinfo);
bool version_alias = LOOP_REQUIRES_VERSIONING_FOR_ALIAS (loop_vinfo);
bool version_niter = LOOP_REQUIRES_VERSIONING_FOR_NITERS (loop_vinfo);
poly_uint64 versioning_threshold
@@ -4145,6 +4197,9 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
vect_create_cond_for_align_checks (loop_vinfo, &cond_expr,
&cond_expr_stmt_list);
+ if (version_spec_read)
+ vect_create_cond_for_vla_spec_read (loop_vinfo, &cond_expr);
+
if (version_alias)
{
vect_create_cond_for_unequal_addrs (loop_vinfo, &cond_expr);
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 85f3e90..5fc24dc 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -163,169 +163,6 @@ static void vect_estimate_min_profitable_iters (loop_vec_info, int *, int *,
static stmt_vec_info vect_is_simple_reduction (loop_vec_info, stmt_vec_info,
bool *, bool *, bool);
-/* Subroutine of vect_determine_vf_for_stmt that handles only one
- statement. VECTYPE_MAYBE_SET_P is true if STMT_VINFO_VECTYPE
- may already be set for general statements (not just data refs). */
-
-static opt_result
-vect_determine_vectype_for_stmt_1 (vec_info *vinfo, stmt_vec_info stmt_info,
- bool vectype_maybe_set_p)
-{
- gimple *stmt = stmt_info->stmt;
-
- if ((!STMT_VINFO_RELEVANT_P (stmt_info)
- && !STMT_VINFO_LIVE_P (stmt_info))
- || gimple_clobber_p (stmt))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "skip.\n");
- return opt_result::success ();
- }
-
- tree stmt_vectype, nunits_vectype;
- opt_result res = vect_get_vector_types_for_stmt (vinfo, stmt_info,
- &stmt_vectype,
- &nunits_vectype);
- if (!res)
- return res;
-
- if (stmt_vectype)
- {
- if (STMT_VINFO_VECTYPE (stmt_info))
- /* The only case when a vectype had been already set is for stmts
- that contain a data ref, or for "pattern-stmts" (stmts generated
- by the vectorizer to represent/replace a certain idiom). */
- gcc_assert ((STMT_VINFO_DATA_REF (stmt_info)
- || vectype_maybe_set_p)
- && STMT_VINFO_VECTYPE (stmt_info) == stmt_vectype);
- else
- STMT_VINFO_VECTYPE (stmt_info) = stmt_vectype;
- }
-
- return opt_result::success ();
-}
-
-/* Subroutine of vect_determine_vectorization_factor. Set the vector
- types of STMT_INFO and all attached pattern statements and update
- the vectorization factor VF accordingly. Return true on success
- or false if something prevented vectorization. */
-
-static opt_result
-vect_determine_vectype_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info)
-{
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "==> examining statement: %G",
- stmt_info->stmt);
- opt_result res = vect_determine_vectype_for_stmt_1 (vinfo, stmt_info, false);
- if (!res)
- return res;
-
- if (STMT_VINFO_IN_PATTERN_P (stmt_info)
- && STMT_VINFO_RELATED_STMT (stmt_info))
- {
- gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
- stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
-
- /* If a pattern statement has def stmts, analyze them too. */
- for (gimple_stmt_iterator si = gsi_start (pattern_def_seq);
- !gsi_end_p (si); gsi_next (&si))
- {
- stmt_vec_info def_stmt_info = vinfo->lookup_stmt (gsi_stmt (si));
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "==> examining pattern def stmt: %G",
- def_stmt_info->stmt);
- res = vect_determine_vectype_for_stmt_1 (vinfo, def_stmt_info, true);
- if (!res)
- return res;
- }
-
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "==> examining pattern statement: %G",
- stmt_info->stmt);
- res = vect_determine_vectype_for_stmt_1 (vinfo, stmt_info, true);
- if (!res)
- return res;
- }
-
- return opt_result::success ();
-}
-
-/* Function vect_set_stmts_vectype
-
- Set STMT_VINFO_VECTYPE of all stmts. */
-
-static opt_result
-vect_set_stmts_vectype (loop_vec_info loop_vinfo)
-{
- class loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
- basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
- unsigned nbbs = loop->num_nodes;
- tree scalar_type = NULL_TREE;
- gphi *phi;
- tree vectype;
- stmt_vec_info stmt_info;
- unsigned i;
-
- DUMP_VECT_SCOPE ("vect_set_stmts_vectype");
-
- for (i = 0; i < nbbs; i++)
- {
- basic_block bb = bbs[i];
-
- for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
- gsi_next (&si))
- {
- phi = si.phi ();
- stmt_info = loop_vinfo->lookup_stmt (phi);
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "==> examining phi: %G",
- (gimple *) phi);
-
- gcc_assert (stmt_info);
-
- if (STMT_VINFO_RELEVANT_P (stmt_info)
- || STMT_VINFO_LIVE_P (stmt_info))
- {
- gcc_assert (!STMT_VINFO_VECTYPE (stmt_info));
- scalar_type = TREE_TYPE (PHI_RESULT (phi));
-
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "get vectype for scalar type: %T\n",
- scalar_type);
-
- vectype = get_vectype_for_scalar_type (loop_vinfo, scalar_type);
- if (!vectype)
- return opt_result::failure_at (phi,
- "not vectorized: unsupported "
- "data-type %T\n",
- scalar_type);
- STMT_VINFO_VECTYPE (stmt_info) = vectype;
-
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "vectype: %T\n",
- vectype);
- }
- }
-
- for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
- gsi_next (&si))
- {
- if (is_gimple_debug (gsi_stmt (si)))
- continue;
- stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si));
- opt_result res
- = vect_determine_vectype_for_stmt (loop_vinfo, stmt_info);
- if (!res)
- return res;
- }
- }
-
- return opt_result::success ();
-}
-
/* Function vect_is_simple_iv_evolution.
@@ -1009,6 +846,7 @@ _loop_vec_info::_loop_vec_info (class loop *loop_in, vec_info_shared *shared)
unaligned_dr (NULL),
peeling_for_alignment (0),
ptr_mask (0),
+ max_spec_read_amount (0),
nonlinear_iv (false),
ivexpr_map (NULL),
scan_map (NULL),
@@ -2482,15 +2320,6 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
}
LOOP_VINFO_MAX_VECT_FACTOR (loop_vinfo) = max_vf;
- ok = vect_set_stmts_vectype (loop_vinfo);
- if (!ok)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "cannot determine vector types.\n");
- return ok;
- }
-
/* Compute the scalar iteration cost. */
vect_compute_single_scalar_iteration_cost (loop_vinfo);
@@ -4956,8 +4785,9 @@ have_whole_vector_shift (machine_mode mode)
See vect_emulate_mixed_dot_prod for the actual sequence used. */
static bool
-vect_is_emulated_mixed_dot_prod (stmt_vec_info stmt_info)
+vect_is_emulated_mixed_dot_prod (slp_tree slp_node)
{
+ stmt_vec_info stmt_info = SLP_TREE_REPRESENTATIVE (slp_node);
gassign *assign = dyn_cast<gassign *> (stmt_info->stmt);
if (!assign || gimple_assign_rhs_code (assign) != DOT_PROD_EXPR)
return false;
@@ -4969,7 +4799,7 @@ vect_is_emulated_mixed_dot_prod (stmt_vec_info stmt_info)
gcc_assert (STMT_VINFO_REDUC_VECTYPE_IN (stmt_info));
return !directly_supported_p (DOT_PROD_EXPR,
- STMT_VINFO_VECTYPE (stmt_info),
+ SLP_TREE_VECTYPE (slp_node),
STMT_VINFO_REDUC_VECTYPE_IN (stmt_info),
optab_vector_mixed_sign);
}
@@ -7118,13 +6948,13 @@ vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
vectype_in);
gcc_assert (ncopies_for_cost >= 1);
- if (vect_is_emulated_mixed_dot_prod (stmt_info))
+ if (vect_is_emulated_mixed_dot_prod (slp_node))
{
/* We need extra two invariants: one that contains the minimum signed
value and one that contains half of its negative. */
int prologue_stmts = 2;
unsigned cost = record_stmt_cost (cost_vec, prologue_stmts,
- scalar_to_vec, stmt_info, 0,
+ scalar_to_vec, slp_node, 0,
vect_prologue);
if (dump_enabled_p ())
dump_printf (MSG_NOTE, "vectorizable_lane_reducing: "
@@ -7134,7 +6964,7 @@ vectorizable_lane_reducing (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
ncopies_for_cost *= 4;
}
- record_stmt_cost (cost_vec, (int) ncopies_for_cost, vector_stmt, stmt_info,
+ record_stmt_cost (cost_vec, (int) ncopies_for_cost, vector_stmt, slp_node,
0, vect_body);
if (LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
@@ -8420,7 +8250,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
}
}
- bool emulated_mixed_dot_prod = vect_is_emulated_mixed_dot_prod (stmt_info);
+ bool emulated_mixed_dot_prod = vect_is_emulated_mixed_dot_prod (slp_node);
unsigned num = vec_oprnds[reduc_index == 0 ? 1 : 0].length ();
unsigned mask_index = 0;
@@ -10141,7 +9971,12 @@ vectorizable_induction (loop_vec_info loop_vinfo,
if (peel_mul)
{
if (!step_mul)
- step_mul = peel_mul;
+ {
+ gcc_assert (!nunits.is_constant ());
+ step_mul = gimple_build (&init_stmts,
+ MINUS_EXPR, step_vectype,
+ build_zero_cst (step_vectype), peel_mul);
+ }
else
step_mul = gimple_build (&init_stmts,
MINUS_EXPR, step_vectype,
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index a6f4db4..26d5be5 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -724,14 +724,21 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo, bool *fatal)
if (vect_stmt_relevant_p (phi_info, loop_vinfo, &relevant, &live_p))
vect_mark_relevant (&worklist, phi_info, relevant, live_p);
}
- for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+ for (si = gsi_after_labels (bb); !gsi_end_p (si); gsi_next (&si))
{
- if (is_gimple_debug (gsi_stmt (si)))
+ gimple *stmt = gsi_stmt (si);
+ if (is_gimple_debug (stmt))
continue;
- stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (gsi_stmt (si));
+ stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (stmt);
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
- "init: stmt relevant? %G", stmt_info->stmt);
+ "init: stmt relevant? %G", stmt);
+
+ if (gimple_get_lhs (stmt) == NULL_TREE
+ && !is_a <gcond *> (stmt)
+ && !is_a <gcall *> (stmt))
+ return opt_result::failure_at
+ (stmt, "not vectorized: irregular stmt: %G", stmt);
if (vect_stmt_relevant_p (stmt_info, loop_vinfo, &relevant, &live_p))
vect_mark_relevant (&worklist, stmt_info, relevant, live_p);
@@ -929,8 +936,7 @@ vect_model_simple_cost (vec_info *, int n, slp_tree node,
is true the stmt is doing widening arithmetic. */
static void
-vect_model_promotion_demotion_cost (stmt_vec_info stmt_info,
- enum vect_def_type *dt,
+vect_model_promotion_demotion_cost (slp_tree slp_node,
unsigned int ncopies, int pwr,
stmt_vector_for_cost *cost_vec,
bool widen_arith)
@@ -943,16 +949,10 @@ vect_model_promotion_demotion_cost (stmt_vec_info stmt_info,
inside_cost += record_stmt_cost (cost_vec, ncopies,
widen_arith
? vector_stmt : vec_promote_demote,
- stmt_info, 0, vect_body);
+ slp_node, 0, vect_body);
ncopies *= 2;
}
- /* FORNOW: Assuming maximum 2 args per stmts. */
- for (i = 0; i < 2; i++)
- if (dt[i] == vect_constant_def || dt[i] == vect_external_def)
- prologue_cost += record_stmt_cost (cost_vec, 1, vector_stmt,
- stmt_info, 0, vect_prologue);
-
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
"vect_model_promotion_demotion_cost: inside_cost = %d, "
@@ -2400,70 +2400,26 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info,
/* We can only peel for loops, of course. */
gcc_checking_assert (loop_vinfo);
+ poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+ poly_uint64 read_amount
+ = vf * TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
+ if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
+ read_amount *= DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info));
+
auto target_alignment
= DR_TARGET_ALIGNMENT (STMT_VINFO_DR_INFO (stmt_info));
- unsigned HOST_WIDE_INT target_align;
-
- bool group_aligned = false;
- if (target_alignment.is_constant (&target_align)
- && nunits.is_constant ())
- {
- poly_uint64 vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
- auto vectype_size
- = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
- poly_uint64 required_alignment = vf * vectype_size;
- /* If we have a grouped access we require that the alignment be N * elem. */
- if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
- required_alignment *=
- DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info));
- if (!multiple_p (target_alignment, required_alignment))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "desired alignment %wu not met. Instead got %wu "
- "for DR alignment at %G",
- required_alignment.to_constant (),
- target_align, STMT_VINFO_STMT (stmt_info));
- return false;
- }
-
- if (!pow2p_hwi (target_align))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "non-power-of-two vector alignment %wd "
- "for DR alignment at %G",
- target_align, STMT_VINFO_STMT (stmt_info));
- return false;
- }
-
- /* For VLA we have to insert a runtime check that the vector loads
- per iterations don't exceed a page size. For now we can use
- POLY_VALUE_MAX as a proxy as we can't peel for VLA. */
- if (known_gt (required_alignment, (unsigned)param_min_pagesize))
+ if (!multiple_p (target_alignment, read_amount))
+ {
+ if (dump_enabled_p ())
{
- if (dump_enabled_p ())
- {
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "alignment required for correctness (");
- dump_dec (MSG_MISSED_OPTIMIZATION, required_alignment);
- dump_printf (MSG_NOTE, ") may exceed page size\n");
- }
- return false;
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "desired alignment not met, target was ");
+ dump_dec (MSG_NOTE, target_alignment);
+ dump_printf (MSG_NOTE, " previously, but read amount is ");
+ dump_dec (MSG_NOTE, read_amount);
+ dump_printf (MSG_NOTE, " at %G.\n", STMT_VINFO_STMT (stmt_info));
}
-
- group_aligned = true;
- }
-
- /* There are multiple loads that have a misalignment that we couldn't
- align. We would need LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P to
- vectorize. */
- if (!group_aligned)
- {
- if (inbounds)
- LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P (loop_vinfo) = true;
- else
- return false;
+ return false;
}
/* When using a group access the first element may be aligned but the
@@ -2485,6 +2441,33 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info,
STMT_VINFO_STMT (stmt_info));
return false;
}
+
+ /* Reject vectorization if we know the read mount per vector iteration
+ exceeds the min page size. */
+ if (known_gt (read_amount, (unsigned) param_min_pagesize))
+ {
+ if (dump_enabled_p ())
+ {
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "alignment required for correctness (");
+ dump_dec (MSG_MISSED_OPTIMIZATION, read_amount);
+ dump_printf (MSG_NOTE, ") may exceed page size.\n");
+ }
+ return false;
+ }
+
+ if (!vf.is_constant ())
+ {
+ /* For VLA modes, we need a runtime check to ensure any speculative
+ read amount does not exceed the page size. Here we record the max
+ possible read amount for the check. */
+ if (maybe_gt (read_amount,
+ LOOP_VINFO_MAX_SPEC_READ_AMOUNT (loop_vinfo)))
+ LOOP_VINFO_MAX_SPEC_READ_AMOUNT (loop_vinfo) = read_amount;
+
+ /* For VLA modes, we must use partial vectors. */
+ LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P (loop_vinfo) = true;
+ }
}
if (*alignment_support_scheme == dr_unaligned_unsupported)
@@ -5403,7 +5386,7 @@ vectorizable_conversion (vec_info *vinfo,
SLP_TREE_TYPE (slp_node) = type_demotion_vec_info_type;
/* The final packing step produces one vector result per copy. */
unsigned int nvectors = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
- vect_model_promotion_demotion_cost (stmt_info, dt, nvectors,
+ vect_model_promotion_demotion_cost (slp_node, nvectors,
multi_step_cvt, cost_vec,
widen_arith);
}
@@ -5415,7 +5398,7 @@ vectorizable_conversion (vec_info *vinfo,
so >> MULTI_STEP_CVT divides by 2^(number of steps - 1). */
unsigned int nvectors
= SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) >> multi_step_cvt;
- vect_model_promotion_demotion_cost (stmt_info, dt, nvectors,
+ vect_model_promotion_demotion_cost (slp_node, nvectors,
multi_step_cvt, cost_vec,
widen_arith);
}
@@ -7794,7 +7777,7 @@ vectorizable_store (vec_info *vinfo,
return false;
}
- tree vectype = SLP_TREE_VECTYPE (stmt_info), rhs_vectype = NULL_TREE;
+ tree vectype = SLP_TREE_VECTYPE (slp_node), rhs_vectype = NULL_TREE;
poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
if (loop_vinfo)
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 9653496..041cff8 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -919,7 +919,10 @@ public:
int peeling_for_alignment;
/* The mask used to check the alignment of pointers or arrays. */
- int ptr_mask;
+ poly_uint64 ptr_mask;
+
+ /* The maximum speculative read amount in VLA modes for runtime check. */
+ poly_uint64 max_spec_read_amount;
/* Indicates whether the loop has any non-linear IV. */
bool nonlinear_iv;
@@ -1155,6 +1158,7 @@ public:
#define LOOP_VINFO_RGROUP_IV_TYPE(L) (L)->rgroup_iv_type
#define LOOP_VINFO_PARTIAL_VECTORS_STYLE(L) (L)->partial_vector_style
#define LOOP_VINFO_PTR_MASK(L) (L)->ptr_mask
+#define LOOP_VINFO_MAX_SPEC_READ_AMOUNT(L) (L)->max_spec_read_amount
#define LOOP_VINFO_LOOP_NEST(L) (L)->shared->loop_nest
#define LOOP_VINFO_DATAREFS(L) (L)->shared->datarefs
#define LOOP_VINFO_DDRS(L) (L)->shared->ddrs
@@ -1209,6 +1213,8 @@ public:
#define LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT(L) \
((L)->may_misalign_stmts.length () > 0)
+#define LOOP_REQUIRES_VERSIONING_FOR_SPEC_READ(L) \
+ (maybe_gt ((L)->max_spec_read_amount, 0U))
#define LOOP_REQUIRES_VERSIONING_FOR_ALIAS(L) \
((L)->comp_alias_ddrs.length () > 0 \
|| (L)->check_unequal_addrs.length () > 0 \
@@ -1219,6 +1225,7 @@ public:
(LOOP_VINFO_SIMD_IF_COND (L))
#define LOOP_REQUIRES_VERSIONING(L) \
(LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (L) \
+ || LOOP_REQUIRES_VERSIONING_FOR_SPEC_READ (L) \
|| LOOP_REQUIRES_VERSIONING_FOR_ALIAS (L) \
|| LOOP_REQUIRES_VERSIONING_FOR_NITERS (L) \
|| LOOP_REQUIRES_VERSIONING_FOR_SIMD_IF_COND (L))
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 7deda4b..874a08a 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,15 @@
+2025-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * include/cpplib.h (struct cpp_options): Add cpp_warn_keyword_macro.
+ (enum cpp_warning_reason): Add CPP_W_KEYWORD_MACRO enumerator.
+ (cpp_keyword_p): New inline function.
+ * directives.cc (do_undef): Support -Wkeyword-macro diagnostics.
+ * macro.cc (warn_of_redefinition): Ignore NODE_WARN flag on nodes
+ registered for -Wkeyword-macro.
+ (_cpp_create_definition): Support -Wkeyword-macro diagnostics.
+ Formatting fixes.
+
2025-08-05 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/120778
diff --git a/libcpp/directives.cc b/libcpp/directives.cc
index 4d06caa..47fb8fb 100644
--- a/libcpp/directives.cc
+++ b/libcpp/directives.cc
@@ -734,13 +734,30 @@ do_undef (cpp_reader *pfile)
if (pfile->cb.undef)
pfile->cb.undef (pfile, pfile->directive_line, node);
+ /* Handle -Wkeyword-macro registered identifiers. */
+ bool diagnosed = false;
+ if (CPP_OPTION (pfile, cpp_warn_keyword_macro) && cpp_keyword_p (node))
+ {
+ if (CPP_OPTION (pfile, cpp_pedantic)
+ && CPP_OPTION (pfile, cplusplus)
+ && CPP_OPTION (pfile, lang) >= CLK_GNUCXX26)
+ cpp_pedwarning (pfile, CPP_W_KEYWORD_MACRO,
+ "undefining keyword %qs", NODE_NAME (node));
+ else
+ cpp_warning (pfile, CPP_W_KEYWORD_MACRO,
+ "undefining keyword %qs", NODE_NAME (node));
+ diagnosed = true;
+ }
/* 6.10.3.5 paragraph 2: [#undef] is ignored if the specified
identifier is not currently defined as a macro name. */
if (cpp_macro_p (node))
{
if (node->flags & NODE_WARN)
- cpp_error (pfile, CPP_DL_WARNING,
- "undefining %qs", NODE_NAME (node));
+ {
+ if (!diagnosed)
+ cpp_error (pfile, CPP_DL_WARNING,
+ "undefining %qs", NODE_NAME (node));
+ }
else if (cpp_builtin_macro_p (node)
&& CPP_OPTION (pfile, warn_builtin_macro_redefined))
cpp_warning (pfile, CPP_W_BUILTIN_MACRO_REDEFINED,
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 75efdcd..bbd88e5 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -620,6 +620,9 @@ struct cpp_options
/* True if -finput-charset= option has been used explicitly. */
bool cpp_input_charset_explicit;
+ /* True if -Wkeyword-macro. */
+ bool cpp_warn_keyword_macro;
+
/* -Wleading-whitespace= value. */
unsigned char cpp_warn_leading_whitespace;
@@ -757,7 +760,8 @@ enum cpp_warning_reason {
CPP_W_HEADER_GUARD,
CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER,
CPP_W_LEADING_WHITESPACE,
- CPP_W_TRAILING_WHITESPACE
+ CPP_W_TRAILING_WHITESPACE,
+ CPP_W_KEYWORD_MACRO
};
/* Callback for header lookup for HEADER, which is the name of a
@@ -1250,6 +1254,17 @@ inline bool cpp_fun_like_macro_p (cpp_hashnode *node)
return cpp_user_macro_p (node) && node->value.macro->fun_like;
}
+/* Return true for nodes marked for -Wkeyword-macro diagnostics. */
+inline bool cpp_keyword_p (cpp_hashnode *node)
+{
+ /* As keywords are marked identifiers which don't start with underscore
+ or start with underscore followed by capital letter (except for
+ _Pragma). */
+ return ((node->flags & NODE_WARN)
+ && (NODE_NAME (node)[0] != '_'
+ || (NODE_NAME (node)[1] != '_' && NODE_NAME (node)[1] != 'P')));
+}
+
extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *);
extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *,
const cpp_macro *);
diff --git a/libcpp/macro.cc b/libcpp/macro.cc
index 158c821..a47e1fe 100644
--- a/libcpp/macro.cc
+++ b/libcpp/macro.cc
@@ -3411,7 +3411,11 @@ warn_of_redefinition (cpp_reader *pfile, cpp_hashnode *node,
{
/* Some redefinitions need to be warned about regardless. */
if (node->flags & NODE_WARN)
- return true;
+ {
+ /* Ignore NODE_WARN on -Wkeyword-macro registered identifiers though. */
+ if (!CPP_OPTION (pfile, cpp_warn_keyword_macro) || !cpp_keyword_p (node))
+ return true;
+ }
/* Suppress warnings for builtins that lack the NODE_WARN flag,
unless Wbuiltin-macro-redefined. */
@@ -3949,6 +3953,25 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node,
if (name_loc)
macro->line = name_loc;
+ /* Handle -Wkeyword-macro registered identifiers. */
+ if (CPP_OPTION (pfile, cpp_warn_keyword_macro) && cpp_keyword_p (node))
+ {
+ if (macro->fun_like
+ && CPP_OPTION (pfile, cplusplus)
+ && (strcmp ((const char *) NODE_NAME (node), "likely") == 0
+ || strcmp ((const char *) NODE_NAME (node), "unlikely") == 0))
+ /* likely and unlikely can be defined as function-like macros. */;
+ else if (CPP_OPTION (pfile, cpp_pedantic)
+ && CPP_OPTION (pfile, cplusplus)
+ && CPP_OPTION (pfile, lang) >= CLK_GNUCXX26)
+ cpp_pedwarning_with_line (pfile, CPP_W_KEYWORD_MACRO, macro->line, 0,
+ "keyword %qs defined as macro",
+ NODE_NAME (node));
+ else
+ cpp_warning_with_line (pfile, CPP_W_KEYWORD_MACRO, macro->line, 0,
+ "keyword %qs defined as macro",
+ NODE_NAME (node));
+ }
if (cpp_macro_p (node))
{
if (CPP_OPTION (pfile, warn_unused_macros))
@@ -3957,12 +3980,12 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node,
if (warn_of_redefinition (pfile, node, macro))
{
const enum cpp_warning_reason reason
- = (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN))
- ? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
+ = (cpp_builtin_macro_p (node) && !(node->flags & NODE_WARN)
+ ? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE);
bool warned
- = cpp_pedwarning_with_line (pfile, reason, macro->line, 0,
- "%qs redefined", NODE_NAME (node));
+ = cpp_pedwarning_with_line (pfile, reason, macro->line, 0,
+ "%qs redefined", NODE_NAME (node));
if (warned && cpp_user_macro_p (node))
cpp_error_with_line (pfile, CPP_DL_NOTE, node->value.macro->line,
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 0962ddf..830685f 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,31 @@
+2025-08-08 Christophe Lyon <christophe.lyon@linaro.org>
+
+ PR libgcc/117600
+ * Makefile.in (WERROR): New.
+ * config/aarch64/t-aarch64: Handle WERROR.
+ * configure: Regenerate.
+ * configure.ac: Add support for --enable-werror.
+
+2025-08-07 Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
+
+ * config/s390/libgcc-glibc.ver: Export _BitInt support
+ functions.
+ * config/s390/t-softfp (softfp_extras): Add fixtfbitint
+ floatbitinttf.
+
+2025-08-07 Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
+
+ * config.host: Include makefiles t-softfp for -m64.
+ * config/s390/sfp-exceptions.c: New file.
+ * config/s390/sfp-machine.h: New file.
+ * config/s390/t-softfp: New file.
+
+2025-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgcc/121397
+ * enable-execute-stack-mprotect.c (check_enabling): Remove useless
+ forward declaration.
+
2025-07-31 Wilco Dijkstra <wilco.dijkstra@arm.com>
* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index f7b48dc..e258f94 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -87,6 +87,7 @@ CC = @CC@
CFLAGS = @CFLAGS@
RANLIB = @RANLIB@
LN_S = @LN_S@
+WERROR = @WERROR@
PWD_COMMAND = $${PWDCMD-pwd}
diff --git a/libgcc/config.host b/libgcc/config.host
index d36f0e3..92acdd0 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1397,6 +1397,8 @@ s390x-*-linux*)
tmake_file="${tmake_file} s390/t-crtstuff s390/t-linux t-stack s390/t-stack-s390"
if test "${host_address}" = 32; then
tmake_file="${tmake_file} s390/32/t-floattodi"
+ else
+ tmake_file="${tmake_file} s390/t-softfp t-softfp"
fi
md_unwind_header=s390/linux-unwind.h
;;
diff --git a/libgcc/config/aarch64/t-aarch64 b/libgcc/config/aarch64/t-aarch64
index d4c5922..c7d83c7 100644
--- a/libgcc/config/aarch64/t-aarch64
+++ b/libgcc/config/aarch64/t-aarch64
@@ -30,4 +30,4 @@ LIB2ADDEH += \
$(srcdir)/config/aarch64/__arm_za_disable.S
SHLIB_MAPFILES += $(srcdir)/config/aarch64/libgcc-sme.ver
-LIBGCC2_CFLAGS += -Werror -Wno-prio-ctor-dtor
+LIBGCC2_CFLAGS += $(WERROR) -Wno-prio-ctor-dtor
diff --git a/libgcc/config/s390/libgcc-glibc.ver b/libgcc/config/s390/libgcc-glibc.ver
index 86c55a0..00375b3 100644
--- a/libgcc/config/s390/libgcc-glibc.ver
+++ b/libgcc/config/s390/libgcc-glibc.ver
@@ -114,3 +114,17 @@ GCC_4.1.0 {
__floatditf
%endif
}
+
+%ifdef __s390x__
+%inherit GCC_16.0.0 GCC_4.1.0
+GCC_16.0.0 {
+ __mulbitint3
+ __divmodbitint4
+ __fixsfbitint
+ __fixdfbitint
+ __fixtfbitint
+ __floatbitintsf
+ __floatbitintdf
+ __floatbitinttf
+}
+%endif
diff --git a/libgcc/config/s390/sfp-exceptions.c b/libgcc/config/s390/sfp-exceptions.c
new file mode 100644
index 0000000..a2fc5dd
--- /dev/null
+++ b/libgcc/config/s390/sfp-exceptions.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 2001-2025 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GCC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sfp-machine.h"
+
+#define __math_force_eval_div(x, y) \
+ do { asm ("" : "+f" (x)); asm volatile ("" : : "f" (x / y)); } while (0)
+
+void
+__sfp_handle_exceptions (int _fex)
+{
+ if (_fex & FP_EX_INVALID)
+ {
+ float x = 0.0f;
+ __math_force_eval_div (x, x);
+ }
+ if (_fex & FP_EX_DIVZERO)
+ {
+ float x = 1.0f;
+ float y = 0.0f;
+ __math_force_eval_div (x, y);
+ }
+ if (_fex & FP_EX_OVERFLOW)
+ {
+ float x = __FLT_MAX__;
+ asm ("" : "+f" (x));
+ asm volatile ("" : : "f" (x + x));
+ }
+ if (_fex & FP_EX_UNDERFLOW)
+ {
+ float x = __FLT_MIN__;
+ asm ("" : "+f" (x));
+ asm volatile ("" : : "f" (x * x));
+ }
+ if (_fex & FP_EX_INEXACT)
+ {
+ float x = 1.0f;
+ float y = 3.0f;
+ __math_force_eval_div (x, y);
+ }
+}
diff --git a/libgcc/config/s390/sfp-machine.h b/libgcc/config/s390/sfp-machine.h
new file mode 100644
index 0000000..960bad7
--- /dev/null
+++ b/libgcc/config/s390/sfp-machine.h
@@ -0,0 +1,89 @@
+/* Copyright (C) 2001-2025 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GCC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if ! __s390x__
+# error "soft-fp implemented for s390x only"
+#endif
+
+#define _FP_W_TYPE_SIZE 64
+#define _FP_W_TYPE unsigned long long
+#define _FP_WS_TYPE signed long long
+#define _FP_I_TYPE long long
+
+typedef int TItype __attribute__ ((mode (TI)));
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
+#define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype))
+
+#define _FP_NANFRAC_H ((_FP_QNANBIT_H << 1) - 1)
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
+
+#define _FP_NANSIGN_H 0
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+#define FP_EX_INVALID 0x01
+#define FP_EX_DIVZERO 0x02
+#define FP_EX_OVERFLOW 0x04
+#define FP_EX_UNDERFLOW 0x08
+#define FP_EX_INEXACT 0x10
+#define FP_EX_ALL \
+ (FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW \
+ | FP_EX_UNDERFLOW | FP_EX_INEXACT)
+
+void __sfp_handle_exceptions (int);
+
+#define FP_HANDLE_EXCEPTIONS \
+ do { \
+ if (__builtin_expect (_fex, 0)) \
+ __sfp_handle_exceptions (_fex); \
+ } while (0)
+
+#define _FP_TININESS_AFTER_ROUNDING 0
+
+#define FP_RND_NEAREST 0x0
+#define FP_RND_ZERO 0x1
+#define FP_RND_PINF 0x2
+#define FP_RND_MINF 0x3
+#define FP_RND_MASK 0x3
+
+#define _FP_DECL_EX \
+ unsigned int _fpcr __attribute__ ((unused)) = FP_RND_NEAREST
+
+#define FP_INIT_ROUNDMODE \
+ do { \
+ __asm__ __volatile__ ("stfpc %0" \
+ : "=m" (_fpcr)); \
+ } while (0)
+
+#define FP_ROUNDMODE (_fpcr & FP_RND_MASK)
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/libgcc/config/s390/t-softfp b/libgcc/config/s390/t-softfp
new file mode 100644
index 0000000..724b15e
--- /dev/null
+++ b/libgcc/config/s390/t-softfp
@@ -0,0 +1,2 @@
+LIB2ADD += $(srcdir)/config/s390/sfp-exceptions.c
+softfp_extras := fixtfbitint floatbitinttf
diff --git a/libgcc/configure b/libgcc/configure
index 1841833..d5e80d2 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -586,6 +586,7 @@ ac_unique_file="static-object.mk"
ac_includes_default='/* none */'
ac_subst_vars='LTLIBOBJS
LIBOBJS
+WERROR
md_unwind_header
md_unwind_def_header
unwind_header
@@ -720,6 +721,7 @@ enable_tm_clone_registry
with_glibc_version
enable_tls
with_gcc_major_version_only
+enable_werror
'
ac_precious_vars='build_alias
host_alias
@@ -1362,6 +1364,7 @@ Optional Features:
installations without PT_GNU_EH_FRAME support
--disable-tm-clone-registry disable TM clone registry
--enable-tls Use thread-local storage [default=yes]
+ --enable-werror build with -Werror for selected targets
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -5789,6 +5792,22 @@ fi
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+ enableval=$enable_werror;
+case ${enable_werror} in
+ no) WERROR="" ;;
+ *) WERROR="-Werror" ;;
+esac
+
+else
+
+WERROR="-Werror"
+
+fi
+
+
+
# We need multilib support.
ac_config_files="$ac_config_files Makefile"
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 85e4f1b..65cd3c6 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -733,6 +733,20 @@ AC_SUBST(md_unwind_header)
AC_SUBST(sfp_machine_header)
AC_SUBST(thread_header)
+AC_ARG_ENABLE(werror,
+[AS_HELP_STRING([--enable-werror],
+ [build with -Werror for selected targets])],
+[
+case ${enable_werror} in
+ no) WERROR="" ;;
+ *) WERROR="-Werror" ;;
+esac
+],
+[
+WERROR="-Werror"
+])
+AC_SUBST(WERROR)
+
# We need multilib support.
AC_CONFIG_FILES([Makefile])
AC_CONFIG_COMMANDS([default],
diff --git a/libgcobol/ChangeLog b/libgcobol/ChangeLog
index 91a3b86..38b6dbc 100644
--- a/libgcobol/ChangeLog
+++ b/libgcobol/ChangeLog
@@ -1,3 +1,22 @@
+2025-08-08 Robert Dubner <rdubner@symas.com>
+
+ * libgcobol.cc (int128_to_field): Switch to the new routine.
+ * stringbin.cc (packed_from_combined): Implement the new routine.
+ (__gg__binary_to_packed): Likewise.
+ * stringbin.h (__gg__binary_to_packed): Likewise.
+
+2025-08-07 Robert Dubner <rdubner@symas.com>
+
+ * Makefile.am: Include new stringbin.cc file.
+ * Makefile.in: Regenerated.
+ * libgcobol.cc (__gg__power_of_ten): Improve error message.
+ (__gg__binary_to_string): Deleted.
+ (__gg__binary_to_string_internal): Deleted.
+ (int128_to_field): Use new conversion routine.
+ (__gg__move): Use new conversion routine.
+ * stringbin.cc: New file. Implements new conversion routine.
+ * stringbin.h: New file. Likewise.
+
2025-07-13 Robert Dubner <rdubner@symas.com>
* common-defs.h (PTRCAST): Moved here from libgcobol.h.
diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am
index 0a17d20..1e3d3432 100644
--- a/libgcobol/Makefile.am
+++ b/libgcobol/Makefile.am
@@ -42,6 +42,7 @@ libgcobol_la_SOURCES = \
intrinsic.cc \
io.cc \
libgcobol.cc \
+ stringbin.cc \
valconv.cc
WARN_CFLAGS = -W -Wall -Wwrite-strings
diff --git a/libgcobol/Makefile.in b/libgcobol/Makefile.in
index 5fdc42c..42dc823 100644
--- a/libgcobol/Makefile.in
+++ b/libgcobol/Makefile.in
@@ -178,7 +178,7 @@ libgcobol_la_LIBADD =
@BUILD_LIBGCOBOL_TRUE@am_libgcobol_la_OBJECTS = charmaps.lo \
@BUILD_LIBGCOBOL_TRUE@ constants.lo gfileio.lo gmath.lo \
@BUILD_LIBGCOBOL_TRUE@ intrinsic.lo io.lo libgcobol.lo \
-@BUILD_LIBGCOBOL_TRUE@ valconv.lo
+@BUILD_LIBGCOBOL_TRUE@ stringbin.lo valconv.lo
libgcobol_la_OBJECTS = $(am_libgcobol_la_OBJECTS)
@BUILD_LIBGCOBOL_TRUE@am_libgcobol_la_rpath = -rpath $(toolexeclibdir)
AM_V_P = $(am__v_P_@AM_V@)
@@ -404,6 +404,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
@BUILD_LIBGCOBOL_TRUE@ intrinsic.cc \
@BUILD_LIBGCOBOL_TRUE@ io.cc \
@BUILD_LIBGCOBOL_TRUE@ libgcobol.cc \
+@BUILD_LIBGCOBOL_TRUE@ stringbin.cc \
@BUILD_LIBGCOBOL_TRUE@ valconv.cc
@BUILD_LIBGCOBOL_TRUE@WARN_CFLAGS = -W -Wall -Wwrite-strings
@@ -526,6 +527,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intrinsic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgcobol.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stringbin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/valconv.Plo@am__quote@
.cc.o:
diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc
index c3d78d4..eac6e31 100644
--- a/libgcobol/libgcobol.cc
+++ b/libgcobol/libgcobol.cc
@@ -72,6 +72,8 @@
#include <sys/time.h>
#include <execinfo.h>
#include "exceptl.h"
+#include "stringbin.h"
+
/* BSD extension. */
#if !defined(LOG_PERROR)
@@ -798,7 +800,7 @@ __gg__power_of_ten(int n)
fprintf(stderr,
"Trying to raise 10 to %d as an int128, which we can't do.\n",
n);
- fprintf(stderr, "The problem is in %s.\n", __func__);
+ fprintf(stderr, "The problem is in %s %s:%d.\n", __func__, __FILE__, __LINE__);
abort();
}
if( n <= MAX_POWER )
@@ -875,56 +877,6 @@ __gg__scale_by_power_of_ten_2(__int128 value, int N)
return value;
}
-extern "C"
-bool
-__gg__binary_to_string(char *result, int digits, __int128 value)
- {
- // The result is not terminated, because this routine is used
- // to put information directly into cblc_field_t::data
- // Our caller has to keep track of whether value was negative.
-
- // Note that this routine operates in the source code-set space; that is
- // the result comes back with zero as an ASCII 0x30, not an EBCDIC 0xF0
-
- if( value < 0 )
- {
- value = -value;
- }
- result += digits-1 ;
- while( digits-- )
- {
- *result-- = value%10 + ascii_zero;
- value /= 10;
- }
- // Should value be non-zero, it means we potentially have a size error
- return value != 0;
- }
-
-extern "C"
-bool
-__gg__binary_to_string_internal(char *result, int digits, __int128 value)
- {
- // The result is not terminated, because this routine is used
- // to put information directly into cblc_field_t::data
- // Our caller has to keep track of whether value was negative.
-
- // Note that this routine operates in the source code-set space; that is
- // the result comes back with zero as an ASCII 0x30, not an EBCDIC 0xF0
-
- if( value < 0 )
- {
- value = -value;
- }
- result += digits-1 ;
- while( digits-- )
- {
- *result-- = (value%10) + internal_zero;
- value /= 10;
- }
- // Should value be non-zero, it means we potentially have a size error
- return value != 0;
- }
-
static bool
value_is_too_big(const cblc_field_t *var,
__int128 value,
@@ -1617,9 +1569,13 @@ int128_to_field(cblc_field_t *var,
// Note that sending a signed value to an alphanumeric strips off
// any plus or minus signs.
+ memset(location, 0, length);
size_error = __gg__binary_to_string_internal(
- PTRCAST(char, location),
- length, value);
+ PTRCAST(char, location),
+ length > MAX_FIXED_POINT_DIGITS
+ ? MAX_FIXED_POINT_DIGITS
+ : length,
+ value);
break;
case FldNumericDisplay:
@@ -1708,7 +1664,7 @@ int128_to_field(cblc_field_t *var,
// At this point, value is scaled to the target's rdigits
- size_error = __gg__binary_to_string(ach, var->digits, value);
+ size_error = __gg__binary_to_string_ascii(ach, var->digits, value);
ach[var->digits] = NULLCH;
// Convert that string according to the PICTURE clause
@@ -1749,7 +1705,7 @@ int128_to_field(cblc_field_t *var,
case FldAlphaEdited:
{
char ach[128];
- size_error = __gg__binary_to_string(ach, length, value);
+ size_error = __gg__binary_to_string_ascii(ach, length, value);
ach[length] = NULLCH;
// Convert that string according to the PICTURE clause
@@ -1763,34 +1719,27 @@ int128_to_field(cblc_field_t *var,
case FldPacked:
{
- static const unsigned char bin2pd[100] =
- {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
- } ;
-
// Convert the binary value to packed decimal.
+ int digits = var->digits;
- // Set the destination bytes to zero
- memset(location, 0, length);
+ // Assume for the moment that the res
unsigned char sign_nybble = 0;
- if( !(var->attr & packed_no_sign_e) )
+ if( var->attr & packed_no_sign_e )
+ {
+ // This is COMP-6 packed decimal, with no sign nybble
+ sign_nybble = 0;
+ }
+ else
{
// This is COMP-3 packed decimal, so we need to make room to the
// right of the final decimal digit for the sign nybble:
value *= 10;
+ digits += 1;
// Figure out what the sign nybble is going to be, and make the
// the value positive:
if(var->attr & signable_e)
{
+ // It is signable, so 0xD for negative, and 0xC for positive
if(value < 0)
{
sign_nybble = 0x0D;
@@ -1803,6 +1752,7 @@ int128_to_field(cblc_field_t *var,
}
else
{
+ // The value is not signable, so the sign nybble is 0xF
sign_nybble = 0x0F;
if(value < 0)
{
@@ -1810,43 +1760,25 @@ int128_to_field(cblc_field_t *var,
}
}
}
- // ploc points to the current rightmost byte of the location:
- unsigned char *ploc = location + length -1 ;
- // Build the target from right to left, so that the result is
- // big-endian:
- while( value && ploc >= location )
- {
- *ploc-- = bin2pd[value%100];
- value /= 100;
- }
+ /* We need to check if the value is too big, in case our caller
+ wants to check for the error condition. In any event, we need
+ to make sure the value actually fits, because otherwise the
+ result might have a bad high-place digit for a value with an
+ odd number of places. */
+
+ __int128 mask = __gg__power_of_ten(digits);
+ size_error = !!(value / mask);
+ value %= mask;
+ // We are now set up to do the conversion:
+ __gg__binary_to_packed(location, digits, value);
+
// We can put the sign nybble into place at this point. Note that
// for COMP-6 numbers the sign_nybble value is zero, so the next
// operation is harmless.
location[length -1] |= sign_nybble;
- // If we still have value left, we have a size error
- if( value )
- {
- size_error = true;
- }
- else
- {
- if( ( sign_nybble && !(var->digits&1) )
- || ( !sign_nybble && (var->digits&1) ) )
- {
- // This is either
- // comp-3 with an even number of digits, or
- // comp-6 with an odd number of digits.
- // Either way, the first byte of the target has to have a high
- // nybble of zero. If it's non-zero, then we have a size error:
- if( location[0] & 0xF0 )
- {
- size_error = true;
- }
- }
- }
// And we're done.
break;
}
@@ -6126,7 +6058,7 @@ __gg__move( cblc_field_t *fdest,
// Convert it to the full complement of digits available
// from the source...but no more
- __gg__binary_to_string(ach, source_digits, value);
+ __gg__binary_to_string_ascii(ach, source_digits, value);
// Binary to string returns ASCII characters:
for(int i=0; i<source_digits; i++)
diff --git a/libgcobol/stringbin.cc b/libgcobol/stringbin.cc
new file mode 100644
index 0000000..2cc229e
--- /dev/null
+++ b/libgcobol/stringbin.cc
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2021-2025 Symas Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Symas Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <algorithm>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <set>
+#include <stack>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include <dirent.h>
+#include <dlfcn.h>
+#include <err.h>
+#include <fcntl.h>
+#include <fenv.h>
+#include <math.h> // required for fpclassify(3), not in cmath
+#include <setjmp.h>
+#include <signal.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <stdarg.h>
+#if __has_include(<errno.h>)
+# include <errno.h> // for program_invocation_short_name
+#endif
+
+#include "config.h"
+#include "libgcobol-fp.h"
+
+#include "ec.h"
+#include "common-defs.h"
+#include "io.h"
+#include "gcobolio.h"
+#include "libgcobol.h"
+#include "gfileio.h"
+#include "charmaps.h"
+#include "valconv.h"
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <execinfo.h>
+#include "exceptl.h"
+#include "stringbin.h"
+
+/* This routine evolved from a primitive binary-to-string routine that simply
+ peeled digits off the bottom of an __int128 by using
+
+ value % 10 + '0';
+ value /= 10;
+
+ That turns out to be unnecessarily slow.
+
+ The routine implemented here uses a divide-and-conquer approach to
+ minimimizing the number of operations, and when you get down to two
+ digits it does a divide-by-100 and uses the remainder in a table lookup
+ to get the digits. */
+
+/* These static tables are born of a pathologic desire to avoid calculations.
+ Whether that paranoia is justified (perhaps "digit%10 + '0';" ) would
+ actually be faster) is currently untested. But I figured this would be
+ pretty darn fast.
+
+ Use them when you know the index is between zero and one hundred. */
+
+static const char digit_low[100] =
+ {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ };
+
+static const char digit_high[100] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ };
+
+static char combined_string[128];
+static char zero_char;
+
+typedef struct
+ {
+ int start;
+ int run;
+ union
+ {
+ unsigned __int128 val128;
+ uint64_t val64;
+ uint32_t val32;
+ uint16_t val16;
+ uint8_t val8;
+ };
+ } COMBINED;
+
+static
+void
+string_from_combined(const COMBINED &combined)
+ {
+ COMBINED left;
+ COMBINED right;
+
+ uint16_t v16;
+
+ switch(combined.run)
+ {
+ case 1:
+ // We know that val8 is a single digit
+ combined_string[combined.start] = combined.val8 + zero_char;;
+ break;
+
+ case 2:
+ // We know that val8 has two digits
+ combined_string[combined.start] = digit_high[combined.val8] + zero_char;
+ combined_string[combined.start+1] = digit_low [combined.val8] + zero_char;
+ break;
+
+ case 3:
+ // We know that val16 has three digits.
+ v16 = combined.val16;
+ combined_string[combined.start] = v16 / 100 + zero_char;
+ v16 %= 100;
+ combined_string[combined.start+1] = v16 / 10 + zero_char;
+ combined_string[combined.start+2] = v16 % 10 + zero_char;
+ break;
+
+ case 4:
+ // We know that val16 has four digits:
+ v16 = combined.val16;
+ combined_string[combined.start] = v16 / 1000 + zero_char;
+ v16 %= 1000;
+ combined_string[combined.start+1] = v16 / 100 + zero_char;
+ v16 %= 100;
+ combined_string[combined.start+2] = v16 / 10 + zero_char;
+ combined_string[combined.start+3] = v16 % 10 + zero_char;
+ break;
+
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ // We know that val32 can be treated as two 4-digit pieces
+ left.start = combined.start;
+ left.run = combined.run - 4;
+ left.val16 = combined.val32 / 10000;
+
+ right.start = combined.start+left.run;
+ right.run = 4;
+ right.val16 = combined.val32 % 10000;
+
+ string_from_combined(left);
+ string_from_combined(right);
+ break;
+
+ case 9:
+ // We break val32 into a 1-digit piece, and an 8-digit piece:
+ left.start = combined.start;
+ left.run = combined.run - 8;
+ left.val32 = combined.val32 / 100000000;
+
+ right.start = combined.start+left.run;
+ right.run = 8;
+ right.val32 = combined.val32 % 100000000;
+
+ string_from_combined(left);
+ string_from_combined(right);
+ break;
+
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ // We know we can treat val64 as two 9-digit pieces:
+ left.start = combined.start;
+ left.run = combined.run - 9;
+ left.val32 = combined.val64 / 1000000000;
+
+ right.start = combined.start+left.run;
+ right.run = 9;
+ right.val32 = combined.val64 % 1000000000;
+
+ string_from_combined(left);
+ string_from_combined(right);
+ break;
+
+ case 19:
+ // We split off the bottom nine digits
+ left.start = combined.start;
+ left.run = combined.run - 9;
+ left.val64 = combined.val64 / 1000000000;
+
+ right.start = combined.start+left.run;
+ right.run = 9;
+ right.val32 = combined.val64 % 1000000000;
+
+ string_from_combined(left);
+ string_from_combined(right);
+ break;
+
+ default:
+ // For twenty or more digits we peel eighteen digits at a time off the
+ // right side:
+ left.start = combined.start;
+ left.run = combined.run - 18;
+ left.val128 = combined.val128 / 1000000000000000000ULL;
+
+ right.start = combined.start+left.run;
+ right.run = 18;
+ right.val64 = combined.val128 % 1000000000000000000ULL;
+
+ string_from_combined(left);
+ string_from_combined(right);
+ break;
+ }
+ }
+
+bool
+__gg__binary_to_string_ascii(char *result, int digits, __int128 value)
+ {
+ zero_char = ascii_zero;
+
+ // Note that this routine does not terminate the generated string with a
+ // NUL. This routine is sometimes used to generate a NumericDisplay string
+ // of digits in place, with no terminator.
+ __int128 mask = __gg__power_of_ten(digits);
+
+ COMBINED combined;
+ if( value < 0 )
+ {
+ value = -value;
+ }
+
+ // A non-zero retval means the number was too big to fit into the desired
+ // number of digits:
+ bool retval = !!(value / mask);
+
+ // mask off the bottom digits to avoid garbage when value is too large
+ value %= mask;
+
+ combined.start = 0;
+ combined.run = digits;
+ combined.val128 = value;
+ string_from_combined(combined);
+ memcpy(result, combined_string, digits);
+ return retval;
+ }
+
+bool
+__gg__binary_to_string_internal(char *result, int digits, __int128 value)
+ {
+ zero_char = internal_zero;
+
+ // Note that this routine does not terminate the generated string with a
+ // NUL. This routine is sometimes used to generate a NumericDisplay string
+ // of digits in place, with no terminator.
+ __int128 mask = __gg__power_of_ten(digits);
+
+ COMBINED combined;
+ if( value < 0 )
+ {
+ value = -value;
+ }
+
+ // A non-zero retval means the number was too big to fit into the desired
+ // number of digits:
+ bool retval = !!(value / mask);
+
+ // mask off the bottom digits to avoid garbage when value is too large
+ value %= mask;
+
+ combined.start = 0;
+ combined.run = digits;
+ combined.val128 = value;
+ string_from_combined(combined);
+ memcpy(result, combined_string, digits);
+ return retval;
+ }
+
+
+static
+void
+packed_from_combined(COMBINED &combined)
+ {
+ /* The combined.value must be positive at this point.
+
+ The combined.run value has to be the number of places needed to hold
+ combined.value. The proper calculation is (digits+1)/2.
+
+ For a signable value, the caller had to multiple the original value by
+ ten to create room on the right for the sign nybble. */
+
+ static const unsigned char bin2pd[100] =
+ {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
+ } ;
+
+ COMBINED left;
+ COMBINED right;
+
+ switch(combined.run)
+ {
+ case 1:
+ // We know that val8 has two digits.
+ combined_string[combined.start] = bin2pd[combined.val8];
+ break;
+
+ case 2:
+ // We know that val16 has four digits.
+ combined_string[combined.start ] = bin2pd[combined.val16/100];
+ combined_string[combined.start+1] = bin2pd[combined.val16%100];
+ break;
+
+ case 3:
+ case 4:
+ // We know that val32 can hold up to eight digits. Break it in half.
+ left.start = combined.start;
+ left.run = combined.run - 2;
+ left.val16 = combined.val32 / 10000;
+
+ right.start = combined.start+left.run;
+ right.run = 2;
+ right.val16 = combined.val32 % 10000;
+
+ packed_from_combined(left);
+ packed_from_combined(right);
+ break;
+
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ // We know that val64 is holding up to 18 digits. Break it into two
+ // eight-digit places that can each go into a val23
+ left.start = combined.start;
+ left.run = combined.run - 4;
+ left.val32 = combined.val64 / 100000000;
+
+ right.start = combined.start+left.run;
+ right.run = 4;
+ right.val32 = combined.val64 % 100000000;
+
+ packed_from_combined(left);
+ packed_from_combined(right);
+ break;
+
+ case 9:
+ // We know that val64 is holding 17 or 18 digits. Break off the
+ // bottom eight.
+ left.start = combined.start;
+ left.run = combined.run - 4;
+ left.val64 = combined.val64 / 100000000;
+
+ right.start = combined.start+left.run;
+ right.run = 4;
+ right.val32 = combined.val64 % 100000000;
+
+ packed_from_combined(left);
+ packed_from_combined(right);
+ break;
+
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ // We know that val64 is holding between 18 and 36 digits. Break it
+ // two val64:
+
+ left.start = combined.start;
+ left.run = combined.run - 9;
+ left.val64 = combined.val128 / 1000000000000000000ULL;
+
+ right.start = combined.start+left.run;
+ right.run = 9;
+ right.val64 = combined.val128 % 1000000000000000000ULL;
+
+ packed_from_combined(left);
+ packed_from_combined(right);
+ break;
+
+ default:
+ // For twenty or more digits we peel eighteen digits at a time off the
+ // right side:
+ left.start = combined.start;
+ left.run = combined.run - 9;
+ left.val128 = combined.val128 / 1000000000000000000ULL;
+
+ right.start = combined.start+left.run;
+ right.run = 9;
+ right.val64 = combined.val128 % 1000000000000000000ULL;
+
+ packed_from_combined(left);
+ packed_from_combined(right);
+ break;
+ }
+ }
+
+extern "C"
+void
+__gg__binary_to_packed( unsigned char *result,
+ int digits,
+ __int128 value)
+ {
+ size_t length = (digits+1)/2;
+
+ COMBINED combined;
+ combined.start = 0;
+ combined.run = length;
+ combined.val128 = value;
+ packed_from_combined(combined);
+ memcpy(result, combined_string, length);
+ }
diff --git a/libgcobol/stringbin.h b/libgcobol/stringbin.h
new file mode 100644
index 0000000..5ddb441
--- /dev/null
+++ b/libgcobol/stringbin.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021-2025 Symas Corporation
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of the Symas Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef STRINGBIN_H_
+#define STRINGBIN_H_
+
+extern "C"
+bool __gg__binary_to_string_ascii(char *result,
+ int digits,
+ __int128 value);
+extern "C"
+bool __gg__binary_to_string_internal( char *result,
+ int digits,
+ __int128 value);
+
+extern "C"
+void __gg__binary_to_packed( unsigned char *result,
+ int digits,
+ __int128 value);
+
+#endif
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index ea41616..440a32a 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2025-08-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/121234
+ * io/list_read.c (read_character): Add checks to bypass eating
+ semicolons when reading strings with decimal mode 'point'
+ (list_formatted_read_scalar): Likewise.
+
2025-07-30 Yuao Ma <c8ef@outlook.com>
* gfortran.map: Add split symbol.
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 2689f3e..722da76 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,23 @@
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+
+ * target.c (gomp_update): Call gomp_merge_iterator_maps. Free
+ allocated variables.
+ * testsuite/libgomp.c-c++-common/target-update-iterators-1.c: New.
+ * testsuite/libgomp.c-c++-common/target-update-iterators-2.c: New.
+ * testsuite/libgomp.c-c++-common/target-update-iterators-3.c: New.
+
+2025-08-06 Kwok Cheung Yeung <kcyeung@baylibre.com>
+ Andrew Stubbs <ams@baylibre.com>
+
+ * target.c (kind_to_name): New.
+ (gomp_merge_iterator_maps): New.
+ (gomp_map_vars_internal): Call gomp_merge_iterator_maps. Copy
+ address of only the first iteration to target vars. Free allocated
+ variables.
+ * testsuite/libgomp.c-c++-common/target-map-iterators-1.c: New.
+ * testsuite/libgomp.c-c++-common/target-map-iterators-2.c: New.
+ * testsuite/libgomp.c-c++-common/target-map-iterators-3.c: New.
+
2025-07-21 Thomas Schwinge <tschwinge@baylibre.com>
PR target/119853
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index cf90917..b072d0b 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2025-08-06 Matthieu Longo <matthieu.longo@arm.com>
+
+ * testsuite/test-doubly-linked-list.c: disable debug logging on
+ stdout.
+
2025-07-09 Matthieu Longo <matthieu.longo@arm.com>
* Makefile.in: Add new header.
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 09ee090..72a8610 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-07 Gerald Pfeifer <gerald@pfeifer.com>
+
+ * doc/xml/manual/build_hacking.xml: Switch gcc.gnu.org installation
+ docs to https.
+ * doc/html/manual/appendix_porting.html: Regenerate.
+
2025-08-05 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/121373
diff --git a/libstdc++-v3/doc/html/manual/appendix_porting.html b/libstdc++-v3/doc/html/manual/appendix_porting.html
index 887fa50..7b63613 100644
--- a/libstdc++-v3/doc/html/manual/appendix_porting.html
+++ b/libstdc++-v3/doc/html/manual/appendix_porting.html
@@ -26,7 +26,7 @@ Support for C++11 dialect.
</a></span></dt><dt><span class="section"><a href="backwards.html#backwards.third.iterator_type">
<code class="code">Container::iterator_type</code> is not necessarily <code class="code">Container::value_type*</code>
</a></span></dt></dl></dd></dl></dd></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="appendix.porting.build_hacking"></a>Configure and Build Hacking</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="build_hacking.prereq"></a>Prerequisites</h3></div></div></div><p>
- As noted <a class="link" href="http://gcc.gnu.org/install/prerequisites.html" target="_top">previously</a>,
+ As noted <a class="link" href="https://gcc.gnu.org/install/prerequisites.html" target="_top">previously</a>,
certain other tools are necessary for hacking on files that
control configure (<code class="code">configure.ac</code>,
<code class="code">acinclude.m4</code>) and make
diff --git a/libstdc++-v3/doc/xml/manual/build_hacking.xml b/libstdc++-v3/doc/xml/manual/build_hacking.xml
index 20de49f..4c044d9 100644
--- a/libstdc++-v3/doc/xml/manual/build_hacking.xml
+++ b/libstdc++-v3/doc/xml/manual/build_hacking.xml
@@ -17,7 +17,7 @@
<section xml:id="build_hacking.prereq"><info><title>Prerequisites</title></info>
<para>
- As noted <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/install/prerequisites.html">previously</link>,
+ As noted <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/install/prerequisites.html">previously</link>,
certain other tools are necessary for hacking on files that
control configure (<code>configure.ac</code>,
<code>acinclude.m4</code>) and make