<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git, branch trunk</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/'/>
<entry>
<title>changelog: Add algol68 as a bugzilla component</title>
<updated>2025-11-22T20:48:56+00:00</updated>
<author>
<name>Andrew Pinski</name>
<email>andrew.pinski@oss.qualcomm.com</email>
</author>
<published>2025-11-22T20:46:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=70789a03fb337d967e57b25c56d1097fff5952e6'/>
<id>70789a03fb337d967e57b25c56d1097fff5952e6</id>
<content type='text'>
Adds algol68 as a bugzilla component for commits.

Pushed as obvious.

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Add algol68.

Signed-off-by: Andrew Pinski &lt;andrew.pinski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Adds algol68 as a bugzilla component for commits.

Pushed as obvious.

contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Add algol68.

Signed-off-by: Andrew Pinski &lt;andrew.pinski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[PR 122701] Emit fresh reg-&gt;reg copy rather than modifying existing insnO</title>
<updated>2025-11-22T18:37:45+00:00</updated>
<author>
<name>Jeff Law</name>
<email>jlaw@ventanamicro.com</email>
</author>
<published>2025-11-22T18:33:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=f73b1b0831fe8f071761cc2c6696d92e258d2b4f'/>
<id>f73b1b0831fe8f071761cc2c6696d92e258d2b4f</id>
<content type='text'>
I took an ill-advised short-cut with the recent ext-dce improvement to detect
certain shift pairs as sign/zero extensions.  Specifically I was adjusting the
SET_SRC of an object.

Often we can get away with that, but as this case shows it's simply not safe
for RTL.  The core issue is the right shift we're modifying into a simple
reg-&gt;reg move may have things like CLOBBERs outside the set resulting in

(parallel
  (set (dstreg) (srcreg))
  (clobber (whatever)))

Even that is often OK as targets which have these kinds of clobbers often need them on their basic moves because those moves often set condition codes.  But that's not true for GCN.

On GCN that transformation leads to an unrecognizable insn as seen in the pr.
The fix is pretty simple.  Just emit a new move and delete the shift.  Of
course we have to be prepared to handle multiple insns once we use
emit_move_insn, but that's not too bad.

	PR rtl-optimization/122701
gcc/
	* ext-dce.cc (ext_dce_try_optimize_rshift): Emit a fresh reg-&gt;reg
	copy rather than modifying the existing right shift.

gcc/testsuite/
	* gcc.dg/torture/pr122701.c: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I took an ill-advised short-cut with the recent ext-dce improvement to detect
certain shift pairs as sign/zero extensions.  Specifically I was adjusting the
SET_SRC of an object.

Often we can get away with that, but as this case shows it's simply not safe
for RTL.  The core issue is the right shift we're modifying into a simple
reg-&gt;reg move may have things like CLOBBERs outside the set resulting in

(parallel
  (set (dstreg) (srcreg))
  (clobber (whatever)))

Even that is often OK as targets which have these kinds of clobbers often need them on their basic moves because those moves often set condition codes.  But that's not true for GCN.

On GCN that transformation leads to an unrecognizable insn as seen in the pr.
The fix is pretty simple.  Just emit a new move and delete the shift.  Of
course we have to be prepared to handle multiple insns once we use
emit_move_insn, but that's not too bad.

	PR rtl-optimization/122701
gcc/
	* ext-dce.cc (ext_dce_try_optimize_rshift): Emit a fresh reg-&gt;reg
	copy rather than modifying the existing right shift.

gcc/testsuite/
	* gcc.dg/torture/pr122701.c: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: Update docs for "begin declare variant" implementation status</title>
<updated>2025-11-22T17:05:23+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=f28f1c519db9eaf9d24ac61dc73a9899bf99ccfc'/>
<id>f28f1c519db9eaf9d24ac61dc73a9899bf99ccfc</id>
<content type='text'>
libgomp/ChangeLog
	* libgomp.texi (OpenMP 5.1): Update "begin declare variant" status.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
