<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git/gcc/gimplify.cc, branch master</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>gimplify: Fix ICE in collect_fallthrough_labels [PR122773]</title>
<updated>2025-11-21T10:25:27+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2025-11-21T10:25:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=3012aad2dc6318ab490c4a2511f5b2e4d30652b9'/>
<id>3012aad2dc6318ab490c4a2511f5b2e4d30652b9</id>
<content type='text'>
In r16-4212 I had to tweak two spots in the gimplifier to ignore
gotos jumping to labels with the new VACUOUS_INIT_LABEL_P flag
(set by C++ FE when implementing goto/case interceptors with
extra .DEFERRED_INIT calls, so that jumps over vacuous initialization
are handled properly with the C++26 erroneous behavior requirements).
Except as the following testcase shows, the checks blindly assumed
that gimple_goto_dest operand is a LABEL_DECL, which is not the case
for computed jumps.

The following patch checks that gimple_goto_dest argument is a LABEL_DECL
before testing VACUOUS_INIT_LABEL_P flag on it.

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

	PR middle-end/122773
	* gimplify.cc (collect_fallthrough_labels): Check whether
	gimple_goto_dest is a LABEL_DECL before testing VACUOUS_INIT_LABEL_P.
	(expand_FALLTHROUGH_r): Likewise.

	* gcc.dg/pr122773.c: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In r16-4212 I had to tweak two spots in the gimplifier to ignore
gotos jumping to labels with the new VACUOUS_INIT_LABEL_P flag
(set by C++ FE when implementing goto/case interceptors with
extra .DEFERRED_INIT calls, so that jumps over vacuous initialization
are handled properly with the C++26 erroneous behavior requirements).
Except as the following testcase shows, the checks blindly assumed
that gimple_goto_dest operand is a LABEL_DECL, which is not the case
for computed jumps.

The following patch checks that gimple_goto_dest argument is a LABEL_DECL
before testing VACUOUS_INIT_LABEL_P flag on it.

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

	PR middle-end/122773
	* gimplify.cc (collect_fallthrough_labels): Check whether
	gimple_goto_dest is a LABEL_DECL before testing VACUOUS_INIT_LABEL_P.
	(expand_FALLTHROUGH_r): Likewise.

	* gcc.dg/pr122773.c: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>c++, gimplify: Implement C++26 P2795R5 - Erroneous behavior for uninitialized reads [PR114457]</title>
<updated>2025-10-04T08:23:15+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2025-10-04T07:50:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=f256a13f8aed833fe964a2ba541b7b30ad9b4a76'/>
<id>f256a13f8aed833fe964a2ba541b7b30ad9b4a76</id>
<content type='text'>
The following patch implements the C++26 P2795R5 paper by enabling something
like -ftrivial-auto-var-init=zero by default for -std=c++26/-std=gnu++26.
There is an important difference between explicit -ftrivial-auto-var-init=zero
and the implicitly enabled one, in particular the explicit one will try to
clear padding bits on vars with explicit initializers, while the default
C++26 mode does not - C++26 says that using the padding bits for anything
but copying structures around is still undefined behavior rather than
erroneous behavior.

Users can still override the default C++26 behavior in both directions,
with -ftrivial-auto-var-init=uninitialized even C++26 will act as C++23
with treating all uninitialized var reads (except for copying) as UB rather
than EB, with -ftrivial-auto-var-init=zero it will also clear padding bits
on explicit initialization and with -ftrivial-auto-var-init=pattern it will
initialize to pattern with clearing padding bits in between.

There are other changes that had to be implemented.  First of all, we need
to magicly preinitialize also temporary objects; this is implemented for
both the C++26 implicit mode and explicit
-ftrivial-auto-var-init={zero,pattern} by emitting .DEFERRED_INIT before
construction of TARGET_EXPR temporaries (if they have void type initializers,
i.e. are initialized by code rather than some value).

Second needed change is dropping *this ={v} {CLOBBER(bob)}; statements
at the start of the constructors for -flifetime-dse=2, that says the old
content of *this is irrelevant, which is not true anymore for C++26,
where we want to treat it like that for -W*uninitialized purposes, but
at runtime actually initialize the values.  Instead for -flifetime-dse=2
we emit such {CLOBBER(bob)} before calling whole object constructor
(on TARGET_EXPR with void type initializer or on DECL_EXPR).
And a separate patch added and another one will be adding more {CLOBBER(bob)}
to new expressions.

The third needed change is about gotos and switches across vacuous
initialization.  C++26 says those are still valid, but don't make an
exception for those in the EB rules.
The patch now includes redirecting of forward/backward gotos
which cross vacuous initializations for -std=c++26 and
-ftrivial-auto-var-init={zero,pattern} by adding an artificial
if (0) { lab1: v1 = .DEFERRED_INIT (...); lab2: v2 = .DEFERRED_INIT (...); }
etc. hunk before the user label (or for case labels moving the case
label into it).  Only one per adjacent set of labels, with perhaps
multiple artificial labels in it.  I believe (and testing seems to
confirm that) that one only needs one set of such initialized vars
per the adjacent label group, if some forward or backward jump
crosses more vacuous inits, it will always cross a subset or superset
of the others and when the vars are ordered right, it can jump into
different positions in the same if (0).
Furthermore, -Wimplicit-fallthrough and -Wswitch-unreachable warnings
have been adjusted to deal with that.
These changes mean that -Wtrivial-auto-var-init warning now doesn't
make sense for C++, as there is nothing to warn about, all the switches
and all the gotos are handled right for -ftrivial-auto-var-init= and
are handled that way both for the implicit C++26 mode and for explicit
-ftrivial-auto-var-init= options.

