[gcc r15-7672] libgomp: Add '__attribute__((unused))' to variables used only in 'assert(...)'

2025-02-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e759ff08e2e2e7128db7e6313b4218daa367c74f

commit r15-7672-ge759ff08e2e2e7128db7e6313b4218daa367c74f
Author: shynur 
Date:   Mon Feb 17 23:06:58 2025 +0800

libgomp: Add '__attribute__((unused))' to variables used only in 
'assert(...)'

Without this attribute, the building process will fail if GCC is configured
with 'CFLAGS=-DNDEBUG'.

libgomp/ChangeLog:

* oacc-mem.c (acc_unmap_data, goacc_exit_datum_1, find_group_last,
goacc_enter_data_internal): Add '__attribute__((unused))'.
* target.c (gomp_unmap_vars_internal): Likewise.

Diff:
---
 libgomp/oacc-mem.c | 9 +
 libgomp/target.c   | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index c75471bc2bea..718252b44ba7 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -480,7 +480,7 @@ acc_unmap_data (void *h)
   tgt->tgt_end = 0;
   tgt->to_free = NULL;
 
-  bool is_tgt_unmapped = gomp_remove_var (acc_dev, n);
+  bool is_tgt_unmapped __attribute__((unused)) = gomp_remove_var (acc_dev, n);
   assert (is_tgt_unmapped);
 
   gomp_mutex_unlock (&acc_dev->lock);
@@ -743,7 +743,8 @@ goacc_exit_datum_1 (struct gomp_device_descr *acc_dev, void 
*h, size_t s,
if (n->tgt->list[l_i].key
&& !n->tgt->list[l_i].is_attach)
  ++num_mappings;
- bool is_tgt_unmapped = gomp_remove_var (acc_dev, n);
+ bool is_tgt_unmapped __attribute__((unused))
+   = gomp_remove_var (acc_dev, n);
  assert (is_tgt_unmapped || num_mappings > 1);
}
 }