libgomp/ChangeLog
	* libgomp.texi (OpenMP 5.1): Update "begin declare variant" status.
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: C/C++ common testcases for "omp begin declare variant"</title>
<updated>2025-11-22T17:05:23+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=bd6d591799385b326b3589071b8cfa0bb61a9d19'/>
<id>bd6d591799385b326b3589071b8cfa0bb61a9d19</id>
<content type='text'>
gcc/testsuite/ChangeLog
	* c-c++-common/gomp/delim-declare-variant-1.c: New.
	* c-c++-common/gomp/delim-declare-variant-2.c: New.
	* c-c++-common/gomp/delim-declare-variant-3.c: New.
	* c-c++-common/gomp/delim-declare-variant-4.c: New.
	* c-c++-common/gomp/delim-declare-variant-5.c: New.
	* c-c++-common/gomp/delim-declare-variant-6.c: New.
	* c-c++-common/gomp/delim-declare-variant-7.c: New.
	* c-c++-common/gomp/delim-declare-variant-8.c: New.
	* c-c++-common/gomp/delim-declare-variant-9.c: New.

libgomp/ChangeLog
	* testsuite/libgomp.c-c++-common/delim-declare-variant-1.c: New.
	* testsuite/libgomp.c-c++-common/delim-declare-variant-2.c: New.

Co-Authored-By: Tobias Burnus &lt;tburnus@baylibre.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
gcc/testsuite/ChangeLog
	* c-c++-common/gomp/delim-declare-variant-1.c: New.
	* c-c++-common/gomp/delim-declare-variant-2.c: New.
	* c-c++-common/gomp/delim-declare-variant-3.c: New.
	* c-c++-common/gomp/delim-declare-variant-4.c: New.
	* c-c++-common/gomp/delim-declare-variant-5.c: New.
	* c-c++-common/gomp/delim-declare-variant-6.c: New.
	* c-c++-common/gomp/delim-declare-variant-7.c: New.
	* c-c++-common/gomp/delim-declare-variant-8.c: New.
	* c-c++-common/gomp/delim-declare-variant-9.c: New.

libgomp/ChangeLog
	* testsuite/libgomp.c-c++-common/delim-declare-variant-1.c: New.
	* testsuite/libgomp.c-c++-common/delim-declare-variant-2.c: New.

Co-Authored-By: Tobias Burnus &lt;tburnus@baylibre.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: C front end support for "begin declare variant"</title>
<updated>2025-11-22T17:05:23+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=5a1a48d3af1001ead74f534b69681579f2586684'/>
<id>5a1a48d3af1001ead74f534b69681579f2586684</id>
<content type='text'>
gcc/c/ChangeLog
	* c-decl.cc (current_omp_declare_variant_attribute): Define.
	* c-lang.h (struct c_omp_declare_variant_attr): Declare.
	(current_omp_declare_variant_attribute): Declare.
	* c-parser.cc (struct omp_begin_declare_variant_map_entry): New.
	(omp_begin_declare_variant_map): New.
	(c_parser_skip_to_pragma_omp_end_declare_variant): New.
	(c_parser_translation_unit): Check for "omp begin declare variant"
	with no matching "end".  Record base functions for variants.
	(c_parser_declaration_or_fndef): Handle functions in "omp begin
	declare variant" block.
	(c_finish_omp_declare_variant): Merge context selectors with
	surrounding "omp begin declare variant".
	(JOIN_STR): Define.
	(omp_start_variant_function): New.
	(omp_finish_variant_function): New.
	(c_parser_omp_begin): Handle "omp begin declare variant".
	(c_parser_omp_end): Likewise.

Co-Authored-By: Julian Brown &lt;julian@codesourcery.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
gcc/c/ChangeLog
	* c-decl.cc (current_omp_declare_variant_attribute): Define.
	* c-lang.h (struct c_omp_declare_variant_attr): Declare.
	(current_omp_declare_variant_attribute): Declare.
	* c-parser.cc (struct omp_begin_declare_variant_map_entry): New.
	(omp_begin_declare_variant_map): New.
	(c_parser_skip_to_pragma_omp_end_declare_variant): New.
	(c_parser_translation_unit): Check for "omp begin declare variant"
	with no matching "end".  Record base functions for variants.
	(c_parser_declaration_or_fndef): Handle functions in "omp begin
	declare variant" block.
	(c_finish_omp_declare_variant): Merge context selectors with
	surrounding "omp begin declare variant".
	(JOIN_STR): Define.
	(omp_start_variant_function): New.
	(omp_finish_variant_function): New.
	(c_parser_omp_begin): Handle "omp begin declare variant".
	(c_parser_omp_end): Likewise.