The fourth change is to avoid regressions for code like
struct A
{
  int f, g;
  A () { f = g; // { dg-warning "g. is used uninitialized" } }
} a;
where with -flifetime-dse=2 -Wuninitialized we were able to warn
about bugs like this because of the *this ={v} {CLOBBER(bob)};
statements at the start of the constructors, but with their removal
wouldn't warn about it.  Instead we now add a magic "clobber *this"
attribute to the this PARM_DECL and use it in -W*uninitialized handling
only as an implicit *this ={v} {CLOBBER(bob)}; at the start of the
function.  If a function is inlined, this disappears, but that shouldn't
be a problem, either it is inlined into another constructor and that
should have "clobber *this" for its this argument or it is inlined into
whole object construction spot and there should be an explicit
{CLOBBER(bob)} for the variable or temporary object.

The fifth change is adding [[indeterminate]] attribute support and
using it to avoid .DEFERRED_INIT calls (like [[gnu::uninitialized]]
is handled).

Some regressions caused by this patch had bugs filed (but for cases
where those already didn't work before with explicit
-ftrivial-auto-var-init=zero), those have been xfailed for now.
See PR121975 and PR122044.

2025-10-04  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/114457
gcc/
	* flag-types.h (enum auto_init_type): Add AUTO_INIT_CXX26.
	* tree.h (VACUOUS_INIT_LABEL_P): Define.
	* gimplify.cc (is_var_need_auto_init): Renamed to ...
	(var_needs_auto_init_p): ... this.  Don't return true for
	vars with "indeterminate" attribute.  Formatting fixes.
	(gimplify_decl_expr): Use var_needs_auto_init_p instead of
	is_var_need_auto_init.
	(emit_warn_switch_unreachable): Remove the flag_auto_var_init
	special cases.
	(warn_switch_unreachable_and_auto_init_r): Handle them here
	by doing just returning NULL.
	(last_stmt_in_scope): Don't skip just debug stmts to find
	the last stmt in seq, skip for
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED also IFN_DEFERRED_INIT
	calls.
	(collect_fallthrough_labels): For
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED ignore
	IFN_DEFERRED_INIT calls and GIMPLE_GOTOs to
	VACUOUS_INIT_LABEL_P.
	(should_warn_for_implicit_fallthrough): For
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED also skip over
	IFN_DEFERRED_INIT calls.
	(expand_FALLTHROUGH_r): Likewise, and handle GIMPLE_GOTOs
	to VACUOUS_INIT_LABEL_P.
	(gimplify_init_constructor): Use var_needs_auto_init_p instead
	of is_var_need_auto_init and for flag_auto_var_init
	AUTO_INIT_CXX26 don't call gimple_add_padding_init_for_auto_var.
	(gimplify_target_expr): If var_needs_auto_init_p and init has
	void type, call gimple_add_init_for_auto_var and for
	AUTO_INIT_PATTERN also gimple_add_padding_init_for_auto_var.
	* tree-ssa-uninit.cc (maybe_warn_operand): Handle loads from *this
	at the start of the function with "clobber *this" attribute on the
	PARM_DECL.
	* ipa-split.cc (split_function): Remove "clobber *this" attribute
	from the first PARM_DECL (if any).
	* doc/invoke.texi (ftrivial-auto-var-init=): Adjust documentation.
gcc/c-family/
	* c-opts.cc (c_common_post_options): For C++26 set
	flag_auto_var_init to AUTO_INIT_CXX26 if not specified explicitly.
	For C++ disable warn_trivial_auto_var_init.
gcc/cp/
	* cp-tree.h: Implement C++26 P2795R5 - Erroneous behavior for
	uninitialized reads.
	(IF_STMT_VACUOUS_INIT_P): Define.
	(check_goto): Change argument type from tree to tree *.
	* call.cc (build_over_call): Add indeterminate attribute to
	TARGET_EXPR slots for indeterminate parameters.
	* constexpr.cc (cxx_eval_internal_function): Handle IFN_DEFERRED_INIT.
	(cxx_eval_store_expression): Temporarily work around PR121965 bug.
	* cp-gimplify.cc (genericize_if_stmt): Handle IF_STMT_VACUOUS_INIT_P.
	(maybe_emit_clobber_object_begin): New function.
	(cp_gimplify_expr): Call it for DECL_EXPRs and TARGET_EXPRs with
	void type non-NULL TARGET_EXPR_INITIAL.
	* decl.cc (struct named_label_fwd_direct_goto,
	struct named_label_bck_direct_goto): New types.
	(struct named_label_use_entry): Add direct_goto member.  Formatting
	fix.
	(struct named_label_entry): Add direct_goto member.  Turn bool members
	into bool : 1.  Add has_bad_decls bitfield.
	(adjust_backward_gotos): New function.
	(pop_labels): For flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED
	call adjust_backward_gotos if needed.
	(poplevel_named_label_1): For decl_jump_unsafe also set
	ent-&gt;has_bad_decls, and for decl_instrument_init_bypass_p decls
	push them into ent-&gt;bad_decls vector too.
	(duplicate_decls): Complain if indeterminate attribute on function
	parameter isn't present on the first function declaration.
	(decl_instrument_init_bypass_p): New function.
	(build_deferred_init_call): Likewise.
	(maybe_add_deferred_init_calls): Likewise.
	(adjust_backward_goto): Likewise.
	(check_previous_goto_1): Add direct_goto and case_label arguments.
	For decl_instrument_init_bypass_p decls seen if
	direct_goto || case_label move case label if needed, call
	maybe_add_deferred_init_calls and adjust GOTO_EXPR operands remembered
	in direct_goto.  Change return type from bool to int, return 0 on
	error, 1 for success with no need to adjust vacuous inits and 2 for
	success with need to adjust those.
	(check_previous_goto): Adjust check_previous_goto_1 call, vec_free
	direct_goto vector.
	(check_switch_goto): Add case_label argument, adjust
	check_previous_goto_1 call.  Change return type from bool to int.
	(check_goto_1): Remove computed argument, add declp argument.  Don't
	reuse previous ent-&gt;uses if
	ent-&gt;binding_level != current_binding_level.  Push declp into
	direct_goto vectors if needed.
	(check_goto): Remove decl argument, add declp argument.  Adjust
	check_goto_1 calls.
	(finish_case_label): Call check_switch_goto up to twice, first time
	to detect errors and find out if second call will be needed, and
	after c_add_case_label second time if needed.  In the first case
	pass NULL_TREE as new argument to it, in the second case r.
	(start_preparsed_function): Don't emit CLOBBER_OBJECT_BEGIN here
	for -flifetime-dse=2, instead add "clobber *this" attribute to
	current_class_ptr.
	* parser.cc (cp_parser_asm_label_list): Call check_goto only
	after the TREE_LIST is created and pass address of its TREE_VALUE to
	it instead of the label.
	* semantics.cc (finish_goto_stmt): Call check_goto only after
	build_stmt has been called and pass it address of its first operand
	rather than destination.
	* tree.cc (handle_indeterminate_attribute): New function.
	(cxx_gnu_attributes): Add entry for indeterminate attribute.
gcc/testsuite/
	* g++.dg/cpp1y/vla-initlist1.C: Remove dg-skip-if for powerpc.
	Initialize i to 43 for ctor from initializer_list and expect value
	43 instead of 42.
	* g++.dg/cpp26/attr-indeterminate1.C: New test.
	* g++.dg/cpp26/attr-indeterminate2.C: New test.
	* g++.dg/cpp26/attr-indeterminate3.C: New test.
	* g++.dg/cpp26/attr-indeterminate4.C: New test.
	* g++.dg/cpp26/erroneous1.C: New test.
	* g++.dg/cpp26/erroneous2.C: New test.
	* g++.dg/cpp26/erroneous3.C: New test.
	* g++.dg/cpp26/erroneous4.C: New test.
	* g++.dg/opt/store-merging-1.C: Add
	-ftrivial-auto-var-init=uninitialized to dg-options.
	* g++.dg/uninit-pred-loop-1_b.C: Expect a warning for C++26.
	* g++.dg/warn/Wuninitialized-13.C: Expect warning on a different
	line.
	* c-c++-common/ubsan/vla-1.c: Add
	-ftrivial-auto-var-init=uninitialized to dg-options.
	* c-c++-common/uninit-17.c: For c++26 expect warning on a different
	line.
	* g++.dg/warn/Warray-bounds-20.C: Expect warning on a different line.
	* c-c++-common/analyzer/invalid-shift-1.c: Xfail for c++26 until
	PR122044 is fixed.
	* g++.dg/analyzer/exception-value-2.C: Skip for c++26 until PR122044
	is fixed.
	* c-c++-common/goacc-gomp/nesting-1.c: Skip for c++26 until PR121975
	is fixed.
	* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr100400-1-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr100400-1-3.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104132-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104133-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104774-1.c: Likewise.
	* c-c++-common/goacc/mdc-1.c: Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following patch implements the C++26 P2795R5 paper by enabling something
like -ftrivial-auto-var-init=zero by default for -std=c++26/-std=gnu++26.
There is an important difference between explicit -ftrivial-auto-var-init=zero
and the implicitly enabled one, in particular the explicit one will try to
clear padding bits on vars with explicit initializers, while the default
C++26 mode does not - C++26 says that using the padding bits for anything
but copying structures around is still undefined behavior rather than
erroneous behavior.

Users can still override the default C++26 behavior in both directions,
with -ftrivial-auto-var-init=uninitialized even C++26 will act as C++23
with treating all uninitialized var reads (except for copying) as UB rather
than EB, with -ftrivial-auto-var-init=zero it will also clear padding bits
on explicit initialization and with -ftrivial-auto-var-init=pattern it will
initialize to pattern with clearing padding bits in between.

There are other changes that had to be implemented.  First of all, we need
to magicly preinitialize also temporary objects; this is implemented for
both the C++26 implicit mode and explicit
-ftrivial-auto-var-init={zero,pattern} by emitting .DEFERRED_INIT before
construction of TARGET_EXPR temporaries (if they have void type initializers,
i.e. are initialized by code rather than some value).

Second needed change is dropping *this ={v} {CLOBBER(bob)}; statements
at the start of the constructors for -flifetime-dse=2, that says the old
content of *this is irrelevant, which is not true anymore for C++26,
where we want to treat it like that for -W*uninitialized purposes, but
at runtime actually initialize the values.  Instead for -flifetime-dse=2
we emit such {CLOBBER(bob)} before calling whole object constructor
(on TARGET_EXPR with void type initializer or on DECL_EXPR).
And a separate patch added and another one will be adding more {CLOBBER(bob)}
to new expressions.

The third needed change is about gotos and switches across vacuous
initialization.  C++26 says those are still valid, but don't make an
exception for those in the EB rules.
The patch now includes redirecting of forward/backward gotos
which cross vacuous initializations for -std=c++26 and
-ftrivial-auto-var-init={zero,pattern} by adding an artificial
if (0) { lab1: v1 = .DEFERRED_INIT (...); lab2: v2 = .DEFERRED_INIT (...); }
etc. hunk before the user label (or for case labels moving the case
label into it).  Only one per adjacent set of labels, with perhaps
multiple artificial labels in it.  I believe (and testing seems to
confirm that) that one only needs one set of such initialized vars
per the adjacent label group, if some forward or backward jump
crosses more vacuous inits, it will always cross a subset or superset
of the others and when the vars are ordered right, it can jump into
different positions in the same if (0).
Furthermore, -Wimplicit-fallthrough and -Wswitch-unreachable warnings
have been adjusted to deal with that.
These changes mean that -Wtrivial-auto-var-init warning now doesn't
make sense for C++, as there is nothing to warn about, all the switches
and all the gotos are handled right for -ftrivial-auto-var-init= and
are handled that way both for the implicit C++26 mode and for explicit
-ftrivial-auto-var-init= options.

The fourth change is to avoid regressions for code like
struct A
{
  int f, g;
  A () { f = g; // { dg-warning "g. is used uninitialized" } }
} a;
where with -flifetime-dse=2 -Wuninitialized we were able to warn
about bugs like this because of the *this ={v} {CLOBBER(bob)};
statements at the start of the constructors, but with their removal
wouldn't warn about it.  Instead we now add a magic "clobber *this"
attribute to the this PARM_DECL and use it in -W*uninitialized handling
only as an implicit *this ={v} {CLOBBER(bob)}; at the start of the
function.  If a function is inlined, this disappears, but that shouldn't
be a problem, either it is inlined into another constructor and that
should have "clobber *this" for its this argument or it is inlined into
whole object construction spot and there should be an explicit
{CLOBBER(bob)} for the variable or temporary object.

The fifth change is adding [[indeterminate]] attribute support and
using it to avoid .DEFERRED_INIT calls (like [[gnu::uninitialized]]
is handled).

Some regressions caused by this patch had bugs filed (but for cases
where those already didn't work before with explicit
-ftrivial-auto-var-init=zero), those have been xfailed for now.
See PR121975 and PR122044.

2025-10-04  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	PR c++/114457
gcc/
	* flag-types.h (enum auto_init_type): Add AUTO_INIT_CXX26.
	* tree.h (VACUOUS_INIT_LABEL_P): Define.
	* gimplify.cc (is_var_need_auto_init): Renamed to ...
	(var_needs_auto_init_p): ... this.  Don't return true for
	vars with "indeterminate" attribute.  Formatting fixes.
	(gimplify_decl_expr): Use var_needs_auto_init_p instead of
	is_var_need_auto_init.
	(emit_warn_switch_unreachable): Remove the flag_auto_var_init
	special cases.
	(warn_switch_unreachable_and_auto_init_r): Handle them here
	by doing just returning NULL.
	(last_stmt_in_scope): Don't skip just debug stmts to find
	the last stmt in seq, skip for
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED also IFN_DEFERRED_INIT
	calls.
	(collect_fallthrough_labels): For
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED ignore
	IFN_DEFERRED_INIT calls and GIMPLE_GOTOs to
	VACUOUS_INIT_LABEL_P.
	(should_warn_for_implicit_fallthrough): For
	flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED also skip over
	IFN_DEFERRED_INIT calls.
	(expand_FALLTHROUGH_r): Likewise, and handle GIMPLE_GOTOs
	to VACUOUS_INIT_LABEL_P.
	(gimplify_init_constructor): Use var_needs_auto_init_p instead
	of is_var_need_auto_init and for flag_auto_var_init
	AUTO_INIT_CXX26 don't call gimple_add_padding_init_for_auto_var.
	(gimplify_target_expr): If var_needs_auto_init_p and init has
	void type, call gimple_add_init_for_auto_var and for
	AUTO_INIT_PATTERN also gimple_add_padding_init_for_auto_var.
	* tree-ssa-uninit.cc (maybe_warn_operand): Handle loads from *this
	at the start of the function with "clobber *this" attribute on the
	PARM_DECL.
	* ipa-split.cc (split_function): Remove "clobber *this" attribute
	from the first PARM_DECL (if any).
	* doc/invoke.texi (ftrivial-auto-var-init=): Adjust documentation.
gcc/c-family/
	* c-opts.cc (c_common_post_options): For C++26 set
	flag_auto_var_init to AUTO_INIT_CXX26 if not specified explicitly.
	For C++ disable warn_trivial_auto_var_init.
gcc/cp/
	* cp-tree.h: Implement C++26 P2795R5 - Erroneous behavior for
	uninitialized reads.
	(IF_STMT_VACUOUS_INIT_P): Define.
	(check_goto): Change argument type from tree to tree *.
	* call.cc (build_over_call): Add indeterminate attribute to
	TARGET_EXPR slots for indeterminate parameters.
	* constexpr.cc (cxx_eval_internal_function): Handle IFN_DEFERRED_INIT.
	(cxx_eval_store_expression): Temporarily work around PR121965 bug.
	* cp-gimplify.cc (genericize_if_stmt): Handle IF_STMT_VACUOUS_INIT_P.
	(maybe_emit_clobber_object_begin): New function.
	(cp_gimplify_expr): Call it for DECL_EXPRs and TARGET_EXPRs with
	void type non-NULL TARGET_EXPR_INITIAL.
	* decl.cc (struct named_label_fwd_direct_goto,
	struct named_label_bck_direct_goto): New types.
	(struct named_label_use_entry): Add direct_goto member.  Formatting
	fix.
	(struct named_label_entry): Add direct_goto member.  Turn bool members
	into bool : 1.  Add has_bad_decls bitfield.
	(adjust_backward_gotos): New function.
	(pop_labels): For flag_auto_var_init &gt; AUTO_INIT_UNINITIALIZED
	call adjust_backward_gotos if needed.
	(poplevel_named_label_1): For decl_jump_unsafe also set
	ent-&gt;has_bad_decls, and for decl_instrument_init_bypass_p decls
	push them into ent-&gt;bad_decls vector too.
	(duplicate_decls): Complain if indeterminate attribute on function
	parameter isn't present on the first function declaration.
	(decl_instrument_init_bypass_p): New function.
	(build_deferred_init_call): Likewise.
	(maybe_add_deferred_init_calls): Likewise.
	(adjust_backward_goto): Likewise.
	(check_previous_goto_1): Add direct_goto and case_label arguments.
	For decl_instrument_init_bypass_p decls seen if
	direct_goto || case_label move case label if needed, call
	maybe_add_deferred_init_calls and adjust GOTO_EXPR operands remembered
	in direct_goto.  Change return type from bool to int, return 0 on
	error, 1 for success with no need to adjust vacuous inits and 2 for
	success with need to adjust those.
	(check_previous_goto): Adjust check_previous_goto_1 call, vec_free
	direct_goto vector.
	(check_switch_goto): Add case_label argument, adjust
	check_previous_goto_1 call.  Change return type from bool to int.
	(check_goto_1): Remove computed argument, add declp argument.  Don't
	reuse previous ent-&gt;uses if
	ent-&gt;binding_level != current_binding_level.  Push declp into
	direct_goto vectors if needed.
	(check_goto): Remove decl argument, add declp argument.  Adjust
	check_goto_1 calls.
	(finish_case_label): Call check_switch_goto up to twice, first time
	to detect errors and find out if second call will be needed, and
	after c_add_case_label second time if needed.  In the first case
	pass NULL_TREE as new argument to it, in the second case r.
	(start_preparsed_function): Don't emit CLOBBER_OBJECT_BEGIN here
	for -flifetime-dse=2, instead add "clobber *this" attribute to
	current_class_ptr.
	* parser.cc (cp_parser_asm_label_list): Call check_goto only
	after the TREE_LIST is created and pass address of its TREE_VALUE to
	it instead of the label.
	* semantics.cc (finish_goto_stmt): Call check_goto only after
	build_stmt has been called and pass it address of its first operand
	rather than destination.
	* tree.cc (handle_indeterminate_attribute): New function.
	(cxx_gnu_attributes): Add entry for indeterminate attribute.
gcc/testsuite/
	* g++.dg/cpp1y/vla-initlist1.C: Remove dg-skip-if for powerpc.
	Initialize i to 43 for ctor from initializer_list and expect value
	43 instead of 42.
	* g++.dg/cpp26/attr-indeterminate1.C: New test.
	* g++.dg/cpp26/attr-indeterminate2.C: New test.
	* g++.dg/cpp26/attr-indeterminate3.C: New test.
	* g++.dg/cpp26/attr-indeterminate4.C: New test.
	* g++.dg/cpp26/erroneous1.C: New test.
	* g++.dg/cpp26/erroneous2.C: New test.
	* g++.dg/cpp26/erroneous3.C: New test.
	* g++.dg/cpp26/erroneous4.C: New test.
	* g++.dg/opt/store-merging-1.C: Add
	-ftrivial-auto-var-init=uninitialized to dg-options.
	* g++.dg/uninit-pred-loop-1_b.C: Expect a warning for C++26.
	* g++.dg/warn/Wuninitialized-13.C: Expect warning on a different
	line.
	* c-c++-common/ubsan/vla-1.c: Add
	-ftrivial-auto-var-init=uninitialized to dg-options.
	* c-c++-common/uninit-17.c: For c++26 expect warning on a different
	line.
	* g++.dg/warn/Warray-bounds-20.C: Expect warning on a different line.
	* c-c++-common/analyzer/invalid-shift-1.c: Xfail for c++26 until
	PR122044 is fixed.
	* g++.dg/analyzer/exception-value-2.C: Skip for c++26 until PR122044
	is fixed.
	* c-c++-common/goacc-gomp/nesting-1.c: Skip for c++26 until PR121975
	is fixed.
	* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr100400-1-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr100400-1-3.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104132-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104133-1.c: Likewise.
	* c-c++-common/goacc/kernels-decompose-pr104774-1.c: Likewise.
	* c-c++-common/goacc/mdc-1.c: Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix various comment typos</title>
<updated>2025-09-30T14:12:46+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2025-09-30T14:11:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=6e624833cbe0a7479564fbe3294e10c9d4746a2e'/>
<id>6e624833cbe0a7479564fbe3294e10c9d4746a2e</id>
<content type='text'>
The following patch fixes various comment typos.

2025-09-30  Jakub Jelinek  &lt;jakub@redhat.com&gt;

gcc/
	* auto-profile.h (maybe_hot_afdo_count_p): Fix comment typos,
	possiby -&gt; possibly and ture -&gt; true.
	* gimplify.cc (build_asan_poison_call_expr): Change "of a for"
	to "memory of the" in a comment.
	* ipa-devirt.cc (add_type_duplicate): Fix comment typo,
	mangles -&gt; mangled.
	* auto-profile.cc: Fix comment typo, -fauto-profile-inlinig
	-&gt; -fauto-profile-inlining.
	(maybe_hot_afdo_count_p): Fix comment typos, possiby -&gt; possibly
	and ture -&gt; true.
	(function_instance::removed_icall_target): Fix comment typo,
	Reutrn -&gt; Return.
	(function_instance::in_worklist_): Fix comment typo, Ture -&gt; True.
	(function_instance::offline): Fix comment typo, tolevel -&gt; toplevel.
	(function_instance::match): Fix comment typo, craeate_gcov -&gt;
	create_gcov.
	(autofdo_source_profile::offline_external_functions): Fix comment
	typos, tolevel -&gt; toplevel and porfile -&gt; profile.
	(autofdo_source_profile::get_function_instance_by_inline_stack): Fix
	comment typo, chekcing -&gt; checking.
	(struct scale): Fix comment typo, scalle -&gt; scale.
	* gimple.h (currently_expanding_gimple_stmt): Fix comment typo,
	comminucating -&gt; communicating.
	* tree.h (canonical_type_used_p): Fix comment typo, ture -&gt; true.
	* tree-ssa-alias.cc (types_equal_for_same_type_for_tbaa_p): Likewise.
	* ipa-profile.cc (contains_hot_call_p): Likewise.
	* cfgexpand.cc (add_scope_conflicts_2): Fix comment typos,
	Querry -&gt; Query, referendd -&gt; referenced and Querrying -&gt; Querying.
	* ipa-param-manipulation.cc (currently_expanding_gimple_stmt): Fix
	comment typo, comminucating -&gt; communicating.
	* ipa-prop.cc (ipa_cst_ref_desc::refcount): Fix comment typo,
	if -&gt; is.
	* tree-if-conv.cc (version_loop_for_if_conversion): Fix comment typos,
	porfile -&gt; profile and confistency -&gt; consistency.
	* fold-const.cc: Change size_int_wide in comment to size_int as
	size_int_wide doesn't exit for 21 years.
gcc/testsuite/
	* gcc.dg/vect/tsvc/vect-tsvc-s1244.c (s1244): Fix comment typo,
	ture -&gt; true.
	* gcc.dg/vect/tsvc/vect-tsvc-s2244.c (s2244): Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following patch fixes various comment typos.

2025-09-30  Jakub Jelinek  &lt;jakub@redhat.com&gt;

gcc/
	* auto-profile.h (maybe_hot_afdo_count_p): Fix comment typos,
	possiby -&gt; possibly and ture -&gt; true.
	* gimplify.cc (build_asan_poison_call_expr): Change "of a for"
	to "memory of the" in a comment.
	* ipa-devirt.cc (add_type_duplicate): Fix comment typo,
	mangles -&gt; mangled.
	* auto-profile.cc: Fix comment typo, -fauto-profile-inlinig
	-&gt; -fauto-profile-inlining.
	(maybe_hot_afdo_count_p): Fix comment typos, possiby -&gt; possibly
	and ture -&gt; true.
	(function_instance::removed_icall_target): Fix comment typo,
	Reutrn -&gt; Return.
	(function_instance::in_worklist_): Fix comment typo, Ture -&gt; True.
	(function_instance::offline): Fix comment typo, tolevel -&gt; toplevel.
	(function_instance::match): Fix comment typo, craeate_gcov -&gt;
	create_gcov.
	(autofdo_source_profile::offline_external_functions): Fix comment
	typos, tolevel -&gt; toplevel and porfile -&gt; profile.
	(autofdo_source_profile::get_function_instance_by_inline_stack): Fix
	comment typo, chekcing -&gt; checking.
	(struct scale): Fix comment typo, scalle -&gt; scale.
	* gimple.h (currently_expanding_gimple_stmt): Fix comment typo,
	comminucating -&gt; communicating.
	* tree.h (canonical_type_used_p): Fix comment typo, ture -&gt; true.
	* tree-ssa-alias.cc (types_equal_for_same_type_for_tbaa_p): Likewise.
	* ipa-profile.cc (contains_hot_call_p): Likewise.
	* cfgexpand.cc (add_scope_conflicts_2): Fix comment typos,
	Querry -&gt; Query, referendd -&gt; referenced and Querrying -&gt; Querying.
	* ipa-param-manipulation.cc (currently_expanding_gimple_stmt): Fix
	comment typo, comminucating -&gt; communicating.
	* ipa-prop.cc (ipa_cst_ref_desc::refcount): Fix comment typo,
	if -&gt; is.
	* tree-if-conv.cc (version_loop_for_if_conversion): Fix comment typos,
	porfile -&gt; profile and confistency -&gt; consistency.
	* fold-const.cc: Change size_int_wide in comment to size_int as
	size_int_wide doesn't exit for 21 years.
gcc/testsuite/
	* gcc.dg/vect/tsvc/vect-tsvc-s1244.c (s1244): Fix comment typo,
	ture -&gt; true.
	* gcc.dg/vect/tsvc/vect-tsvc-s2244.c (s2244): Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>Bail out early during gimplify_asm_expr [PR121391]</title>
<updated>2025-09-15T07:10:53+00:00</updated>
<author>
<name>Stefan Schulze Frielinghaus</name>
<email>stefansf@gcc.gnu.org</email>
</author>
<published>2025-09-15T07:10:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=4cff794ca18a96ceeb83ccb18b08ffa0a63c58af'/>
<id>4cff794ca18a96ceeb83ccb18b08ffa0a63c58af</id>
<content type='text'>
In case an asm operand is an error node, constraints etc. are still
validated.  Furthermore, all other operands are gimplified, although an
error is returned in the end anyway.  For hard register constraints an
operand is required in order to determine the mode from which the number
of registers follows.  Therefore, instead of adding extra guards, bail
out early.

gcc/ChangeLog:

	PR middle-end/121391
	* gimplify.cc (gimplify_asm_expr): In case an asm operand is an
	error node, bail out early.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr121391-1.c: New test.
	* gcc.dg/pr121391-2.c: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In case an asm operand is an error node, constraints etc. are still
validated.  Furthermore, all other operands are gimplified, although an
error is returned in the end anyway.  For hard register constraints an
operand is required in order to determine the mode from which the number
of registers follows.  Therefore, instead of adding extra guards, bail
out early.

gcc/ChangeLog:

	PR middle-end/121391
	* gimplify.cc (gimplify_asm_expr): In case an asm operand is an
	error node, bail out early.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr121391-1.c: New test.
	* gcc.dg/pr121391-2.c: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>openmp: Add support for iterators in 'target update' clauses (C/C++)</title>
<updated>2025-08-06T00:37:10+00:00</updated>
<author>
<name>Kwok Cheung Yeung</name>
<email>kcyeung@baylibre.com</email>
</author>
<published>2025-08-06T00:07:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=87262627fd65a1a7acd80a529077f098a7e26f18'/>
<id>87262627fd65a1a7acd80a529077f098a7e26f18</id>
<content type='text'>
This adds support for iterators in 'to' and 'from' clauses in the
'target update' OpenMP directive.

gcc/c/