@@ -1023,7 +1024,7 @@ static int
 find_group_last (int pos, size_t mapnum, size_t *sizes, unsigned short *kinds)
 {
   unsigned char kind0 = kinds[pos] & 0xff;
-  int first_pos = pos;
+  int first_pos __attribute__((unused)) = pos;
 
   switch (kind0)
 {
@@ -1203,7 +1204,7 @@ goacc_enter_data_internal (struct gomp_device_descr 
*acc_dev, size_t mapnum,
  /* Let 'goacc_map_vars' -> 'gomp_map_vars_internal' handle
 this.  */
  gomp_mutex_unlock (&acc_dev->lock);
- struct target_mem_desc *tgt_
+ struct target_mem_desc *tgt_ __attribute__((unused))
= goacc_map_vars (acc_dev, aq, groupnum, &hostaddrs[i], NULL,
  &sizes[i], &kinds[i], true,
  GOMP_MAP_VARS_ENTER_DATA);
diff --git a/libgomp/target.c b/libgomp/target.c
index 9fc51b160f09..dbc4535b96f3 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2092,8 +2092,9 @@ gomp_unmap_vars_internal (struct target_mem_desc *tgt, 
bool do_copyfrom,
tgt->list[i].length);
   if (do_remove)
{
- struct target_mem_desc *k_tgt = k->tgt;
- bool is_tgt_unmapped = gomp_remove_var (devicep, k);
+ struct target_mem_desc *k_tgt __attribute__((unused)) = k->tgt;
+ bool is_tgt_unmapped __attribute__((unused))
+   = gomp_remove_var (devicep, k);
  /* It would be bad if TGT got unmapped while we're still iterating
 over its LIST_COUNT, and also expect to use it in the following
 code.  */


[gcc r15-7670] libstdc++: Remove redundant cast in floating_from_chars.cc

2025-02-22 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:a742b27bd2da33640222b1f85a4576d6d0aa2759

commit r15-7670-ga742b27bd2da33640222b1f85a4576d6d0aa2759
Author: Jonathan Wakely 
Date:   Thu Feb 20 15:16:11 2025 +

libstdc++: Remove redundant cast in floating_from_chars.cc

In r15-7647-g32457bc25fea80 I added a cast and also changed the type of
the variable, making the cast redundant. This removes the cast.

libstdc++-v3/ChangeLog:

* src/c++17/floating_from_chars.cc (__floating_from_chars_hex):
Remove redundant cast.

Diff:
---
 libstdc++-v3/src/c++17/floating_from_chars.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc 
b/libstdc++-v3/src/c++17/floating_from_chars.cc
index d48f1c0d4545..9bad12c7f69e 100644
--- a/libstdc++-v3/src/c++17/floating_from_chars.cc
+++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
@@ -1103,8 +1103,7 @@ namespace
// If the leading hexit is not '1', shift MANTISSA to make it so.
// This normalizes input like "4.08p0" into "1.02p2".
const unsigned leading_hexit = mantissa >> mantissa_bits;
-   const int leading_hexit_width
- = __bit_width((unsigned)leading_hexit); // FIXME: optimize?
+   const int leading_hexit_width = __bit_width(leading_hexit); // FIXME: 
optimize?
__glibcxx_assert(leading_hexit_width >= 1 && leading_hexit_width <= 4);
shift_mantissa(leading_hexit_width - 1);
// After this adjustment, we can assume the leading hexit is '1'.


[gcc r15-7671] libstdc++: Remove misleading comment in __atomic_base

2025-02-22 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:4470229653e9e539f389d6f41d013d243d6acafb

commit r15-7671-g4470229653e9e539f389d6f41d013d243d6acafb
Author: Jonathan Wakely 
Date:   Tue Apr 15 20:13:41 2014 +0100

libstdc++: Remove misleading comment in __atomic_base

No conversion is needed because the type of _M_i is __int_type anyway.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (__atomic_base<_ITp>): Remove
misleading comment.

Diff:
---
 libstdc++-v3/include/bits/atomic_base.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/atomic_base.h 
b/libstdc++-v3/include/bits/atomic_base.h
index b56007b7bf5f..92d1269493f7 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -355,7 +355,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __atomic_base& operator=(const __atomic_base&) = delete;
   __atomic_base& operator=(const __atomic_base&) volatile = delete;
 
-  // Requires __int_type convertible to _M_i.
   constexpr __atomic_base(__int_type __i) noexcept : _M_i (__i) { }
 
   operator __int_type() const noexcept


[gcc r15-7675] Gracefully handle the case that 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has not been called (

2025-02-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e8e228acffe382f003a7f2ca37c068a5e0c74df4

commit r15-7675-ge8e228acffe382f003a7f2ca37c068a5e0c74df4
Author: Thomas Schwinge 
Date:   Fri Feb 21 21:54:59 2025 +0100

Gracefully handle the case that 
'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has not been called (indirectly) 
from 'dg-test'

No change in behavior intended.

gcc/testsuite/
* lib/gcc-dg.exp (find-dg-do-what): Gracefully handle the case
that we've not be called (indirectly) from 'dg-test'.
* lib/target-supports.exp (check_effective_target_stack_size)
(check_effective_target_alloca): Catch this.

Diff:
---
 gcc/testsuite/lib/gcc-dg.exp  | 6 +-
 gcc/testsuite/lib/target-supports.exp | 6 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6e9a7b207ab8..c0adef6c450e 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1375,8 +1375,9 @@ set dg_runtest_extra_prunes ""
 # the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable
 # without interfering with this search.
 proc find-dg-do-what { } {
+set level [info level]
 set lookup_level 2
-while true {
+while { $lookup_level <= $level } {
upvar $lookup_level dg-do-what dg-do-what
if { [info exists dg-do-what] } {
verbose "find-dg-do-what: found 'dg-do-what' at level 
$lookup_level: ${dg-do-what}" 2
@@ -1384,4 +1385,7 @@ proc find-dg-do-what { } {
}
incr lookup_level
 }
+# We've not be called (indirectly) from 'dg-test'.
+verbose "find-dg-do-what: have not found 'dg-do-what'" 2
+return [list]
 }
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 7b3172d55b45..4970536bb592 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -653,6 +653,9 @@ proc check_effective_target_stack_size { } {
 # For nvptx target, stack size limits are relevant for execution only.
 if { [istarget nvptx-*-*] } {
set dg-do-what [find-dg-do-what]
+   if { ![llength ${dg-do-what}] } {
+   error "unexpected call stack"
+   }
if { ![string equal [lindex ${dg-do-what} 0] run] } {
return 0
}
@@ -1014,6 +1017,9 @@ proc check_effective_target_alloca {} {
}
 
set dg-do-what [find-dg-do-what]
+   if { ![llength ${dg-do-what}] } {
+   error "unexpected call stack"
+   }
if { [string equal [lindex ${dg-do-what} 0] run] } {
# For 'dg-do run', it additionally depends on runtime support.
# (If not supported, we don't try to demote 'run' to 'link',


[gcc r15-7673] BPF, nvptx: Standardize on 'sorry, unimplemented: dynamic stack allocation not supported'

2025-02-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2abc942fd486be217de1ba0282a3dc8e21d599aa

commit r15-7673-g2abc942fd486be217de1ba0282a3dc8e21d599aa
Author: Thomas Schwinge 
Date:   Fri Feb 21 11:21:08 2025 +0100

BPF, nvptx: Standardize on 'sorry, unimplemented: dynamic stack allocation 
not supported'

... instead of BPF: 'error: BPF does not support dynamic stack allocation', 
and
nvptx: 'sorry, unimplemented: target cannot support alloca'.

gcc/
* config/bpf/bpf.md (define_expand "allocate_stack"): Emit
'sorry, unimplemented: dynamic stack allocation not supported'.
* config/nvptx/nvptx.md (define_expand "allocate_stack")
[!TARGET_SOFT_STACK && !(TARGET_PTX_7_3 && TARGET_SM52)]: Likewise.
gcc/testsuite/
* gcc.target/bpf/diag-alloca-1.c: Adjust 'dg-message'.
* gcc.target/bpf/diag-alloca-2.c: Likewise.
* gcc.target/nvptx/alloca-1-sm_30.c: Likewise.
* gcc.target/nvptx/vla-1-sm_30.c: Likewise.
* lib/target-supports.exp (proc check_effective_target_alloca):
Adjust comment.

Diff:
---
 gcc/config/bpf/bpf.md   | 5 ++---
 gcc/config/nvptx/nvptx.md   | 2 +-
 gcc/testsuite/gcc.target/bpf/diag-alloca-1.c| 3 ++-
 gcc/testsuite/gcc.target/bpf/diag-alloca-2.c| 4 +++-
 gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c | 2 +-
 gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c| 2 +-
 gcc/testsuite/lib/target-supports.exp   | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md
index 12cf9fae855c..91d94838e395 100644
--- a/gcc/config/bpf/bpf.md
+++ b/gcc/config/bpf/bpf.md
@@ -121,12 +121,11 @@
   [(match_operand:DI 0 "general_operand" "")
(match_operand:DI 1 "general_operand" "")]
   ""
-  "
 {
-  error (\"BPF does not support dynamic stack allocation\");
+  sorry ("dynamic stack allocation not supported");
   emit_insn (gen_nop ());
   DONE;
-}")
+})
 
  Arithmetic/Logical
 
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index d3d538070c0f..e7d3630d4c4b 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1677,7 +1677,7 @@
 emit_insn (gen_nvptx_alloca (Pmode, operands[0], operands[1]));
   else if (!TARGET_SOFT_STACK)
 {
-  sorry ("target cannot support alloca");
+  sorry ("dynamic stack allocation not supported");
   emit_insn (gen_nop ());
 }
   else if (TARGET_SOFT_STACK)
diff --git a/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c 
b/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
index 0406f2c35958..e549cab84caf 100644
--- a/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
+++ b/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
@@ -3,7 +3,8 @@
 int
 foo (int x)
 {
-  int *p = __builtin_alloca (x); /* { dg-error "support" } */
+  int *p = __builtin_alloca (x);
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not 
supported} {} { target *-*-* } .-1 } */
 
   return p[2];
 }
diff --git a/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c 
b/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
index ef7170b2c3d3..b1084bf57268 100644
--- a/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
+++ b/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
@@ -4,6 +4,8 @@
 int
 foo (int x)
 {
-  int arr[x]; /* { dg-error "support" } */
+  int arr[x];
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not 
supported} {} { target *-*-* } .-1 } */
+
   return arr[3];
 }
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c 
b/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
index 261a603ec4ce..5538751035bc 100644
--- a/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
@@ -7,5 +7,5 @@ void sink(void *);
 void f(void)
 {
   sink(__builtin_alloca(123));
-  /* { dg-message {sorry, unimplemented: target cannot support alloca} {} { 
target *-*-* } .-1 } */
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not 
supported} {} { target *-*-* } .-1 } */
 }
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c 
b/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
index 2bf2c91d60e9..7c2d2e0e35ba 100644
--- a/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
@@ -7,6 +7,6 @@ void sink(void *);
 void f(int s)
 {
   char a[s];
-  /* { dg-message {sorry, unimplemented: target cannot support alloca} {} { 
target *-*-* } .-1 } */
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not 
supported} {} { target *-*-* } .-1 } */
   sink(a);
 }
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 9b5fbe527561..7eab76a7eb66 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1002,7 +1002,7 @@ proc check_effective_target_untyped_assembly {} {
 return 1
 }
 
-# Return 1 if alloca is supported, 0 otherwise.
+# Retur

[gcc r15-7674] Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'

2025-02-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:f553b1aaa2b1b925c918e5dcf966290b045321c2

commit r15-7674-gf553b1aaa2b1b925c918e5dcf966290b045321c2
Author: Thomas Schwinge 
Date:   Fri Feb 21 19:42:28 2025 +0100

Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'

No change in behavior intended.

gcc/testsuite/
* lib/gcc-dg.exp (proc find-dg-do-what): New.
* lib/target-supports.exp (check_effective_target_stack_size)
(check_effective_target_alloca): Use it.

Diff:
---
 gcc/testsuite/lib/gcc-dg.exp  | 16 
 gcc/testsuite/lib/target-supports.exp | 20 ++--
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 70be7a8d5fd1..6e9a7b207ab8 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1369,3 +1369,19 @@ proc gcc-transform-out-of-tree { args } {
 
 set additional_prunes ""
 set dg_runtest_extra_prunes ""
+
+# Find the 'dg-do-what' variable living inside DejaGnu's 'dg-test' procedure,
+# as a local variable.  We start looking at the second-outer frame: this way,
+# the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable
+# without interfering with this search.
+proc find-dg-do-what { } {
+set lookup_level 2
+while true {
+   upvar $lookup_level dg-do-what dg-do-what
+   if { [info exists dg-do-what] } {
+   verbose "find-dg-do-what: found 'dg-do-what' at level 
$lookup_level: ${dg-do-what}" 2
+   return ${dg-do-what}
+   }
+   incr lookup_level
+}
+}
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 7eab76a7eb66..7b3172d55b45 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -652,15 +652,7 @@ proc check_effective_target_trampolines { } {
 proc check_effective_target_stack_size { } {
 # For nvptx target, stack size limits are relevant for execution only.
 if { [istarget nvptx-*-*] } {
-   # Find 'dg-do-what' in an outer frame.
-   set level 1
-   while true {
-   upvar $level dg-do-what dg-do-what
-   if [info exists dg-do-what] then break
-   incr level
-   }
-   verbose "check_effective_target_stack_size: found dg-do-what at level 
$level" 2
-
+   set dg-do-what [find-dg-do-what]
if { ![string equal [lindex ${dg-do-what} 0] run] } {
return 0
}
@@ -1021,15 +1013,7 @@ proc check_effective_target_alloca {} {
return 0
}
 
-   # Find 'dg-do-what' in an outer frame.
-   set level 1
-   while true {
-   upvar $level dg-do-what dg-do-what
-   if [info exists dg-do-what] then break
-   incr level
-   }
-   verbose "check_effective_target_alloca: found dg-do-what at level 
$level" 2
-
+   set dg-do-what [find-dg-do-what]
if { [string equal [lindex ${dg-do-what} 0] run] } {
# For 'dg-do run', it additionally depends on runtime support.
# (If not supported, we don't try to demote 'run' to 'link',


[gcc r14-11324] Fortran: passing of derived type to VALUE, OPTIONAL dummy argument [PR118080]

2025-02-22 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:02eedd2932e4c91f41437f56c34eee1a128c24fb

commit r14-11324-g02eedd2932e4c91f41437f56c34eee1a128c24fb
Author: Harald Anlauf 
Date:   Sat Feb 15 20:36:15 2025 +0100

Fortran: passing of derived type to VALUE,OPTIONAL dummy argument [PR118080]

For scalar OPTIONAL dummy arguments with the VALUE attribute, gfortran
passes a hidden flag to denote presence or absence of the actual argument
for intrinsic types.  Extend this treatment to derived type (user-defined
as well as from intrinsic module ISO_C_BINDING).

PR fortran/118080

gcc/fortran/ChangeLog:

* gfortran.texi: Adjust documentation.
* trans-decl.cc (create_function_arglist): Adjust to pass hidden
presence flag also for derived type dummies with VALUE,OPTIONAL
attribute.
* trans-expr.cc (gfc_conv_expr_present): Expect hidden presence
flag also for derived type dummies with VALUE,OPTIONAL attribute.
(conv_cond_temp): Adjust to allow derived types.
(conv_dummy_value): Extend to handle derived type dummies with
VALUE,OPTIONAL attribute.
(gfc_conv_procedure_call): Adjust for actual arguments passed to
derived type dummies with VALUE,OPTIONAL attribute.
* trans-types.cc (gfc_get_function_type): Adjust fndecl for
hidden presence flag.

gcc/testsuite/ChangeLog:

* gfortran.dg/value_optional_2.f90: New test.

(cherry picked from commit 8859dce9037bcb242819305f02e16edbea38923c)

Diff:
---
 gcc/fortran/gfortran.texi  |   3 +-
 gcc/fortran/trans-decl.cc  |   8 +-
 gcc/fortran/trans-expr.cc  |  39 +--
 gcc/fortran/trans-types.cc |   5 +-
 gcc/testsuite/gfortran.dg/value_optional_2.f90 | 338 +
 5 files changed, 369 insertions(+), 24 deletions(-)

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 371666dcbb60..c3bf1ce02768 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -3766,7 +3766,8 @@ passed by value.
 
 For @code{OPTIONAL} dummy arguments, an absent argument is denoted
 by a NULL pointer, except for scalar dummy arguments of intrinsic type
-which have the @code{VALUE} attribute.  For those, a hidden Boolean
+or derived type (but not @code{CLASS}) and
+that have the @code{VALUE} attribute.  For those, a hidden Boolean
 argument (@code{logical(kind=C_bool),value}) is used to indicate
 whether the argument is present.
 
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 7a38151f..5010e93c1a46 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -2661,8 +2661,7 @@ create_function_arglist (gfc_symbol * sym)
   for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
 if (f->sym != NULL
&& f->sym->attr.optional && f->sym->attr.value
-   && !f->sym->attr.dimension && f->sym->ts.type != BT_CLASS
-   && !gfc_bt_struct (f->sym->ts.type))
+   && !f->sym->attr.dimension && f->sym->ts.type != BT_CLASS)
   hidden_typelist = TREE_CHAIN (hidden_typelist);
 
   for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
@@ -2744,12 +2743,11 @@ create_function_arglist (gfc_symbol * sym)
type = gfc_sym_type (f->sym);
}
}
-  /* For scalar intrinsic types, VALUE passes the value,
+  /* For scalar intrinsic types or derived types, VALUE passes the value,
 hence, the optional status cannot be transferred via a NULL pointer.
 Thus, we will use a hidden argument in that case.  */
   if (f->sym->attr.optional && f->sym->attr.value
- && !f->sym->attr.dimension && f->sym->ts.type != BT_CLASS
- && !gfc_bt_struct (f->sym->ts.type))
+ && !f->sym->attr.dimension && f->sym->ts.type != BT_CLASS)
{
   tree tmp;
   strcpy (&name[1], f->sym->name);
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index f6de2227675b..68b627cc4651 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -2047,10 +2047,9 @@ gfc_conv_expr_present (gfc_symbol * sym, bool 
use_saved_desc)
   gcc_assert (sym->attr.dummy);
   orig_decl = decl = gfc_get_symbol_decl (sym);
 
-  /* Intrinsic scalars with VALUE attribute which are passed by value
- use a hidden argument to denote the present status.  */
-  if (sym->attr.value && !sym->attr.dimension
-  && sym->ts.type != BT_CLASS && !gfc_bt_struct (sym->ts.type))
+  /* Intrinsic scalars and derived types with VALUE attribute which are passed
+ by value use a hidden argument to denote the presence status.  */
+  if (sym->attr.value && !sym->attr.dimension && sym->ts.type != BT_CLASS)
 {
   char name[GFC_MAX_SYMBOL_LEN + 2];
   tree tree_name;
@@ -6128,13 +6127,13 @@ post_call:
 
 /* Create "conditional temporary" to handle scalar dummy v

[gcc r15-7677] libstdc++: Fix bootstrap failure with --enable-vtable-verify [PR118981]

2025-02-22 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d4a777d098d524a3f26c3db28e50d064a7a4407e

commit r15-7677-gd4a777d098d524a3f26c3db28e50d064a7a4407e
Author: Jonathan Wakely 
Date:   Sat Feb 22 21:02:29 2025 +

libstdc++: Fix bootstrap failure with --enable-vtable-verify [PR118981]

The compiler emits code with init_priority(99) for -fvtable-verify=std
and that creates a section conflict with the uses of init_priority(99)
that I recently added to src/c++20/tzdb.cc.

Change tzdb.cc to use a different priority to avoid the conflict.

libstdc++-v3/ChangeLog:

PR c++/118981
* src/c++20/tzdb.cc: Use init_priority(98) instead of
init_priority(99).

Diff:
---
 libstdc++-v3/src/c++20/tzdb.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index c3bb6a12ccc1..9cf9eeccc599 100644
--- a/libstdc++-v3/src/c++20/tzdb.cc
+++ b/libstdc++-v3/src/c++20/tzdb.cc
@@ -181,14 +181,14 @@ namespace std::chrono
 
 #pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
 
-  [[gnu::init_priority(99)]]
+  [[gnu::init_priority(98)]]
   constinit tzdb_list tzdb_list::_Node::_S_the_list(nullptr);
 
-  [[gnu::init_priority(99)]]
+  [[gnu::init_priority(98)]]
   constinit tzdb_list::_Node::head_ptr 
tzdb_list::_Node::_S_head_owner{nullptr};
 
 #if USE_ATOMIC_LIST_HEAD
-  [[gnu::init_priority(99)]]
+  [[gnu::init_priority(98)]]
   constinit atomic tzdb_list::_Node::_S_head_cache{nullptr};
 #endif


[gcc r15-7669] OpenMP: Silence uninitialized variable warning in C++ front end.

2025-02-22 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:c978965b445079abbb88c22ba74de1e26e9f5b81

commit r15-7669-gc978965b445079abbb88c22ba74de1e26e9f5b81
Author: Sandra Loosemore 
Date:   Sat Feb 22 16:54:50 2025 +

OpenMP: Silence uninitialized variable warning in C++ front end.

There's no actual problem with the code here, just a false-positive
warning emitted by some older GCC versions.

gcc/cp/ChangeLog
* parser.cc (cp_finish_omp_declare_variant): Initialize
append_args_last.

Diff:
---
 gcc/cp/parser.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 0578aad1b1cf..9f619b111673 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -50383,7 +50383,7 @@ cp_finish_omp_declare_variant (cp_parser *parser, 
cp_token *pragma_tok,
   location_t varid_loc = make_location (caret_loc, start_loc, finish_loc);
 
   tree append_args_tree = NULL_TREE;
-  tree append_args_last;
+  tree append_args_last = NULL_TREE;
   vec adjust_args_list = vNULL;
   bool has_match = false, has_adjust_args = false;
   location_t adjust_args_loc = UNKNOWN_LOCATION;


[gcc r15-7668] PR modula2/118978 ICE when attempting to pass an incompatible parameter

2025-02-22 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:a2f60c1ff5a85497f84dc307301bcbc4bd77082e

commit r15-7668-ga2f60c1ff5a85497f84dc307301bcbc4bd77082e
Author: Gaius Mulley 
Date:   Sat Feb 22 16:47:21 2025 +

PR modula2/118978 ICE when attempting to pass an incompatible parameter

This bugfix is for a an ICE which occurs if an incompatible parameter
is passed to a procedure.  In particular if a REAL constant actual
parameter is passed to INTEGER formal parameter then M2Range is invoked
to check the type and then M2Range is called to check the value range.

The value range check causes an ICE.  The bug fix introduces range
dependencies on type checks.  If the type check fails an
error message is generated and any future range check cancelled.
These range and type checks are tightly coupled when generating
parameter quad intermediate code.

gcc/m2/ChangeLog:

PR modula2/118978
* gm2-compiler/M2Check.mod (checkConstMeta): Add check for
typed constants.
* gm2-compiler/M2Quads.mod (BoolFrame): New field RangeDep.
(CheckProcedureParameters): Call PutRangeDep to associate the
range dependency with the parameter on the quad stack.
Pass ParamCheckId to CheckParameter.
(CheckProcTypeAndProcedure): Add ParamCheckId parameter.
Pass ParamCheckId to BuildRange.
(CheckParameter): New parameter ParamCheckId.
Pass ParamCheckId to CheckProcTypeAndProcedure.
(CheckParameterOrdinals): Add extra range dep parameter to the
call of InitParameterRangeCheck.
(ConvertBooleanToVariable): Initialize RangeDep field.
(PushBacktok): Ditto.
(OperandRangeDep): New procedure.
(PutRangeDep): Ditto.
* gm2-compiler/M2Range.def (InitTypesParameterCheck): Add new
parameter depRangeId.
(InitParameterRangeCheck): Add new parameter parentRangeId.
(FoldRangeCheck): Add new parameter range.
* gm2-compiler/M2Range.mod (InitTypesParameterCheck): Add new
parameter depRangeId.
(InitParameterRangeCheck): Add new parameter parentRangeId.
(FoldRangeCheck): Add new parameter range and rewrite.
(FoldRangeCheckLower): New procedure.
(Range): New field cancelled.
New field dependantid.
(PutRangeParam): Initialize dependantid.
(PutRangeParamAssign): Ditto.
(CheckCancelled): New procedure.
(Cancel): Ditto.
(IsCancelled): New procedure function.
(FoldTypeParam): Add depRangeId parameter.
(WriteRangeCheck): Add dependent debugging.

gcc/testsuite/ChangeLog:

PR modula2/118978
* gm2/pim/fail/badparamtype.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Check.mod |   6 +
 gcc/m2/gm2-compiler/M2Quads.mod |  64 +++---
 gcc/m2/gm2-compiler/M2Range.def |  15 +--
 gcc/m2/gm2-compiler/M2Range.mod | 186 ++--
 gcc/testsuite/gm2/pim/fail/badparamtype.mod |  10 ++
 5 files changed, 219 insertions(+), 62 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Check.mod b/gcc/m2/gm2-compiler/M2Check.mod
index d2bb4ab7da35..528c51deaf36 100644
--- a/gcc/m2/gm2-compiler/M2Check.mod
+++ b/gcc/m2/gm2-compiler/M2Check.mod
@@ -768,6 +768,7 @@ END checkVarEquivalence ;
 PROCEDURE checkConstMeta (result: status; tinfo: tInfo;
   left, right: CARDINAL) : status ;
 VAR
+   typeLeft,
typeRight: CARDINAL ;
 BEGIN
Assert (IsConst (left)) ;
@@ -798,6 +799,11 @@ BEGIN
 RETURN doCheckPair (result, tinfo, Char, typeRight)
  END
   END
+   ELSIF IsTyped (left) AND IsTyped (right)
+   THEN
+  typeRight := GetDType (right) ;
+  typeLeft := GetDType (left) ;
+  RETURN doCheckPair (result, tinfo, typeLeft, typeRight)
END ;
RETURN result
 END checkConstMeta ;
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 46db4a6556da..d057a27fd862 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -300,6 +300,7 @@ TYPE
  Dimension : CARDINAL ;
  ReadWrite : CARDINAL ;
  name  : CARDINAL ;
+ RangeDep  : CARDINAL ;
  Annotation: String ;
  tokenno   : CARDINAL ;
   END ;
@@ -5623,6 +5624,7 @@ VAR
proctok,
paramtok: CARDINAL ;
n1, n2  : Name ;
+   ParamCheckId,   
Dim,
Actual,
FormalI,
@@ -5686,8 +5688,11 @@ BEGIN
 s := InitString ('actual') ;
 WarnStringAt (s, paramtok)
  END ;
-
- BuildRange (InitTypesParameterCheck (para