Co-Authored-By: Julian Brown &lt;julian@codesourcery.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: C++ front end support for "begin declare variant"</title>
<updated>2025-11-22T17:05:22+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=a469cf3df2ac97944a44948891e9fe22ba2f1d10'/>
<id>a469cf3df2ac97944a44948891e9fe22ba2f1d10</id>
<content type='text'>
This patch implements C++ support for the "begin declare variant"
construct.  The OpenMP specification is hazy on interaction of this
feature with C++ language features.  Variant functions in classes are
supported but must be defined as members in the class definition,
using an unqualified name for the base function which also must be
present in that class.  Similarly variant functions in a namespace can
only be defined in that namespace using an unqualified name for a base
function already declared in that namespace.  Variants for template
functions or inside template classes seem to (mostly) work.

gcc/c-family/ChangeLog
	* c-omp.cc (c_omp_directives): Uncomment "begin declare variant"
	and "end declare variant".

gcc/cp/ChangeLog
	* cp-tree.h (struct cp_omp_declare_variant_attr): New.
	(struct saved_scope): Add omp_declare_variant_attribute field.
	* decl.cc (omp_declare_variant_finalize_one): Add logic to inject
	"this" parameter for method calls.
	* parser.cc (cp_parser_skip_to_pragma_omp_end_declare_variant): New.
	(cp_parser_translation_unit): Handle leftover "begin declare variant"
	functions.
	(omp_start_variant_function): New.
	(omp_finish_variant_function): New.
	(omp_maybe_record_variant_base): New.
	(cp_parser_init_declarator): Handle variant functions.
	(cp_parser_class_specifier): Handle deferred lookup of base functions
	when the entire class has been seen.
	(cp_parser_member_declaration): Handle variant functions.
	(cp_finish_omp_declare_variant): Merge context selectors if in
	a "begin declare variant" block.
	(cp_parser_omp_begin): Match "omp begin declare variant".  Adjust
	error messages.
	(cp_parser_omp_end): Match "omp end declare variant".
	* parser.h (struct omp_begin_declare_variant_map_entry): New.
	(struct cp_parser): Add omp_begin_declare_variant_map field.
	* semantics.cc (finish_translation_unit): Detect unmatched
	"omp begin declare variant".

gcc/testsuite/ChangeLog
	* g++.dg/gomp/delim-declare-variant-1.C: New.
	* g++.dg/gomp/delim-declare-variant-2.C: New.
	* g++.dg/gomp/delim-declare-variant-3.C: New.
	* g++.dg/gomp/delim-declare-variant-4.C: New.
	* g++.dg/gomp/delim-declare-variant-5.C: New.
	* g++.dg/gomp/delim-declare-variant-6.C: New.
	* g++.dg/gomp/delim-declare-variant-7.C: New.
	* g++.dg/gomp/delim-declare-variant-40.C: New.
	* g++.dg/gomp/delim-declare-variant-41.C: New.
	* g++.dg/gomp/delim-declare-variant-50.C: New.
	* g++.dg/gomp/delim-declare-variant-51.C: New.
	* g++.dg/gomp/delim-declare-variant-52.C: New.
	* g++.dg/gomp/delim-declare-variant-70.C: New.
	* g++.dg/gomp/delim-declare-variant-71.C: New.

libgomp/
	* testsuite/libgomp.c++/bdv_module1.C: New.
	* testsuite/libgomp.c++/bdv_module1_main.C: New.
	* testsuite/libgomp.c++/bdv_module2.C: New.
	* testsuite/libgomp.c++/bdv_module2_impl.C: New.
	* testsuite/libgomp.c++/bdv_module2_main.C: New.
	* testsuite/libgomp.c++/bdv_module3.C: New.
	* testsuite/libgomp.c++/bdv_module3_impl.C: New.
	* testsuite/libgomp.c++/bdv_module3_main.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-1.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-2.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-7.C: New.

Co-Authored-By: Julian Brown &lt;julian@codesourcery.com&gt;
Co-Authored-By: waffl3x &lt;waffl3x@baylibre.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch implements C++ support for the "begin declare variant"
construct.  The OpenMP specification is hazy on interaction of this
feature with C++ language features.  Variant functions in classes are
supported but must be defined as members in the class definition,
using an unqualified name for the base function which also must be
present in that class.  Similarly variant functions in a namespace can
only be defined in that namespace using an unqualified name for a base
function already declared in that namespace.  Variants for template
functions or inside template classes seem to (mostly) work.