	* 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.

gcc/cp/

	* parser.cc (cp_parser_omp_clause_from_to): Parse 'iterator' modifier.
	* semantics.cc (finish_omp_clauses): Finish iterators for to/from
	clauses.

gcc/

	* 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.

gcc/testsuite/

	* 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.

libgomp/

	* 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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds support for iterators in 'to' and 'from' clauses in the
'target update' OpenMP directive.

gcc/c/

	* 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.

gcc/cp/

	* parser.cc (cp_parser_omp_clause_from_to): Parse 'iterator' modifier.
	* semantics.cc (finish_omp_clauses): Finish iterators for to/from
	clauses.

gcc/

	* 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.

gcc/testsuite/

	* 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.

libgomp/

	* 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.
</pre>
</div>
</content>
</entry>
<entry>
<title>openmp: Add support for iterators in map clauses (C/C++)</title>
<updated>2025-08-06T00:37:10+00:00</updated>
<author>
<name>Kwok Cheung Yeung</name>
<email>kcyeung@baylibre.com</email>
</author>
<published>2025-08-06T00:07:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=8b8b0eada6ff03707b26a13202a40a436d4e6a38'/>
<id>8b8b0eada6ff03707b26a13202a40a436d4e6a38</id>
<content type='text'>
This adds preliminary support for iterators in map clauses within OpenMP
'target' constructs (which includes constructs such as 'target enter data').

Iterators with non-constant loop bounds are not currently supported.

gcc/c/

