[gcc r15-9554] libstdc++: Update status tables to refer to GCC 15 not mainline

2025-04-17 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:7336054f9b012a0812cd0a260375cd987e4aadf9

commit r15-9554-g7336054f9b012a0812cd0a260375cd987e4aadf9
Author: Jonathan Wakely 
Date:   Fri Apr 26 11:46:01 2024 +0100

libstdc++: Update status tables to refer to GCC 15 not mainline

libstdc++-v3/ChangeLog:

* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Replace references to
mainline GCC.
* doc/xml/manual/status_cxx2011.xml: Likewise.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/xml/manual/status_cxx2023.xml: Likewise.
* doc/xml/manual/status_cxxtr1.xml: Likewise.
* doc/xml/manual/status_cxxtr24733.xml: Likewise.

Diff:
---
 libstdc++-v3/doc/html/manual/status.html  | 16 
 libstdc++-v3/doc/xml/manual/status_cxx1998.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2011.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2014.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2017.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2020.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2023.xml|  2 +-
 libstdc++-v3/doc/xml/manual/status_cxxtr1.xml |  2 +-
 libstdc++-v3/doc/xml/manual/status_cxxtr24733.xml |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/status.html 
b/libstdc++-v3/doc/html/manual/status.html
index 3d55e2652729..0f095b8c858a 100644
--- a/libstdc++-v3/doc/html/manual/status.html
+++ b/libstdc++-v3/doc/html/manual/status.html
@@ -6,7 +6,7 @@
 This status table is based on the table of contents of ISO/IEC 14882:2003.
 
 This section describes the C++ support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 Table 1.1. C++ 1998/2003 Implementation 
StatusSectionDescriptionStatusComments
18
   
@@ -161,7 +161,7 @@ since that release.
 This status table is based on the table of contents of ISO/IEC 14882:2011.
 
 This section describes the C++11 support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 Table 1.2. C++ 2011 Implementation 
StatusSectionDescriptionStatusComments
18
   
@@ -434,7 +434,7 @@ Some subclauses are not shown in the table where the 
content is unchanged
 since C++11 and the implementation is complete.
 
 This section describes the C++14 and library TS support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 Table 1.3. C++ 2014 Implementation 
StatusSectionDescriptionStatusComments
18
   
@@ -579,7 +579,7 @@ so the API and ABI of features added in C++17 is only stable
 since that release.
 
 This section describes the C++17 and library TS support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 
 The following table lists new library features that are included in
 the C++17 standard. The "Proposal" column provides a link to the
@@ -1255,7 +1255,7 @@ options. The pre-defined symbol
 presence of the required flag.
 
 This section describes the C++20 and library TS support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 
 The following table lists new library features that are included in
 the C++20 standard. The "Proposal" column provides a link to the
@@ -1725,7 +1725,7 @@ options. The pre-defined symbol
 presence of the required flag.
 
 This section describes the C++23 and library TS support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 
 The following table lists new library features that have been accepted into
 the C++23 working draft. The "Proposal" column provides a link to the
@@ -2213,7 +2213,7 @@ In this implementation the header names are prefixed by
 , and so on.
 
 This page describes the TR1 support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 Table 1.11. C++ TR1 Implementation 
StatusSectionDescriptionStatusComments2General Utilities2.1Reference wrappers 
 2.1.1Additions to header  
synopsisY 2.1.2Class template reference_wrapper  2.1.2.1reference_wrapper construct/copy/destroyY 2.1.2.2reference_wrapper assignmentY 2.1.2.3reference_wrapper accessY 2.1.2.4reference_wrapper invocationY 2.1.2.5reference_wrapper helper functionsY 
 2.2Smart pointers  2.2.1Additions to header  
synopsisY 2.2.2Class bad_weak_ptrY 
2.2.3Class template shared_ptr 

  Uses code from
@@ -2234,7 +2234,7 @@ ISO/IEC TR 24733:2011,
 decimal floating-point arithmetic".
 
 This page describes the TR 24733 support in
-mainline GCC, not in any particular release.
+the GCC 15 release series.
 Table 1.12. C++ TR 24733 Implementation 
StatusSectionDescriptionStatusComments
0
   
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx1998.xml 
b/libstdc++-v3/doc/xml/manual

[gcc r16-3] doc: say "compatible types" for -fstrict-aliasing

2025-04-17 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:7c47badcdc8625ea53aed275be96c32bc78db25b

commit r16-3-g7c47badcdc8625ea53aed275be96c32bc78db25b
Author: Sam James 
Date:   Mon Mar 24 04:32:47 2025 +

doc: say "compatible types" for -fstrict-aliasing

Include the term used in the standard to ease further research for users,
and while at it, rephrase the description of the rule entirely using
Alexander Monakov's suggestion: it was previously wrong (and imprecise) as
"the same address" may well be re-used later on, and the issue is the
access via an expression of the wrong type.

gcc/ChangeLog:

* doc/invoke.texi: Use "compatible types" term. Rephrase to be
more precise (and correct).

Diff:
---
 gcc/doc/invoke.texi | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 14a78fd236f6..020442aa032e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -14649,12 +14649,14 @@ Enabled at levels @option{-O2}, @option{-O3}, 
@option{-Os}.
 @item -fstrict-aliasing
 Allow the compiler to assume the strictest aliasing rules applicable to
 the language being compiled.  For C (and C++), this activates
-optimizations based on the type of expressions.  In particular, an
-object of one type is assumed never to reside at the same address as an
-object of a different type, unless the types are almost the same.  For
-example, an @code{unsigned int} can alias an @code{int}, but not a
-@code{void*} or a @code{double}.  A character type may alias any other
-type.
+optimizations based on the type of expressions.  In particular, accessing
+an object of one type via an expression of a different type is not allowed,
+unless the types are @dfn{compatible types}, differ only in signedness or
+qualifiers, or the expression has a character type.  Accessing scalar
+objects via a corresponding vector type is also allowed.
+
+For example, an @code{unsigned int} can alias an @code{int}, but not a
+@code{void*} or a @code{double}.  A character type may alias any other type.
 
 @anchor{Type-punning}Pay special attention to code like this:
 @smallexample


[gcc/devel/omp/gcc-14] nvptx: Support '-mfake-ptx-alloca': defer failure to run-time 'alloca' usage

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2c87363e915f799ef9fd42026d2c2991ca9a

commit 2c87363e915f799ef9fd42026d2c2991ca9a
Author: Thomas Schwinge 
Date:   Sun Apr 6 17:44:18 2025 +0200

nvptx: Support '-mfake-ptx-alloca': defer failure to run-time 'alloca' usage

Follow-up to commit 1146410c0feb0e82c689b1333fdf530a2b34dc2b
"nvptx: Support '-mfake-ptx-alloca'".  '-mfake-ptx-alloca' is applicable 
only
for configurations where PTX 'alloca' is not supported, where target 
libraries
are built with it enabled (that is, libstdc++, libgfortran).

This change progresses:

[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 
[-compilation failed to produce executable-]{+execution test+}
[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 
[-compilation failed to produce executable-]{+execution test+}
UNSUPPORTED: g++.dg/tree-ssa/pr20458.C  -std=gnu++98: exception 
handling not supported

..., and "enables" a few test cases:

FAIL: g++.old-deja/g++.other/sibcall1.C  -std=gnu++17 (test for excess 
errors)
[Etc.]

FAIL: g++.old-deja/g++.other/unchanging1.C  -std=gnu++17 (test for 
excess errors)
[Etc.]

..., which now (unrelatedly to 'alloca', and in the same way as 
configurations
where PTX 'alloca' is supported) FAIL due to:

unresolved symbol _Unwind_DeleteException
collect2: error: ld returned 1 exit status

Most importantly, it progresses ~830 libstdc++ test cases:

[-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

[-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce 
executable-]{+execution test+}

..., or just a few 'FAIL: [...] execution test' where these test cases also
FAIL in configurations where PTX 'alloca' is supported, or ~120 instances of
'FAIL: [...]  execution test' due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

This change also resolves the cases noted in
commit bac2d8a246892334e24dfa7d62be0cd0648c5606
"nvptx: Build libgfortran with '-mfake-ptx-alloca' [PR107635]":

| With '-mfake-ptx-alloca', libgfortran again succeeds to build, and 
compared
| to before, we've got only a small number of regressions due to nvptx 'ld'
| complaining about 'unresolved symbol 
__GCC_nvptx__PTX_alloca_not_supported':
|
| [-PASS:-]{+FAIL:+} gfortran.dg/coarray/codimension_2.f90 
-fcoarray=lib  -O2  -lcaf_single (test for excess errors)

[-FAIL:-]{+PASS:+} gfortran.dg/coarray/codimension_2.f90 -fcoarray=lib  
-O2  -lcaf_single (test for excess errors)

| [-PASS:-]{+FAIL:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2 
 -lcaf_single (test for excess errors)
| [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/event_4.f08 
-fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to 
produce executable+}

[-FAIL:-]{+PASS:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  -O2  
-lcaf_single (test for excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/event_4.f08 -fcoarray=lib  
-O2  -lcaf_single [-compilation failed to produce executable-]{+execution test+}

| [-PASS:-]{+FAIL:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib 
 -O2  -lcaf_single (test for excess errors)
| [-PASS:-]{+UNRESOLVED:+} gfortran.dg/coarray/fail_image_2.f08 
-fcoarray=lib  -O2  -lcaf_single [-execution test-]{+compilation failed to 
produce executable+}

[-FAIL:-]{+PASS:+} gfortran.dg/coarray/fail_image_2.f08 -fcoarray=lib  
-O2  -lcaf_single (test for excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/fail_image_2.f08 
-fcoarray=lib  -O2  -lcaf_single [-compilation failed to produce 
executable-]{+execution test+}

| [-PASS:-]{+FAIL:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 
-fcoarray=lib  -O2  -lcaf_single (test for excess errors)
| [-PASS:-]{+UNRESOLVED:+} 
gfortran.dg/coarray/proc_pointer_assign_1.f90 -fcoarray=lib  -O2  -lcaf_single 
[-execution test-]{+compilation failed to produce executable+}

[-FAIL:-]{+PASS:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 
-fcoarray=lib  -O2  -lcaf_single (test for excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/coarray/proc_pointer_assign_1.f90 
-fcoarray=lib  -O2  -lcaf_single [-compilation failed to produce 
executable-]{+execution test+}

| [-PASS:-]{+FAIL:+} gfortran.dg/coarray_43.f90   -O  (test for excess 
errors)

[-FAIL:-]{+PASS:+} gfortran.dg/coarray_43.f90   -O  (test for excess 
errors)

..., and further progresses:

[-FAIL:-]{+PASS:+} gfor

[gcc r16-5] c++: add assert to cp_make_fname_decl

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:eff4dc423327682d4b1e32f0122d9e973e3c6f99

commit r16-5-geff4dc423327682d4b1e32f0122d9e973e3c6f99
Author: Jason Merrill 
Date:   Fri Apr 4 23:27:50 2025 -0400

c++: add assert to cp_make_fname_decl

In the PR118629 testcase, pushdecl_outermost_localscope was failing and
returning error_mark_node without ever actually giving an error; in addition
to my earlier fix for the failure, make sure failures aren't silent.

gcc/cp/ChangeLog:

* decl.cc (cp_make_fname_decl): Prevent silent failure.

Diff:
---
 gcc/cp/decl.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 4e97093b1341..84398e5952a1 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -5339,6 +5339,8 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep)
   decl = pushdecl_outermost_localscope (decl);
   if (decl != error_mark_node)
add_decl_expr (decl);
+  else
+   gcc_assert (seen_error ());
 }
   else
 {


[gcc r16-4] c++: 'requires' diagnostic before C++20

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:47b62be9cace0e2e124650f331788d52ffd5fb25

commit r16-4-g47b62be9cace0e2e124650f331788d52ffd5fb25
Author: Jason Merrill 
Date:   Tue Jan 28 17:46:59 2025 -0500

c++: 'requires' diagnostic before C++20

We were giving a generic "not declared" error for a requires-expression
without concepts enabled; we can do better.

gcc/cp/ChangeLog:

* lex.cc (unqualified_name_lookup_error): Handle 'requires' better.

Diff:
---
 gcc/cp/lex.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/cp/lex.cc b/gcc/cp/lex.cc
index c12b084aad99..12af81ed078c 100644
--- a/gcc/cp/lex.cc
+++ b/gcc/cp/lex.cc
@@ -749,6 +749,9 @@ unqualified_name_lookup_error (tree name, location_t loc)
 
   if (IDENTIFIER_ANY_OP_P (name))
 error_at (loc, "%qD not defined", name);
+  else if (!flag_concepts && name == ridpointers[(int)RID_REQUIRES])
+error_at (loc, "% only available with %<-std=c++20%> or "
+ "%<-fconcepts%>");
   else
 {
   if (!objc_diagnose_private_ivar (name))


[gcc/devel/omp/gcc-14] openmp, fortran: Move udm field of gfc_omp_namelist into a new union

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:2afb6281a5a8711b82aa744e71c181bab6537e3c

commit 2afb6281a5a8711b82aa744e71c181bab6537e3c
Author: Kwok Cheung Yeung 
Date:   Thu Sep 12 21:30:34 2024 +0100

openmp, fortran: Move udm field of gfc_omp_namelist into a new union

This patch moves u2.udm into u3.udm.

This is necessary to avoid clashes when mappers are used together with
iterators, which uses u2.ns.

gcc/fortran/

* gfortran.h (struct gfc_omp_namelist): Move udm field into a new
union u3.
* match.cc (gfc_free_omp_namelist): Change references to u2.udm to
u3.udm.
* module.cc (load_omp_udms): Likewise.
(write_omp_udm): Likewise.
* openmp.cc (gfc_match_motion_var_list): Likewise.
(gfc_match_omp_clauses): Likewise.
(resolve_omp_clauses): Likewise.
(gfc_omp_instantiate_mapper): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
(gfc_find_nested_mappers): Likewise.

Diff:
---
 gcc/fortran/ChangeLog.omp   | 15 +++
 gcc/fortran/gfortran.h  |  5 -
 gcc/fortran/match.cc|  4 ++--
 gcc/fortran/module.cc   | 20 ++--
 gcc/fortran/openmp.cc   | 32 
 gcc/fortran/trans-openmp.cc | 16 
 6 files changed, 55 insertions(+), 37 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 969b2f306bc2..2b9d095cfa33 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,18 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * gfortran.h (struct gfc_omp_namelist): Move udm field into a new
+   union u3.
+   * match.cc (gfc_free_omp_namelist): Change references to u2.udm to
+   u3.udm.
+   * module.cc (load_omp_udms): Likewise.
+   (write_omp_udm): Likewise.
+   * openmp.cc (gfc_match_motion_var_list): Likewise.
+   (gfc_match_omp_clauses): Likewise.
+   (resolve_omp_clauses): Likewise.
+   (gfc_omp_instantiate_mapper): Likewise.
+   * trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
+   (gfc_find_nested_mappers): Likewise.
+
 2025-03-21  Paul-Antoine Arras  
 
Backported from master:
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 40711fcec52f..2cef5a1d913c 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1410,13 +1410,16 @@ typedef struct gfc_omp_namelist
   union
 {
   struct gfc_omp_namelist_udr *udr;
-  struct gfc_omp_namelist_udm *udm;
   gfc_namespace *ns;
   gfc_expr *allocator;
   struct gfc_symbol *traits_sym;
   struct gfc_omp_namelist *duplicate_of;
   char *init_interop;
 } u2;
+  union
+{
+  struct gfc_omp_namelist_udm *udm;
+} u3;
   struct gfc_omp_namelist *next;
   locus where;
 }
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 0f01e28dc692..02f6468b6b7f 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -5578,8 +5578,8 @@ gfc_free_omp_namelist (gfc_omp_namelist *name, int list)
  free (name->u2.init_interop);
}
}
-  else if (free_mapper && name->u2.udm)
-   free (name->u2.udm);
+  else if (free_mapper && name->u3.udm)
+   free (name->u3.udm);
   else if (!free_mapper && name->u2.udr)
{
  if (name->u2.udr->combiner)
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index e5c14d76f9c3..32e17c92a0ef 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -5548,14 +5548,14 @@ load_omp_udms (void)
 
  if (peek_atom () != ATOM_RPAREN)
{
- n->u2.udm = gfc_get_omp_namelist_udm ();
- mio_pool_string (&n->u2.udm->mapper_id);
+ n->u3.udm = gfc_get_omp_namelist_udm ();
+ mio_pool_string (&n->u3.udm->mapper_id);
 
- if (n->u2.udm->mapper_id == NULL)
-   n->u2.udm->mapper_id = gfc_get_string ("%s", "");
+ if (n->u3.udm->mapper_id == NULL)
+   n->u3.udm->mapper_id = gfc_get_string ("%s", "");
 
- n->u2.udm->multiple_elems_p = mio_name (0, omp_map_cardinality);
- mio_pointer_ref (&n->u2.udm->udm);
+ n->u3.udm->multiple_elems_p = mio_name (0, omp_map_cardinality);
+ mio_pointer_ref (&n->u3.udm->udm);
}
 
  mio_rparen ();
@@ -6628,11 +6628,11 @@ write_omp_udm (gfc_omp_udm *udm)
 
   mio_lparen ();
 
-  if (n->u2.udm)
+  if (n->u3.udm)
{
- mio_pool_string (&n->u2.udm->mapper_id);
- mio_name (n->u2.udm->multiple_elems_p, omp_map_cardinality);
- mio_pointer_ref (&n->u2.udm->udm);
+ mio_pool_string (&n->u3.udm->mapper_id);
+ mio_name (n->u3.udm->multiple_elems_p, omp_map_cardinality);
+ mio_pointer_ref (&n->u3.udm->udm);
}
 
   mio_rparen ();
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 7f

[gcc/devel/omp/gcc-14] openmp: Add support for iterators in 'target update' clauses (C/C++)

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:3e3966d78461a4cfadfde079812e3d98335095b0

commit 3e3966d78461a4cfadfde079812e3d98335095b0
Author: Kwok Cheung Yeung 
Date:   Wed Nov 27 21:51:34 2024 +

openmp: Add support for iterators in 'target update' clauses (C/C++)

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

Diff:
---
 gcc/ChangeLog.omp  | 19 ++
 gcc/c/ChangeLog.omp|  6 ++
 gcc/c/c-parser.cc  | 55 ++
 gcc/c/c-typeck.cc  |  5 +-
 gcc/cp/ChangeLog.omp   |  6 ++
 gcc/cp/parser.cc   | 56 --
 gcc/cp/semantics.cc|  5 +-
 gcc/gimplify.cc| 37 +++-
 gcc/testsuite/ChangeLog.omp|  6 ++
 .../c-c++-common/gomp/target-update-iterators-1.c  | 20 +++
 .../c-c++-common/gomp/target-update-iterators-2.c  | 23 
 .../c-c++-common/gomp/target-update-iterators-3.c  | 17 ++
 gcc/tree-pretty-print.cc   | 10 
 gcc/tree.cc|  4 +-
 gcc/tree.h |  6 +-
 libgomp/ChangeLog.omp  |  8 +++
 libgomp/target.c   | 14 +
 .../target-update-iterators-1.c| 65 +
 .../target-update-iterators-2.c| 58 +++
 .../target-update-iterators-3.c| 67 ++
 20 files changed, 449 insertions(+), 38 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 0d31c77933e0..2ba1ef83f204 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,22 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * gimplify.cc (gimplify_scan_omp_clauses): Add argument for iterator
+   loop sequence.   Gimplify the clause decl and size into the iterator
+   loop if iterators are used.
+   (gimplify_omp_workshare): Add argument for iterator loops sequence
+   in call to gimplify_scan_omp_clauses.
+   (gimplify_omp_target_update): Call remove_unused_omp_iterator_vars and
+   build_omp_iterators_loops.  Add loop sequence as argument when calling
+   gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses and building
+   the Gimple statement.
+   * tree-pretty-print.cc (dump_omp_clause): Call dump_omp_iterators
+   for to/from clauses with iterators.
+   * tree.cc (omp_clause_num_ops): Add extra operand for OMP_CLAUSE_FROM
+   and OMP_CLAUSE_TO.
+   * tree.h (OMP_CLAUSE_HAS_ITERATORS): Add check for OMP_CLAUSE_TO and
+   OMP_CLAUSE_FROM.
+   (OMP_CLAUSE_ITERATORS): Likewise.
+
 2025-04-17  Kwok Cheung Yeung  
 
* gimple-pretty-print.cc (dump_gi

[gcc/devel/omp/gcc-14] openmp: Add support for iterators in map clauses (C/C++)

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:28f09913235880d5011fb9b11a1c6e2c7ea6fcfb

commit 28f09913235880d5011fb9b11a1c6e2c7ea6fcfb
Author: Kwok Cheung Yeung 
Date:   Wed Nov 27 21:49:32 2024 +

openmp: Add support for iterators in map clauses (C/C++)

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_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 

Diff:
---
 gcc/ChangeLog.omp

[gcc/devel/omp/gcc-14] openmp: Disable strided target updates when iterators are used

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:1adb0ccac34ca39b6539108bdaa0262256c842d5

commit 1adb0ccac34ca39b6539108bdaa0262256c842d5
Author: Kwok Cheung Yeung 
Date:   Thu Sep 12 21:33:58 2024 +0100

openmp: Disable strided target updates when iterators are used

Non-contiguous target updates result in the new strided target updates code
being used, resulting in new clauses such as GOMP_MAP_GRID_DIM,
GOMP_MAP_GRID_STRIDE etc. These are not currently supported in conjunction
with iterators, so this code-path is disabled when used together with
iterators.

The older target updates supports non-contiguous updates as long as a stride
is not applied.

gcc/c/

* c-typeck.cc (handle_omp_array_sections): Add extra argument.  Set
argument to true if array section has a stride that is not one.
(c_finish_omp_clauses): Disable strided updates when iterators are
used in the clause.  Emit sorry if strided.

gcc/cp/

* semantics.cc (handle_omp_array_sections): Add extra argument.  Set
argument to true if array section has a stride that is not one.
(finish_omp_clauses): Disable strided updates when iterators are
used in the clause.  Emit sorry if strided.

gcc/fortran/

* trans-openmp.cc (gfc_trans_omp_clauses): Disable strided updates
when iterators are used in the clause.

Diff:
---
 gcc/c/ChangeLog.omp |  7 +++
 gcc/c/c-typeck.cc   | 17 ++---
 gcc/cp/ChangeLog.omp|  7 +++
 gcc/cp/semantics.cc | 18 ++
 gcc/fortran/ChangeLog.omp   |  5 +
 gcc/fortran/trans-openmp.cc |  3 +++
 6 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index af995a398571..80a771f50207 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,10 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * c-typeck.cc (handle_omp_array_sections): Add extra argument.  Set
+   argument to true if array section has a stride that is not one.
+   (c_finish_omp_clauses): Disable strided updates when iterators are
+   used in the clause.  Emit sorry if strided.
+
 2025-04-17  Kwok Cheung Yeung  
 
* c-parser.cc (c_parser_omp_clause_from_to): Parse 'iterator' modifier.
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index e6ec927c6bc2..78272d582357 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -14597,7 +14597,7 @@ omp_array_section_low_bound (location_t loc, tree node)
 
 static bool
 handle_omp_array_sections (tree *pc, tree **pnext, enum c_omp_region_type ort,
-  int *discontiguous)
+  int *discontiguous, bool *strided = NULL)
 {
   tree c = *pc;
   bool maybe_zero_len = false;
@@ -14686,6 +14686,8 @@ handle_omp_array_sections (tree *pc, tree **pnext, enum 
c_omp_region_type ort,
 
  if (stride == NULL_TREE)
stride = size_one_node;
+ if (strided && !integer_onep (stride))
+   *strided = true;
  if (discontiguous && *discontiguous)
{
  /* This condition is similar to the error check below, but
@@ -16214,13 +16216,22 @@ c_finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
grp_sentinel = OMP_CLAUSE_CHAIN (c);
 
tree *pnext = NULL;
+   /* FIXME: Strided target updates not supported together with
+  iterators yet.  */
int discontiguous
  = (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
-|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM);
-   if (handle_omp_array_sections (pc, &pnext, ort, &discontiguous))
+|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM)
+   && !OMP_CLAUSE_ITERATORS (c);
+   bool strided = false;
+   if (handle_omp_array_sections (pc, &pnext, ort, &discontiguous,
+  &strided))
  remove = true;
else
  {
+   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
+|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM)
+   && OMP_CLAUSE_ITERATORS (c) && strided)
+ sorry ("strided target updates with iterators");
c = *pc;
t = OMP_CLAUSE_DECL (c);
if (!omp_mappable_type (TREE_TYPE (t)))
diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 80d2c3b5069e..95e2b32e60e3 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,10 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * semantics.cc (handle_omp_array_sections): Add extra argument.  Set
+   argument to true if array section has a stride that is not one.
+   (finish_omp_clauses): Disable strided updates when iterators are
+   used in the clause.  E

[gcc/devel/omp/gcc-14] openmp, fortran: Revert to using tree expressions when translating Fortran OpenMP array sections

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:89e6586616e84564902b4721364a091daa6cd0a3

commit 89e6586616e84564902b4721364a091daa6cd0a3
Author: Kwok Cheung Yeung 
Date:   Wed Apr 16 11:43:00 2025 +0100

openmp, fortran: Revert to using tree expressions when translating Fortran 
OpenMP array sections

In the patch 'OpenACC 2.7: Implement reductions for arrays and records',
temporaries are used to hold the decl and bias of clauses resulting from 
array
sections, which breaks some assumptions made for map iterator support.

This patch reverts the change for OpenMP only.

gcc/fortran/

* trans-openmp.cc (gfc_trans_omp_array_section): Use temporaries 
only
when translating OpenACC.

gcc/testsuite/

* gfortran.dg/gomp/target-enter-exit-data.f90: Revert expected tree
dumps.

Diff:
---
 gcc/fortran/ChangeLog.omp  |  5 +
 gcc/fortran/trans-openmp.cc| 24 ++
 gcc/testsuite/ChangeLog.omp|  5 +
 .../gfortran.dg/gomp/target-enter-exit-data.f90|  8 
 4 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 2b9d095cfa33..b0846c29029a 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,8 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * trans-openmp.cc (gfc_trans_omp_array_section): Use temporaries only
+   when translating OpenACC.
+
 2025-04-17  Kwok Cheung Yeung  
 
* gfortran.h (struct gfc_omp_namelist): Move udm field into a new
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 7c76360a56e4..1babad8aa741 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -4114,10 +4114,14 @@ gfc_trans_omp_array_section (stmtblock_t *block, 
toc_directive cd,
  offset = build2 (TRUNC_DIV_EXPR, ptrdiff_type_node,
   offset, fold_convert (ptrdiff_type_node, elemsz));
 
- tree offset_tmp = create_tmp_var (ptrdiff_type_node);
- gfc_add_expr_to_block (block, build2 (MODIFY_EXPR, ptrdiff_type_node,
-   offset_tmp, offset));
- offset = offset_tmp;
+ if (!openmp)
+   {
+ tree offset_tmp = create_tmp_var (ptrdiff_type_node);
+ gfc_add_expr_to_block (block, build2 (MODIFY_EXPR,
+   ptrdiff_type_node,
+   offset_tmp, offset));
+ offset = offset_tmp;
+   }
  offset = build4_loc (input_location, ARRAY_REF,
   TREE_TYPE (TREE_TYPE (decl)),
   decl, offset, NULL_TREE, NULL_TREE);
@@ -4137,12 +4141,16 @@ gfc_trans_omp_array_section (stmtblock_t *block, 
toc_directive cd,
   OMP_CLAUSE_DECL (node3) = decl;
 }
 
-  tree ptr_tmp = create_tmp_var (ptrdiff_type_node);
   ptr = fold_build2 (MINUS_EXPR, ptrdiff_type_node, ptr,
 fold_convert (ptrdiff_type_node, ptr2));
-  gfc_add_expr_to_block (block, build2 (MODIFY_EXPR, ptrdiff_type_node,
-   ptr_tmp, ptr));
-  OMP_CLAUSE_SIZE (node3) = ptr_tmp;
+  if (!openmp)
+{
+  tree ptr_tmp = create_tmp_var (ptrdiff_type_node);
+  gfc_add_expr_to_block (block, build2 (MODIFY_EXPR, ptrdiff_type_node,
+   ptr_tmp, ptr));
+  ptr = ptr_tmp;
+}
+  OMP_CLAUSE_SIZE (node3) = ptr;
 
   if (n->u.map.readonly)
 OMP_CLAUSE_MAP_POINTS_TO_READONLY (node3) = 1;
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 55b0ec12dcb3..331cb11af96a 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * gfortran.dg/gomp/target-enter-exit-data.f90: Revert expected tree
+   dumps.
+
 2025-04-17  Kwok Cheung Yeung  
 
* c-c++-common/gomp/target-update-iterators-1.c: New.
diff --git a/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90 
b/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
index dc267c2af2e6..74eb894c04c6 100644
--- a/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/target-enter-exit-data.f90
@@ -9,17 +9,17 @@ type(t) :: var
 allocate (var%arr(1:100))
 
 !$omp target enter data map(to: var%arr(10:20))
-! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data 
map\(to:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) parm\.[0-9]+\.data \[len: 
D\.[0-9]+ \* [0-9]+\]\) map\(to:var\.arr \[pointer set, len: [0-9]+\]\) 
map\(attach_detach:\(integer\(kind=[0-9]+\)\[0:\] \*\) var\.arr\.data \[bias: 
D\.[0-9]+\]\)$} 1 "original" } }
+! { dg-final { scan-tree-dump-times {(?n)#pragma omp target enter data 
map\(to:\*\(integer\(kind=[0-9]+\)\[0:\] \*\) parm\.[0-9]+\.data \[len: 
D\.[0

[gcc/devel/omp/gcc-14] openmp, fortran: Add support for non-constant iterator bounds in Fortran deep-mapping iterator suppo

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:d28dcc50cebc6dc7e751b29352da28718de80036

commit d28dcc50cebc6dc7e751b29352da28718de80036
Author: Kwok Cheung Yeung 
Date:   Mon Feb 17 22:00:28 2025 +

openmp, fortran: Add support for non-constant iterator bounds in Fortran 
deep-mapping iterator support

gcc/fortran/

* trans-openmp.cc (gfc_omp_deep_mapping_map): Add new argument for
vector of newly created iterators.  Push new iterators onto the
vector.
(gfc_omp_deep_mapping_comps): Add new argument for vector of new
iterators.  Pass argument in calls to gfc_omp_deep_mapping_item and
gfc_omp_deep_mapping_comps.
(gfc_omp_deep_mapping_item): Add new argument for vector of new
iterators.  Pass argument in calls to gfc_omp_deep_mapping_map and
gfc_omp_deep_mapping_comps.
(gfc_omp_deep_mapping_do): Add new argument for vector of new
iterators.  Pass argument in calls to gfc_omp_deep_mapping_item.
(gfc_omp_deep_mapping_cnt): Pass NULL to new argument for
gfc_omp_deep_mapping_do.
(gfc_omp_deep_mapping): Add new argument for vector of new
iterators.  Pass argument in calls to gfc_omp_deep_mapping_do.
* trans.h (gfc_omp_deep_mapping): Add new argument.

gcc/

* langhooks-def.h (lhd_omp_deep_mapping): Add new argument.
* langhooks.cc (lhd_omp_deep_mapping): Likewise.
* langhooks.h (omp_deep_mapping): Likewise.
* omp-low.cc (allocate_omp_iterator_elems): Work on the supplied
iterator set instead of the iterators in a supplied set of clauses.
(free_omp_iterator_elems): Likewise.
(lower_omp_target): Maintain vector of new iterators generated by
deep-mapping.  Allocate and free iterator element arrays using
iterators found in clauses and in the new iterator vector.

libgomp/

* testsuite/libgomp.fortran/allocatable-comp-iterators.f90: Add test
for non-const iterator boundaries.

Diff:
---
 gcc/ChangeLog.omp  |  12 +++
 gcc/fortran/ChangeLog.omp  |  19 
 gcc/fortran/trans-openmp.cc|  40 
 gcc/fortran/trans.h|   2 +-
 gcc/langhooks-def.h|   3 +-
 gcc/langhooks.cc   |   2 +-
 gcc/langhooks.h|   3 +-
 gcc/omp-low.cc | 103 ++---
 libgomp/ChangeLog.omp  |   5 +
 .../libgomp.fortran/allocatable-comp-iterators.f90 |   3 +-
 10 files changed, 119 insertions(+), 73 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 5a102279c1e3..2ec578ce6d0a 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,15 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * langhooks-def.h (lhd_omp_deep_mapping): Add new argument.
+   * langhooks.cc (lhd_omp_deep_mapping): Likewise.
+   * langhooks.h (omp_deep_mapping): Likewise.
+   * omp-low.cc (allocate_omp_iterator_elems): Work on the supplied
+   iterator set instead of the iterators in a supplied set of clauses.
+   (free_omp_iterator_elems): Likewise.
+   (lower_omp_target): Maintain vector of new iterators generated by
+   deep-mapping.  Allocate and free iterator element arrays using
+   iterators found in clauses and in the new iterator vector.
+
 2025-04-17  Kwok Cheung Yeung  
 
* gimplify.cc (enter_omp_iterator_loop_context): New function variant.
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index f9412db0a49e..e17f709e31b3 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,22 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * trans-openmp.cc (gfc_omp_deep_mapping_map): Add new argument for
+   vector of newly created iterators.  Push new iterators onto the
+   vector.
+   (gfc_omp_deep_mapping_comps): Add new argument for vector of new
+   iterators.  Pass argument in calls to gfc_omp_deep_mapping_item and
+   gfc_omp_deep_mapping_comps.
+   (gfc_omp_deep_mapping_item): Add new argument for vector of new
+   iterators.  Pass argument in calls to gfc_omp_deep_mapping_map and
+   gfc_omp_deep_mapping_comps.
+   (gfc_omp_deep_mapping_do): Add new argument for vector of new
+   iterators.  Pass argument in calls to gfc_omp_deep_mapping_item.
+   (gfc_omp_deep_mapping_cnt): Pass NULL to new argument for
+   gfc_omp_deep_mapping_do.
+   (gfc_omp_deep_mapping): Add new argument for vector of new
+   iterators.  Pass argument in calls to gfc_omp_deep_mapping_do.
+   * trans.h (gfc_omp_deep_mapping): Add new argument.
+
 2025-04-17  Kwok Cheung Yeung  
 
* trans-openmp.cc (gfc_omp_de

[gcc/devel/omp/gcc-14] openmp: Add support for non-constant iterator parameters in map, to and from clauses

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:ab5fc0ca64e809b070669312b1a91bbe992301f7

commit ab5fc0ca64e809b070669312b1a91bbe992301f7
Author: Kwok Cheung Yeung 
Date:   Thu Dec 12 21:22:20 2024 +

openmp: Add support for non-constant iterator parameters in map, to and 
from clauses

This patch enables support for using non-constant expressions when 
specifying
iterators in the map clause of target constructs and to/from clauses of
target update constructs.

gcc/

* gimplify.cc (omp_iterator_elems_length): New.
(build_omp_iterators_loops): Change type of elements
array to pointer of pointers if array length is non-constant, and
assign size with indirect reference.  Reorder elements added to
iterator vector and add element containing the iteration count.  Use
omp_iterator_elems_length to compute element array size required.
* gimplify.h (omp_iterator_elems_length): New prototype.
* omp-low.cc (lower_omp_map_iterator_expr): Reorder elements read
from iterator vector.  If elements field is a pointer type, assign
using pointer arithmetic followed by indirect reference, and return
the field directly.
(lower_omp_map_iterator_size): Reorder elements read from iterator
vector.  If elements field is a pointer type, assign using pointer
arithmetic followed by indirect reference.
(allocate_omp_iterator_elems): New.
(free_omp_iterator_elems): New.
(lower_omp_target): Call allocate_omp_iterator_elems before 
inserting
loops sequence, and call free_omp_iterator_elems afterwards.
* tree-pretty-print.cc (dump_omp_iterators): Print extra elements in
iterator vector.

gcc/testsuite/

* c-c++-common/gomp/target-map-iterators-3.c: Update expected Gimple
output.
* c-c++-common/gomp/target-map-iterators-5.c: New.
* c-c++-common/gomp/target-update-iterators-3.c: Update expected
Gimple output.
* gfortran.dg/gomp/target-map-iterators-3.f90: Likewise.
* gfortran.dg/gomp/target-map-iterators-5.f90: New.
* gfortran.dg/gomp/target-update-iterators-3.f90: Update expected
Gimple output.

libgomp/

* testsuite/libgomp.c-c++-common/target-map-iterators-4.c: New.
* testsuite/libgomp.c-c++-common/target-map-iterators-5.c: New.
* testsuite/libgomp.c-c++-common/target-update-iterators-4.c: New.
* testsuite/libgomp.fortran/target-map-iterators-4.f90: New.
* testsuite/libgomp.fortran/target-map-iterators-5.f90: New.
* testsuite/libgomp.fortran/target-update-iterators-4.f90: New.

Diff:
---
 gcc/ChangeLog.omp  |  23 +
 gcc/gimplify.cc|  44 -
 gcc/gimplify.h |   1 +
 gcc/omp-low.cc | 100 ++---
 gcc/testsuite/ChangeLog.omp|  12 +++
 .../c-c++-common/gomp/target-map-iterators-3.c |   8 +-
 .../c-c++-common/gomp/target-map-iterators-5.c |  14 +++
 .../c-c++-common/gomp/target-update-iterators-3.c  |   4 +-
 .../gfortran.dg/gomp/target-map-iterators-3.f90|   8 +-
 .../gfortran.dg/gomp/target-map-iterators-5.f90|  21 +
 .../gfortran.dg/gomp/target-update-iterators-3.f90 |   6 +-
 gcc/tree-pretty-print.cc   |   6 +-
 libgomp/ChangeLog.omp  |   9 ++
 .../libgomp.c-c++-common/target-map-iterators-4.c  |  48 ++
 .../libgomp.c-c++-common/target-map-iterators-5.c  |  59 
 .../target-update-iterators-4.c|  66 ++
 .../libgomp.fortran/target-map-iterators-4.f90 |  48 ++
 .../libgomp.fortran/target-map-iterators-5.f90 |  61 +
 .../libgomp.fortran/target-update-iterators-4.f90  |  70 +++
 19 files changed, 562 insertions(+), 46 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index dd40ea3548de..0470a69cab03 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,26 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * gimplify.cc (omp_iterator_elems_length): New.
+   (build_omp_iterators_loops): Change type of elements
+   array to pointer of pointers if array length is non-constant, and
+   assign size with indirect reference.  Reorder elements added to
+   iterator vector and add element containing the iteration count.  Use
+   omp_iterator_elems_length to compute element array size required.
+   * gimplify.h (omp_iterator_elems_length): New prototype.
+   * omp-low.cc (lower_omp_map_iterator_expr): Reorder elements read
+   from iterator vector.  If elements field is a pointer type, assign
+   using pointe

[gcc/devel/omp/gcc-14] openmp, Fortran: Add support using iterators with custom mappers in Fortran

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:8fab63e1ce20ea15bd99f805b7af003fab63f7fb

commit 8fab63e1ce20ea15bd99f805b7af003fab63f7fb
Author: Kwok Cheung Yeung 
Date:   Tue Mar 11 22:41:54 2025 +

openmp, Fortran: Add support using iterators with custom mappers in Fortran

gcc/fortran/

* openmp.cc (gfc_omp_instantiate_mapper): Add argument for 
namespace.
Apply namespace to new clauses.  Propagate namespace to nested
mappers.
(gfc_omp_instantiate_mappers): Pass namespace of clause to clauses
generated by mappers.

libgomp/

* testsuite/libgomp.fortran/mapper-iterators-1.f90: New test.
* testsuite/libgomp.fortran/mapper-iterators-2.f90: New test.
* testsuite/libgomp.fortran/mapper-iterators-3.f90: New test.
* testsuite/libgomp.fortran/mapper-iterators-4.f90: New test.

Co-authored-by: Andrew Stubbs 

Diff:
---
 gcc/fortran/ChangeLog.omp  |  8 
 gcc/fortran/openmp.cc  |  9 ++--
 libgomp/ChangeLog.omp  |  7 +++
 .../libgomp.fortran/mapper-iterators-1.f90 | 38 
 .../libgomp.fortran/mapper-iterators-2.f90 | 49 
 .../libgomp.fortran/mapper-iterators-3.f90 | 33 ++
 .../libgomp.fortran/mapper-iterators-4.f90 | 52 ++
 7 files changed, 193 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index d10c2f883cb6..1d05abede709 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,11 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * openmp.cc (gfc_omp_instantiate_mapper): Add argument for namespace.
+   Apply namespace to new clauses.  Propagate namespace to nested
+   mappers.
+   (gfc_omp_instantiate_mappers): Pass namespace of clause to clauses
+   generated by mappers.
+
 2025-04-17  Kwok Cheung Yeung  
 
* trans-openmp.cc (gfc_trans_omp_array_section): Use macros for
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 99029d63059d..348c1b820ffc 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -14026,6 +14026,7 @@ static gfc_omp_namelist **
 gfc_omp_instantiate_mapper (gfc_omp_namelist **outlistp,
gfc_omp_namelist *clause,
gfc_omp_map_op outer_map_op, gfc_omp_udm *udm,
+   gfc_namespace *ns,
toc_directive cd, int list)
 {
   /* Here "sym" and "expr" describe the clause as written, to be substituted
@@ -14141,14 +14142,15 @@ gfc_omp_instantiate_mapper (gfc_omp_namelist 
**outlistp,
new_clause->u.map.op = new_kind;
 
   new_clause->where = clause->where;
+  new_clause->u2.ns = ns;
 
   if (mapper_clause->u3.udm
  && mapper_clause->u3.udm->udm != udm)
{
  gfc_omp_udm *inner_udm = mapper_clause->u3.udm->udm;
  outlistp = gfc_omp_instantiate_mapper (outlistp, new_clause,
-outer_map_op, inner_udm, cd,
-list);
+outer_map_op, inner_udm, ns,
+cd, list);
}
   else
{
@@ -14191,7 +14193,8 @@ gfc_omp_instantiate_mappers (gfc_code *code, 
gfc_omp_clauses *clauses,
  gcc_unreachable ();
}
  clausep = gfc_omp_instantiate_mapper (clausep, clause, outer_map_op,
-   clause->u3.udm->udm, cd, list);
+   clause->u3.udm->udm,
+   clause->u2.ns, cd, list);
  *clausep = clause->next;
  invoked_mappers = true;
}
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 3612f1a419be..e441b06073db 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,10 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * testsuite/libgomp.fortran/mapper-iterators-1.f90: New test.
+   * testsuite/libgomp.fortran/mapper-iterators-2.f90: New test.
+   * testsuite/libgomp.fortran/mapper-iterators-3.f90: New test.
+   * testsuite/libgomp.fortran/mapper-iterators-4.f90: New test.
+
 2025-04-17  Kwok Cheung Yeung  
 
* testsuite/libgomp.c-c++-common/mapper-iterators-1.c: New test.
diff --git a/libgomp/testsuite/libgomp.fortran/mapper-iterators-1.f90 
b/libgomp/testsuite/libgomp.fortran/mapper-iterators-1.f90
new file mode 100644
index ..d0f2bc3217d2
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/mapper-iterators-1.f90
@@ -0,0 +1,38 @@
+program myprog
+  type t
+integer :: size
+integer :: arr(99)
+  end type t
+
+  type u
+type(t) :: myt
+  end type u
+
+  integer :: i, j
+  integer, parameter :: N = 10
+  type(u) :: 

[gcc r16-9] Document peculiarities of BOOLEAN_TYPE

2025-04-17 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:3dabe6a53ef3ac24956938e2974d1c21a2a5c7ee

commit r16-9-g3dabe6a53ef3ac24956938e2974d1c21a2a5c7ee
Author: Eric Botcazou 
Date:   Thu Apr 17 20:46:57 2025 +0200

Document peculiarities of BOOLEAN_TYPE

gcc/
* tree.def (BOOLEAN_TYPE): Add more details.

Diff:
---
 gcc/tree.def | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/tree.def b/gcc/tree.def
index c4ad8d08f10c..2c37e449442d 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -135,7 +135,11 @@ DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0)
 DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0)
 
 /* Boolean type (true or false are the only values).  Looks like an
-   INTEGRAL_TYPE.  */
+   INTEGER_TYPE, but must be dealt with specially because TYPE_PRECISION
+   may be arbitrary despite the restricted set of valid values (in other
+   words, boolean types with TYPE_PRECISION > 1 exist in some languages).
+   Similarly, TYPE_UNSIGNED may be false for components of vector masks,
+   as well as for boolean types in languages other than C.  */
 DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
 
 /* Integer types in all languages, including char in C.


[gcc r16-8] c++: constexpr new diagnostic location

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:4cff0434e8bf6683988482a7e47f8459c06f2c05

commit r16-8-g4cff0434e8bf6683988482a7e47f8459c06f2c05
Author: Jason Merrill 
Date:   Mon Mar 10 11:49:57 2025 -0400

c++: constexpr new diagnostic location

Presenting the allocation location as the location of the outermost
expression we're trying to evaluate is inaccurate; let's provide both
locations.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Give both
expression and allocation location in allocated storage diagnostics.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/constexpr-new.C: Adjust diagnostics.
* g++.dg/cpp1z/constexpr-asm-5.C: Likewise.
* g++.dg/cpp26/static_assert1.C: Likewise.
* g++.dg/cpp2a/constexpr-dtor7.C: Likewise.
* g++.dg/cpp2a/constexpr-new26.C: Likewise.
* g++.dg/cpp2a/constexpr-new3.C: Likewise.
* g++.dg/cpp2a/constinit14.C: Likewise.

Diff:
---
 gcc/cp/constexpr.cc  | 16 ++--
 gcc/testsuite/g++.dg/cpp1y/constexpr-new.C   |  6 --
 gcc/testsuite/g++.dg/cpp1z/constexpr-asm-5.C |  4 +++-
 gcc/testsuite/g++.dg/cpp26/static_assert1.C  |  3 ++-
 gcc/testsuite/g++.dg/cpp2a/constexpr-dtor7.C |  3 ++-
 gcc/testsuite/g++.dg/cpp2a/constexpr-new26.C |  5 ++---
 gcc/testsuite/g++.dg/cpp2a/constexpr-new3.C  | 12 ++--
 gcc/testsuite/g++.dg/cpp2a/constinit14.C |  3 ++-
 8 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index d647a09269d3..8a5b68c71faf 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9262,9 +9262,11 @@ cxx_eval_outermost_constant_expr (tree t, bool 
allow_non_constant,
   if (heap_var)
{
  if (!allow_non_constant && !non_constant_p)
-   error_at (DECL_SOURCE_LOCATION (heap_var),
- "%qE is not a constant expression because it refers to "
- "a result of %", t);
+   {
+ error ("%qE is not a constant expression because it refers to "
+"a result of %", t);
+ inform (DECL_SOURCE_LOCATION (heap_var), "allocated here");
+   }
  r = t;
  non_constant_p = true;
}
@@ -9273,9 +9275,11 @@ cxx_eval_outermost_constant_expr (tree t, bool 
allow_non_constant,
  if (DECL_NAME (heap_var) != heap_deleted_identifier)
{
  if (!allow_non_constant && !non_constant_p)
-   error_at (DECL_SOURCE_LOCATION (heap_var),
- "%qE is not a constant expression because allocated "
- "storage has not been deallocated", t);
+   {
+ error ("%qE is not a constant expression because allocated "
+"storage has not been deallocated", t);
+ inform (DECL_SOURCE_LOCATION (heap_var), "allocated here");
+   }
  r = t;
  non_constant_p = true;
}
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C 
b/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C
index d0ca0b7d27f7..f4c6d2e534d9 100644
--- a/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-new.C
@@ -6,7 +6,9 @@ constexpr int *f4(bool b) {
 return nullptr;
   } else {
 return new int{42}; // { dg-error "call to non-.constexpr." "" { target 
c++17_down } }
-  }// { dg-error "is not a constant expression because 
allocated storage has not been deallocated" "" { target c++2a } .-1 }
+// { dg-message "allocated here" "" { target c++20 } .-1 }
+  }
 }
 static_assert(f4(true) == nullptr, "");
-static_assert(f4(false) == nullptr, ""); // { dg-error "non-.constant. 
condition|" }
+static_assert(f4(false) == nullptr, ""); // { dg-error "non-constant 
condition" }
+// { dg-error "is not a constant expression because allocated storage has not 
been deallocated" "" { target c++20 } .-1 }
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-5.C 
b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-5.C
index bcecea9d6b50..35beb27f7d53 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-5.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-5.C
@@ -28,7 +28,7 @@ struct M { constexpr K size () const { return {}; }
   constexpr L data () const { return {}; } };
 #if  __cpp_constexpr_dynamic_alloc >= 201907L
 struct N { constexpr int size () const { return 3; }
-  constexpr const char *data () const { return new char[3] { 'b', 'a', 
'd' }; } }; // { dg-error "'\\\* N\\\(\\\).N::data\\\(\\\)' is not a constant 
expression because allocated storage has not been deallocated" "" { target 
c++20 } }
+  constexpr const char *data () const { return new char[3] { 'b', 'a', 
'd' }; } };
 #endif
 constexpr const char a[] = { 't', 'e', 's', 't' };
 struct O { constexpr int size () const { return 4; }
@@ -117,6 +117,7 @@ fo

[gcc r16-10] c++: constexpr virtual base diagnostic

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:3f0eccfd90370a7c5300f92493143c7e5a66be85

commit r16-10-g3f0eccfd90370a7c5300f92493143c7e5a66be85
Author: Jason Merrill 
Date:   Wed Apr 16 16:02:09 2025 -0400

c++: constexpr virtual base diagnostic

I thought this diagnostic could be clearer that the problem is the
combination of virtual bases and constexpr constructor, not just complain
that the class has virtual bases without context.

gcc/cp/ChangeLog:

* constexpr.cc (is_valid_constexpr_fn): Improve diagnostic.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-dtor16.C: Adjust diagnostic.
* g++.dg/cpp2a/constexpr-dynamic10.C: Likewise.

Diff:
---
 gcc/cp/constexpr.cc  | 9 -
 gcc/testsuite/g++.dg/cpp2a/constexpr-dtor16.C| 2 +-
 gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C | 2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 8a5b68c71faf..f56c5c42c821 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -307,7 +307,14 @@ is_valid_constexpr_fn (tree fun, bool complain)
 {
   ret = false;
   if (complain)
-   error ("%q#T has virtual base classes", DECL_CONTEXT (fun));
+   {
+ if (DECL_CONSTRUCTOR_P (fun))
+   error ("% constructor in %q#T that has "
+  "virtual base classes", DECL_CONTEXT (fun));
+ else
+   error ("% destructor in %q#T that has "
+  "virtual base classes", DECL_CONTEXT (fun));
+   }
 }
 
   return ret;
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor16.C 
b/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor16.C
index b84aaf95b9d0..99d130705713 100644
--- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor16.C
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor16.C
@@ -3,5 +3,5 @@
 
 struct A { virtual ~A (); };
 struct B : virtual A { constexpr ~B () {} };
-// { dg-error "'struct B' has virtual base classes" "" { target c++20 } .-1 }
+// { dg-error "'constexpr' destructor in 'struct B' that has virtual base 
classes" "" { target c++20 } .-1 }
 // { dg-error "'constexpr' destructors only available with" "" { target 
c++17_down } .-2 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C 
b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C
index f9f82236d15f..e543ce46b518 100644
--- a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic10.C
@@ -5,7 +5,7 @@
 
 struct C { virtual void a(); };
 struct B { virtual void b(); };
-struct A : virtual B, C { virtual void c(); }; // { dg-error ".struct A. has 
virtual base classes" }
+struct A : virtual B, C { virtual void c(); }; // { dg-error "virtual base 
classes" }
 
 constexpr A a; // { dg-error "call" }


[gcc r16-11] [PATCH] RISC-V: Do not free a riscv_arch_string when handling target-arch attribute

2025-04-17 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:2d6f1ca17f25b28da8f8d83622f0e029da2340e7

commit r16-11-g2d6f1ca17f25b28da8f8d83622f0e029da2340e7
Author: 翁愷邑 
Date:   Thu Apr 17 16:24:20 2025 -0600

[PATCH] RISC-V: Do not free a riscv_arch_string when handling target-arch 
attribute

The build_target_option_node() function may return a cached node when
fndecl having the same effective global_options. Therefore, freeing
memory used in target nodes can lead to a use-after-free issue, as a
target node may be shared by multiple fndecl.
This issue occurs in gcc.target/riscv/target-attr-16.c, where all
functions have the same march, but the last function tries to free its
old x_riscv_arch_string (which is shared) when processing the second
target attribute.However, the behavior of this issue depends on how the
OS handles malloc. It's very likely that xstrdup returns the old address
just freed, coincidentally hiding the issue. We can verify the issue by
forcing xstrdup to return a new address, e.g.,

-  if (opts->x_riscv_arch_string != default_opts->x_riscv_arch_string)
-free (CONST_CAST (void *, (const void *) opts->x_riscv_arch_string));
+  // Force it to use a new address, NFCI
+  const char *tmp = opts->x_riscv_arch_string;
   opts->x_riscv_arch_string = xstrdup (local_arch_str);

+  if (tmp != default_opts->x_riscv_arch_string)
+free (CONST_CAST (void *, (const void *) tmp));

This patch replaces xstrdup with ggc_strdup and let gc to take care of
unused strings.

gcc/ChangeLog:

* config/riscv/riscv-target-attr.cc
(riscv_target_attr_parser::update_settings):
Do not manually free any arch string.

Diff:
---
 gcc/config/riscv/riscv-target-attr.cc | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gcc/config/riscv/riscv-target-attr.cc 
b/gcc/config/riscv/riscv-target-attr.cc
index 1d968655f95d..8ad3025579b2 100644
--- a/gcc/config/riscv/riscv-target-attr.cc
+++ b/gcc/config/riscv/riscv-target-attr.cc
@@ -257,11 +257,7 @@ riscv_target_attr_parser::update_settings (struct 
gcc_options *opts) const
 {
   std::string local_arch = m_subset_list->to_string (true);
   const char* local_arch_str = local_arch.c_str ();
-  struct cl_target_option *default_opts
-   = TREE_TARGET_OPTION (target_option_default_node);
-  if (opts->x_riscv_arch_string != default_opts->x_riscv_arch_string)
-   free (CONST_CAST (void *, (const void *) opts->x_riscv_arch_string));
-  opts->x_riscv_arch_string = xstrdup (local_arch_str);
+  opts->x_riscv_arch_string = ggc_strdup (local_arch_str);
 
   riscv_set_arch_by_subset_list (m_subset_list, opts);
 }


[gcc r15-9544] d: Fix infinite loop regression in CTFE

2025-04-17 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:0eae20c899e327aec0e48b9ff2d856aba44b2639

commit r15-9544-g0eae20c899e327aec0e48b9ff2d856aba44b2639
Author: Iain Buclaw 
Date:   Thu Apr 17 08:21:40 2025 +0200

d: Fix infinite loop regression in CTFE

An infinite loop was introduced by a previous refactoring in the
semantic pass for DeclarationExp nodes. Ensure the loop properly
terminates and add tests cases.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 956e73d64e.

gcc/testsuite/ChangeLog:

* gdc.test/fail_compilation/test21247.d: New test.
* gdc.test/fail_compilation/test21247b.d: New test.

Reviewed-on: https://github.com/dlang/dmd/pull/21248

Diff:
---
 gcc/d/dmd/MERGE  |  2 +-
 gcc/d/dmd/expressionsem.d|  6 +++---
 gcc/testsuite/gdc.test/fail_compilation/test21247.d  | 20 
 gcc/testsuite/gdc.test/fail_compilation/test21247b.d | 14 ++
 4 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index ee5eb853284b..58d19b4e951d 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-1b34fea4788136b54ec77c6ed9678754d109fc79
+956e73d64e532a68213970316c2590c572ec03f3
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index 19111e31baa0..b02f6ea64102 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -6978,10 +6978,10 @@ private extern (C++) final class 
ExpressionSemanticVisitor : Visitor
 while (1)
 {
 AttribDeclaration ad = s.isAttribDeclaration();
-if (!ad)
-break;
-if (ad.decl && ad.decl.length == 1)
+if (ad && ad.decl && ad.decl.length == 1)
 s = (*ad.decl)[0];
+else
+break;
 }
 
 //printf("inserting '%s' %p into sc = %p\n", s.toChars(), s, sc);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21247.d 
b/gcc/testsuite/gdc.test/fail_compilation/test21247.d
new file mode 100644
index ..c3e4105a05c3
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21247.d
@@ -0,0 +1,20 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test21247.d(13): Error: anonymous union can only be a part of 
an aggregate, not function `hang_dmd`
+fail_compilation/test21247.d(17): Error: undefined identifier `u`
+fail_compilation/test21247.d(18): Error: undefined identifier `b`
+fail_compilation/test21247.d(20):called from here: `hang_dmd(0u)`
+---
+ */
+// https://github.com/dlang/dmd/issues/21247
+ubyte[4] hang_dmd(uint a)
+{
+union {
+uint u = void;
+ubyte[4] b;
+}
+u = a;
+return b;
+}
+enum T = hang_dmd(0);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21247b.d 
b/gcc/testsuite/gdc.test/fail_compilation/test21247b.d
new file mode 100644
index ..ecd4603c064b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21247b.d
@@ -0,0 +1,14 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test21247b.d(10): Error: anonymous union can only be a part 
of an aggregate, not function `test21247`
+---
+ */
+// https://github.com/dlang/dmd/issues/21247
+void test21247()
+{
+union {
+uint u = void;
+ubyte[4] b;
+}
+}


[gcc/devel/omp/gcc-14] Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:72fdbc3fce7836ca94e52383774c01677cc4abe4

commit 72fdbc3fce7836ca94e52383774c01677cc4abe4
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' 
offloading

gcc/testsuite/
* g++.target/gcn/exceptions-throw-1.C: New.
* g++.target/nvptx/exceptions-throw-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-1.C: New.
* testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.

(cherry picked from commit 1362d9d49449bec12741ef158f4bf81a8b3ff2cd)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  6 +++
 gcc/testsuite/g++.target/gcn/exceptions-throw-1.C  | 16 
 .../g++.target/nvptx/exceptions-throw-1.C  | 16 
 libgomp/ChangeLog.omp  |  7 
 .../libgomp.c++/target-exceptions-throw-1-O0.C | 23 +++
 .../libgomp.c++/target-exceptions-throw-1.C| 25 
 .../libgomp.oacc-c++/exceptions-throw-1.C  | 46 ++
 7 files changed, 139 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index b04a06bf1e85..62db33e19000 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * g++.target/gcn/exceptions-throw-1.C: New.
+   * g++.target/nvptx/exceptions-throw-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* g++.target/gcn/exceptions-bad_cast-3.C: New.
* g++.target/nvptx/exceptions-bad_cast-3.C: Likewise.
 
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C
new file mode 100644
index ..6cadf589bb0d
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C
new file mode 100644
index ..6cadf589bb0d
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 24f3335cec75..7fbfac71f266 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,13 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-throw-1.C: New.
+   * testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.
 
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C
new file mode 100644
index ..00d7c13859da
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C
@@ -0,0 +1,23 @@
+/* 'throw' in OpenMP 'target' region.  */
+
+/* { dg-additional-options -O0 } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-throw-1.C"
+
+/* { dg-output {CheC

[gcc/devel/omp/gcc-14] openmp: Add support for using custom mappers with iterators (C, C++)

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:53b8a20948e921bca6815f8cd70bfa57c264bca3

commit 53b8a20948e921bca6815f8cd70bfa57c264bca3
Author: Kwok Cheung Yeung 
Date:   Mon Jan 13 13:08:07 2025 +

openmp: Add support for using custom mappers with iterators (C, C++)

gcc/c-family/

* c-omp.cc (omp_instantiate_mapper): Apply iterator to new clauses
generated from mapper.

gcc/c/

* c-parser.cc (c_parser_omp_clause_map): Apply iterator to push and
pop mapper clauses.

gcc/cp/

* parser.cc (cp_parser_omp_clause_map): Apply iterator to push and
pop mapper clauses.
* semantics.cc (cxx_omp_map_array_section): Allow array types for
base type of array sections.

libgomp/

* testsuite/libgomp.c-c++-common/mapper-iterators-1.c: New test.
* testsuite/libgomp.c-c++-common/mapper-iterators-2.c: New test.
* testsuite/libgomp.c-c++-common/mapper-iterators-3.c: New test.

Co-authored-by: Andrew Stubbs 

Diff:
---
 gcc/c-family/ChangeLog.omp |  5 ++
 gcc/c-family/c-omp.cc  |  2 +
 gcc/c/ChangeLog.omp|  5 ++
 gcc/c/c-parser.cc  |  4 +
 gcc/cp/ChangeLog.omp   |  7 ++
 gcc/cp/parser.cc   |  4 +
 gcc/cp/semantics.cc|  3 +-
 libgomp/ChangeLog.omp  |  6 ++
 .../libgomp.c-c++-common/mapper-iterators-1.c  | 83 ++
 .../libgomp.c-c++-common/mapper-iterators-2.c  | 81 ++
 .../libgomp.c-c++-common/mapper-iterators-3.c  | 98 ++
 11 files changed, 297 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/ChangeLog.omp b/gcc/c-family/ChangeLog.omp
index 9fe71baa001c..1f2303a241f0 100644
--- a/gcc/c-family/ChangeLog.omp
+++ b/gcc/c-family/ChangeLog.omp
@@ -1,3 +1,8 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * c-omp.cc (omp_instantiate_mapper): Apply iterator to new clauses
+   generated from mapper.
+
 2025-04-17  Kwok Cheung Yeung  
 
* c-omp.cc (c_finish_omp_depobj): Use OMP_ITERATOR_DECL_P.
diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc
index ada8d8f03240..5c11e74fa739 100644
--- a/gcc/c-family/c-omp.cc
+++ b/gcc/c-family/c-omp.cc
@@ -4759,6 +4759,7 @@ omp_instantiate_mapper (location_t loc, tree *outlist, 
tree mapper, tree expr,
   tree clauses = OMP_DECLARE_MAPPER_CLAUSES (mapper);
   tree dummy_var = OMP_DECLARE_MAPPER_DECL (mapper);
   tree mapper_name = NULL_TREE;
+  tree iterator = *outlist ? OMP_CLAUSE_ITERATORS (*outlist) : NULL_TREE;
 
   remap_mapper_decl_info map_info;
   map_info.dummy_var = dummy_var;
@@ -4887,6 +4888,7 @@ omp_instantiate_mapper (location_t loc, tree *outlist, 
tree mapper, tree expr,
}
   else
{
+ OMP_CLAUSE_ITERATORS (unshared) = iterator;
  *outlist = unshared;
  outlist = &OMP_CLAUSE_CHAIN (unshared);
}
diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index 452c95f2a94c..e046bc4e60bd 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,8 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * c-parser.cc (c_parser_omp_clause_map): Apply iterator to push and
+   pop mapper clauses.
+
 2025-04-17  Kwok Cheung Yeung  
 
* c-parser.cc (c_parser_omp_iterators): Use macros for accessing
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index c78c17a3a5cc..5eaeaf8914be 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -19694,6 +19694,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list, 
enum gomp_map_kind kind)
   tree name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_PUSH_MAPPER_NAME);
   OMP_CLAUSE_DECL (name) = mapper_name;
+  if (iterators)
+   OMP_CLAUSE_ITERATORS (name) = iterators;
   OMP_CLAUSE_CHAIN (name) = nl;
   nl = name;
 
@@ -19702,6 +19704,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list, 
enum gomp_map_kind kind)
   name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_POP_MAPPER_NAME);
   OMP_CLAUSE_DECL (name) = null_pointer_node;
+  if (iterators)
+   OMP_CLAUSE_ITERATORS (name) = iterators;
   OMP_CLAUSE_CHAIN (name) = OMP_CLAUSE_CHAIN (last_new);
   OMP_CLAUSE_CHAIN (last_new) = name;
 }
diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 9dde3721faad..80b4344a1b5b 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,10 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * parser.cc (cp_parser_omp_clause_map): Apply iterator to push and
+   pop mapper clauses.
+   * semantics.cc (cxx_omp_map_array_section): Allow array types for
+   base type of array sections.
+
 2025-04-17  Kwok Cheung Yeung  
 
 

[gcc/devel/omp/gcc-14] openmp: Fix struct handling for OpenMP iterators

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:6c130074c9a7ab9aaff0950a5011c48fd705be55

commit 6c130074c9a7ab9aaff0950a5011c48fd705be55
Author: Kwok Cheung Yeung 
Date:   Fri Apr 11 18:27:00 2025 +0100

openmp: Fix struct handling for OpenMP iterators

New clauses can be created for structs, and these will also need to have
iterators applied to them if the base clause is using iterators.  As this
occurs after the initial iterator expansion, a new mechanism for allocating
new entries in the iterator loop is required.

gcc/

* gimplify.cc (add_new_omp_iterators_clause): New.
(build_omp_struct_comp_nodes): Add extra argument for loops 
sequence.
Call add_new_omp_iterators_clause on newly generated clauses.
(omp_accumulate_sibling_list): Add extra argument for loops 
sequence.
Pass to calls to build_omp_struct_comp_nodes.  Add iterators to 
newly
generator clauses for struct accesses.
(omp_build_struct_sibling_lists): Add extra argument for loops
sequence. Pass to call to omp_accumulate_sibling_list.
(gimplify_adjust_omp_clauses): Pass loops sequence to
omp_build_struct_sibling_lists.

Diff:
---
 gcc/ChangeLog.omp | 13 +
 gcc/gimplify.cc   | 81 +--
 2 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index a1103c0d135d..035396457fa1 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,16 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * gimplify.cc (add_new_omp_iterators_clause): New.
+   (build_omp_struct_comp_nodes): Add extra argument for loops sequence.
+   Call add_new_omp_iterators_clause on newly generated clauses.
+   (omp_accumulate_sibling_list): Add extra argument for loops sequence.
+   Pass to calls to build_omp_struct_comp_nodes.  Add iterators to newly
+   generator clauses for struct accesses.
+   (omp_build_struct_sibling_lists): Add extra argument for loops
+   sequence. Pass to call to omp_accumulate_sibling_list.
+   (gimplify_adjust_omp_clauses): Pass loops sequence to
+   omp_build_struct_sibling_lists.
+
 2025-04-17  Kwok Cheung Yeung  
 
* gimplify.cc (gimplify_omp_affinity): Use macros for accessing
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index f075eb337d0d..19640113ab53 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -10067,6 +10067,60 @@ exit_omp_iterator_loop_context (tree c)
   pop_gimplify_context (NULL);
 }
 
+/* Insert new OpenMP clause C into pre-existing iterator loop LOOPS_SEQ_P.
+   If the clause has an iterator, then that iterator is assumed to be in
+   the expanded form (i.e. it has info regarding the loop, expanded elements
+   etc.).  */
+
+void
+add_new_omp_iterators_clause (tree c, gimple_seq *loops_seq_p)
+{
+  gimple_stmt_iterator gsi;
+  tree iters = OMP_CLAUSE_ITERATORS (c);
+  if (!iters)
+return;
+  gcc_assert (OMP_ITERATORS_EXPANDED_P (iters));
+
+  /* Search for  = -1.  */
+  tree index = OMP_ITERATORS_INDEX (iters);
+  for (gsi = gsi_start (*loops_seq_p); !gsi_end_p (gsi); gsi_next (&gsi))
+{
+  gimple *stmt = gsi_stmt (gsi);
+  if (gimple_code (stmt) == GIMPLE_ASSIGN
+ && gimple_assign_lhs (stmt) == index
+ && gimple_assign_rhs1 (stmt) == size_int (-1))
+   break;
+}
+  gcc_assert (!gsi_end_p (gsi));
+
+  /* Create array for this clause.  */
+  tree arr_length = omp_iterator_elems_length (OMP_ITERATORS_COUNT (iters));
+  tree elems_type = TREE_CONSTANT (arr_length)
+   ? build_array_type (ptr_type_node,
+   build_index_type (arr_length))
+   : build_pointer_type (ptr_type_node);
+  tree elems = create_tmp_var_raw (elems_type, "omp_iter_data");
+  TREE_ADDRESSABLE (elems) = 1;
+  gimple_add_tmp_var (elems);
+
+  /* BEFORE LOOP:  */
+  /* elems[0] = count;  */
+  tree lhs = TREE_CODE (TREE_TYPE (elems)) == ARRAY_TYPE
+   ? build4 (ARRAY_REF, ptr_type_node, elems, size_int (0), NULL_TREE,
+ NULL_TREE)
+   : build1 (INDIRECT_REF, ptr_type_node, elems);
+
+  gimple_seq assign_seq = NULL;
+  gimplify_assign (lhs, OMP_ITERATORS_COUNT (iters), &assign_seq);
+  gsi_insert_seq_after (&gsi, assign_seq, GSI_SAME_STMT);
+
+  /* Update iterator information.  */
+  tree new_iterator = copy_omp_iterator (OMP_CLAUSE_ITERATORS (c));
+  OMP_ITERATORS_ELEMS (new_iterator) = elems;
+  TREE_CHAIN (new_iterator) = TREE_CHAIN (OMP_CLAUSE_ITERATORS (c));
+  OMP_CLAUSE_ITERATORS (c) = new_iterator;
+}
+
 /* If *LIST_P contains any OpenMP depend clauses with iterators,
lower all the depend clauses by populating corresponding depend
array.  Returns 0 if there are no such depend clauses, or
@@ -10485,7 +10539,7 @@ omp_maybe_get_descriptor_from_ptr (tree ptr)
 
 static tree
 build_omp_struct_comp_nodes (enum tree_code code, tree grp_s

[gcc/devel/omp/gcc-14] openmp, fortran: Add support for iterators in OpenMP 'target update' constructs (Fortran)

2025-04-17 Thread Kwok Yeung via Gcc-cvs
https://gcc.gnu.org/g:0861d9c3e63cdc8cb0fd08b06dbfd3ea6b999ddf

commit 0861d9c3e63cdc8cb0fd08b06dbfd3ea6b999ddf
Author: Kwok Cheung Yeung 
Date:   Wed Nov 27 21:56:08 2024 +

openmp, fortran: Add support for iterators in OpenMP 'target update' 
constructs (Fortran)

This adds Fortran support for iterators in 'to' and 'from' clauses in the
'target update' OpenMP directive.

gcc/fortran/

* dump-parse-tree.cc (show_omp_namelist): Add iterator support for
OMP_LIST_TO and OMP_LIST_FROM.
* match.cc (gfc_free_namelist): Free namespace for OMP_LIST_TO and
OMP_LIST_FROM.
* openmp.cc (gfc_free_omp_clauses): Free namespace for OMP_LIST_TO
and OMP_LIST_FROM.
(gfc_match_motion_var_list): Parse 'iterator' modifier.
(resolve_omp_clauses): Resolve iterators for OMP_LIST_TO and
OMP_LIST_FROM.
* trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in
OMP_LIST_TO and OMP_LIST_FROM clauses.  Add expressions to
iter_block rather than block.

gcc/testsuite/

* gfortran.dg/gomp/target-update-iterators-1.f90: New.
* gfortran.dg/gomp/target-update-iterators-2.f90: New.
* gfortran.dg/gomp/target-update-iterators-3.f90: New.

libgomp/

* testsuite/libgomp.fortran/target-update-iterators-1.f90: New.
* testsuite/libgomp.fortran/target-update-iterators-2.f90: New.
* testsuite/libgomp.fortran/target-update-iterators-3.f90: New.

Co-authored-by: Andrew Stubbs  

Diff:
---
 gcc/fortran/ChangeLog.omp  | 15 +
 gcc/fortran/dump-parse-tree.cc |  7 +-
 gcc/fortran/match.cc   |  3 +-
 gcc/fortran/openmp.cc  | 28 +++-
 gcc/fortran/trans-openmp.cc| 50 --
 gcc/testsuite/ChangeLog.omp|  6 ++
 .../gfortran.dg/gomp/target-update-iterators-1.f90 | 25 +++
 .../gfortran.dg/gomp/target-update-iterators-2.f90 | 28 
 .../gfortran.dg/gomp/target-update-iterators-3.f90 | 23 +++
 libgomp/ChangeLog.omp  |  6 ++
 .../libgomp.fortran/target-update-iterators-1.f90  | 68 +++
 .../libgomp.fortran/target-update-iterators-2.f90  | 63 +
 .../libgomp.fortran/target-update-iterators-3.f90  | 78 ++
 13 files changed, 392 insertions(+), 8 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index c652ec1775a9..ebbdf3d149e7 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,18 @@
+2025-04-17  Kwok Cheung Yeung  
+
+   * dump-parse-tree.cc (show_omp_namelist): Add iterator support for
+   OMP_LIST_TO and OMP_LIST_FROM.
+   * match.cc (gfc_free_namelist): Free namespace for OMP_LIST_TO and
+   OMP_LIST_FROM.
+   * openmp.cc (gfc_free_omp_clauses): Free namespace for OMP_LIST_TO
+   and OMP_LIST_FROM.
+   (gfc_match_motion_var_list): Parse 'iterator' modifier.
+   (resolve_omp_clauses): Resolve iterators for OMP_LIST_TO and
+   OMP_LIST_FROM.
+   * trans-openmp.cc (gfc_trans_omp_clauses): Handle iterators in
+   OMP_LIST_TO and OMP_LIST_FROM clauses.  Add expressions to
+   iter_block rather than block.
+
 2025-04-17  Kwok Cheung Yeung  
 
* dump-parse-tree.cc (show_omp_namelist): Add iterator support for
diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 9fce015598e2..1ac1d632031a 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -1354,7 +1354,8 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n)
 {
   gfc_current_ns = ns_curr;
   if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND
- || list_type == OMP_LIST_MAP)
+ || list_type == OMP_LIST_MAP
+ || list_type == OMP_LIST_TO || list_type == OMP_LIST_FROM)
{
  gfc_current_ns = n->u2.ns ? n->u2.ns : ns_curr;
  if (n->u2.ns != ns_iter)
@@ -1370,6 +1371,10 @@ show_omp_namelist (int list_type, gfc_omp_namelist *n)
fputs ("DEPEND (", dumpfile);
  else if (list_type == OMP_LIST_MAP)
fputs ("MAP (", dumpfile);
+ else if (list_type == OMP_LIST_TO)
+   fputs ("TO (", dumpfile);
+ else if (list_type == OMP_LIST_FROM)
+   fputs ("FROM (", dumpfile);
  else
gcc_unreachable ();
}
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 2bf1a7f583b2..1986803bbeac 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -5540,7 +5540,8 @@ void
 gfc_free_omp_namelist (gfc_omp_namelist *name, int list)
 {
   bool free_ns = (list == OMP_LIST_AFFINITY || list == OMP_LI

[gcc r16-7] c++: vec_safe_reserve usage tweaks

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:53d4e355db18fec21515d055924df8290ef5ce14

commit r16-7-g53d4e355db18fec21515d055924df8290ef5ce14
Author: Jason Merrill 
Date:   Sun Jan 19 05:15:01 2025 -0500

c++: vec_safe_reserve usage tweaks

A couple of cleanups from noticing that the semantics of
std::vector::reserve() (request the new minimum allocation) differ from
the GCC vec<...>::reserve() (request a minimum number of slots available).

In preserve_state, we were tripling the size of the vec when doubling it is
more than enough.

In get_tinfo_desc we were using vec_safe_reserve properly, but it's
simpler to use vec_safe_grow_cleared.

gcc/cp/ChangeLog:

* name-lookup.cc (name_lookup::preserve_state): Fix reserve call.
* rtti.cc (get_tinfo_desc): Use vec_safe_grow_cleared.

Diff:
---
 gcc/cp/name-lookup.cc |  2 +-
 gcc/cp/rtti.cc| 15 +++
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 1cd982e12d49..498126a191ab 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -583,7 +583,7 @@ name_lookup::preserve_state ()
   if (previous)
 {
   unsigned length = vec_safe_length (previous->scopes);
-  vec_safe_reserve (previous->scopes, length * 2);
+  vec_safe_reserve (previous->scopes, length);
   for (unsigned ix = length; ix--;)
{
  tree decl = (*previous->scopes)[ix];
diff --git a/gcc/cp/rtti.cc b/gcc/cp/rtti.cc
index 353996206f5c..18bc479dc50b 100644
--- a/gcc/cp/rtti.cc
+++ b/gcc/cp/rtti.cc
@@ -1318,18 +1318,9 @@ get_pseudo_ti_index (tree type)
 static tinfo_s *
 get_tinfo_desc (unsigned ix)
 {
-  unsigned len = tinfo_descs->length ();
-
-  if (len <= ix)
-{
-  /* too short, extend.  */
-  len = ix + 1 - len;
-  vec_safe_reserve (tinfo_descs, len);
-  tinfo_s elt;
-  elt.type = elt.vtable = elt.name = NULL_TREE;
-  while (len--)
-   tinfo_descs->quick_push (elt);
-}
+  if (tinfo_descs->length () <= ix)
+/* too short, extend.  */
+vec_safe_grow_cleared (tinfo_descs, ix + 1);
 
   tinfo_s *res = &(*tinfo_descs)[ix];


[gcc r16-6] c++: improve pack index diagnostics

2025-04-17 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:20e31f507a2dd6cbd40cc65a7c06d07bfaa2a5e1

commit r16-6-g20e31f507a2dd6cbd40cc65a7c06d07bfaa2a5e1
Author: Jason Merrill 
Date:   Mon Mar 24 12:59:39 2025 -0400

c++: improve pack index diagnostics

While looking at pack-indexing16.C I thought it would be helpful to print
the problematic type/value.

gcc/cp/ChangeLog:

* semantics.cc (finish_type_pack_element): Add more info
to diagnostics.

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
diagnostic.

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/pack-indexing2.C: Adjust diagnostics.
* g++.dg/ext/type_pack_element2.C: Likewise.
* g++.dg/ext/type_pack_element4.C: Likewise.

Diff:
---
 gcc/cp/semantics.cc| 18 ++
 gcc/testsuite/g++.dg/cpp26/pack-indexing2.C|  6 +++---
 gcc/testsuite/g++.dg/ext/type_pack_element2.C  |  2 +-
 gcc/testsuite/g++.dg/ext/type_pack_element4.C  |  2 +-
 .../testsuite/20_util/tuple/element_access/get_neg.cc  |  2 +-
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index a10ef34383c2..7f23efd4a11e 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -5088,22 +5088,32 @@ static tree
 finish_type_pack_element (tree idx, tree types, tsubst_flags_t complain)
 {
   idx = maybe_constant_value (idx, NULL_TREE, mce_true);
-  if (TREE_CODE (idx) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (idx)))
+  if (!INTEGRAL_TYPE_P (TREE_TYPE (idx)))
 {
   if (complain & tf_error)
-   error ("pack index is not an integral constant");
+   error ("pack index has non-integral type %qT", TREE_TYPE (idx));
+  return error_mark_node;
+}
+  if (TREE_CODE (idx) != INTEGER_CST)
+{
+  if (complain & tf_error)
+   {
+ error ("pack index is not an integral constant");
+ cxx_constant_value (idx);
+   }
   return error_mark_node;
 }
   if (tree_int_cst_sgn (idx) < 0)
 {
   if (complain & tf_error)
-   error ("pack index is negative");
+   error ("pack index %qE is negative", idx);
   return error_mark_node;
 }
   if (wi::to_widest (idx) >= TREE_VEC_LENGTH (types))
 {
   if (complain & tf_error)
-   error ("pack index is out of range");
+   error ("pack index %qE is out of range for pack of length %qd",
+  idx, TREE_VEC_LENGTH (types));
   return error_mark_node;
 }
   return TREE_VEC_ELT (types, tree_to_shwi (idx));
diff --git a/gcc/testsuite/g++.dg/cpp26/pack-indexing2.C 
b/gcc/testsuite/g++.dg/cpp26/pack-indexing2.C
index fdc8320e2555..4a7e494ab043 100644
--- a/gcc/testsuite/g++.dg/cpp26/pack-indexing2.C
+++ b/gcc/testsuite/g++.dg/cpp26/pack-indexing2.C
@@ -49,7 +49,7 @@ template
 int
 getT2 (auto... Ts)
 {
-  return Ts...[N]; // { dg-error "pack index is negative" }
+  return Ts...[N]; // { dg-error "pack index '-1' is negative" }
 }
 
 template
@@ -63,7 +63,7 @@ template
 void
 badtype2 ()
 {
-  Ts...[N] t; // { dg-error "pack index is out of range" }
+  Ts...[N] t; // { dg-error "pack index '1' is out of range for pack of length 
'1'" }
 }
 
 template
@@ -77,7 +77,7 @@ template
 void
 badtype4 ()
 {
-  Ts...[N] t; // { dg-error "pack index is negative" }
+  Ts...[N] t; // { dg-error "pack index '-1' is negative" }
 }
 
 int nonconst () { return 42; }
diff --git a/gcc/testsuite/g++.dg/ext/type_pack_element2.C 
b/gcc/testsuite/g++.dg/ext/type_pack_element2.C
index 1bf77534097f..1b076733d97d 100644
--- a/gcc/testsuite/g++.dg/ext/type_pack_element2.C
+++ b/gcc/testsuite/g++.dg/ext/type_pack_element2.C
@@ -2,7 +2,7 @@
 
 int p;
 
-using type = __type_pack_element<&p, int>;  // { dg-error "not an integral 
constant" }
+using type = __type_pack_element<&p, int>;  // { dg-error "non-integral 
type" }
 using type = __type_pack_element<1, int>;   // { dg-error "out of range" }
 using type = __type_pack_element<2, int, char>; // { dg-error "out of range" }
 using type = __type_pack_element<-1, int>;  // { dg-error "negative" }
diff --git a/gcc/testsuite/g++.dg/ext/type_pack_element4.C 
b/gcc/testsuite/g++.dg/ext/type_pack_element4.C
index aa508c79090b..5a391947c7be 100644
--- a/gcc/testsuite/g++.dg/ext/type_pack_element4.C
+++ b/gcc/testsuite/g++.dg/ext/type_pack_element4.C
@@ -3,7 +3,7 @@
 
 template  class tuple{};
 template 
-__type_pack_element<__i, _Elements...> &get(tuple<_Elements...> &__t) 
noexcept; // { dg-error "index is out of range" }
+__type_pack_element<__i, _Elements...> &get(tuple<_Elements...> &__t) 
noexcept; // { dg-error "out of range" }
 tuple data;
 template 
 unsigned take_impl(unsigned idx) {
diff --git a/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc 
b/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc
index 48628a98884b..18d47d266ce8 100644
--- a/libst

[gcc(refs/vendors/redhat/heads/gcc-15-branch)] Merge commit 'r15-9554-g7336054f9b012a0812cd0a260375cd987e4aadf9' into redhat/gcc-15-branch

2025-04-17 Thread Jakub Jelinek via Libstdc++-cvs
https://gcc.gnu.org/g:dd2ccfe5989486cafb7f6108ff0c4e9f5a93f5a1

commit dd2ccfe5989486cafb7f6108ff0c4e9f5a93f5a1
Merge: 5f1acb12c814 7336054f9b01
Author: Jakub Jelinek 
Date:   Thu Apr 17 20:21:21 2025 +0200

Merge commit 'r15-9554-g7336054f9b012a0812cd0a260375cd987e4aadf9' into 
redhat/gcc-15-branch

Diff:

 ChangeLog  |4 +
 MAINTAINERS|1 +
 config/ChangeLog   |4 +
 config/bootstrap-lto-locality.mk   |   20 +
 contrib/ChangeLog  |9 +
 contrib/unicode/DerivedGeneralCategory.txt | 4323 
 contrib/unicode/README |3 +-
 contrib/unicode/gen_libstdcxx_unicode_data.py  |   47 +-
 gcc/ChangeLog  |  517 +++
 gcc/DATESTAMP  |2 +-
 gcc/DEV-PHASE  |2 +-
 gcc/Makefile.in|2 +
 gcc/ada/ChangeLog  |6 +
 gcc/ada/sem_ch8.adb|3 +-
 gcc/c/ChangeLog|6 +
 gcc/c/c-typeck.cc  |8 +-
 gcc/calls.cc   |   62 +-
 gcc/cgraph.h   |1 +
 gcc/cgraphclones.cc|2 +-
 gcc/cobol/ChangeLog|   74 +
 gcc/cobol/LICENSE  |   29 -
 gcc/cobol/Make-lang.in |7 +-
 gcc/cobol/cbldiag.h|8 +-
 gcc/cobol/cdf.y|2 +-
 gcc/cobol/cobol1.cc|   10 +-
 gcc/cobol/except.cc|4 +-
 gcc/cobol/gcobol.1 |2 +-
 gcc/cobol/genapi.cc|   73 +-
 gcc/cobol/lang.opt |   10 +-
 gcc/cobol/lang.opt.urls|6 -
 gcc/cobol/lexio.cc |6 +-
 gcc/cobol/parse.y  |  148 +-
 gcc/cobol/scan.l   |6 +-
 gcc/cobol/scan_ante.h  |3 -
 gcc/cobol/show_parse.h |3 -
 gcc/cobol/symbols.cc   |  177 +-
 gcc/cobol/symfind.cc   |   27 -
 gcc/cobol/token_names.h|2 +-
 gcc/cobol/util.cc  |   47 +-
 gcc/combine.cc |6 +-
 gcc/common.opt |9 +-
 gcc/common.opt.urls|   11 +-
 gcc/common/config/s390/s390-common.cc  |4 +-
 gcc/config.gcc |2 +-
 gcc/config.in  |7 +
 gcc/config/aarch64/aarch64-sve.md  |6 +-
 gcc/config/aarch64/aarch64.cc  |4 -
 gcc/config/darwin.h|1 +
 gcc/config/gcn/gcn.md  |4 +-
 gcc/config/gcn/gcn.opt |8 +
 gcc/config/gcn/mkoffload.cc|3 +
 gcc/config/i386/i386-options.cc|4 +-
 gcc/config/i386/i386.cc|   18 +-
 gcc/config/i386/x86-tune-costs.h   |2 +-
 gcc/config/i386/x86-tune-sched.cc  |   15 +-
 gcc/config/nvptx/mkoffload.cc  |3 +
 gcc/config/nvptx/nvptx.cc  |   34 +-
 gcc/config/nvptx/nvptx.md  |4 +-
 gcc/config/nvptx/nvptx.opt |8 +
 gcc/config/riscv/multilib-generator|4 +-
 gcc/config/riscv/riscv-vsetvl.cc   |   19 +-
 gcc/config/riscv/riscv.cc  |2 +-
 gcc/config/riscv/riscv.h   |2 +-
 gcc/config/rx/rx.md|   20 +-
 gcc/config/s390/9175.md|  316 ++
 gcc/config/s390/driver-native.cc   |4 +
 gcc/config/s390/s390-builtins.def  |8 +-
 gcc/config/s390/s390-c.cc  |4 +-
 gcc/config/s390/s390-opts.h|2 +-
 gcc/config/s390/s390.cc|   37 +-
 gcc/config/s390/s390.h |   18 +-
 gcc/config/s390/s390.md|   61 +-
 gcc/config/s390/s390.opt   |5 +-
 gcc/configure  |   47 +-
 gcc/configure.ac   |   22 +-
 gcc/cp/ChangeLog   

[gcc] Created tag 'basepoints/gcc-16'

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
The signed tag 'basepoints/gcc-16' was created pointing to:

 7eac294e0871... Bump BASE-VER.

Tagger: Jakub Jelinek 
Date: Thu Apr 17 12:46:59 2025 +0200

GCC 16 basepoint

Diff:

Summary of changes (added commits):
---

  7eac294... Bump BASE-VER.


[gcc r16-13] LoongArch: Change {dg-do-what-default} save and restore logical.

2025-04-17 Thread LuluCheng via Gcc-cvs
https://gcc.gnu.org/g:dd982198656d914a4958bf86356a4c996c728b9d

commit r16-13-gdd982198656d914a4958bf86356a4c996c728b9d
Author: Xing Li 
Date:   Wed Apr 16 10:29:57 2025 +0800

LoongArch: Change {dg-do-what-default} save and restore logical.

The set of {dg-do-what-default} to 'run' may lead some test hang
during make check.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/loongarch-vector.exp: Change
{dg-do-what-default} save and restore logical.

Diff:
---
 gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp 
b/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp
index f56d2f11bb37..9df3f2908573 100644
--- a/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp
+++ b/gcc/testsuite/gcc.target/loongarch/vector/loongarch-vector.exp
@@ -35,7 +35,7 @@ dg-init
 
 # If the target hardware supports LSX, the default action is "run", otherwise
 # just "compile".
-global dg-do-what-default
+set saved-dg-do-what-default ${dg-do-what-default}
 if {[check_effective_target_loongarch_sx_hw]} then {
   set dg-do-what-default run
 } else {
@@ -45,6 +45,7 @@ if {[check_effective_target_loongarch_sx_hw]} then {
 #Main loop.
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/lsx/*.\[cS\]]] \
" -mlsx" $DEFAULT_CFLAGS
+set dg-do-what-default ${saved-dg-do-what-default}
 
 dg-finish
 
@@ -52,7 +53,7 @@ dg-init
 # If the target hardware supports LASX, the default action is "run", otherwise
 # just "compile".
 
-global dg-do-what-default
+set saved-dg-do-what-default ${dg-do-what-default}
 if {[check_effective_target_loongarch_asx_hw]} then {
   set dg-do-what-default run
 } else {
@@ -61,5 +62,6 @@ if {[check_effective_target_loongarch_asx_hw]} then {
 
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/lasx/*.\[cS\]]] \
" -mlasx" $DEFAULT_CFLAGS
+set dg-do-what-default ${saved-dg-do-what-default}
 # All done.
 dg-finish


[gcc/devel/omp/gcc-14] Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test cases

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2358e874fdbbfb75ef7f4d5921a65d1fe0d1da01

commit 2358e874fdbbfb75ef7f4d5921a65d1fe0d1da01
Author: Thomas Schwinge 
Date:   Fri Mar 28 09:15:19 2025 +0100

Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test cases

Like 'gcc.target/gcn/gcn.exp' is modeled after 'gcc.dg/dg.exp', this new
'g++.target/gcn/gcn.exp' is modeled after 'g++.dg/dg.exp'.

gcc/testsuite/
* g++.target/gcn/gcn.exp: New.

(cherry picked from commit 785448f0465cf9802f1ccfea798f5b732f73f62c)

Diff:
---
 gcc/testsuite/ChangeLog.omp  |  5 
 gcc/testsuite/g++.target/gcn/gcn.exp | 56 
 2 files changed, 61 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 9383e8b457f7..75b609ed755b 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,5 +1,10 @@
 2025-04-17  Thomas Schwinge  
 
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
+   * g++.target/gcn/gcn.exp: New.
+
Backported from trunk:
2025-04-07  Thomas Schwinge  
 
diff --git a/gcc/testsuite/g++.target/gcn/gcn.exp 
b/gcc/testsuite/g++.target/gcn/gcn.exp
new file mode 100644
index ..a3bd75f2a79e
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/gcn.exp
@@ -0,0 +1,56 @@
+# Specific regression driver for GCN.
+#   Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# G++ testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a GCN target.
+if ![istarget amdgcn*-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CXXFLAGS
+if ![info exists DEFAULT_CXXFLAGS] then {
+set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Recursively find files in $dir and subdirs, do not walk into subdirs
+# that contain their own .exp file.
+proc find-cxx-tests { dir suffix } {
+set tests [lsort [glob -nocomplain -directory $dir "*.$suffix" ]]
+foreach subdir [lsort [glob -nocomplain -type d -directory $dir *]] {
+   if { [glob -nocomplain -directory $subdir *.exp] eq "" } {
+   eval lappend tests [find-cxx-tests $subdir $suffix]
+   }
+}
+return $tests
+}
+
+set tests [find-cxx-tests $srcdir/$subdir {C}]
+
+# Main loop.
+g++-dg-runtest $tests "" $DEFAULT_CXXFLAGS
+
+
+# All done.
+dg-finish


[gcc/devel/omp/gcc-14] nvptx: Don't use PTX '.const', constant state space [PR119573]

2025-04-17 Thread Thomas Schwinge via Libstdc++-cvs
https://gcc.gnu.org/g:df14f6e45a41b9d7f72ef67b17b3657663559443

commit df14f6e45a41b9d7f72ef67b17b3657663559443
Author: Thomas Schwinge 
Date:   Wed Apr 2 10:25:17 2025 +0200

nvptx: Don't use PTX '.const', constant state space [PR119573]

This avoids cases where a "File uses too much global constant data" (final
executable, or single object file), and avoids cases of wrong code 
generation:
"error : State space incorrect for instruction 'st'" ('st.const'), or 
another
case where an "illegal instruction was encountered", or a lot of cases where
for two compilation units (such as a library linked with user code) we ran 
into
"error : Memory space doesn't match" due to differences in '.const' usage
between definition and use of a variable.

We progress:

ptxas error   : File uses too much global constant data (0x1f01a bytes, 
0x1 max)
nvptx-run: cuLinkAddData failed: a PTX JIT compilation failed 
(CUDA_ERROR_INVALID_PTX, 218)

... into:

PASS: 20_util/to_chars/103955.cc  -std=gnu++17 (test for excess errors)
[-FAIL:-]{+PASS:+} 20_util/to_chars/103955.cc  -std=gnu++17 execution 
test

We progress:

ptxas error   : File uses too much global constant data (0x36c65 bytes, 
0x1 max)
nvptx-as: ptxas returned 255 exit status

... into:

[-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c   -O0  
{+(test for excess errors)+}
[-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c   -O1  
{+(test for excess errors)+}
[-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c   -O2  
{+(test for excess errors)+}
[-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c   -O3 -g  
{+(test for excess errors)+}
[-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c   -Os  
{+(test for excess errors)+}

[-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C   -O0  (test for excess 
errors)
[-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C   -O1  (test for excess 
errors)
[-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C   -O2  (test for excess 
errors)
[-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C   -O3 -g  (test for excess 
errors)
[-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C   -Os  (test for excess 
errors)

[-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-1.f90   -O0  (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-1.f90   -O0  
[-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-4.f90   -O0  (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-4.f90   -O0  
[-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-5.f90   -O0  (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-5.f90   -O0  
[-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} 20_util/to_chars/double.cc  -std=gnu++17 (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} 20_util/to_chars/double.cc  -std=gnu++17 
[-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} 20_util/to_chars/float.cc  -std=gnu++17 (test for 
excess errors)
[-UNRESOLVED:-]{+PASS:+} 20_util/to_chars/float.cc  -std=gnu++17 
[-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} special_functions/13_ellint_3/check_value.cc  
-std=gnu++17 (test for excess errors)
[-UNRESOLVED:-]{+PASS:+} special_functions/13_ellint_3/check_value.cc  
-std=gnu++17 [-compilation failed to produce executable-]{+execution test+}

[-FAIL:-]{+PASS:+} 
tr1/5_numerical_facilities/special_functions/14_ellint_3/check_value.cc  
-std=gnu++17 (test for excess errors)
[-UNRESOLVED:-]{+PASS:+} 
tr1/5_numerical_facilities/special_functions/14_ellint_3/check_value.cc  
-std=gnu++17 [-compilation failed to produce executable-]{+execution test+}

..., and progress likewise, but fail later with an unrelated error:

[-FAIL:-]{+PASS:+} ext/special_functions/hyperg/check_value.cc  
-std=gnu++17 (test for excess errors)
[-UNRESOLVED:-]{+FAIL:+} ext/special_functions/hyperg/check_value.cc  
-std=gnu++17 [-compilation failed to produce executable-]{+execution test+}


[...]/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_value.cc:12317: 
void test(const testcase_hyperg (&)[Num], Ret) [with Ret = double; 
unsigned int Num = 19]: Assertion 'max_abs_frac < toler' failed.

..., and:

[-FAIL:-]{+PASS:+} 
tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc  
-std=gnu++17 (test for excess errors)
[-UNRESOLVED:-]{+FAIL:+} 
tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc  
-std=gnu++17 [-comp

[gcc/devel/omp/gcc-14] libstdc++, nvptx: Remove machinery to inject per-file flags

2025-04-17 Thread Thomas Schwinge via Libstdc++-cvs
https://gcc.gnu.org/g:70e36d8d0429ba9474501d79eaf630764f77efc4

commit 70e36d8d0429ba9474501d79eaf630764f77efc4
Author: Thomas Schwinge 
Date:   Wed Apr 2 11:05:08 2025 +0200

libstdc++, nvptx: Remove machinery to inject per-file flags

Not used anymore.

libstdc++-v3/
* config/cpu/nvptx/t-nvptx: Remove.
* configure.host [nvptx]: Adjust.

(cherry picked from commit 287f360b3e75a19c48ee14c71f51b6e7968474ef)

Diff:
---
 libstdc++-v3/ChangeLog.omp| 6 ++
 libstdc++-v3/config/cpu/nvptx/t-nvptx | 1 -
 libstdc++-v3/configure.host   | 5 -
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/ChangeLog.omp b/libstdc++-v3/ChangeLog.omp
index dd14652de22b..daca152e84a5 100644
--- a/libstdc++-v3/ChangeLog.omp
+++ b/libstdc++-v3/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-03  Thomas Schwinge  
 
+   * config/cpu/nvptx/t-nvptx: Remove.
+   * configure.host [nvptx]: Adjust.
+
+   Backported from trunk:
+   2025-04-03  Thomas Schwinge  
+
PR target/119573
* config/cpu/nvptx/t-nvptx (AM_MAKEFLAGS): Don't amend.
 
diff --git a/libstdc++-v3/config/cpu/nvptx/t-nvptx 
b/libstdc++-v3/config/cpu/nvptx/t-nvptx
deleted file mode 100644
index eacc5468d627..
--- a/libstdc++-v3/config/cpu/nvptx/t-nvptx
+++ /dev/null
@@ -1 +0,0 @@
-# Per-file flags, see '../../../configure.host', "inject per-file flags".
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index 0bed9dfff957..8375764bf4dc 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -374,11 +374,6 @@ case "${host}" in
  
port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
  ;;
   nvptx-*-none)
-# For 'make all-target-libstdc++-v3', we need to inject per-file flags:
-OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} \$(CXXFLAGS-\$(subdir)/\$@)"
-# ..., see:
-tmake_file="$tmake_file cpu/nvptx/t-nvptx"
-
 # For 'make all-target-libstdc++-v3', re 'alloca'/VLA usage:
 EXTRA_CFLAGS="${EXTRA_CFLAGS} -mfake-ptx-alloca"
 OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -mfake-ptx-alloca"


[gcc/devel/omp/gcc-14] Add test cases for exception handling constructs in dead code for GCN, nvptx target and OpenMP 'targ

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:95219213053cc0d6111230f196f961f21026b799

commit 95219213053cc0d6111230f196f961f21026b799
Author: Thomas Schwinge 
Date:   Thu Mar 27 23:06:37 2025 +0100

Add test cases for exception handling constructs in dead code for GCN, 
nvptx target and OpenMP 'target' offloading [PR118794]

PR target/118794
gcc/testsuite/
* g++.target/gcn/exceptions-pr118794-1.C: New.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.

(cherry picked from commit aa3e72f943032e5f074b2bd2fd06d130dda8760b)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  7 +++
 .../g++.target/gcn/exceptions-pr118794-1.C | 16 ++
 .../g++.target/nvptx/exceptions-pr118794-1.C   | 16 ++
 libgomp/ChangeLog.omp  | 10 
 ...arget-exceptions-pr118794-1-offload-sorry-GCN.C | 23 +
 ...get-exceptions-pr118794-1-offload-sorry-nvptx.C | 23 +
 .../libgomp.c++/target-exceptions-pr118794-1.C | 58 ++
 7 files changed, 153 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 3cdde0e8ac39..7a295230e79a 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,13 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   PR target/118794
+   * g++.target/gcn/exceptions-pr118794-1.C: New.
+   * g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
PR c++/119692
* g++.target/gcn/pr119692-1-1.C: New.
* g++.target/nvptx/pr119692-1-1.C: Likewise.
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 80578d93d800..a0fdd14aaf3c 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,16 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   PR target/118794
+   * testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
+   * 
testsuite/libgomp.c++/target-exceptions-pr118

[gcc/devel/omp/gcc-14] GCN, nvptx: Define '_Unwind_RaiseException', '_Unwind_Resume_or_Rethrow'

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ae9cb9fc18992c8c505d46c28b3c493ac7d7fbde

commit ae9cb9fc18992c8c505d46c28b3c493ac7d7fbde
Author: Thomas Schwinge 
Date:   Tue Mar 18 10:10:30 2025 +0100

GCN, nvptx: Define '_Unwind_RaiseException', '_Unwind_Resume_or_Rethrow'

This resolves GCN:

ld: error: undefined symbol: _Unwind_RaiseException
>>> referenced by eh_throw.cc:93 
([...]/source-gcc/libstdc++-v3/libsupc++/eh_throw.cc:93)
>>>   eh_throw.o:(__cxa_throw) in archive 
/srv/data/tschwinge/amd-instinct2/gcc/build/submit-light-target_gcn/build-gcc/amdgcn-amdhsa/gfx908/libstdc++-v3/src/.libs/libstdc++.a
[...]
collect2: error: ld returned 1 exit status

..., and/or:

ld: error: undefined symbol: _Unwind_Resume_or_Rethrow
>>> referenced by eh_throw.cc:129 
([...]/source-gcc/libstdc++-v3/libsupc++/eh_throw.cc:129)
>>>   eh_throw.o:(__cxa_rethrow) in archive 
/srv/data/tschwinge/amd-instinct2/gcc/build/submit-light-target_gcn/build-gcc/amdgcn-amdhsa/gfx908/libstdc++-v3/src/.libs/libstdc++.a
[...]
collect2: error: ld returned 1 exit status

..., and nvptx:

unresolved symbol _Unwind_RaiseException
collect2: error: ld returned 1 exit status

..., or:

unresolved symbol _Unwind_Resume_or_Rethrow
collect2: error: ld returned 1 exit status

For both GCN, nvptx, this each progresses ~25 'check-gcc-c++',
and ~10 'check-target-libstdc++-v3' test cases:

[-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

[-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce 
executable-]{+execution test+}

..., or some 'FAIL: [...] execution test' where these test cases now FAIL 
when
attempting to use these interfaces, or, if applicable, FAIL due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

libgcc/
* config/gcn/unwind-gcn.c (_Unwind_RaiseException)
(_Unwind_Resume_or_Rethrow): New.
* config/nvptx/unwind-nvptx.c (_Unwind_RaiseException)
(_Unwind_Resume_or_Rethrow): Likewise.

(cherry picked from commit 54ab0f6785c006ddff056dab9c0240cddae82020)

Diff:
---
 libgcc/ChangeLog.omp   |  8 
 libgcc/config/gcn/unwind-gcn.c | 14 ++
 libgcc/config/nvptx/unwind-nvptx.c | 14 ++
 3 files changed, 36 insertions(+)

diff --git a/libgcc/ChangeLog.omp b/libgcc/ChangeLog.omp
index 2683de6b8249..c4efc083b53d 100644
--- a/libgcc/ChangeLog.omp
+++ b/libgcc/ChangeLog.omp
@@ -3,6 +3,14 @@
Backported from trunk:
2025-04-08  Thomas Schwinge  
 
+   * config/gcn/unwind-gcn.c (_Unwind_RaiseException)
+   (_Unwind_Resume_or_Rethrow): New.
+   * config/nvptx/unwind-nvptx.c (_Unwind_RaiseException)
+   (_Unwind_Resume_or_Rethrow): Likewise.
+
+   Backported from trunk:
+   2025-04-08  Thomas Schwinge  
+
* config/gcn/unwind-gcn.c (_Unwind_DeleteException): New.
* config/nvptx/unwind-nvptx.c (_Unwind_DeleteException): Likewise.
 
diff --git a/libgcc/config/gcn/unwind-gcn.c b/libgcc/config/gcn/unwind-gcn.c
index 2ee389b19533..d229417866fa 100644
--- a/libgcc/config/gcn/unwind-gcn.c
+++ b/libgcc/config/gcn/unwind-gcn.c
@@ -24,6 +24,13 @@
 
 #include "unwind.h"
 
+_Unwind_Reason_Code
+_Unwind_RaiseException(struct _Unwind_Exception *exc __attribute__ 
((__unused__)))
+{
+  __builtin_abort ();
+  return 0;
+}
+
 void
 _Unwind_DeleteException (struct _Unwind_Exception *exc)
 {
@@ -31,6 +38,13 @@ _Unwind_DeleteException (struct _Unwind_Exception *exc)
 (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
 }
 
+_Unwind_Reason_Code
+_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc __attribute__ 
((__unused__)))
+{
+  __builtin_abort ();
+  return 0;
+}
+
 _Unwind_Reason_Code
 _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
 {
diff --git a/libgcc/config/nvptx/unwind-nvptx.c 
b/libgcc/config/nvptx/unwind-nvptx.c
index 2ee389b19533..d229417866fa 100644
--- a/libgcc/config/nvptx/unwind-nvptx.c
+++ b/libgcc/config/nvptx/unwind-nvptx.c
@@ -24,6 +24,13 @@
 
 #include "unwind.h"
 
+_Unwind_Reason_Code
+_Unwind_RaiseException(struct _Unwind_Exception *exc __attribute__ 
((__unused__)))
+{
+  __builtin_abort ();
+  return 0;
+}
+
 void
 _Unwind_DeleteException (struct _Unwind_Exception *exc)
 {
@@ -31,6 +38,13 @@ _Unwind_DeleteException (struct _Unwind_Exception *exc)
 (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
 }
 
+_Unwind_Reason_Code
+_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc __attribute__ 
((__unused__)))
+{
+  __builtin_abort ();
+  return 0;
+}
+
 _Unwind_Reason_Code
 _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
 {


[gcc/devel/omp/gcc-14] nvptx: In offloading compilation, special-case certain host-setup symbol aliases: avoid unused label

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0852f789d440bc17c15473015e31ad13103b2bdd

commit 0852f789d440bc17c15473015e31ad13103b2bdd
Author: Thomas Schwinge 
Date:   Mon Apr 7 12:39:33 2025 +0200

nvptx: In offloading compilation, special-case certain host-setup symbol 
aliases: avoid unused label 'emit_ptx_alias' diagnostic

Minor fix-up for commit 65b31b3fff2fced015ded1026733605f34053796
"nvptx: In offloading compilation, special-case certain host-setup symbol 
aliases [PR101544]",
as of which we see for non-offloading configurations:

+[...]/source-gcc/gcc/config/nvptx/nvptx.cc: In function 'void 
nvptx_asm_output_def_from_decls(FILE*, tree, tree)':
+[...]/source-gcc/gcc/config/nvptx/nvptx.cc:7769:2: warning: label 
'emit_ptx_alias' defined but not used [-Wunused-label]
+ 7769 |  emit_ptx_alias:
+  |  ^~

gcc/
* config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
[!ACCEL_COMPILER]: Don't define label 'emit_ptx_alias'.

(cherry picked from commit 175016de6f9d800343ce31cf1837a3265569b657)

Diff:
---
 gcc/ChangeLog.omp | 8 
 gcc/config/nvptx/nvptx.cc | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 0ffb30b66c04..c5fd3e18383e 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,11 @@
+2025-04-17  Thomas Schwinge  
+
+   Backported from trunk:
+   2025-04-08  Thomas Schwinge  
+
+   * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
+   [!ACCEL_COMPILER]: Don't define label 'emit_ptx_alias'.
+
 2025-04-08  Tobias Burnus  
 
Backported from master:
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 8e5d9ecce70a..23987a479c47 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -8497,7 +8497,9 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name,
   return;
 }
 
+#ifdef ACCEL_COMPILER
  emit_ptx_alias:
+#endif
 
   cgraph_node *cnode = cgraph_node::get (name);
   if (!cnode->referred_to_p ())


[gcc/devel/omp/gcc-14] GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]

2025-04-17 Thread Thomas Schwinge via Libstdc++-cvs
https://gcc.gnu.org/g:0804fea06587c55f09aaf9b9a11ad1724ec7389e

commit 0804fea06587c55f09aaf9b9a11ad1724ec7389e
Author: Thomas Schwinge 
Date:   Sat Apr 5 23:11:23 2025 +0200

GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]

For both GCN, nvptx, this gets rid of 'configure'-time:

configure: WARNING: No native atomic operations are provided for this 
platform.
configure: WARNING: They will be faked using a mutex.
configure: WARNING: Performance of certain classes will degrade as a 
result.

..., and changes:

-checking for lock policy for shared_ptr reference counts... mutex
+checking for lock policy for shared_ptr reference counts... atomic

That means, '[...]/[target]/libstdc++-v3/', 'Makefile's change:

-ATOMICITY_SRCDIR = config/cpu/generic/atomicity_mutex
+ATOMICITY_SRCDIR = config/cpu/generic/atomicity_builtins

..., and '[...]/[target]/libstdc++-v3/config.h' changes:

/* Defined if shared_ptr reference counting should use atomic 
operations. */
-/* #undef HAVE_ATOMIC_LOCK_POLICY */
+#define HAVE_ATOMIC_LOCK_POLICY 1

/* Define if the compiler supports C++11 atomics. */
-/* #undef _GLIBCXX_ATOMIC_BUILTINS */
+#define _GLIBCXX_ATOMIC_BUILTINS 1

..., and '[...]/[target]/libstdc++-v3/include/[target]/bits/c++config.h'
changes:

/* Defined if shared_ptr reference counting should use atomic 
operations. */
-/* #undef _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */
+#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1

/* Define if the compiler supports C++11 atomics. */
-/* #undef _GLIBCXX_ATOMIC_BUILTINS */
+#define _GLIBCXX_ATOMIC_BUILTINS 1

This means that '[...]/[target]/libstdc++-v3/libsupc++/atomicity.cc',
'[...]/[target]/libstdc++-v3/libsupc++/atomicity.o' then uses atomic
instructions for synchronization instead of C++ static local variables, 
which
in turn for their guard variables, via 'libstdc++-v3/libsupc++/guard.cc', 
used
'libgcc/gthr.h' recursive mutexes, which currently are unsupported for GCN.

For GCN, this turns ~500 libstdc++ execution test FAILs into PASSes, and 
also
progresses:

PASS: g++.dg/tree-ssa/pr20458.C  -std=gnu++17 (test for excess errors)
[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++17 execution 
test
PASS: g++.dg/tree-ssa/pr20458.C  -std=gnu++26 (test for excess errors)
[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C  -std=gnu++26 execution 
test
UNSUPPORTED: g++.dg/tree-ssa/pr20458.C  -std=gnu++98: exception 
handling not supported

(For nvptx, there is no effective change, due to other misconfiguration.)

PR target/119645
libstdc++-v3/
* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]:
Hard-code results.
* configure: Regenerate.
* configure.host [GCN, nvptx] (atomicity_dir): Set to
'cpu/generic/atomicity_builtins'.

(cherry picked from commit 059b5509c14904b55c37f659170240ae0d2c1c8e)

Diff:
---
 libstdc++-v3/ChangeLog.omp  | 10 ++
 libstdc++-v3/acinclude.m4   |  7 ---
 libstdc++-v3/configure  | 11 ++-
 libstdc++-v3/configure.host | 11 +++
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/ChangeLog.omp b/libstdc++-v3/ChangeLog.omp
index daca152e84a5..a704e56156fe 100644
--- a/libstdc++-v3/ChangeLog.omp
+++ b/libstdc++-v3/ChangeLog.omp
@@ -1,5 +1,15 @@
 2025-04-17  Thomas Schwinge  
 
+   Backported from trunk:
+   2025-04-07  Thomas Schwinge  
+
+   PR target/119645
+   * acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]:
+   Hard-code results.
+   * configure: Regenerate.
+   * configure.host [GCN, nvptx] (atomicity_dir): Set to
+   'cpu/generic/atomicity_builtins'.
+
Backported from trunk:
2025-04-03  Thomas Schwinge  
 
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 1c6d725a1359..453e231c7ec1 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4023,10 +4023,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LOCK_POLICY], [
 dnl Why don't we check 8-byte CAS for sparc64, where _Atomic_word is long?!
 dnl New targets should only check for CAS for the _Atomic_word type.
 AC_TRY_COMPILE([
-#if defined __riscv
+#if defined __AMDGCN__ || defined __nvptx__
+/* Yes, please.  */
+#elif defined __riscv
 # error "Defaulting to mutex-based locks for ABI compatibility"
-#endif
-#if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
 # error "No 2-byte compare-and-swap"
 #elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
 # error "No 4-byte compare-and-swap"
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 7

[gcc/devel/omp/gcc-14] Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" test cases [PR119692

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:fa868840a6366d0f3717360c0c39d8f2cc9977b1

commit fa868840a6366d0f3717360c0c39d8f2cc9977b1
Author: Thomas Schwinge 
Date:   Thu Apr 10 09:46:56 2025 +0200

Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' 
offloading" test cases [PR119692]

... documenting the status quo.

PR c++/119692
gcc/testsuite/
* g++.target/gcn/pr119692-1-1.C: New.
* g++.target/nvptx/pr119692-1-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/pr119692-1-1.C: New.
* testsuite/libgomp.c++/pr119692-1-2.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-3.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-4.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.

(cherry picked from commit a304c88b6feb9ee580d3e389f08a6ed40dfe2292)

Diff:
---
 gcc/testsuite/ChangeLog.omp   |  7 
 gcc/testsuite/g++.target/gcn/pr119692-1-1.C   |  6 
 gcc/testsuite/g++.target/nvptx/pr119692-1-1.C |  6 
 libgomp/ChangeLog.omp | 15 
 libgomp/testsuite/libgomp.c++/pr119692-1-1.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-2.C  | 11 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-3.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-4.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-5.C  | 10 ++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C | 42 +++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C | 12 +++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-3.C | 12 +++
 12 files changed, 151 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 75b609ed755b..3cdde0e8ac39 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,13 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   PR c++/119692
+   * g++.target/gcn/pr119692-1-1.C: New.
+   * g++.target/nvptx/pr119692-1-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* g++.target/gcn/gcn.exp: New.
 
Backported from trunk:
diff --git a/gcc/testsuite/g++.target/gcn/pr119692-1-1.C 
b/gcc/testsuite/g++.target/gcn/pr119692-1-1.C
new file mode 100644
index ..b44b08d667dd
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/pr119692-1-1.C
@@ -0,0 +1,6 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C"
diff --git a/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C 
b/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C
new file mode 100644
index ..b44b08d667dd
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C
@@ -0,0 +1,6 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C"
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 5d2d151eadc7..80578d93d800 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,18 @@
+2025-04-17  Thomas Schwinge  
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
+   PR c++/119692
+   * testsuite/libgomp.c++/pr119692-1-1.C: New.
+   * testsuite/libgomp.c++/pr119692-1-2.C: Likewise.
+   * testsuite/libgomp.c++/pr119692-1-3.C: Likewise.
+   * testsuite/libgomp.c++/pr119692-1-4.C: Likewise.
+   * testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.
+
 2025-04-08  Tobias Burnus  
 
Backported from master:
diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-1.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-1.C
new file mode 100644
index ..1f59b1515405
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-1.C
@@ -0,0 +1,10 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-additional-options -UDEFAULT }
+   Wrong code for offloading execution.
+   { dg-additional-options -foffload=disable } */
+/* { dg-additional-options -fdump-tree-gimple } */
+
+#include "../libgomp.oacc-c++/pr119692-1-1.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* 
map\(tofrom:_ZTI2C2 \

[gcc/devel/omp/gcc-14] GCN, nvptx: Define '_Unwind_DeleteException'

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:9eed92a0b47ebc25932ced9b5db86b66b59f7857

commit 9eed92a0b47ebc25932ced9b5db86b66b59f7857
Author: Thomas Schwinge 
Date:   Tue Mar 18 10:10:30 2025 +0100

GCN, nvptx: Define '_Unwind_DeleteException'

This resolves GCN:

ld: error: undefined symbol: _Unwind_DeleteException
>>> referenced by eh_catch.cc:109 
([...]/source-gcc/libstdc++-v3/libsupc++/eh_catch.cc:109)
>>>   eh_catch.o:(__cxa_end_catch) in archive 
[...]/build-gcc/amdgcn-amdhsa/libstdc++-v3/src/.libs/libstdc++.a
[...]
collect2: error: ld returned 1 exit status

..., and nvptx:

unresolved symbol _Unwind_DeleteException
collect2: error: ld returned 1 exit status

For both GCN, nvptx, this each progresses ~100 'check-gcc-c++',
and ~500 'check-target-libstdc++-v3' test cases:

[-FAIL:-]{+PASS:+} [...] (test for excess errors)

..., with (if applicable, for most of them):

[-UNRESOLVED:-]{+PASS:+} [...] [-compilation failed to produce 
executable-]{+execution test+}

..., or just a few 'FAIL: [...] execution test' where these test cases now
FAIL for unrelated reasons, or, if applicable, FAIL due to run-time
'GCC/nvptx: sorry, unimplemented: dynamic stack allocation not supported'.

libgcc/
* config/gcn/unwind-gcn.c (_Unwind_DeleteException): New.
* config/nvptx/unwind-nvptx.c (_Unwind_DeleteException): Likewise.

(cherry picked from commit 815abd68353751d53ed9299e218f8ca1cc108d5f)

Diff:
---
 libgcc/ChangeLog.omp   | 6 ++
 libgcc/config/gcn/unwind-gcn.c | 7 +++
 libgcc/config/nvptx/unwind-nvptx.c | 7 +++
 3 files changed, 20 insertions(+)

diff --git a/libgcc/ChangeLog.omp b/libgcc/ChangeLog.omp
index a03e92b34aed..2683de6b8249 100644
--- a/libgcc/ChangeLog.omp
+++ b/libgcc/ChangeLog.omp
@@ -1,5 +1,11 @@
 2025-04-17  Thomas Schwinge  
 
+   Backported from trunk:
+   2025-04-08  Thomas Schwinge  
+
+   * config/gcn/unwind-gcn.c (_Unwind_DeleteException): New.
+   * config/nvptx/unwind-nvptx.c (_Unwind_DeleteException): Likewise.
+
Backported from trunk:
2025-04-07  Thomas Schwinge  
 
diff --git a/libgcc/config/gcn/unwind-gcn.c b/libgcc/config/gcn/unwind-gcn.c
index d08ba266be10..2ee389b19533 100644
--- a/libgcc/config/gcn/unwind-gcn.c
+++ b/libgcc/config/gcn/unwind-gcn.c
@@ -24,6 +24,13 @@
 
 #include "unwind.h"
 
+void
+_Unwind_DeleteException (struct _Unwind_Exception *exc)
+{
+  if (exc->exception_cleanup)
+(*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
+}
+
 _Unwind_Reason_Code
 _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
 {
diff --git a/libgcc/config/nvptx/unwind-nvptx.c 
b/libgcc/config/nvptx/unwind-nvptx.c
index d08ba266be10..2ee389b19533 100644
--- a/libgcc/config/nvptx/unwind-nvptx.c
+++ b/libgcc/config/nvptx/unwind-nvptx.c
@@ -24,6 +24,13 @@
 
 #include "unwind.h"
 
+void
+_Unwind_DeleteException (struct _Unwind_Exception *exc)
+{
+  if (exc->exception_cleanup)
+(*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
+}
+
 _Unwind_Reason_Code
 _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
 {


[gcc/devel/omp/gcc-14] For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:62f8948456e1973bb79113af8943b7f23ebef228

commit 62f8948456e1973bb79113af8943b7f23ebef228
Author: Thomas Schwinge 
Date:   Wed Apr 16 14:00:31 2025 +0200

For nvptx offloading, make sure to emit C++ constructor, destructor aliases 
[PR97106]

PR target/97106
gcc/
* config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
[ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor
aliases.
libgomp/
* testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading.
* testsuite/libgomp.c-c++-common/pr96390.c: Adjust.

(cherry picked from commit ca9cffe737d20953082333dacebb65d4261e0d0c)

Diff:
---
 gcc/ChangeLog.omp|  8 
 gcc/config/nvptx/nvptx.cc| 12 
 libgomp/ChangeLog.omp|  7 +++
 libgomp/testsuite/libgomp.c++/pr96390.C  |  2 --
 libgomp/testsuite/libgomp.c-c++-common/pr96390.c |  2 +-
 5 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 78f31903196e..6988afbd2388 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,5 +1,13 @@
 2025-04-17  Thomas Schwinge  
 
+   Backported from trunk:
+   2025-04-16  Thomas Schwinge  
+
+   PR target/97106
+   * config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
+   [ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor
+   aliases.
+
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index b8116e83c5f1..2c29091bfc19 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -8518,6 +8518,18 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name,
 #endif
 
   cgraph_node *cnode = cgraph_node::get (name);
+#ifdef ACCEL_COMPILER
+  /* For nvptx offloading, make sure to emit C++ constructor, destructor 
aliases [PR97106]
+
+ For some reason (yet to be analyzed), they're not 'cnode->referred_to_p 
()'.
+ (..., or that's not the right approach at all;
+ 
+ "Re: [committed][nvptx] Use .alias directive for mptx >= 6.3").  */
+  if (DECL_CXX_CONSTRUCTOR_P (name)
+  || DECL_CXX_DESTRUCTOR_P (name))
+;
+  else
+#endif
   if (!cnode->referred_to_p ())
 /* Prevent "Internal error: reference to deleted section".  */
 return;
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 967664b183bd..5343b9bbecc2 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,12 @@
 2025-04-17  Thomas Schwinge  
 
+   Backported from trunk:
+   2025-04-16  Thomas Schwinge  
+
+   PR target/97106
+   * testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading.
+   * testsuite/libgomp.c-c++-common/pr96390.c: Adjust.
+
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
diff --git a/libgomp/testsuite/libgomp.c++/pr96390.C 
b/libgomp/testsuite/libgomp.c++/pr96390.C
index 1f3c3e056618..be1960186eaa 100644
--- a/libgomp/testsuite/libgomp.c++/pr96390.C
+++ b/libgomp/testsuite/libgomp.c++/pr96390.C
@@ -1,6 +1,4 @@
 /* { dg-additional-options "-O0 -fdump-tree-omplower" } */
-/* { dg-additional-options "-foffload=-Wa,--verify" { target 
offload_target_nvptx } } */
-/* { dg-xfail-if "PR 97106/PR 97102 - .alias not (yet) supported for nvptx" { 
offload_target_nvptx } } */
 
 #include 
 #include 
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr96390.c 
b/libgomp/testsuite/libgomp.c-c++-common/pr96390.c
index b89f934811a5..ca7865d322df 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/pr96390.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr96390.c
@@ -1,7 +1,7 @@
 /* { dg-additional-options "-O0 -fdump-tree-omplower" } */
 /* { dg-additional-options "-foffload=-Wa,--verify" { target 
offload_target_nvptx } } */
 /* { dg-require-alias "" } */
-/* { dg-xfail-if "PR 97102/PR 97106 - .alias not (yet) supported for nvptx" { 
offload_target_nvptx } } */
+/* { dg-xfail-if PR105018 { offload_target_nvptx } } */
 
 #ifdef __cplusplus
 extern "C" {


[gcc/devel/omp/gcc-14] GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:9c083c6f2b2acd0a8fe2ba2f1fa90df80dad734e

commit 9c083c6f2b2acd0a8fe2ba2f1fa90df80dad734e
Author: Thomas Schwinge 
Date:   Fri Mar 28 09:20:49 2025 +0100

GCN, nvptx: Support '-mfake-exceptions', and use it for offloading 
compilation [PR118794]

With '-mfake-exceptions' enabled, the user-visible behavior in presence of
exception handling constructs changes such that the compile-time
'sorry, unimplemented: exception handling not supported' is skipped, code
generation proceeds, and instead, exception handling constructs 'abort' at
run time.  (..., or don't, if they're in dead code.)

PR target/118794
gcc/
* config/gcn/gcn.opt (-mfake-exceptions): Support.
* config/nvptx/nvptx.opt (-mfake-exceptions): Likewise.
* config/gcn/gcn.md (define_expand "exception_receiver"): Use it.
* config/nvptx/nvptx.md (define_expand "exception_receiver"):
Likewise.
* config/gcn/mkoffload.cc (main): Set it.
* config/nvptx/mkoffload.cc (main): Likewise.
* config/nvptx/nvptx.cc (nvptx_assemble_integer)
: Special handling for
'SYMBOL_REF's.
* except.cc (expand_dw2_landing_pad_for_region): Don't generate
bogus code for (default)
'#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'.
libgcc/
* config/gcn/unwind-gcn.c (_Unwind_Resume): New.
* config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise.
gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-2.C: Set
'-mno-fake-exceptions'.
* g++.target/gcn/exceptions-pr118794-1.C: Likewise.
* g++.target/gcn/exceptions-throw-2.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
* g++.target/nvptx/exceptions-throw-2.C: Likewise.
* g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New.
* g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C:
Likewise.
libgomp/
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C:
Set '-foffload-options=-mno-fake-exceptions'.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust.
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.

(cherry picked from commit fe283dba774be57b705a7a871b000d2894d2e553)

Diff:
---
 gcc/ChangeLog.omp  | 18 +
 gcc/config/gcn/gcn.md  |  4 ++-
 gcc/config/gcn/gcn.opt |  8 ++
 gcc/config/gcn/mkoffload.cc|  3 +++
 gcc/config/nvptx/mkoffload.cc  |  3 +++
 gcc/config/nvptx/nvptx.cc  | 20 +-
 gcc/config/nvptx/nvptx.md  |  4 ++-
 gcc/config/nvptx/nvptx.opt |  8 ++
 gcc/except.cc  | 24 +
 gcc/testsuite/ChangeLog.omp| 22 +++
 .../g++.target/gcn/exceptions-bad_cast-2.C |  1 +
 .../gcn/exceptions-bad_cast-2_-mfake-exceptions.C  | 18 

[gcc/devel/omp/gcc-14] OpenACC: Improve implicit mapping for non-lexically nested offload regions: Adjust cherry-picked tes

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:77e9a05316b9b56e21086a3e22cc6eb313c2efa3

commit 77e9a05316b9b56e21086a3e22cc6eb313c2efa3
Author: Thomas Schwinge 
Date:   Wed Apr 16 21:52:53 2025 +0200

OpenACC: Improve implicit mapping for non-lexically nested offload regions: 
Adjust cherry-picked test cases

Adjust cherry-picked test cases per
OG14 commit b918a7e4b4bdf070bfa9ede48ef9d22f89ff7795
"OpenACC: Improve implicit mapping for non-lexically nested offload regions"
(in combination with
OG14 commit 5fb2987d33c7296543fa7b8dbeab597fc552b110
"Clarify 'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' in 
'gcc/tree-pretty-print.cc:dump_omp_clause'"
(cherry picked from trunk commit d6e66e7b3a40315ad303344e19bccb4006c51cac)).

libgomp/
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Adjust.
* testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.

Diff:
---
 libgomp/ChangeLog.omp  | 6 ++
 libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C | 2 +-
 libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C| 2 +-
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C  | 2 +-
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C  | 2 +-
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-3.C  | 2 +-
 6 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 44cc3227bbda..56ddb4378fd3 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,11 @@
 2025-04-17  Thomas Schwinge  
 
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Adjust.
+   * testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
+   * testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.
+
Backported from trunk:
2025-04-16  Thomas Schwinge  
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C
index 4fa419f245fc..e9372fa95273 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C
@@ -44,6 +44,6 @@ int main()
   }
 }
 
-/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI2C2 \[len: [0-9]+\]\) map\(tofrom:_ZTI2C1 \[len: [0-9]+\]\) 
map\(tofrom:_ZTV2C1 \[len: [0-9]+\]\)$} gimple { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI2C2 \[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTI2C1 
\[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTV2C1 \[len: [0-9]+\] 
\[runtime_implicit\]\)$} gimple { xfail *-*-* } } } */
 
 /* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
index 74a62b3abfac..6664f800e697 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
@@ -37,7 +37,7 @@ int main()
   }
 }
 
-/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI11MyException \[len: [0-9]+\]\)$} gimple { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI11MyException \[len: [0-9]+\] \[runtime_implicit\]\)$} gimple { 
xfail *-*-* } } } */
 
 /* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
{ dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C 
b/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C
index 5c3e037f5911..4a876f74f1fa 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C
@@ -39,4 +39,4 @@ int main()
   }
 }
 
-/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI2C2 \[len: [0-9]+\]\) map\(tofrom:_ZTI2C1 \[len: [0-9]+\]\) 
map\(tofrom:_ZTV2C1 \[len: [0-9]+\]\)$} gimple { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial 
map\(tofrom:_ZTI2C2 \[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTI2C1 
\[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTV2C1 \[len: [0-9]+\] 
\[runtime_implicit\]\)$} gimple { xfail *-*-* } } } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C 
b/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C
index 207b183163ff..052e423ca08e 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C
+++ b/libg

[gcc/devel/omp/gcc-14] Add 'throw', caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0f9ca500212854a8f36950ddf89cd2c1f80ad9c1

commit 0f9ca500212854a8f36950ddf89cd2c1f80ad9c1
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'throw', caught test cases for GCN, nvptx target and OpenACC, OpenMP 
'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-throw-2.C: New.
* g++.target/nvptx/exceptions-throw-2.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-2.C: New.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C: Likewise.

(cherry picked from commit 1daf57049878a79b8bb40fb57ee2370f3cd4d4e7)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  6 
 gcc/testsuite/g++.target/gcn/exceptions-throw-2.C  | 13 
 .../g++.target/nvptx/exceptions-throw-2.C  | 13 
 libgomp/ChangeLog.omp  | 10 ++
 .../target-exceptions-throw-2-offload-sorry-GCN.C  | 20 +++
 ...target-exceptions-throw-2-offload-sorry-nvptx.C | 20 +++
 .../libgomp.c++/target-exceptions-throw-2.C| 15 +
 .../exceptions-throw-2-offload-sorry-GCN.C | 19 +++
 .../exceptions-throw-2-offload-sorry-nvptx.C   | 21 
 .../libgomp.oacc-c++/exceptions-throw-2.C  | 39 ++
 10 files changed, 176 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 62db33e19000..677f7d190b08 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * g++.target/gcn/exceptions-throw-2.C: New.
+   * g++.target/nvptx/exceptions-throw-2.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* g++.target/gcn/exceptions-throw-1.C: New.
* g++.target/nvptx/exceptions-throw-1.C: Likewise.
 
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-2.C 
b/gcc/testsuite/g++.target/gcn/exceptions-throw-2.C
new file mode 100644
index ..0ae64eebd478
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-throw-2.C
@@ -0,0 +1,13 @@
+/* 'throw', caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-2.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-throw-2.C
new file mode 100644
index ..0ae64eebd478
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-throw-2.C
@@ -0,0 +1,13 @@
+/* 'throw', caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 7fbfac71f266..acd9dac9cb89 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,16 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-throw-2.C: New.
+   * testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: 
Likewise.
+   * 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
+   * te

[gcc/devel/omp/gcc-14] Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloadi

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e0025f09d80930bf6913286ef5265f65b915b7dc

commit e0025f09d80930bf6913286ef5265f65b915b7dc
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, 
OpenMP 'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-1.C: New.
* g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.

(cherry picked from commit 0e68f49db986d8d6c1eaaa96dd14f7b2a927a0d0)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  6 +++
 .../g++.target/gcn/exceptions-bad_cast-1.C | 15 ++
 .../g++.target/nvptx/exceptions-bad_cast-1.C   | 15 ++
 libgomp/ChangeLog.omp  |  6 +++
 .../libgomp.c++/target-exceptions-bad_cast-1.C | 25 ++
 .../libgomp.oacc-c++/exceptions-bad_cast-1.C   | 54 ++
 6 files changed, 121 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 7a295230e79a..574ec55f9c85 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * g++.target/gcn/exceptions-bad_cast-1.C: New.
+   * g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
PR target/118794
* g++.target/gcn/exceptions-pr118794-1.C: New.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C
new file mode 100644
index ..f3e30994bc7c
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C
@@ -0,0 +1,15 @@
+/* 'std::bad_cast' exception.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'std::bad_cast' exception} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C
new file mode 100644
index ..f3e30994bc7c
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C
@@ -0,0 +1,15 @@
+/* 'std::bad_cast' exception.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'std::bad_cast' exception} } */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index a0fdd14aaf3c..4c81b3107402 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New.
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
PR target/118794
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
new file mode 100644
index ..3848295fbabc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
@@ -0,0 +1,25 @@
+/* 'std::bad_cast' exception in OpenMP 'target' region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   For host execution, we print something like:
+   

[gcc/devel/omp/gcc-14] Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ad51cb1221fdddb246b421e6529e5af7524a15de

commit ad51cb1221fdddb246b421e6529e5af7524a15de
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 
'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-throw-3.C: New.
* g++.target/nvptx/exceptions-throw-3.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-3.C: New.
* testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.

(cherry picked from commit 6c0ea840265454b01d9ef4eb8850a4f015788788)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  6 +++
 gcc/testsuite/g++.target/gcn/exceptions-throw-3.C  | 11 ++
 .../g++.target/nvptx/exceptions-throw-3.C  | 11 ++
 libgomp/ChangeLog.omp  |  6 +++
 .../libgomp.c++/target-exceptions-throw-3.C| 19 ++
 .../libgomp.oacc-c++/exceptions-throw-3.C  | 43 ++
 6 files changed, 96 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 677f7d190b08..a0abef706bd0 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * g++.target/gcn/exceptions-throw-3.C: New.
+   * g++.target/nvptx/exceptions-throw-3.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* g++.target/gcn/exceptions-throw-2.C: New.
* g++.target/nvptx/exceptions-throw-2.C: Likewise.
 
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C 
b/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C
new file mode 100644
index ..5c1ad7a8fde4
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C
new file mode 100644
index ..5c1ad7a8fde4
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} } */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index acd9dac9cb89..8965de690745 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-throw-3.C: New.
+   * testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* testsuite/libgomp.c++/target-exceptions-throw-2.C: New.
* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: 
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C
new file mode 100644
index ..c35180de28d3
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C
@@ -0,0 +1,19 @@
+/* 'throw' in OpenMP 'target' region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -DDEFAULT=defaultmap(to) }
+   ... to avoid wrong code for offloading execution; PR119692.
+   With this, the device code still isn't correct, but the defects are in dead 
code.
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* defaultmap\(to\) 
map\(to:_ZTI11MyException \[len: [0-9]+\] \[runtime_implicit\]\)$} gimple {

[gcc/devel/omp/gcc-14] Add 'libgomp.c++/pr106445-1{, -O0}.C' [PR106445]

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:378906bd64ba0eb2883f5d8947c586063a36f05a

commit 378906bd64ba0eb2883f5d8947c586063a36f05a
Author: Thomas Schwinge 
Date:   Thu Mar 20 17:25:14 2025 +0100

Add 'libgomp.c++/pr106445-1{,-O0}.C' [PR106445]

PR target/106445
libgomp/
* testsuite/libgomp.c++/pr106445-1.C: New.
* testsuite/libgomp.c++/pr106445-1-O0.C: Likewise.

(cherry picked from commit 0b2a2490bebd29acc4da18562eec7464601cbb05)

Diff:
---
 libgomp/ChangeLog.omp |  7 +++
 libgomp/testsuite/libgomp.c++/pr106445-1-O0.C |  3 +++
 libgomp/testsuite/libgomp.c++/pr106445-1.C| 18 ++
 3 files changed, 28 insertions(+)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 5343b9bbecc2..0c3741fd0031 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,13 @@
Backported from trunk:
2025-04-16  Thomas Schwinge  
 
+   PR target/106445
+   * testsuite/libgomp.c++/pr106445-1.C: New.
+   * testsuite/libgomp.c++/pr106445-1-O0.C: Likewise.
+
+   Backported from trunk:
+   2025-04-16  Thomas Schwinge  
+
PR target/97106
* testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading.
* testsuite/libgomp.c-c++-common/pr96390.c: Adjust.
diff --git a/libgomp/testsuite/libgomp.c++/pr106445-1-O0.C 
b/libgomp/testsuite/libgomp.c++/pr106445-1-O0.C
new file mode 100644
index ..bcd499c664c1
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr106445-1-O0.C
@@ -0,0 +1,3 @@
+// { dg-additional-options -O0 }
+
+#include "pr106445-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr106445-1.C 
b/libgomp/testsuite/libgomp.c++/pr106445-1.C
new file mode 100644
index ..329ce62eb7b2
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr106445-1.C
@@ -0,0 +1,18 @@
+#include 
+
+int main()
+{
+#pragma omp target
+  {
+{
+  std::vector v;
+  if (!v.empty())
+   __builtin_abort();
+}
+{
+  std::vector v(100);
+  if (v.capacity() < 100)
+   __builtin_abort();
+}
+  }
+}


[gcc r15-9545] libgomp.texi: For HIP interop, mention cpp defines to set

2025-04-17 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:4bff3f0b89af9a9aad69b8f85859c0a3667533ae

commit r15-9545-g4bff3f0b89af9a9aad69b8f85859c0a3667533ae
Author: Tobias Burnus 
Date:   Thu Apr 17 10:21:05 2025 +0200

libgomp.texi: For HIP interop, mention cpp defines to set

The HIP header files recognize the used compiler, defaulting to either AMD
or Nvidia/CUDA; thus, the alternative way of explicitly defining a macro is
less prominently documented. With GCC, the user has to define the
preprocessor macro manually. Hence, as a service to the user, mention
__HIP_PLATFORM_AMD__ and __HIP_PLATFORM_NVIDIA__ in the interop 
documentation,
even though it has only indirectly to do with GCC and its interop support.

Note to commit-log readers, only: For Fortran, the hipfort modules can be
used; when compiling the hipfort package (defaults to use gfortran), it
generates the module (*.mod) files in include/hipfort/{amdgcn,nvidia}/ such
that the choice is made by setting the respective include path.

libgomp/ChangeLog:

* libgomp.texi (gcn interop, nvptx interop): For HIP with C/C++, add
a note about setting a preprocessor define.

Diff:
---
 libgomp/libgomp.texi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index dfd189b646e8..6909c2b16f88 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -6945,6 +6945,9 @@ or string (str) data type, call 
@code{omp_get_interop_int},
 Note that @code{device_num} is the OpenMP device number
 while @code{device} is the HIP device number or HSA device handle.
 
+When using HIP with C and C++, the @code{__HIP_PLATFORM_AMD__} preprocessor
+macro must be defined before including the HIP header files.
+
 For the API routine call, add the prefix @code{omp_ipr_} to the property name;
 for instance:
 @smallexample
@@ -7107,6 +7110,9 @@ or string (str) data type, call 
@code{omp_get_interop_int},
 Note that @code{device_num} is the OpenMP device number while @code{device}
 is the CUDA, CUDA Driver, or HIP device number.
 
+When using HIP with C and C++, the @code{__HIP_PLATFORM_NVIDIA__} preprocessor
+macro must be defined before including the HIP header files.
+
 For the API routine call, add the prefix @code{omp_ipr_} to the property name;
 for instance:
 @smallexample


[gcc r14-11648] i386: Enable -mnop-mcount for -fpic with PLTs [PR119386]

2025-04-17 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:203bce172aba0f09cea8a7853403c99956674b6a

commit r14-11648-g203bce172aba0f09cea8a7853403c99956674b6a
Author: Ard Biesheuvel 
Date:   Thu Apr 10 14:26:41 2025 +0200

i386: Enable -mnop-mcount for -fpic with PLTs [PR119386]

-mnop-mcount can be trivially enabled for -fPIC codegen as long as PLTs
are being used, given that the instruction encodings are identical, only
the target may resolve differently depending on how the linker decides
to incorporate the object file.

So relax the option check, and add a test to ensure that 5-byte NOPs are
emitted when -mnop-mcount is being used.

Signed-off-by: Ard Biesheuvel 

gcc/ChangeLog:

PR target/119386
* config/i386/i386-options.cc: Permit -mnop-mcount when
using -fpic with PLTs.

gcc/testsuite/ChangeLog:

PR target/119386
* gcc.target/i386/pr119386-3.c: New test.

(cherry picked from commit 6b4569a3ebdd0df44d87d67a18272ec0b878f2ee)

Diff:
---
 gcc/config/i386/i386-options.cc|  4 ++--
 gcc/testsuite/gcc.target/i386/pr119386-3.c | 10 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 57c83a9aa1c7..81dd217ab727 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -2842,8 +2842,8 @@ ix86_option_override_internal (bool main_args_p,
   if (flag_nop_mcount)
 error ("%<-mnop-mcount%> is not compatible with this target");
 #endif
-  if (flag_nop_mcount && flag_pic)
-error ("%<-mnop-mcount%> is not implemented for %<-fPIC%>");
+  if (flag_nop_mcount && flag_pic && !flag_plt)
+error ("%<-mnop-mcount%> is not implemented for %<-fno-plt%>");
 
   /* Accept -msseregparm only if at least SSE support is enabled.  */
   if (TARGET_SSEREGPARM_P (opts->x_target_flags)
diff --git a/gcc/testsuite/gcc.target/i386/pr119386-3.c 
b/gcc/testsuite/gcc.target/i386/pr119386-3.c
new file mode 100644
index ..287410b951a4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr119386-3.c
@@ -0,0 +1,10 @@
+/* PR target/119386 */
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -pg -mnop-mcount" } */
+/* { dg-final { scan-assembler ".byte\[ \t\]+0x0f, 0x1f, 0x44, 0x00, 0x00" } } 
*/
+
+int
+main ()
+{
+  return 0;
+}


[gcc r12-11055] libstdc++: Fix bogus -Wstringop-overflow in std::vector::insert [PR117983]

2025-04-17 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:1bfcb247ef2f2b7afb9f4b682740ceb332db86ce

commit r12-11055-g1bfcb247ef2f2b7afb9f4b682740ceb332db86ce
Author: Jonathan Wakely 
Date:   Fri Mar 28 22:00:38 2025 +

libstdc++: Fix bogus -Wstringop-overflow in std::vector::insert [PR117983]

This was fixed on trunk by r15-4473-g3abe751ea86e34, but that isn't
suitable for backporting. Instead, just add another unreachable
condition in std::vector::_M_range_insert so the compiler knows this
memcpy doesn't use a length originating from a negative ptrdiff_t
converted to a very positive size_t.

libstdc++-v3/ChangeLog:

PR libstdc++/117983
* include/bits/vector.tcc (vector::_M_range_insert): Add
unreachable condition to tell the compiler begin() <= end().
* testsuite/23_containers/vector/modifiers/insert/117983.cc: New
test.

Reviewed-by: Tomasz Kamiński 

(cherry picked from commit 878812b6f6905774ab37cb78903e3e11bf1c508c)

Diff:
---
 libstdc++-v3/include/bits/vector.tcc|  2 ++
 .../23_containers/vector/modifiers/insert/117983.cc | 17 +
 2 files changed, 19 insertions(+)

diff --git a/libstdc++-v3/include/bits/vector.tcc 
b/libstdc++-v3/include/bits/vector.tcc
index 27ef1a4ee7fe..d949e2d418e3 100644
--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -793,6 +793,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// reachable.
pointer __old_start = this->_M_impl._M_start;
pointer __old_finish = this->_M_impl._M_finish;
+   if ((__old_finish - __old_start) < 0)
+ __builtin_unreachable();
 
const size_type __len =
  _M_check_len(__n, "vector::_M_range_insert");
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc 
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc
new file mode 100644
index ..e6027a677eed
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc
@@ -0,0 +1,17 @@
+// { dg-options "-O3 -Werror=stringop-overflow" }
+// { dg-do compile }
+
+// PR libstdc++/117983
+// -Wstringop-overflow false positive for __builtin_memmove from vector::insert
+
+#include 
+
+typedef std::vector bytes;
+
+void push(bytes chunk, bytes& data) {
+  if (data.empty()) {
+data.swap(chunk);
+  } else {
+data.insert(data.end(), chunk.begin(), chunk.end());
+  }
+}


[gcc r12-11054] libstdc++: Fix std::deque::insert(pos, first, last) undefined behaviour [PR118035]

2025-04-17 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:d14333852ebd77b898b3bf1030f9bf5152497345

commit r12-11054-gd14333852ebd77b898b3bf1030f9bf5152497345
Author: Jonathan Wakely 
Date:   Mon Dec 16 17:42:24 2024 +

libstdc++: Fix std::deque::insert(pos, first, last) undefined behaviour 
[PR118035]

Inserting an empty range into a std::deque results in undefined calls to
either std::copy, std::copy_backward, std::move, or std::move_backward.
We call those algos with invalid arguments where the output range is the
same as the input range, e.g.  std::copy(first, last, first) which
violates the preconditions for the algorithms.

This fix simply returns early if there's nothing to insert. Most callers
already ensure that we don't even call _M_range_insert_aux with an empty
range, but some callers don't. Rather than checking for n == 0 in each
of the callers, this just does the check once and uses __builtin_expect
to treat empty insertions as unlikely.

libstdc++-v3/ChangeLog:

PR libstdc++/118035
* include/bits/deque.tcc (_M_range_insert_aux): Return
immediately if inserting an empty range.
* testsuite/23_containers/deque/modifiers/insert/118035.cc: New
test.

(cherry picked from commit b273e25e11c842a5729d0e03c85088cf5ba8e06c)

Diff:
---
 libstdc++-v3/include/bits/deque.tcc|  3 +++
 .../23_containers/deque/modifiers/insert/118035.cc | 26 ++
 2 files changed, 29 insertions(+)

diff --git a/libstdc++-v3/include/bits/deque.tcc 
b/libstdc++-v3/include/bits/deque.tcc
index 03e0a505e14b..2ba5d7b8602f 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -601,6 +601,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
  std::forward_iterator_tag)
   {
const size_type __n = std::distance(__first, __last);
+   if (__builtin_expect(__n == 0, 0))
+ return;
+
if (__pos._M_cur == this->_M_impl._M_start._M_cur)
  {
iterator __new_start = _M_reserve_elements_at_front(__n);
diff --git 
a/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/118035.cc 
b/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/118035.cc
new file mode 100644
index ..a37d3dc3d04c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/118035.cc
@@ -0,0 +1,26 @@
+// { dg-do run }
+
+#include 
+#include 
+
+struct Sparks
+{
+  Sparks& operator=(const Sparks& s)
+  {
+VERIFY( this != &s ); // This town ain't big enough for the both of us.
+return *this;
+  }
+};
+
+void
+test_pr118035()
+{
+  std::deque d(3, Sparks());
+  Sparks s[1];
+  d.insert(d.begin() + 1, s, s);
+}
+
+int main()
+{
+  test_pr118035();
+}


[gcc r12-11056] libstdc++: Fix infinite loop in std::istream::ignore(n, delim) [PR93672]

2025-04-17 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:d143630ff7242ebaf9667667ecc1deb6bb678023

commit r12-11056-gd143630ff7242ebaf9667667ecc1deb6bb678023
Author: Jonathan Wakely 
Date:   Thu Apr 4 10:33:33 2024 +0100

libstdc++: Fix infinite loop in std::istream::ignore(n, delim) [PR93672]

A negative delim value passed to std::istream::ignore can never match
any character in the stream, because the comparison is done using
traits_type::eq_int_type(sb->sgetc(), delim) and sgetc() never returns
negative values (except at EOF). The optimized version of ignore for the
std::istream specialization uses traits_type::find to locate the delim
character in the streambuf, which _can_ match a negative delim on
platforms where char is signed, but then we do another comparison using
eq_int_type which fails. The code then keeps looping forever, with
traits_type::find locating the character and traits_type::eq_int_type
saying it's not a match, so traits_type::find is used again and finds
the same character again.

A possible fix would be to check with eq_int_type after a successful
find, to see whether we really have a match. However, that would be
suboptimal since we know that a negative delimiter will never match
using eq_int_type. So a better fix is to adjust the check at the top of
the function that handles delim==eof(), so that we treat all negative
delim values as equivalent to EOF. That way we don't bother using find
to search for something that will never match with eq_int_type.

The version of ignore in the primary template doesn't need a change,
because it doesn't use traits_type::find, instead characters are
extracted one-by-one and always matched using eq_int_type. That avoids
the inconsistency between find and eq_int_type. The specialization for
std::wistream does use traits_type::find, but traits_type::to_int_type
is equivalent to an implicit conversion from wchar_t to wint_t, so
passing a wchar_t directly to ignore without using to_int_type works.

libstdc++-v3/ChangeLog:

PR libstdc++/93672
* src/c++98/istream.cc (istream::ignore(streamsize, int_type)):
Treat all negative delimiter values as eof().
* testsuite/27_io/basic_istream/ignore/char/93672.cc: New test.
* testsuite/27_io/basic_istream/ignore/wchar_t/93672.cc: New
test.

(cherry picked from commit 2d694414ada8e3b58f504c1b175d31088529632e)

Diff:
---
 libstdc++-v3/src/c++98/istream.cc  |  13 ++-
 .../27_io/basic_istream/ignore/char/93672.cc   | 101 +
 .../27_io/basic_istream/ignore/wchar_t/93672.cc|  34 +++
 3 files changed, 146 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++98/istream.cc 
b/libstdc++-v3/src/c++98/istream.cc
index 4d1e34fee846..33a511e58a46 100644
--- a/libstdc++-v3/src/c++98/istream.cc
+++ b/libstdc++-v3/src/c++98/istream.cc
@@ -112,8 +112,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 basic_istream::
 ignore(streamsize __n, int_type __delim)
 {
-  if (traits_type::eq_int_type(__delim, traits_type::eof()))
-   return ignore(__n);
+  {
+   // If conversion to int_type changes the value then __delim does not
+   // correspond to a value of type char_type, and so will never match
+   // a character extracted from the input sequence. Just use ignore(n).
+   const int_type chk_delim = traits_type::to_int_type(__delim);
+   const bool matchable = traits_type::eq_int_type(chk_delim, __delim);
+   if (__builtin_expect(!matchable, 0))
+ return ignore(__n);
+   // Now we know that __delim is a valid char_type value, so it's safe
+   // for the code below to use traits_type::find to search for it.
+  }
 
   _M_gcount = 0;
   sentry __cerb(*this, true);
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/93672.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/93672.cc
new file mode 100644
index ..96737485b83d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/93672.cc
@@ -0,0 +1,101 @@
+// { dg-do run }
+
+#include 
+#include 
+#include 
+
+void
+test_pr93672() // std::basic_istream::ignore hangs if delim MSB is set
+{
+  std::istringstream in(".\xfc..\xfd...\xfe.");
+
+  // This should find '\xfd' even on platforms where char is signed,
+  // because the delimiter is correctly converted to the stream's int_type.
+  in.ignore(100, std::char_traits::to_int_type('\xfc'));
+  VERIFY( in.gcount() == 2 );
+  VERIFY( ! in.eof() );
+
+  // This should work equivalently to traits_type::to_int_type
+  in.ignore(100, (unsigned char)'\xfd');
+  VERIFY( in.gcount() == 3 );
+  VERIFY( ! in.eof() );
+
+  // This only works if char is unsigned.
+  in.ignore(100, '\xfe');
+  if (std::numeric_limits::is_signed)
+  {
+// When char is signed, '\xfe' != traits_type::to_int_type('\xfe')
+/

[gcc r12-11057] libstdc++: Qualify calls to debug mode helpers

2025-04-17 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:2ea39e7b58376b2fb57cd74098a374604b627266

commit r12-11057-g2ea39e7b58376b2fb57cd74098a374604b627266
Author: Jonathan Wakely 
Date:   Fri Jun 23 13:50:01 2023 +0100

libstdc++: Qualify calls to debug mode helpers

These functions should be qualified to disable unwanted ADL.

The overload of __check_singular_aux for safe iterators was previously
being found by ADL, because it wasn't declared before __check_singular.
Add a declaration so that it can be found by qualified lookup.

libstdc++-v3/ChangeLog:

* include/debug/helper_functions.h (__get_distance)
(__check_singular, __valid_range_aux, __valid_range): Qualify
calls to disable ADL.
(__check_singular_aux(const _Safe_iterator_base*)): Declare
overload that was previously found via ADL.

(cherry picked from commit fa98bc4270dcb4ec78b5b1c0f4c067094c84bae6)

Diff:
---
 libstdc++-v3/include/debug/helper_functions.h | 32 ++-
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libstdc++-v3/include/debug/helper_functions.h 
b/libstdc++-v3/include/debug/helper_functions.h
index d28e4b51bb9f..a641fc2eaa00 100644
--- a/libstdc++-v3/include/debug/helper_functions.h
+++ b/libstdc++-v3/include/debug/helper_functions.h
@@ -111,12 +111,19 @@ namespace __gnu_debug
 _GLIBCXX_CONSTEXPR
 inline typename _Distance_traits<_Iterator>::__type
 __get_distance(_Iterator __lhs, _Iterator __rhs)
-{ return __get_distance(__lhs, __rhs, std::__iterator_category(__lhs)); }
+{
+  return __gnu_debug::__get_distance(__lhs, __rhs,
+std::__iterator_category(__lhs));
+}
 
   // An arbitrary iterator pointer is not singular.
   inline bool
   __check_singular_aux(const void*) { return false; }
 
+  // Defined in 
+  bool
+  __check_singular_aux(const class _Safe_iterator_base*);
+
   // We may have an iterator that derives from _Safe_iterator_base but isn't
   // a _Safe_iterator.
   template
@@ -125,7 +132,7 @@ namespace __gnu_debug
 __check_singular(_Iterator const& __x)
 {
   return ! std::__is_constant_evaluated()
-  && __check_singular_aux(std::__addressof(__x));
+  && __gnu_debug::__check_singular_aux(std::__addressof(__x));
 }
 
   /** Non-NULL pointers are nonsingular. */
@@ -163,7 +170,8 @@ namespace __gnu_debug
  std::input_iterator_tag)
 {
   return __first == __last
-   || (!__check_singular(__first) && !__check_singular(__last));
+   || (!__gnu_debug::__check_singular(__first)
+ && !__gnu_debug::__check_singular(__last));
 }
 
   template
@@ -172,8 +180,8 @@ namespace __gnu_debug
 __valid_range_aux(_InputIterator __first, _InputIterator __last,
  std::random_access_iterator_tag)
 {
-  return
-   __valid_range_aux(__first, __last, std::input_iterator_tag())
+  return __gnu_debug::__valid_range_aux(__first, __last,
+   std::input_iterator_tag())
&& __first <= __last;
 }
 
@@ -186,8 +194,8 @@ namespace __gnu_debug
 __valid_range_aux(_InputIterator __first, _InputIterator __last,
  std::__false_type)
 {
-  return __valid_range_aux(__first, __last,
-  std::__iterator_category(__first));
+  return __gnu_debug::__valid_range_aux(__first, __last,
+   std::__iterator_category(__first));
 }
 
   template
@@ -197,10 +205,11 @@ namespace __gnu_debug
  typename _Distance_traits<_InputIterator>::__type& __dist,
  std::__false_type)
 {
-  if (!__valid_range_aux(__first, __last, std::input_iterator_tag()))
+  if (!__gnu_debug::__valid_range_aux(__first, __last,
+ std::input_iterator_tag()))
return false;
 
-  __dist = __get_distance(__first, __last);
+  __dist = __gnu_debug::__get_distance(__first, __last);
   switch (__dist.second)
{
case __dp_none:
@@ -231,7 +240,8 @@ namespace __gnu_debug
  typename _Distance_traits<_InputIterator>::__type& __dist)
 {
   typedef typename std::__is_integer<_InputIterator>::__type _Integral;
-  return __valid_range_aux(__first, __last, __dist, _Integral());
+  return __gnu_debug::__valid_range_aux(__first, __last, __dist,
+   _Integral());
 }
 
   template
@@ -254,7 +264,7 @@ namespace __gnu_debug
 __valid_range(_InputIterator __first, _InputIterator __last)
 {
   typedef typename std::__is_integer<_InputIterator>::__type _Integral;
-  return __valid_range_aux(__first, __last, _Integral());
+  return __gnu_debug::__valid_range_aux(__first, __last, _Integral());
 }
 
   template


[gcc r15-9547] libstdc++: Remove dead code in range_formatter::format [PR109162]

2025-04-17 Thread Tomasz Kaminski via Gcc-cvs
https://gcc.gnu.org/g:843b273c6851b71407b116584982b0389be4d6fd

commit r15-9547-g843b273c6851b71407b116584982b0389be4d6fd
Author: Tomasz Kamiński 
Date:   Wed Apr 16 15:28:46 2025 +0200

libstdc++: Remove dead code in range_formatter::format [PR109162]

Because the _M_format(__rg, __fc) were placed outside of if constexpr,
these method and its children  where instantiated, even if
_M_format could be used.

To simplify the if constexpr chain, we introduce a 
__simply_formattable_range
(name based on simple-view) exposition only concept, that checks if range is
const and mutable formattable and uses same formatter specialization for
references in each case.

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/std/format (__format::__simply_formattable_range): Define.
(range_formatter::format): Do not instantiate _M_format for mutable
_Rg if const _Rg can be used.

Reviewed-by: Jonathan Wakely 
Signed-off-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/include/std/format | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 27253f50ea8d..2668382c7edb 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -5252,6 +5252,14 @@ namespace __format
   = ranges::input_range
  && formattable, _CharT>;
 
+  // _Rg& and const _Rg& are both formattable and use same formatter
+  // specialization for their references.
+  template
+concept __simply_formattable_range
+  = __const_formattable_range<_Rg, _CharT>
+ && same_as>,
+remove_cvref_t>>;
+
   template
 using __maybe_const_range
   = __conditional_t<__const_formattable_range<_Rg, _CharT>, const _Rg, 
_Rg>;
@@ -5635,13 +5643,10 @@ namespace __format
format(_Rg&& __rg, basic_format_context<_Out, _CharT>& __fc) const
{
  using _Range = remove_reference_t<_Rg>;
- if constexpr (__format::__const_formattable_range<_Range, _CharT>)
- {
-   using _CRef = ranges::range_reference_t;
-   if constexpr (same_as, _Tp>)
- return _M_format(__rg, __fc);
- }
- return _M_format(__rg, __fc);
+ if constexpr (__format::__simply_formattable_range<_Range, _CharT>)
+   return _M_format(__rg, __fc);
+ else
+   return _M_format(__rg, __fc);
}
 
 private:


[gcc r15-9548] s390: Use match_scratch instead of scratch in define_split [PR119834]

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:22fe83d6fc9f59311241c981bcad58b61e2056d4

commit r15-9548-g22fe83d6fc9f59311241c981bcad58b61e2056d4
Author: Jakub Jelinek 
Date:   Thu Apr 17 10:57:18 2025 +0200

s390: Use match_scratch instead of scratch in define_split [PR119834]

The following testcase ICEs since r15-1579 (addition of late combiner),
because *clrmem_short can't be split.
The problem is that the define_insn uses
   (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
   (use (match_operand 2 "immediate_operand" "X,R,X,X"))
   (clobber (match_scratch:P 3 "=X,X,X,&a"))
and define_split assumed that if operands[1] is const_int_operand,
match_scratch will be always scratch, and it will be reg only if
it was the last alternative where operands[1] is a reg.
The pattern doesn't guarantee it though, of course RA will not try to
uselessly assign a reg there if it is not needed, but during RA
on the testcase below we match the last alternative, but then comes
late combiner and propagates const_int 3 into operands[1].  And that
matches fine, match_scratch matches either scratch or reg and the constraint
in that case is X for the first variant, so still just fine.  But we won't
split that because the splitters only expect scratch.

The following patch fixes it by using match_scratch instead of scratch,
so that it accepts either.

2025-04-17  Jakub Jelinek  

PR target/119834
* config/s390/s390.md (define_split after *cpymem_short): Use
(clobber (match_scratch N)) instead of (clobber (scratch)).  Use
(match_dup 4) and operands[4] instead of (match_dup 3) and 
operands[3]
in the last of those.
(define_split after *clrmem_short): Use (clobber (match_scratch N))
instead of (clobber (scratch)).
(define_split after *cmpmem_short): Likewise.

* g++.target/s390/pr119834.C: New test.

Diff:
---
 gcc/config/s390/s390.md  | 22 -
 gcc/testsuite/g++.target/s390/pr119834.C | 76 
 2 files changed, 87 insertions(+), 11 deletions(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 874974a54563..05b9da6976ac 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -3597,7 +3597,7 @@
 (match_operand:BLK 1 "memory_operand" ""))
(use (match_operand 2 "const_int_operand" ""))
(use (match_operand 3 "immediate_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
 [(set (match_dup 0) (match_dup 1))
@@ -3609,7 +3609,7 @@
 (match_operand:BLK 1 "memory_operand" ""))
(use (match_operand 2 "register_operand" ""))
(use (match_operand 3 "memory_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
 [(unspec [(match_dup 2) (match_dup 3)
@@ -3623,14 +3623,14 @@
 (match_operand:BLK 1 "memory_operand" ""))
(use (match_operand 2 "register_operand" ""))
(use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
-   (clobber (scratch))]
+   (clobber (match_scratch 3))]
   "TARGET_Z10 && reload_completed"
   [(parallel
 [(unspec [(match_dup 2) (const_int 0)
-  (label_ref (match_dup 3))] UNSPEC_EXECUTE)
+ (label_ref (match_dup 4))] UNSPEC_EXECUTE)
  (set (match_dup 0) (match_dup 1))
  (use (const_int 1))])]
-  "operands[3] = gen_label_rtx ();")
+  "operands[4] = gen_label_rtx ();")
 
 (define_split
   [(set (match_operand:BLK 0 "memory_operand" "")
@@ -3852,7 +3852,7 @@
 (const_int 0))
(use (match_operand 1 "const_int_operand" ""))
(use (match_operand 2 "immediate_operand" ""))
-   (clobber (scratch))
+   (clobber (match_scratch 3))
(clobber (reg:CC CC_REGNUM))]
   "reload_completed"
   [(parallel
@@ -3866,7 +3866,7 @@
 (const_int 0))
(use (match_operand 1 "register_operand" ""))
(use (match_operand 2 "memory_operand" ""))
-   (clobber (scratch))
+   (clobber (match_scratch 3))
(clobber (reg:CC CC_REGNUM))]
   "reload_completed"
   [(parallel
@@ -3882,7 +3882,7 @@
 (const_int 0))
(use (match_operand 1 "register_operand" ""))
(use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
-   (clobber (scratch))
+   (clobber (match_scratch 2))
(clobber (reg:CC CC_REGNUM))]
   "TARGET_Z10 && reload_completed"
   [(parallel
@@ -4047,7 +4047,7 @@
  (match_operand:BLK 1 "memory_operand" "")))
(use (match_operand 2 "const_int_operand" ""))
(use (match_operand 3 "immediate_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
@@ -4060,7 +4060,7 @@
  (match_operand:BLK 1 "memory_operand" "")))
(use (match_operand 2 "register_operand" ""))
(use (match

[gcc r15-9546] nvptx: Remove 'TARGET_ASM_NEED_VAR_DECL_BEFORE_USE'

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:55620672d77812bb6f1ac8835f0c949680d9c7d0

commit r15-9546-g55620672d77812bb6f1ac8835f0c949680d9c7d0
Author: Thomas Schwinge 
Date:   Mon Feb 24 19:06:28 2025 +0100

nvptx: Remove 'TARGET_ASM_NEED_VAR_DECL_BEFORE_USE'

Unused; remnant of an (internal) experiment, before we had nvptx 'as'.

gcc/
* config/nvptx/nvptx.cc (TARGET_ASM_NEED_VAR_DECL_BEFORE_USE):
Don't '#define'.

Diff:
---
 gcc/config/nvptx/nvptx.cc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index d1e25b99701c..f8939715dee2 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -7905,8 +7905,6 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name,
 #define TARGET_ASM_DECLARE_CONSTANT_NAME nvptx_asm_declare_constant_name
 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P hook_bool_mode_const_rtx_true
-#undef TARGET_ASM_NEED_VAR_DECL_BEFORE_USE
-#define TARGET_ASM_NEED_VAR_DECL_BEFORE_USE true
 
 #undef TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG nvptx_reorg


[gcc r15-9549] libstdc++: Do not use 'not' alternative token in

2025-04-17 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:0be3dff1aadcc3e879f3d1ffd45d842ab0e0c0bf

commit r15-9549-g0be3dff1aadcc3e879f3d1ffd45d842ab0e0c0bf
Author: Jonathan Wakely 
Date:   Wed Apr 16 11:44:46 2025 +0100

libstdc++: Do not use 'not' alternative token in 

This fixes:
FAIL: 17_intro/headers/c++1998/operator_names.cc  -std=gnu++23 (test for 
excess errors)
FAIL: 17_intro/headers/c++1998/operator_names.cc  -std=gnu++26 (test for 
excess errors)

The purpose of 'not defined>' is to be ill-formed (as
required by [format.range.fmtkind]) and to give an error that includes
the string "not defined>". That was intended to tell you
that format_kind is not defined, just like it says!

But user code can use -fno-operator-names so we can't use 'not' here,
and "! defined" in the diagnostic doesn't seem as user-friendly. It also
raises questions about whether it was intended to be the preprocessor
token 'defined' (it's not) or where 'defined' is defined (it's not).

Replace it with __primary_template_not_defined> and a
comment, which seems to give a fairly clear diagnostic with both GCC and
Clang. The diagnostic now looks like:

.../include/c++/15.0.1/format:5165:7: error: use of 'std::format_kind' 
before deduction of 'auto'
 5165 |   format_kind<_Rg> // you can specialize this for non-const 
input ranges
  |   ^~~~
.../include/c++/15.0.1/format:5164:35: error: 
'__primary_template_not_defined' was not declared in this scope
 5164 | __primary_template_not_defined(
  | ~~^
 5165 |   format_kind<_Rg> // you can specialize this for non-const 
input ranges
  |   
~~
 5166 | );
  | ~

libstdc++-v3/ChangeLog:

* include/std/format (format_kind): Do not use 'not'
alternative token to make the primary template ill-formed. Use
the undeclared identifier __primary_template_not_defined and a
comment that will appear in diagnostics.
* testsuite/std/format/ranges/format_kind_neg.cc: New test.

Diff:
---
 libstdc++-v3/include/std/format |  5 -
 libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc | 13 +
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 2668382c7edb..f3fd837897bd 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -5160,7 +5160,10 @@ namespace __format
 
   /// @cond undocumented
   template
-constexpr auto format_kind = not defined(format_kind<_Rg>);
+constexpr auto format_kind =
+__primary_template_not_defined(
+  format_kind<_Rg> // you can specialize this for non-const input ranges
+);
 
   template
 consteval range_format
diff --git a/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc 
b/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc
new file mode 100644
index ..bf8619d3d276
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++23 } }
+
+// C++23 22.14.7.1 [format.range.fmtkind] p1: A program that instantiates
+// the primary template of format_kind is ill-formed.
+
+#include 
+
+template struct Tester { };
+
+Tester> t; // { dg-error "here" }
+
+// { dg-error "use of 'std::format_kind" "" { target *-*-* } 0 }
+// { dg-error "primary_template_not_defined" "" { target *-*-* } 0 }


[gcc r14-11649] libstdc++: Correct preprocessing checks for floatX_t and bfloat_16 formatting

2025-04-17 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:a295863e953c772a0ae91a11f652d1f641d3a3dc

commit r14-11649-ga295863e953c772a0ae91a11f652d1f641d3a3dc
Author: Tomasz Kamiński 
Date:   Tue Mar 11 11:59:36 2025 +0100

libstdc++: Correct preprocessing checks for floatX_t and bfloat_16 
formatting

Floating points types _Float16, _Float32, _Float64, and bfloat16,
can be formatted only if std::to_chars overloads for such types
were provided. Currently this is only the case for architectures
where float and double are 32-bits and 64-bits IEEE floating points types.

This patch updates the preprocessing checks for formatters
for above types to check _GLIBCXX_FLOAT_IS_IEEE_BINARY32
and _GLIBCXX_DOUBLE_IS_IEEE_BINARY64. Making them non-formattable
on non-IEEE architectures.

Remove a potential UB, where we could produce basic_format_arg
with _M_type set to _Arg_fp32 or _Arg_fp64, that was later not
handled by `_M_visit`.

libstdc++-v3/ChangeLog:

* include/std/format (formatter<_Float16, _CharT>): Define only if
_GLIBCXX_FLOAT_IS_IEEE_BINARY32 macro is defined.
(formatter<_Float16, _CharT>): As above.
(formatter<__gnu_cxx::__bfloat16_t, _CharT>): As above.
(formatter<_Float64, _CharT>): Define only if
_GLIBCXX_DOUBLE_IS_IEEE_BINARY64 is defined.
(basic_format_arg::_S_to_arg_type): Normalize _Float32 and _Float64
only to float and double respectivelly.
(basic_format_arg::_S_to_enum): Remove handling of _Float32 and 
_Float64.

Reviewed-by: Jonathan Wakely 
Signed-off-by: Tomasz Kamiński 
(cherry picked from commit 445128c12cf22081223f7385196ee3889ef4c4b2)

Diff:
---
 libstdc++-v3/include/std/format | 32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index b8830766f40f..604f4cde3c47 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -2208,7 +2208,7 @@ namespace __format
 };
 #endif
 
-#ifdef __STDCPP_FLOAT16_T__
+#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
   // Reuse __formatter_fp::format for _Float16.
   template<__format::__char _CharT>
 struct formatter<_Float16, _CharT>
@@ -2230,7 +2230,7 @@ namespace __format
 };
 #endif
 
-#if defined(__FLT32_DIG__)
+#if defined(__FLT32_DIG__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
   // Reuse __formatter_fp::format for _Float32.
   template<__format::__char _CharT>
 struct formatter<_Float32, _CharT>
@@ -2252,7 +2252,7 @@ namespace __format
 };
 #endif
 
-#if defined(__FLT64_DIG__)
+#if defined(__FLT64_DIG__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
   // Reuse __formatter_fp::format for _Float64.
   template<__format::__char _CharT>
 struct formatter<_Float64, _CharT>
@@ -2296,7 +2296,7 @@ namespace __format
 };
 #endif
 
-#ifdef __STDCPP_BFLOAT16_T__
+#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
   // Reuse __formatter_fp::format for bfloat16_t.
   template<__format::__char _CharT>
 struct formatter<__gnu_cxx::__bfloat16_t, _CharT>
@@ -3367,22 +3367,16 @@ namespace __format
return type_identity();
 #endif
 
-#ifdef __FLT32_DIG__
+#if defined(__FLT32_DIG__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  else if constexpr (is_same_v<_Td, _Float32>)
-# ifdef _GLIBCXX_FLOAT_IS_IEEE_BINARY32
return type_identity();
-# else
-   return type_identity<_Float32>();
-# endif
 #endif
-#ifdef __FLT64_DIG__
+
+#if defined(__FLT64_DIG__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
  else if constexpr (is_same_v<_Td, _Float64>)
-# ifdef _GLIBCXX_DOUBLE_IS_IEEE_BINARY64
return type_identity();
-# else
-   return type_identity<_Float64>();
-# endif
 #endif
+
 #if _GLIBCXX_FORMAT_F128
 # if __FLT128_DIG__
  else if constexpr (is_same_v<_Td, _Float128>)
@@ -3462,16 +3456,6 @@ namespace __format
return _Arg_u128;
 #endif
 
- // N.B. some of these types will never actually be used here,
- // because they get normalized to a standard floating-point type.
-#if defined __FLT32_DIG__ && ! _GLIBCXX_FLOAT_IS_IEEE_BINARY32
- else if constexpr (is_same_v<_Tp, _Float32>)
-   return _Arg_f32;
-#endif
-#if defined __FLT64_DIG__ && ! _GLIBCXX_DOUBLE_IS_IEEE_BINARY64
- else if constexpr (is_same_v<_Tp, _Float64>)
-   return _Arg_f64;
-#endif
 #if _GLIBCXX_FORMAT_F128 == 2
  else if constexpr (is_same_v<_Tp, __format::__float128_t>)
return _Arg_f128;


[gcc r16-1] Update crontab and git_update_version.py

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:6027ba0c05efc8be80110424292a07fddf7f071f

commit r16-1-g6027ba0c05efc8be80110424292a07fddf7f071f
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:50:35 2025 +0200

Update crontab and git_update_version.py

2025-04-17  Jakub Jelinek  

maintainer-scripts/
* crontab: Snapshots from trunk are now GCC 16 related.
Add GCC 15 snapshots from the respective branch.
contrib/
* gcc-changelog/git_update_version.py (active_refs): Add
releases/gcc-15.

Diff:
---
 contrib/gcc-changelog/git_update_version.py | 4 ++--
 maintainer-scripts/crontab  | 9 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/contrib/gcc-changelog/git_update_version.py 
b/contrib/gcc-changelog/git_update_version.py
index 8e36c7458367..aa9adee58fef 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -85,8 +85,8 @@ def prepend_to_changelog_files(repo, folder, git_commit, 
add_to_git):
 repo.git.add(full_path)
 
 
-active_refs = ['master',
-   'releases/gcc-12', 'releases/gcc-13', 'releases/gcc-14']
+active_refs = ['master', 'releases/gcc-12',
+   'releases/gcc-13', 'releases/gcc-14', 'releases/gcc-15']
 
 parser = argparse.ArgumentParser(description='Update DATESTAMP and generate '
  'ChangeLog entries')
diff --git a/maintainer-scripts/crontab b/maintainer-scripts/crontab
index 7bb73625bd88..c880d7d80954 100644
--- a/maintainer-scripts/crontab
+++ b/maintainer-scripts/crontab
@@ -1,7 +1,8 @@
 16  0 * * * sh /home/gccadmin/scripts/update_version_git
 50  0 * * * sh /home/gccadmin/scripts/update_web_docs_git
 55  0 * * * sh /home/gccadmin/scripts/update_web_docs_libstdcxx_git
-32 22 * * 4 sh /home/gccadmin/scripts/gcc_release -s 12:releases/gcc-12 -l -d 
/sourceware/snapshot-tmp/gcc all
-32 22 * * 5 sh /home/gccadmin/scripts/gcc_release -s 13:releases/gcc-13 -l -d 
/sourceware/snapshot-tmp/gcc all
-32 22 * * 6 sh /home/gccadmin/scripts/gcc_release -s 14:releases/gcc-14 -l -d 
/sourceware/snapshot-tmp/gcc all
-32 22 * * 7 sh /home/gccadmin/scripts/gcc_release -s 15:master -l -d 
/sourceware/snapshot-tmp/gcc all
+32 22 * * 3 sh /home/gccadmin/scripts/gcc_release -s 12:releases/gcc-12 -l -d 
/sourceware/snapshot-tmp/gcc all
+32 22 * * 4 sh /home/gccadmin/scripts/gcc_release -s 13:releases/gcc-13 -l -d 
/sourceware/snapshot-tmp/gcc all
+32 22 * * 5 sh /home/gccadmin/scripts/gcc_release -s 14:releases/gcc-14 -l -d 
/sourceware/snapshot-tmp/gcc all
+32 22 * * 6 sh /home/gccadmin/scripts/gcc_release -s 15:releases/gcc-15 -l -d 
/sourceware/snapshot-tmp/gcc all
+32 22 * * 7 sh /home/gccadmin/scripts/gcc_release -s 16:master -l -d 
/sourceware/snapshot-tmp/gcc all


[gcc r16-2] ada: bump Library_Version to 16.

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:c237297ee596545552f48ec9582d7d16703d8949

commit r16-2-gc237297ee596545552f48ec9582d7d16703d8949
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:51:46 2025 +0200

ada: bump Library_Version to 16.

gcc/ada/ChangeLog:

* gnatvsn.ads: Bump Library_Version to 16.

Diff:
---
 gcc/ada/gnatvsn.ads | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/gnatvsn.ads b/gcc/ada/gnatvsn.ads
index 176f88a84b80..ad11c30aa039 100644
--- a/gcc/ada/gnatvsn.ads
+++ b/gcc/ada/gnatvsn.ads
@@ -32,7 +32,7 @@ package Gnatvsn is
--  Static string identifying this version, that can be used as an argument
--  to e.g. pragma Ident.
 
-   Library_Version : constant String := "15";
+   Library_Version : constant String := "16";
--  Library version. It needs to be updated whenever the major version
--  number is changed.
--


[gcc r1] Bump BASE-VER.

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:7eac294e087165e2f2bceee4d8ea11c70667cb7b

commit r16
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:40:07 2025 +0200

Bump BASE-VER.

2025-04-17  Jakub Jelinek  

* BASE-VER: Set to 16.0.0.

Diff:
---
 gcc/BASE-VER | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index 2bbd2b4b42ff..946789e6195a 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-15.0.1
+16.0.0


[gcc] Created branch 'releases/gcc-15'

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
The branch 'releases/gcc-15' was created pointing to:

 5d05d496b2b4... libgomp: Don't test ompx::allocator::gnu_pinned_mem on non-


[gcc/basepoints/gcc-16] Bump BASE-VER.

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:7eac294e087165e2f2bceee4d8ea11c70667cb7b

commit 7eac294e087165e2f2bceee4d8ea11c70667cb7b
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:40:07 2025 +0200

Bump BASE-VER.

2025-04-17  Jakub Jelinek  

* BASE-VER: Set to 16.0.0.

Diff:
---
 gcc/BASE-VER | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index 2bbd2b4b42ff..946789e6195a 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-15.0.1
+16.0.0


[gcc r15-9552] libgomp: Don't test ompx::allocator::gnu_pinned_mem on non-linux targets.

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:5d05d496b2b4a3d4674b2e5a46d3a355abf4055d

commit r15-9552-g5d05d496b2b4a3d4674b2e5a46d3a355abf4055d
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:14:15 2025 +0200

libgomp: Don't test ompx::allocator::gnu_pinned_mem on non-linux targets.

The libgomp.c/alloc-pinned*.c test have
/* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } 
} */
so they are only run on Linux targets right now.  Duplicating the tests or
reworking them into headers looked like too much work for me right now this
late in stage4, so I've just #ifdefed the uses at least for now.

2025-04-17  Jakub Jelinek  

PR libgomp/119849
* testsuite/libgomp.c++/allocator-1.C (test_inequality, main): Guard
ompx::allocator::gnu_pinned_mem uses with #ifdef __gnu_linux__.
* testsuite/libgomp.c++/allocator-2.C (main): Likewise.

Diff:
---
 libgomp/testsuite/libgomp.c++/allocator-1.C | 13 +
 libgomp/testsuite/libgomp.c++/allocator-2.C |  9 +
 2 files changed, 22 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c++/allocator-1.C 
b/libgomp/testsuite/libgomp.c++/allocator-1.C
index f82072284883..49425386b33f 100644
--- a/libgomp/testsuite/libgomp.c++/allocator-1.C
+++ b/libgomp/testsuite/libgomp.c++/allocator-1.C
@@ -78,7 +78,10 @@ void test_inequality ()
   CHECK_INEQUALITY (omp::allocator::cgroup_mem, void);
   CHECK_INEQUALITY (omp::allocator::pteam_mem, void);
   CHECK_INEQUALITY (omp::allocator::thread_mem, void);
+#ifdef __gnu_linux__
+  /* Pinning not implemented on other targets.  */
   CHECK_INEQUALITY (ompx::allocator::gnu_pinned_mem, void);
+#endif
   /* And again with the same type passed to the allocator.  */
   CHECK_INEQUALITY (omp::allocator::null_allocator, T);
   CHECK_INEQUALITY (omp::allocator::default_mem, T);
@@ -89,7 +92,9 @@ void test_inequality ()
   CHECK_INEQUALITY (omp::allocator::cgroup_mem, T);
   CHECK_INEQUALITY (omp::allocator::pteam_mem, T);
   CHECK_INEQUALITY (omp::allocator::thread_mem, T);
+#ifdef __gnu_linux__
   CHECK_INEQUALITY (ompx::allocator::gnu_pinned_mem, T);
+#endif
 }
 
 #undef CHECK_INEQUALITY
@@ -121,7 +126,9 @@ int main ()
   test(42);
   test(42);
   test(42);
+#ifdef __gnu_linux__
   test(42);
+#endif
 
   test(42);
   test(42);
@@ -132,7 +139,9 @@ int main ()
   test(42);
   test(42);
   test(42);
+#ifdef __gnu_linux__
   test(42);
+#endif
 
   test( S{42, true, 128.f});
   test(S{42, true, 128.f});
@@ -143,7 +152,9 @@ int main ()
   test( S{42, true, 128.f});
   test(  S{42, true, 128.f});
   test( S{42, true, 128.f});
+#ifdef __gnu_linux__
   test(S{42, true, 128.f});
+#endif
 
   test_inequality();
   test_inequality();
@@ -154,5 +165,7 @@ int main ()
   test_inequality();
   test_inequality();
   test_inequality();
+#ifdef __gnu_linux__
   test_inequality();
+#endif
 }
diff --git a/libgomp/testsuite/libgomp.c++/allocator-2.C 
b/libgomp/testsuite/libgomp.c++/allocator-2.C
index d25b75501a99..ca94fc7e376e 100644
--- a/libgomp/testsuite/libgomp.c++/allocator-2.C
+++ b/libgomp/testsuite/libgomp.c++/allocator-2.C
@@ -86,7 +86,10 @@ int main ()
   f(0, 1, 2, 3);
   f(0, 1, 2, 3);
   f(0, 1, 2, 3);
+#ifdef __gnu_linux__
+  /* Pinning not implemented on other targets.  */
   f(0, 1, 2, 3);
+#endif
 
   f(0, 1, 2, 3);
   f(0, 1, 2, 3);
@@ -97,7 +100,9 @@ int main ()
   f(0, 1, 2, 3);
   f(0, 1, 2, 3);
   f(0, 1, 2, 3);
+#ifdef __gnu_linux__
   f(0, 1, 2, 3);
+#endif
 
   S0 s0_0{   42, true,  28.f};
   S0 s0_1{  142, false,  11128.f};
@@ -112,7 +117,9 @@ int main ()
   f(s0_0, s0_1, s0_2, s0_3);
   f(s0_0, s0_1, s0_2, s0_3);
   f(s0_0, s0_1, s0_2, s0_3);
+#ifdef __gnu_linux__
   f(s0_0, s0_1, s0_2, s0_3);
+#endif
 
   S1 s1_0{   42, true,  28.f};
   S1 s1_1{  142, false,  11128.f};
@@ -128,5 +135,7 @@ int main ()
   f(s1_0, s1_1, s1_2, s1_3);
   f(s1_0, s1_1, s1_2, s1_3);
   f(s1_0, s1_1, s1_2, s1_3);
+#ifdef __gnu_linux__
   f(s1_0, s1_1, s1_2, s1_3);
+#endif
 }


[gcc/devel/omp/gcc-14] Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target'

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a91765a14cc0eb52978c5db1ab450053ef7f365a

commit a91765a14cc0eb52978c5db1ab450053ef7f365a
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and 
OpenACC, OpenMP 'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-2.C: New.
* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: 
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: 
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: 
Likewise.

(cherry picked from commit 00cde164eeb834958ae8f9eec0c7c9cc3ac697a1)

Diff:
---
 gcc/testsuite/ChangeLog.omp|  6 +++
 .../g++.target/gcn/exceptions-bad_cast-2.C | 12 ++
 .../g++.target/nvptx/exceptions-bad_cast-2.C   | 12 ++
 libgomp/ChangeLog.omp  | 10 +
 ...arget-exceptions-bad_cast-2-offload-sorry-GCN.C | 18 
 ...get-exceptions-bad_cast-2-offload-sorry-nvptx.C | 18 
 .../libgomp.c++/target-exceptions-bad_cast-2.C | 14 +++
 .../exceptions-bad_cast-2-offload-sorry-GCN.C  | 17 
 .../exceptions-bad_cast-2-offload-sorry-nvptx.C| 19 +
 .../libgomp.oacc-c++/exceptions-bad_cast-2.C   | 48 ++
 10 files changed, 174 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 574ec55f9c85..2305ff63e3a9 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * g++.target/gcn/exceptions-bad_cast-2.C: New.
+   * g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
+
+   Backported from trunk:
+   2025-04-14  Thomas Schwinge  
+
* g++.target/gcn/exceptions-bad_cast-1.C: New.
* g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
 
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C 
b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C
new file mode 100644
index ..ffe9e19a281e
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C
@@ -0,0 +1,12 @@
+/* 'std::bad_cast' exception, caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C
new file mode 100644
index ..ffe9e19a281e
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C
@@ -0,0 +1,12 @@
+/* 'std::bad_cast' exception, caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 4c81b3107402..9bb73ff1195b 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,16 @@
Backported from trunk:
2025-04-14  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New.
+   * 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: 
Likewise.
+   * 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: 
Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: 
Likewi

[gcc/devel/omp/gcc-14] Remove 'ALWAYS_INLINE' workaround in 'libgomp.c++/target-exceptions-pr118794-1.C'

2025-04-17 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:c3f4dedfdadfe9b85a50ebd493428e72f111ac80

commit c3f4dedfdadfe9b85a50ebd493428e72f111ac80
Author: Thomas Schwinge 
Date:   Wed Apr 16 16:52:08 2025 +0200

Remove 'ALWAYS_INLINE' workaround in 
'libgomp.c++/target-exceptions-pr118794-1.C'

With commit ca9cffe737d20953082333dacebb65d4261e0d0c
"For nvptx offloading, make sure to emit C++ constructor, destructor 
aliases [PR97106]",
we're able to remove the 'ALWAYS_INLINE' workaround added in
commit fe283dba774be57b705a7a871b000d2894d2e553
"GCN, nvptx: Support '-mfake-exceptions', and use it for offloading 
compilation [PR118794]".

libgomp/
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Remove
'ALWAYS_INLINE' workaround.

(cherry picked from commit 518efed8cb7d003cd85477060b1fe926a2d7a53b)

Diff:
---
 libgomp/ChangeLog.omp| 6 ++
 libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C | 6 --
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 0c3741fd0031..44cc3227bbda 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,12 @@
Backported from trunk:
2025-04-16  Thomas Schwinge  
 
+   * testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Remove
+   'ALWAYS_INLINE' workaround.
+
+   Backported from trunk:
+   2025-04-16  Thomas Schwinge  
+
PR target/106445
* testsuite/libgomp.c++/pr106445-1.C: New.
* testsuite/libgomp.c++/pr106445-1-O0.C: Likewise.
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C
index a73e7f897be7..24e3d076a1b1 100644
--- a/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C
@@ -9,10 +9,6 @@
 /* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C',
'../../../gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C'.  */
 
-/* Help nvptx offloading overcome a code generation issue;
-   PR106445, PR118518.  */
-#define ALWAYS_INLINE __attribute__((always_inline))
-
 #pragma omp begin declare target
 
 bool ok = false;
@@ -20,12 +16,10 @@ bool ok = false;
 template 
 struct C
 {
-  ALWAYS_INLINE
   C()
   {
 ok = true;
   }
-  ALWAYS_INLINE
   C(int) {};
   ~C() {};


[gcc r15-9553] Set DEV-PHASE to prerelease.

2025-04-17 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:d24527cded1338033872d9c190df2e5a72a65049

commit r15-9553-gd24527cded1338033872d9c190df2e5a72a65049
Author: Jakub Jelinek 
Date:   Thu Apr 17 12:56:00 2025 +0200

Set DEV-PHASE to prerelease.

2025-04-17  Jakub Jelinek  

* DEV-PHASE: Set to prerelease.

Diff:
---
 gcc/DEV-PHASE | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/DEV-PHASE b/gcc/DEV-PHASE
index 9839eb20815b..373fbc60bb98 100644
--- a/gcc/DEV-PHASE
+++ b/gcc/DEV-PHASE
@@ -1 +1 @@
-experimental
+prerelease


[gcc r15-9551] libstdc++: Fixed signed comparision in _M_parse_fill_and_align [PR119840]

2025-04-17 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:930b504b598864ba1774eb209a748ed76b6fc7c1

commit r15-9551-g930b504b598864ba1774eb209a748ed76b6fc7c1
Author: Tomasz Kamiński 
Date:   Thu Apr 17 10:33:10 2025 +0200

libstdc++: Fixed signed comparision in _M_parse_fill_and_align [PR119840]

Explicitly cast elements of __not_fill to _CharT. Only '{' and ':'
are used as `__not_fill`, so they are never negative.

PR libstdc++/119840

libstdc++-v3/ChangeLog:

* include/std/format (_M_parse_fill_and_align): Cast elements of
__not_fill to _CharT.

Diff:
---
 libstdc++-v3/include/std/format | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index f3fd837897bd..e557e104d74d 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -555,8 +555,8 @@ namespace __format
   constexpr iterator
   _M_parse_fill_and_align(iterator __first, iterator __last, string_view 
__not_fill) noexcept
   {
-   for (char c : __not_fill)
- if (*__first == c)
+   for (char __c : __not_fill)
+ if (*__first == static_cast<_CharT>(__c))
return __first;
 
using namespace __unicode;