gcc/c-family/ChangeLog
	* c-omp.cc (c_omp_directives): Uncomment "begin declare variant"
	and "end declare variant".

gcc/cp/ChangeLog
	* cp-tree.h (struct cp_omp_declare_variant_attr): New.
	(struct saved_scope): Add omp_declare_variant_attribute field.
	* decl.cc (omp_declare_variant_finalize_one): Add logic to inject
	"this" parameter for method calls.
	* parser.cc (cp_parser_skip_to_pragma_omp_end_declare_variant): New.
	(cp_parser_translation_unit): Handle leftover "begin declare variant"
	functions.
	(omp_start_variant_function): New.
	(omp_finish_variant_function): New.
	(omp_maybe_record_variant_base): New.
	(cp_parser_init_declarator): Handle variant functions.
	(cp_parser_class_specifier): Handle deferred lookup of base functions
	when the entire class has been seen.
	(cp_parser_member_declaration): Handle variant functions.
	(cp_finish_omp_declare_variant): Merge context selectors if in
	a "begin declare variant" block.
	(cp_parser_omp_begin): Match "omp begin declare variant".  Adjust
	error messages.
	(cp_parser_omp_end): Match "omp end declare variant".
	* parser.h (struct omp_begin_declare_variant_map_entry): New.
	(struct cp_parser): Add omp_begin_declare_variant_map field.
	* semantics.cc (finish_translation_unit): Detect unmatched
	"omp begin declare variant".

gcc/testsuite/ChangeLog
	* g++.dg/gomp/delim-declare-variant-1.C: New.
	* g++.dg/gomp/delim-declare-variant-2.C: New.
	* g++.dg/gomp/delim-declare-variant-3.C: New.
	* g++.dg/gomp/delim-declare-variant-4.C: New.
	* g++.dg/gomp/delim-declare-variant-5.C: New.
	* g++.dg/gomp/delim-declare-variant-6.C: New.
	* g++.dg/gomp/delim-declare-variant-7.C: New.
	* g++.dg/gomp/delim-declare-variant-40.C: New.
	* g++.dg/gomp/delim-declare-variant-41.C: New.
	* g++.dg/gomp/delim-declare-variant-50.C: New.
	* g++.dg/gomp/delim-declare-variant-51.C: New.
	* g++.dg/gomp/delim-declare-variant-52.C: New.
	* g++.dg/gomp/delim-declare-variant-70.C: New.
	* g++.dg/gomp/delim-declare-variant-71.C: New.

libgomp/
	* testsuite/libgomp.c++/bdv_module1.C: New.
	* testsuite/libgomp.c++/bdv_module1_main.C: New.
	* testsuite/libgomp.c++/bdv_module2.C: New.
	* testsuite/libgomp.c++/bdv_module2_impl.C: New.
	* testsuite/libgomp.c++/bdv_module2_main.C: New.
	* testsuite/libgomp.c++/bdv_module3.C: New.
	* testsuite/libgomp.c++/bdv_module3_impl.C: New.
	* testsuite/libgomp.c++/bdv_module3_main.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-1.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-2.C: New.
	* testsuite/libgomp.c++/delim-declare-variant-7.C: New.

Co-Authored-By: Julian Brown &lt;julian@codesourcery.com&gt;
Co-Authored-By: waffl3x &lt;waffl3x@baylibre.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: Add flag for code elision to omp_context_selector_matches.</title>
<updated>2025-11-22T17:05:22+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=31107ba466715f3f662e9ddcefd5c33c483d0a31'/>
<id>31107ba466715f3f662e9ddcefd5c33c483d0a31</id>
<content type='text'>
The "begin declare variant" has different rules for determining
whether a context selector cannot match for purposes of code elision
than we normally use; it excludes the case of a constant false
"condition" selector for the "user" set.

gcc/ChangeLog
	* omp-general.cc (omp_context_selector_matches): Add an optional
	bool argument for the code elision case.
	* omp-general.h (omp_context_selector_matches): Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The "begin declare variant" has different rules for determining
whether a context selector cannot match for purposes of code elision
than we normally use; it excludes the case of a constant false
"condition" selector for the "user" set.