	* 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.

gcc/cp/

	* parser.cc (cp_parser_omp_clause_map): Parse 'iterator' modifier.
	* semantics.cc (finish_omp_clauses): Finish iterators.  Apply
	iterators to generated clauses.

gcc/

	* 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.

gcc/testsuite/

	* 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.

libgomp/

	* 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.

Co-authored-by: Andrew Stubbs &lt;ams@baylibre.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds preliminary support for iterators in map clauses within OpenMP
'target' constructs (which includes constructs such as 'target enter data').

Iterators with non-constant loop bounds are not currently supported.

gcc/c/

	* 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.

gcc/cp/

	* parser.cc (cp_parser_omp_clause_map): Parse 'iterator' modifier.
	* semantics.cc (finish_omp_clauses): Finish iterators.  Apply
	iterators to generated clauses.

gcc/

	* 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.

gcc/testsuite/

	* 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.

libgomp/

	* 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.

Co-authored-by: Andrew Stubbs &lt;ams@baylibre.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Error handling for hard register constraints</title>
<updated>2025-07-21T11:05:26+00:00</updated>
<author>
<name>Stefan Schulze Frielinghaus</name>
<email>stefansf@gcc.gnu.org</email>
</author>
<published>2025-07-21T11:05:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=cbf17db978c663817e4cd3337bbc80f59fa05bb6'/>
<id>cbf17db978c663817e4cd3337bbc80f59fa05bb6</id>
<content type='text'>
This implements error handling for hard register constraints including
potential conflicts with register asm operands.

In contrast to register asm operands, hard register constraints allow
more than just one register per operand.  Even more than just one
register per alternative.  For example, a valid constraint for an
operand is "{r0}{r1}m,{r2}".  However, this also means that we have to
make sure that each register is used at most once in each alternative
over all outputs and likewise over all inputs.  For asm statements this
is done by this patch during gimplification.  For hard register
constraints used in machine description, error handling is still a todo
and I haven't investigated this so far and consider this rather a low
priority.

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (gnat_to_gnu): Pass null pointer to
	parse_{input,output}_constraint().

gcc/analyzer/ChangeLog:

	* region-model-asm.cc (region_model::on_asm_stmt): Pass null
	pointer to parse_{input,output}_constraint().

gcc/c/ChangeLog:

	* c-typeck.cc (build_asm_expr): Pass null pointer to
	parse_{input,output}_constraint().

gcc/ChangeLog:

	* cfgexpand.cc (n_occurrences): Move this ...
	(check_operand_nalternatives): and this ...
	(expand_asm_stmt): and the call to gimplify.cc.
	* config/s390/s390.cc (s390_md_asm_adjust): Pass null pointer to
	parse_{input,output}_constraint().
	* gimple-walk.cc (walk_gimple_asm): Pass null pointer to
	parse_{input,output}_constraint().
	(walk_stmt_load_store_addr_ops): Ditto.
	* gimplify-me.cc (gimple_regimplify_operands): Ditto.
	* gimplify.cc (num_occurrences): Moved from cfgexpand.cc.
	(num_alternatives): Ditto.
	(gimplify_asm_expr): Deal with hard register constraints.
	* stmt.cc (eliminable_regno_p): New helper.
	(hardreg_ok_p): Perform a similar check as done in
	make_decl_rtl().
	(parse_output_constraint): Add parameter for gimplify_reg_info
	and validate hard register constrained operands.
	(parse_input_constraint): Ditto.
	* stmt.h (class gimplify_reg_info): Forward declaration.
	(parse_output_constraint): Add parameter.
	(parse_input_constraint): Ditto.
	* tree-ssa-operands.cc
	(operands_scanner::get_asm_stmt_operands): Pass null pointer
	to parse_{input,output}_constraint().
	* tree-ssa-structalias.cc (find_func_aliases): Pass null pointer
	to parse_{input,output}_constraint().
	* varasm.cc (assemble_asm): Pass null pointer to
	parse_{input,output}_constraint().
	* gimplify_reg_info.h: New file.

gcc/cp/ChangeLog:

	* semantics.cc (finish_asm_stmt): Pass null pointer to
	parse_{input,output}_constraint().

gcc/d/ChangeLog:

	* toir.cc: Pass null pointer to
	parse_{input,output}_constraint().

gcc/testsuite/ChangeLog:

	* gcc.dg/pr87600-2.c: Split test into two files since errors for
	functions test{0,1} are thrown during expand, and for
	test{2,3} during gimplification.
	* lib/scanasm.exp: On s390, skip lines beginning with #.
	* gcc.dg/asm-hard-reg-error-1.c: New test.
	* gcc.dg/asm-hard-reg-error-2.c: New test.
	* gcc.dg/asm-hard-reg-error-3.c: New test.
	* gcc.dg/asm-hard-reg-error-4.c: New test.
	* gcc.dg/asm-hard-reg-error-5.c: New test.
	* gcc.dg/pr87600-3.c: New test.
	* gcc.target/aarch64/asm-hard-reg-2.c: New test.
	* gcc.target/s390/asm-hard-reg-7.c: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This implements error handling for hard register constraints including
potential conflicts with register asm operands.

In contrast to register asm operands, hard register constraints allow
more than just one register per operand.  Even more than just one
register per alternative.  For example, a valid constraint for an
operand is "{r0}{r1}m,{r2}".  However, this also means that we have to
make sure that each register is used at most once in each alternative
over all outputs and likewise over all inputs.  For asm statements this
is done by this patch during gimplification.  For hard register
constraints used in machine description, error handling is still a todo
and I haven't investigated this so far and consider this rather a low
priority.

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (gnat_to_gnu): Pass null pointer to
	parse_{input,output}_constraint().

gcc/analyzer/ChangeLog:

	* region-model-asm.cc (region_model::on_asm_stmt): Pass null
	pointer to parse_{input,output}_constraint().

gcc/c/ChangeLog:

	* c-typeck.cc (build_asm_expr): Pass null pointer to
	parse_{input,output}_constraint().

gcc/ChangeLog:

	* cfgexpand.cc (n_occurrences): Move this ...
	(check_operand_nalternatives): and this ...
	(expand_asm_stmt): and the call to gimplify.cc.
	* config/s390/s390.cc (s390_md_asm_adjust): Pass null pointer to
	parse_{input,output}_constraint().
	* gimple-walk.cc (walk_gimple_asm): Pass null pointer to
	parse_{input,output}_constraint().
	(walk_stmt_load_store_addr_ops): Ditto.
	* gimplify-me.cc (gimple_regimplify_operands): Ditto.
	* gimplify.cc (num_occurrences): Moved from cfgexpand.cc.
	(num_alternatives): Ditto.
	(gimplify_asm_expr): Deal with hard register constraints.
	* stmt.cc (eliminable_regno_p): New helper.
	(hardreg_ok_p): Perform a similar check as done in
	make_decl_rtl().
	(parse_output_constraint): Add parameter for gimplify_reg_info
	and validate hard register constrained operands.
	(parse_input_constraint): Ditto.
	* stmt.h (class gimplify_reg_info): Forward declaration.
	(parse_output_constraint): Add parameter.
	(parse_input_constraint): Ditto.
	* tree-ssa-operands.cc
	(operands_scanner::get_asm_stmt_operands): Pass null pointer
	to parse_{input,output}_constraint().
	* tree-ssa-structalias.cc (find_func_aliases): Pass null pointer
	to parse_{input,output}_constraint().
	* varasm.cc (assemble_asm): Pass null pointer to
	parse_{input,output}_constraint().
	* gimplify_reg_info.h: New file.

gcc/cp/ChangeLog:

	* semantics.cc (finish_asm_stmt): Pass null pointer to
	parse_{input,output}_constraint().

gcc/d/ChangeLog:

	* toir.cc: Pass null pointer to
	parse_{input,output}_constraint().

gcc/testsuite/ChangeLog:

	* gcc.dg/pr87600-2.c: Split test into two files since errors for
	functions test{0,1} are thrown during expand, and for
	test{2,3} during gimplification.
	* lib/scanasm.exp: On s390, skip lines beginning with #.
	* gcc.dg/asm-hard-reg-error-1.c: New test.
	* gcc.dg/asm-hard-reg-error-2.c: New test.
	* gcc.dg/asm-hard-reg-error-3.c: New test.
	* gcc.dg/asm-hard-reg-error-4.c: New test.
	* gcc.dg/asm-hard-reg-error-5.c: New test.
	* gcc.dg/pr87600-3.c: New test.
	* gcc.target/aarch64/asm-hard-reg-2.c: New test.
	* gcc.target/s390/asm-hard-reg-7.c: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>openmp: Refactor handling of iterators</title>
<updated>2025-07-16T18:38:23+00:00</updated>
<author>
<name>Kwok Cheung Yeung</name>
<email>kcyeung@baylibre.com</email>
</author>
<published>2025-07-16T16:59:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=7f8742ca479b326eb8a25bd2501cb14d7d09a83a'/>
<id>7f8742ca479b326eb8a25bd2501cb14d7d09a83a</id>
<content type='text'>
Move code to calculate the iteration size and to generate the iterator
expansion loop into separate functions.

Use OMP_ITERATOR_DECL_P to check for iterators in clause declarations.

gcc/c-family/

	* c-omp.cc (c_finish_omp_depobj): Use OMP_ITERATOR_DECL_P.

gcc/c/

	* c-typeck.cc (handle_omp_array_sections): Use OMP_ITERATOR_DECL_P.
	(c_finish_omp_clauses): Likewise.

gcc/cp/

	* pt.cc (tsubst_omp_clause_decl): Use OMP_ITERATOR_DECL_P.
	* semantics.cc (handle_omp_array_sections): Likewise.
	(finish_omp_clauses): Likewise.

gcc/

	* gimplify.cc (gimplify_omp_affinity): Use OMP_ITERATOR_DECL_P.
	(compute_omp_iterator_count): New.
	(build_omp_iterator_loop): New.
	(gimplify_omp_depend): Use OMP_ITERATOR_DECL_P,
	compute_omp_iterator_count and build_omp_iterator_loop.
	* tree-inline.cc (copy_tree_body_r): Use OMP_ITERATOR_DECL_P.
	* tree-pretty-print.cc (dump_omp_clause): Likewise.
	* tree.h (OMP_ITERATOR_DECL_P): New macro.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move code to calculate the iteration size and to generate the iterator
expansion loop into separate functions.

Use OMP_ITERATOR_DECL_P to check for iterators in clause declarations.

gcc/c-family/

	* c-omp.cc (c_finish_omp_depobj): Use OMP_ITERATOR_DECL_P.

gcc/c/

	* c-typeck.cc (handle_omp_array_sections): Use OMP_ITERATOR_DECL_P.
	(c_finish_omp_clauses): Likewise.

gcc/cp/

	* pt.cc (tsubst_omp_clause_decl): Use OMP_ITERATOR_DECL_P.
	* semantics.cc (handle_omp_array_sections): Likewise.
	(finish_omp_clauses): Likewise.

gcc/

	* gimplify.cc (gimplify_omp_affinity): Use OMP_ITERATOR_DECL_P.
	(compute_omp_iterator_count): New.
	(build_omp_iterator_loop): New.
	(gimplify_omp_depend): Use OMP_ITERATOR_DECL_P,
	compute_omp_iterator_count and build_omp_iterator_loop.
	* tree-inline.cc (copy_tree_body_r): Use OMP_ITERATOR_DECL_P.
	* tree-pretty-print.cc (dump_omp_clause): Likewise.
	* tree.h (OMP_ITERATOR_DECL_P): New macro.
</pre>
</div>
</content>
</entry>
<entry>
<title>c, c++: Fix unused result for empty types [PR82134]</title>
<updated>2025-07-16T03:50:51+00:00</updated>
<author>
<name>Jeremy Rifkin</name>
<email>jeremy@rifkin.dev</email>
</author>
<published>2025-07-15T22:17:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=32ff6f4728e4021ff33fb1da6eb3bafe3ea5a15e'/>
<id>32ff6f4728e4021ff33fb1da6eb3bafe3ea5a15e</id>
<content type='text'>
Hi,
This fixes PR c/82134 which concerns gcc emitting an incorrect unused
result diagnostic for empty types. This diagnostic is emitted from
tree-cfg.cc because of a couple code paths which attempt to avoid
copying empty types, resulting in GIMPLE that isn't using the returned
value of a call. To fix this I've added suppress_warning in three locations
and a corresponding check in do_warn_unused_result.

Cheers,
Jeremy

	PR c/82134

gcc/cp/ChangeLog:

	* call.cc (build_call_a): Add suppress_warning
	* cp-gimplify.cc (cp_gimplify_expr): Add suppress_warning

gcc/ChangeLog:

	* gimplify.cc (gimplify_modify_expr): Add suppress_warning
	* tree-cfg.cc (do_warn_unused_result): Check warning_suppressed_p

gcc/testsuite/ChangeLog:

	* c-c++-common/attr-warn-unused-result-2.c: New test.

Signed-off-by: Jeremy Rifkin &lt;jeremy@rifkin.dev&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hi,
This fixes PR c/82134 which concerns gcc emitting an incorrect unused
result diagnostic for empty types. This diagnostic is emitted from
tree-cfg.cc because of a couple code paths which attempt to avoid
copying empty types, resulting in GIMPLE that isn't using the returned
value of a call. To fix this I've added suppress_warning in three locations
and a corresponding check in do_warn_unused_result.

Cheers,
Jeremy