gcc/ChangeLog
	* omp-general.cc (omp_context_selector_matches): Add an optional
	bool argument for the code elision case.
	* omp-general.h (omp_context_selector_matches): Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: Support functions for nested "begin declare variant"</title>
<updated>2025-11-22T17:05:21+00:00</updated>
<author>
<name>Sandra Loosemore</name>
<email>sloosemore@baylibre.com</email>
</author>
<published>2025-11-20T21:45:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=77b8221af8fc827a95b08a381bf5b2a43b3b2ba5'/>
<id>77b8221af8fc827a95b08a381bf5b2a43b3b2ba5</id>
<content type='text'>
This patch adds functions for variant name mangling and context selector
merging that are shared by the C and C++ front ends.

The OpenMP specification says that name mangling is supposed to encode
the context selector for the variant, but also provides for no way to
reference these functions directly by name or from a different
compilation unit.  It also gives no guidance on how dynamic selectors
might be encoded across compilation units.

The GCC implementation of this feature instead treats variant
functions as if they have no linkage and uses a simple counter to
generate names.  The exception is variants declared in a module interface,
which are given module linkage.

gcc/ChangeLog
	* omp-general.cc (omp_mangle_variant_name): New.
	(omp_check_for_duplicate_variant): New.
	(omp_copy_trait_set): New.
	(omp_trait_selectors_equivalent): New.
	(omp_combine_trait_sets): New.
	(omp_merge_context_selectors): New.
	* omp-general.h (omp_mangle_variant_name): Declare.
	(omp_check_for_duplicate_variant): Declare.
	(omp_merge_context_selectors): Declare.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds functions for variant name mangling and context selector
merging that are shared by the C and C++ front ends.

The OpenMP specification says that name mangling is supposed to encode
the context selector for the variant, but also provides for no way to
reference these functions directly by name or from a different
compilation unit.  It also gives no guidance on how dynamic selectors
might be encoded across compilation units.

The GCC implementation of this feature instead treats variant
functions as if they have no linkage and uses a simple counter to
generate names.  The exception is variants declared in a module interface,
which are given module linkage.

gcc/ChangeLog
	* omp-general.cc (omp_mangle_variant_name): New.
	(omp_check_for_duplicate_variant): New.
	(omp_copy_trait_set): New.
	(omp_trait_selectors_equivalent): New.
	(omp_combine_trait_sets): New.
	(omp_merge_context_selectors): New.
	* omp-general.h (omp_mangle_variant_name): Declare.
	(omp_check_for_duplicate_variant): Declare.
	(omp_merge_context_selectors): Declare.
</pre>
</div>
</content>
</entry>
<entry>
<title>c++: Fix up [[maybe_unused]] handling on expansion stmts [PR122788]</title>
<updated>2025-11-22T11:39:09+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2025-11-22T11:39:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=cf865c811be1b83e960b3e661123cb19105d3181'/>
<id>cf865c811be1b83e960b3e661123cb19105d3181</id>
<content type='text'>
This PR complains that [[maybe_unused]] attribute is ignored on
the range-for-declaration of expansion-statement.

We copy DECL_ATTRIBUTES and apply late attributes, but early attributes
don't have their handlers called again, so some extra flags need to be
copied as well.
This copies TREE_USED and DECL_READ_P flags.

2025-11-22  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/122788
	* pt.cc (finish_expansion_stmt): Or in TREE_USED and DECL_READ_P
	flags from range_decl to decl or from corresponding structured binding
	to this_decl.

	* g++.dg/cpp26/expansion-stmt27.C: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR complains that [[maybe_unused]] attribute is ignored on
the range-for-declaration of expansion-statement.

We copy DECL_ATTRIBUTES and apply late attributes, but early attributes
don't have their handlers called again, so some extra flags need to be
copied as well.
This copies TREE_USED and DECL_READ_P flags.

2025-11-22  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/122788
	* pt.cc (finish_expansion_stmt): Or in TREE_USED and DECL_READ_P
	flags from range_decl to decl or from corresponding structured binding
	to this_decl.

	* g++.dg/cpp26/expansion-stmt27.C: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>c++: Readd type checks for cp_fold -ffold-simple-inlines foldings [PR122185]</title>
<updated>2025-11-22T11:24:35+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2025-11-22T11:24:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=fb22d7f3b665555cfb55673ca2b954f860d28b50'/>
<id>fb22d7f3b665555cfb55673ca2b954f860d28b50</id>
<content type='text'>
In GCC15, cp_fold -ffold-simple-inlines code contained
  if (INDIRECT_TYPE_P (TREE_TYPE (x))
      &amp;&amp; INDIRECT_TYPE_P (TREE_TYPE (r)))
check around the optimization, but as std::to_underlying has been
added to the set, it got removed.
Now, the check isn't needed when using correct libstdc++-v3 headers,
because the function template types ensure the converted types are sane
(so for most of them both are some kind of REFERENCE_TYPEs, for addressof
one REFERENCE_TYPE and one POINTER_TYPE, for to_underlying one ENUMERAL_TYPE
and one INTEGRAL_TYPE_P).
But when some fuzzer or user attempts to implement one or more of those
std:: functions and does it wrong (sure, such code is invalid), we can ICE
because build_nop certainly doesn't handle all possible type conversions.

So, the following patch readds the INDIRECT_REF_P &amp;&amp; INDIRECT_REF_P check
for everything but to_underlying, for which it checks ENUMERAL_TYPE to
INTEGRAL_TYPE_P.  That way we don't ICE on bogus code.

Though, I wonder about 2 things, whether the CALL_EXPR_ARG in there
shouldn't be also guarded just in case somebody tries to compile
namespace std { int to_underlying (); }; int a = std::to_underlying ();
and also whether this to_underlying folding doesn't behave differently
from the libstdc++-v3 implementation if the enum is
enum A : bool { B, C };
I think -fno-fold-simple-inlines will compile it as != 0, while
the -ffold-simple-inlines code just as a cast.  Sure, enum with underlying
bool can't contain enumerators with values other than 0 and 1, but it is
still 8-bit at least and so what happens with other values?

2025-11-22  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/122185
	* cp-gimplify.cc (cp_fold) &lt;case CALL_EXPR&gt;: For -ffold-simple-inlines
	restore check that both types are INDIRECT_TYPE_P, except for
	"to_underlying" check that r has ENUMERAL_TYPE and x has
	INTEGRAL_TYPE_P.

	* g++.dg/cpp1z/pr122185.C: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In GCC15, cp_fold -ffold-simple-inlines code contained
  if (INDIRECT_TYPE_P (TREE_TYPE (x))
      &amp;&amp; INDIRECT_TYPE_P (TREE_TYPE (r)))
check around the optimization, but as std::to_underlying has been
added to the set, it got removed.
Now, the check isn't needed when using correct libstdc++-v3 headers,
because the function template types ensure the converted types are sane
(so for most of them both are some kind of REFERENCE_TYPEs, for addressof
one REFERENCE_TYPE and one POINTER_TYPE, for to_underlying one ENUMERAL_TYPE
and one INTEGRAL_TYPE_P).
But when some fuzzer or user attempts to implement one or more of those
std:: functions and does it wrong (sure, such code is invalid), we can ICE
because build_nop certainly doesn't handle all possible type conversions.

So, the following patch readds the INDIRECT_REF_P &amp;&amp; INDIRECT_REF_P check
for everything but to_underlying, for which it checks ENUMERAL_TYPE to
INTEGRAL_TYPE_P.  That way we don't ICE on bogus code.

Though, I wonder about 2 things, whether the CALL_EXPR_ARG in there
shouldn't be also guarded just in case somebody tries to compile
namespace std { int to_underlying (); }; int a = std::to_underlying ();
and also whether this to_underlying folding doesn't behave differently
from the libstdc++-v3 implementation if the enum is
enum A : bool { B, C };
I think -fno-fold-simple-inlines will compile it as != 0, while
the -ffold-simple-inlines code just as a cast.  Sure, enum with underlying
bool can't contain enumerators with values other than 0 and 1, but it is
still 8-bit at least and so what happens with other values?

2025-11-22  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/122185
	* cp-gimplify.cc (cp_fold) &lt;case CALL_EXPR&gt;: For -ffold-simple-inlines
	restore check that both types are INDIRECT_TYPE_P, except for
	"to_underlying" check that r has ENUMERAL_TYPE and x has
	INTEGRAL_TYPE_P.

	* g++.dg/cpp1z/pr122185.C: New test.
</pre>
</div>
</content>
</entry>
</feed>