	PR c/82134

gcc/cp/ChangeLog:

	* call.cc (build_call_a): Add suppress_warning
	* cp-gimplify.cc (cp_gimplify_expr): Add suppress_warning

gcc/ChangeLog:

	* gimplify.cc (gimplify_modify_expr): Add suppress_warning
	* tree-cfg.cc (do_warn_unused_result): Check warning_suppressed_p

gcc/testsuite/ChangeLog:

	* c-c++-common/attr-warn-unused-result-2.c: New test.

Signed-off-by: Jeremy Rifkin &lt;jeremy@rifkin.dev&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>OpenMP: C++ "declare mapper" support</title>
<updated>2025-05-30T07:00:37+00:00</updated>
<author>
<name>Julian Brown</name>
<email>julian@codesourcery.com</email>
</author>
<published>2025-05-30T06:41:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=48973e8783e59462ab6e34d5d48b74a2146a05f1'/>
<id>48973e8783e59462ab6e34d5d48b74a2146a05f1</id>
<content type='text'>
This patch adds support for OpenMP 5.0 "declare mapper" functionality
for C++.  I've merged it to og13 based on the last version
posted upstream, with some minor changes due to the newly-added
'present' map modifier support.  There's also a fix to splay-tree
traversal in gimplify.cc:omp_instantiate_implicit_mappers, and this patch
omits the rearrangement of gimplify.cc:gimplify_{scan,adjust}_omp_clauses
that I separated out into its own patch and applied (to og13) already.

gcc/c-family/
	* c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and
	C_ORT_OMP_DECLARE_MAPPER codes.
	(omp_mapper_list): Add forward declaration.
	(c_omp_find_nested_mappers, c_omp_instantiate_mappers): Add prototypes.
	* c-omp.cc (c_omp_find_nested_mappers): New function.
	(remap_mapper_decl_info): New struct.
	(remap_mapper_decl_1, omp_instantiate_mapper,
	c_omp_instantiate_mappers): New functions.

gcc/cp/
	* constexpr.cc (reduced_constant_expression_p): Add OMP_DECLARE_MAPPER
	case.
	(cxx_eval_constant_expression, potential_constant_expression_1):
	Likewise.
	* cp-gimplify.cc (cxx_omp_finish_mapper_clauses): New function.
	* cp-objcp-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks.
	* cp-tree.h (lang_decl_base): Add omp_declare_mapper_p field.  Recount
	spare bits comment.
	(DECL_OMP_DECLARE_MAPPER_P): New macro.
	(omp_mapper_id): Add prototype.
	(cp_check_omp_declare_mapper): Add prototype.
	(omp_instantiate_mappers): Add prototype.
	(cxx_omp_finish_mapper_clauses): Add prototype.
	(cxx_omp_mapper_lookup): Add prototype.
	(cxx_omp_extract_mapper_directive): Add prototype.
	(cxx_omp_map_array_section): Add prototype.
	* decl.cc (check_initializer): Add OpenMP declare mapper support.
	(cp_finish_decl): Set DECL_INITIAL for OpenMP declare mapper var decls
	as appropriate.
	* decl2.cc (mark_used): Instantiate OpenMP "declare mapper" magic var
	decls.
	* error.cc (dump_omp_declare_mapper): New function.
	(dump_simple_decl): Use above.
	* parser.cc (cp_parser_omp_clause_map): Add KIND parameter.  Support
	"mapper" modifier.
	(cp_parser_omp_all_clauses): Add KIND argument to
	cp_parser_omp_clause_map call.
	(cp_parser_omp_target): Call omp_instantiate_mappers before
	finish_omp_clauses.
	(cp_parser_omp_declare_mapper): New function.
	(cp_parser_omp_declare): Add "declare mapper" support.
	* pt.cc (tsubst_decl): Adjust name of "declare mapper" magic var decls
	once we know their type.
	(tsubst_omp_clauses): Call omp_instantiate_mappers before
	finish_omp_clauses, for target regions.
	(tsubst_expr): Support OMP_DECLARE_MAPPER nodes.
	(instantiate_decl): Instantiate initialiser (i.e definition) for OpenMP
	declare mappers.
	* semantics.cc (gimplify.h): Include.
	(omp_mapper_id, omp_mapper_lookup, omp_extract_mapper_directive,
	cxx_omp_map_array_section, cp_check_omp_declare_mapper): New functions.
	(finish_omp_clauses): Delete GOMP_MAP_PUSH_MAPPER_NAME and
	GOMP_MAP_POP_MAPPER_NAME artificial clauses.
	(omp_target_walk_data): Add MAPPERS field.
	(finish_omp_target_clauses_r): Scan for uses of struct/union/class type
	variables.
	(finish_omp_target_clauses): Create artificial mapper binding clauses
	for used structs/unions/classes in offload region.

gcc/fortran/
	* parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes
	(for additions to omp-general.h).

gcc/
	* gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field.
	(new_omp_context): Initialise IMPLICIT_MAPPERS hash map.
	(delete_omp_context): Delete IMPLICIT_MAPPERS hash map.
	(instantiate_mapper_info): New structs.
	(remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper,
	omp_instantiate_implicit_mappers): New functions.
	(gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses.
	(gimplify_adjust_omp_clauses): Instantiate implicit declared mappers.
	(gimplify_omp_declare_mapper): New function.
	(gimplify_expr): Call above function.
	* langhooks-def.h (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add
	prototypes.
	(LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros.
	(LANG_HOOK_DECLS): Add above macros.
	* langhooks.cc (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New
	dummy functions.
	* langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES,
	OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION
	hooks.
	* omp-general.h (omp_name_type&lt;T&gt;): Add templatized struct, hash type
	traits (for omp_name_type&lt;tree&gt; specialization).
	(omp_mapper_list&lt;T&gt;): Add struct.
	* tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_.
	* tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clauses.  Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
	OMP_CLAUSE__MAPPER_BINDING_.
	* tree.def (OMP_DECLARE_MAPPER): New tree code.
	* tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL,
	OMP_DECLARE_MAPPER_CLAUSES): New defines.
	(OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL,
	OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines.

include/
	* gomp-constants.h (gomp_map_kind): Add GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clause types.

gcc/testsuite/
	* c-c++-common/gomp/map-6.c: Update error scan output.
	* c-c++-common/gomp/declare-mapper-3.c: New test (only enabled for C++
	for now).
	* c-c++-common/gomp/declare-mapper-4.c: Likewise.
	* c-c++-common/gomp/declare-mapper-5.c: Likewise.
	* c-c++-common/gomp/declare-mapper-6.c: Likewise.
	* c-c++-common/gomp/declare-mapper-7.c: Likewise.
	* c-c++-common/gomp/declare-mapper-8.c: Likewise.
	* c-c++-common/gomp/declare-mapper-9.c: Likewise.
	* c-c++-common/gomp/declare-mapper-10.c: Likewise.
	* c-c++-common/gomp/declare-mapper-12.c: Likewise.
	* g++.dg/gomp/declare-mapper-1.C: New test.
	* g++.dg/gomp/declare-mapper-2.C: New test.
	* g++.dg/gomp/declare-mapper-3.C: New test.

libgomp/
	* testsuite/libgomp.c++/declare-mapper-1.C: New test.
	* testsuite/libgomp.c++/declare-mapper-2.C: New test.
	* testsuite/libgomp.c++/declare-mapper-3.C: New test.
	* testsuite/libgomp.c++/declare-mapper-4.C: New test.
	* testsuite/libgomp.c++/declare-mapper-5.C: New test.
	* testsuite/libgomp.c++/declare-mapper-6.C: New test.
	* testsuite/libgomp.c++/declare-mapper-7.C: New test.
	* testsuite/libgomp.c++/declare-mapper-8.C: New test.
	* testsuite/libgomp.c-c++-common/declare-mapper-9.c: New test (only
	enabled for C++ for now).
	* testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise.

Co-authored-by: Tobias Burnus &lt;tburnus@baylibre.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds support for OpenMP 5.0 "declare mapper" functionality
for C++.  I've merged it to og13 based on the last version
posted upstream, with some minor changes due to the newly-added
'present' map modifier support.  There's also a fix to splay-tree
traversal in gimplify.cc:omp_instantiate_implicit_mappers, and this patch
omits the rearrangement of gimplify.cc:gimplify_{scan,adjust}_omp_clauses
that I separated out into its own patch and applied (to og13) already.

gcc/c-family/
	* c-common.h (c_omp_region_type): Add C_ORT_DECLARE_MAPPER and
	C_ORT_OMP_DECLARE_MAPPER codes.
	(omp_mapper_list): Add forward declaration.
	(c_omp_find_nested_mappers, c_omp_instantiate_mappers): Add prototypes.
	* c-omp.cc (c_omp_find_nested_mappers): New function.
	(remap_mapper_decl_info): New struct.
	(remap_mapper_decl_1, omp_instantiate_mapper,
	c_omp_instantiate_mappers): New functions.

gcc/cp/
	* constexpr.cc (reduced_constant_expression_p): Add OMP_DECLARE_MAPPER
	case.
	(cxx_eval_constant_expression, potential_constant_expression_1):
	Likewise.
	* cp-gimplify.cc (cxx_omp_finish_mapper_clauses): New function.
	* cp-objcp-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks.
	* cp-tree.h (lang_decl_base): Add omp_declare_mapper_p field.  Recount
	spare bits comment.
	(DECL_OMP_DECLARE_MAPPER_P): New macro.
	(omp_mapper_id): Add prototype.
	(cp_check_omp_declare_mapper): Add prototype.
	(omp_instantiate_mappers): Add prototype.
	(cxx_omp_finish_mapper_clauses): Add prototype.
	(cxx_omp_mapper_lookup): Add prototype.
	(cxx_omp_extract_mapper_directive): Add prototype.
	(cxx_omp_map_array_section): Add prototype.
	* decl.cc (check_initializer): Add OpenMP declare mapper support.
	(cp_finish_decl): Set DECL_INITIAL for OpenMP declare mapper var decls
	as appropriate.
	* decl2.cc (mark_used): Instantiate OpenMP "declare mapper" magic var
	decls.
	* error.cc (dump_omp_declare_mapper): New function.
	(dump_simple_decl): Use above.
	* parser.cc (cp_parser_omp_clause_map): Add KIND parameter.  Support
	"mapper" modifier.
	(cp_parser_omp_all_clauses): Add KIND argument to
	cp_parser_omp_clause_map call.
	(cp_parser_omp_target): Call omp_instantiate_mappers before
	finish_omp_clauses.
	(cp_parser_omp_declare_mapper): New function.
	(cp_parser_omp_declare): Add "declare mapper" support.
	* pt.cc (tsubst_decl): Adjust name of "declare mapper" magic var decls
	once we know their type.
	(tsubst_omp_clauses): Call omp_instantiate_mappers before
	finish_omp_clauses, for target regions.
	(tsubst_expr): Support OMP_DECLARE_MAPPER nodes.
	(instantiate_decl): Instantiate initialiser (i.e definition) for OpenMP
	declare mappers.
	* semantics.cc (gimplify.h): Include.
	(omp_mapper_id, omp_mapper_lookup, omp_extract_mapper_directive,
	cxx_omp_map_array_section, cp_check_omp_declare_mapper): New functions.
	(finish_omp_clauses): Delete GOMP_MAP_PUSH_MAPPER_NAME and
	GOMP_MAP_POP_MAPPER_NAME artificial clauses.
	(omp_target_walk_data): Add MAPPERS field.
	(finish_omp_target_clauses_r): Scan for uses of struct/union/class type
	variables.
	(finish_omp_target_clauses): Create artificial mapper binding clauses
	for used structs/unions/classes in offload region.

gcc/fortran/
	* parse.cc (tree.h, fold-const.h, tree-hash-traits.h): Add includes
	(for additions to omp-general.h).

gcc/
	* gimplify.cc (gimplify_omp_ctx): Add IMPLICIT_MAPPERS field.
	(new_omp_context): Initialise IMPLICIT_MAPPERS hash map.
	(delete_omp_context): Delete IMPLICIT_MAPPERS hash map.
	(instantiate_mapper_info): New structs.
	(remap_mapper_decl_1, omp_mapper_copy_decl, omp_instantiate_mapper,
	omp_instantiate_implicit_mappers): New functions.
	(gimplify_scan_omp_clauses): Handle MAPPER_BINDING clauses.
	(gimplify_adjust_omp_clauses): Instantiate implicit declared mappers.
	(gimplify_omp_declare_mapper): New function.
	(gimplify_expr): Call above function.
	* langhooks-def.h (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): Add
	prototypes.
	(LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
	LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
	LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define macros.
	(LANG_HOOK_DECLS): Add above macros.
	* langhooks.cc (lhd_omp_mapper_lookup,
	lhd_omp_extract_mapper_directive, lhd_omp_map_array_section): New
	dummy functions.
	* langhooks.h (lang_hooks_for_decls): Add OMP_FINISH_MAPPER_CLAUSES,
	OMP_MAPPER_LOOKUP, OMP_EXTRACT_MAPPER_DIRECTIVE, OMP_MAP_ARRAY_SECTION
	hooks.
	* omp-general.h (omp_name_type&lt;T&gt;): Add templatized struct, hash type
	traits (for omp_name_type&lt;tree&gt; specialization).
	(omp_mapper_list&lt;T&gt;): Add struct.
	* tree-core.h (omp_clause_code): Add OMP_CLAUSE__MAPPER_BINDING_.
	* tree-pretty-print.cc (dump_omp_clause): Support GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clauses.  Support OMP_CLAUSE__MAPPER_BINDING_ and OMP_DECLARE_MAPPER.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
	OMP_CLAUSE__MAPPER_BINDING_.
	* tree.def (OMP_DECLARE_MAPPER): New tree code.
	* tree.h (OMP_DECLARE_MAPPER_ID, OMP_DECLARE_MAPPER_DECL,
	OMP_DECLARE_MAPPER_CLAUSES): New defines.
	(OMP_CLAUSE__MAPPER_BINDING__ID, OMP_CLAUSE__MAPPER_BINDING__DECL,
	OMP_CLAUSE__MAPPER_BINDING__MAPPER): New defines.

include/
	* gomp-constants.h (gomp_map_kind): Add GOMP_MAP_UNSET,
	GOMP_MAP_PUSH_MAPPER_NAME, GOMP_MAP_POP_MAPPER_NAME artificial mapping
	clause types.

gcc/testsuite/
	* c-c++-common/gomp/map-6.c: Update error scan output.
	* c-c++-common/gomp/declare-mapper-3.c: New test (only enabled for C++
	for now).
	* c-c++-common/gomp/declare-mapper-4.c: Likewise.
	* c-c++-common/gomp/declare-mapper-5.c: Likewise.
	* c-c++-common/gomp/declare-mapper-6.c: Likewise.
	* c-c++-common/gomp/declare-mapper-7.c: Likewise.
	* c-c++-common/gomp/declare-mapper-8.c: Likewise.
	* c-c++-common/gomp/declare-mapper-9.c: Likewise.
	* c-c++-common/gomp/declare-mapper-10.c: Likewise.
	* c-c++-common/gomp/declare-mapper-12.c: Likewise.
	* g++.dg/gomp/declare-mapper-1.C: New test.
	* g++.dg/gomp/declare-mapper-2.C: New test.
	* g++.dg/gomp/declare-mapper-3.C: New test.

libgomp/
	* testsuite/libgomp.c++/declare-mapper-1.C: New test.
	* testsuite/libgomp.c++/declare-mapper-2.C: New test.
	* testsuite/libgomp.c++/declare-mapper-3.C: New test.
	* testsuite/libgomp.c++/declare-mapper-4.C: New test.
	* testsuite/libgomp.c++/declare-mapper-5.C: New test.
	* testsuite/libgomp.c++/declare-mapper-6.C: New test.
	* testsuite/libgomp.c++/declare-mapper-7.C: New test.
	* testsuite/libgomp.c++/declare-mapper-8.C: New test.
	* testsuite/libgomp.c-c++-common/declare-mapper-9.c: New test (only
	enabled for C++ for now).
	* testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise.
	* testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise.

Co-authored-by: Tobias Burnus &lt;tburnus@baylibre.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
