[gcc r15-9406] Fix ICE in compare_parameter.

2025-04-13 Thread Thomas Koenig via Gcc-cvs
https://gcc.gnu.org/g:64319b2ccae2fdfae06347545e031e56d790dad7

commit r15-9406-g64319b2ccae2fdfae06347545e031e56d790dad7
Author: Thomas Koenig 
Date:   Sun Apr 13 10:22:07 2025 +0200

Fix ICE in compare_parameter.

This patch fixes an ICE by setting the typespec of a dummy argument
from a global function if known. plus setting the correct flag.
This also removes the corresponding assert.  I'm not quite sure
that the code with the subroutine attribute can be reached, but
I thought better safe than sorry.

gcc/fortran/ChangeLog:

PR fortran/119669
* interface.cc (compare_parameter): Error when mismatch between
formal argument as subroutine and function.  If the dummy
argument is a known function, set its typespec.

gcc/testsuite/ChangeLog:

PR fortran/119669
* gfortran.dg/interface_59.f90: New test.

Diff:
---
 gcc/fortran/interface.cc   | 31 +++---
 gcc/testsuite/gfortran.dg/interface_59.f90 | 15 +++
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index c702239d64da..1e552a3df861 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -2534,16 +2534,33 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
  gfc_find_symbol (actual_name, gsym->ns, 0, &global_asym);
  if (global_asym != NULL)
{
- gcc_assert (formal->attr.function);
- if (!gfc_compare_types (&global_asym->ts, &formal->ts))
+ if (formal->attr.subroutine)
{
- gfc_error ("Type mismatch at %L passing global "
-"function %qs declared at %L (%s/%s)",
-&actual->where, actual_name, &gsym->where,
-gfc_typename (&global_asym->ts),
-gfc_dummy_typename (&formal->ts));
+ gfc_error ("Mismatch between subroutine and "
+"function at %L", &actual->where);
  return false;
}
+ else if (formal->attr.function)
+   {
+ if (!gfc_compare_types (&global_asym->ts,
+ &formal->ts))
+   {
+ gfc_error ("Type mismatch at %L passing global "
+"function %qs declared at %L (%s/%s)",
+&actual->where, actual_name,
+&gsym->where,
+gfc_typename (&global_asym->ts),
+gfc_dummy_typename (&formal->ts));
+ return false;
+   }
+   }
+ else
+   {
+ /* The global symbol is a function.  Set the formal
+argument acordingly.  */
+ formal->attr.function = 1;
+ formal->ts = global_asym->ts;
+   }
}
}
}
diff --git a/gcc/testsuite/gfortran.dg/interface_59.f90 
b/gcc/testsuite/gfortran.dg/interface_59.f90
new file mode 100644
index ..c9ccd67f1a12
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/interface_59.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/119669 - this used to generate an ICE.
+
+program a
+  implicit real(a-h,o-z)
+  external abstract_caller, caller, func
+!  real func
+  call abstract_caller (caller, func, 1.5)
+  call abstract_caller (caller, func, 1.5)
+end program a
+
+function func (x)
+  real func, x
+  func = x * x - 1.
+end


[gcc r15-9409] c++/modules: Give more specific diagnostics in is_matching_decl

2025-04-13 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:714e9020becc260a05f17ae694a6bdde65d9c567

commit r15-9409-g714e9020becc260a05f17ae694a6bdde65d9c567
Author: Nathaniel Shead 
Date:   Fri Apr 11 07:09:33 2025 +1000

c++/modules: Give more specific diagnostics in is_matching_decl

This patch also rephrases the diagnostics to talk about "imported
declarations" rather than "global module declarations", since as the
FIXME noted we can also get mismatches with some declarations attached
to modules.  Ideally I'd like to revisit the way this is structured
entirely but that won't be appropriate for GCC 15.

gcc/cp/ChangeLog:

* module.cc (trees_in::is_matching_decl): Add custom errors for
different kinds of mismatches.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-8_b.C: Adjust error.
* g++.dg/modules/leg-merge-4_c.C: Likewise.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/cp/module.cc | 55 ++--
 gcc/testsuite/g++.dg/modules/lambda-8_b.C|  2 +-
 gcc/testsuite/g++.dg/modules/leg-merge-4_c.C |  6 +--
 3 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 37fab5b5a43e..8efa18baff1d 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12090,6 +12090,8 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
   gcc_checking_assert (TREE_CODE (e_inner) == TREE_CODE (d_inner));
 }
 
+  // FIXME: do more precise errors at point of mismatch
+  const char *mismatch_msg = nullptr;
   if (TREE_CODE (d_inner) == FUNCTION_DECL)
 {
   tree e_ret = fndecl_declared_return_type (existing);
@@ -12099,13 +12101,20 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
  && LAMBDA_TYPE_P (DECL_CONTEXT (d_inner)))
/* This has a recursive type that will compare different.  */;
   else if (!same_type_p (d_ret, e_ret))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting type for imported declaration %#qD");
+ goto mismatch;
+   }
 
   tree e_type = TREE_TYPE (e_inner);
   tree d_type = TREE_TYPE (d_inner);
 
   if (DECL_EXTERN_C_P (d_inner) != DECL_EXTERN_C_P (e_inner))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting language linkage for imported "
+   "declaration %#qD");
+ goto mismatch;
+   }
 
   for (tree e_args = TYPE_ARG_TYPES (e_type),
 d_args = TYPE_ARG_TYPES (d_type);
@@ -12113,10 +12122,18 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
   e_args = TREE_CHAIN (e_args), d_args = TREE_CHAIN (d_args))
{
  if (!(e_args && d_args))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting argument list for imported "
+   "declaration %#qD");
+ goto mismatch;
+   }
 
  if (!same_type_p (TREE_VALUE (d_args), TREE_VALUE (e_args)))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting argument types for imported "
+   "declaration %#qD");
+ goto mismatch;
+   }
}
 
   /* If EXISTING has an undeduced or uninstantiated exception
@@ -12149,7 +12166,11 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
}
   else if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)
   && !comp_except_specs (d_spec, e_spec, ce_type))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting % specifier for "
+   "imported declaration %#qD");
+ goto mismatch;
+   }
 
   /* Similarly if EXISTING has an undeduced return type, but DECL's
 is already deduced.  */
@@ -12163,7 +12184,11 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
}
   else if (type_uses_auto (d_ret)
   && !same_type_p (TREE_TYPE (d_type), TREE_TYPE (e_type)))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting deduced return type for "
+   "imported declaration %#qD");
+ goto mismatch;
+   }
 
   /* Similarly if EXISTING has undeduced constexpr, but DECL's
 is already deduced.  */
@@ -12172,7 +12197,11 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
   else if (DECL_DECLARED_CONSTEXPR_P (e_inner)
   != DECL_DECLARED_CONSTEXPR_P (d_inner))
-   goto mismatch;
+   {
+ mismatch_msg = G_("conflicting % for imported "
+   "declaration %#qD");
+ goto mismatch;
+   }
 
   /* Don't synthesize a defaulted function if we're importing one
 we've already determined.  */
@@ -12184,13 +12213,17 @@ trees_in::is_matching_decl (t

[gcc r15-9410] c++/modules: More fixes for merging DECL_MAYBE_DELETED functions

2025-04-13 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:f40e39515e0b7fa69bd50bad99f1f1b8c446692f

commit r15-9410-gf40e39515e0b7fa69bd50bad99f1f1b8c446692f
Author: Nathaniel Shead 
Date:   Fri Apr 11 07:29:11 2025 +1000

c++/modules: More fixes for merging DECL_MAYBE_DELETED functions

My change in r15-9216 broke the case where we imported an uninstantiated
defaulted function over the top of one we had already finished.  This
patch ensures that we don't error for mismatches in this case.

gcc/cp/ChangeLog:

* module.cc (trees_in::is_matching_decl): Don't check for
mismatches when importing a DECL_MAYBE_DELETED function over one
that's already finished.

gcc/testsuite/ChangeLog:

* g++.dg/modules/noexcept-4_a.H: New test.
* g++.dg/modules/noexcept-4_b.C: New test.

Signed-off-by: Nathaniel Shead 
Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/module.cc|  5 -
 gcc/testsuite/g++.dg/modules/noexcept-4_a.H |  6 ++
 gcc/testsuite/g++.dg/modules/noexcept-4_b.C | 18 ++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 8efa18baff1d..5ff5c462e79c 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12164,7 +12164,8 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
}
}
}
-  else if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)
+  else if (!DECL_MAYBE_DELETED (d_inner)
+  && !DEFERRED_NOEXCEPT_SPEC_P (d_spec)
   && !comp_except_specs (d_spec, e_spec, ce_type))
{
  mismatch_msg = G_("conflicting % specifier for "
@@ -12195,6 +12196,8 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
   if (DECL_MAYBE_DELETED (e_inner) && !DECL_MAYBE_DELETED (d_inner)
  && DECL_DECLARED_CONSTEXPR_P (d_inner))
DECL_DECLARED_CONSTEXPR_P (e_inner) = true;
+  else if (!DECL_MAYBE_DELETED (e_inner) && DECL_MAYBE_DELETED (d_inner))
+   /* Nothing to do.  */;
   else if (DECL_DECLARED_CONSTEXPR_P (e_inner)
   != DECL_DECLARED_CONSTEXPR_P (d_inner))
{
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_a.H 
b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
new file mode 100644
index ..b888a1b93e62
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_a.H
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodule-header -std=c++20" }
+// { dg-module-cmi {} }
+
+struct exception_ptr {
+  friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
diff --git a/gcc/testsuite/g++.dg/modules/noexcept-4_b.C 
b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
new file mode 100644
index ..7cc55316c7cb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/noexcept-4_b.C
@@ -0,0 +1,18 @@
+// { dg-additional-options "-fmodules -std=c++20" }
+
+struct exception_ptr {
+  friend bool operator==(const exception_ptr&, const exception_ptr&) = default;
+};
+
+void enqueue() {
+  exception_ptr e;
+  e == e;
+}
+
+import "noexcept-4_a.H";
+
+int main() {
+  constexpr exception_ptr e;
+  static_assert(e == e);
+  static_assert(noexcept(e == e));
+}


[gcc r15-9411] libgcobol: Use strchr instead of index

2025-04-13 Thread Rainer Orth via Gcc-cvs
https://gcc.gnu.org/g:45e93925beaf67ba99c67f78bd9771cacd316853

commit r15-9411-g45e93925beaf67ba99c67f78bd9771cacd316853
Author: Rainer Orth 
Date:   Sun Apr 13 12:46:31 2025 +0200

libgcobol: Use strchr instead of index

valconf.cc doesn't compile on Solaris:

cobol/valconv.cc: In function ‘bool __gg__string_to_numeric_edited(char*, 
char*, int, int, const char*)’:
cobol/valconv.cc:856:40: error: ‘index’ was not declared in this scope; did 
you mean ‘Rindex’?
  856 | const char *decimal_location = index(dest, 
__gg__decimal_point);  |^
 |Rindex

On Solaris, it's only declared in .  While one could get that
included, it's way easier to just use strchr as is already the case in
other instances.

Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

2025-04-08  Rainer Orth  

libgcobol:
* valconv.cc (__gg__string_to_numeric_edited): Use strchr instead
of index.

Diff:
---
 libgcobol/valconv.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libgcobol/valconv.cc b/libgcobol/valconv.cc
index 33d9a0dd1ffd..7e5830156c14 100644
--- a/libgcobol/valconv.cc
+++ b/libgcobol/valconv.cc
@@ -853,14 +853,14 @@ got_float:
 }
   else
 {
-const char *decimal_location = index(dest, __gg__decimal_point);
+const char *decimal_location = strchr(dest, __gg__decimal_point);
 if( !decimal_location )
   {
-  decimal_location = index(dest, ascii_v);
+  decimal_location = strchr(dest, ascii_v);
   }
 if( !decimal_location )
   {
-  decimal_location = index(dest, ascii_V);
+  decimal_location = strchr(dest, ascii_V);
   }
 if( !decimal_location )
   {


[gcc r15-9412] cobol: Heed ASM_COMMENT_START

2025-04-13 Thread Rainer Orth via Gcc-cvs
https://gcc.gnu.org/g:4b990a03bd4cd6cf13ae1b5ab6c965dadf404619

commit r15-9412-g4b990a03bd4cd6cf13ae1b5ab6c965dadf404619
Author: Rainer Orth 
Date:   Sun Apr 13 12:50:19 2025 +0200

cobol: Heed ASM_COMMENT_START

When building COBOL on Solaris/sparcv9 with the native assembler, many
tests FAIL to assemble at -O0 like this:

FAIL: cobol.dg/data1.cob   -O0  (test for excess errors)
Excess errors:
/usr/ccs/bin/as: "/var/tmp//ccUduuqd.s", line 302: error: invalid character
(0x50)
/usr/ccs/bin/as: "/var/tmp//ccUduuqd.s", line 302: error: unknown opcode
"PERFORM"
/usr/ccs/bin/as: "/var/tmp//ccUduuqd.s", line 302: error: statement syntax

The problem is that genapi.cc hardcodes # as assembler comment
character, which isn't valid in general.

Instead, this patch uses ASM_COMMENT_START.

Bootstrapped without regressions on sparcv9-sun-solaris2.11,
amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.

2025-04-08  Rainer Orth  

gcc/cobol:
* genapi.cc: Include target.h.
(section_label): Use ASM_COMMENT_START.
(paragraph_label): Likewise.
(parser_perform): Likewise.
(internal_perform_through): Likewise.
(hijack_for_development): Likewise.

Diff:
---
 gcc/cobol/genapi.cc | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 622387f01a5f..c8911f964d59 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -34,6 +34,7 @@
 #include "tree-iterator.h"
 #include "stringpool.h"
 #include "diagnostic-core.h"
+#include "target.h"
 
 #include "../../libgcobol/ec.h"
 #include "../../libgcobol/common-defs.h"
@@ -2357,7 +2358,8 @@ section_label(struct cbl_proc_t *procedure)
 
   cbl_label_t *label = procedure->label;
   // The _initialize_program section isn't relevant.
-  char *psz = xasprintf("# SECTION %s in %s (%ld)",
+  char *psz = xasprintf("%s SECTION %s in %s (%ld)",
+ASM_COMMENT_START,
 label->name,
 current_function->our_unmangled_name,
 deconflictor);
@@ -2408,7 +2410,8 @@ paragraph_label(struct cbl_proc_t *procedure)
   
   char *psz1 = 
   xasprintf(
-  "# PARAGRAPH %s of %s in %s (%ld)",
+  "%s PARAGRAPH %s of %s in %s (%ld)",
+  ASM_COMMENT_START,
   para_name ? para_name: "" ,
   section_name ? section_name: "(null)" ,
   current_function->our_unmangled_name ? 
current_function->our_unmangled_name: "" ,
@@ -3006,7 +3009,8 @@ parser_perform(cbl_label_t *label, bool suppress_nexting)
 para_name = label->name;
 sect_name = section_label->name;
 sprintf(ach,
-"# PERFORM %s of %s of %s (%ld)",
+"%s PERFORM %s of %s of %s (%ld)",
+ASM_COMMENT_START,
 para_name,
 sect_name,
 program_name,
@@ -3018,7 +3022,8 @@ parser_perform(cbl_label_t *label, bool suppress_nexting)
 {
 sect_name = label->name;
 sprintf(ach,
-"# PERFORM %s of %s (%ld)",
+"%s PERFORM %s of %s (%ld)",
+ASM_COMMENT_START,
 sect_name,
 program_name,
 deconflictor);
@@ -3170,8 +3175,8 @@ internal_perform_through( cbl_label_t *proc_1,
   pseudo_return_push(proc2, return_addr);
 
   // Create the code that will launch the first procedure
-  gg_insert_into_assembler("# PERFORM %s THROUGH %s",
-proc_1->name, proc_2->name);
+  gg_insert_into_assembler("%s PERFORM %s THROUGH %s",
+ASM_COMMENT_START, proc_1->name, proc_2->name);
 
   if( !suppress_nexting )
 {
@@ -13606,7 +13611,7 @@ hijack_for_development(const char *funcname)
   // Assume that funcname is lowercase with no hyphens
   enter_program_common(funcname, funcname);
   parser_display_literal("You have been hijacked by a program named 
\"dubner\"");
-  gg_insert_into_assembler("# HIJACKED DUBNER CODE START");
+  gg_insert_into_assembler("%s HIJACKED DUBNER CODE START", ASM_COMMENT_START);
 
   for(int i=0; i<10; i++)
 {
@@ -13619,7 +13624,7 @@ hijack_for_development(const char *funcname)
 NULL_TREE);
 }
 
-  gg_insert_into_assembler("# HIJACKED DUBNER CODE END");
+  gg_insert_into_assembler("%s HIJACKED DUBNER CODE END", ASM_COMMENT_START);
   gg_return(0);
   }


[gcc r13-9520] [PR115568][LRA]: Use more strict output reload check in rematerialization

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:7578243dcd42855e4a8ae85ef8ab2598f0f6cbe9

commit r13-9520-g7578243dcd42855e4a8ae85ef8ab2598f0f6cbe9
Author: Vladimir N. Makarov 
Date:   Wed Feb 5 14:23:23 2025 -0500

[PR115568][LRA]: Use more strict output reload check in rematerialization

  In this PR case LRA rematerialized a value from inheritance insn
instead of output reload one.  This resulted in considering a
rematerilization candidate value available when it was actually
not.  As a consequence an insn after rematerliazation used the
unexpected value and this use resulted in fp exception.  The patch
fixes this bug.

gcc/ChangeLog:

PR rtl-optimization/115568
* lra-remat.cc (create_cands): Check that output reload insn is
adjacent to given insn.  Update a comment.

gcc/testsuite/ChangeLog:

PR rtl-optimization/115568
* gcc.target/i386/pr115568.c: New.

(cherry picked from commit 98545441308c2ae4d535f14b108ad6551fd927d5)

Diff:
---
 gcc/lra-remat.cc | 10 +
 gcc/testsuite/gcc.target/i386/pr115568.c | 38 
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index 681dcf36331c..f56130777b94 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -459,7 +459,8 @@ create_cands (void)
if (insn2 != NULL 
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
-   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn))
+   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
+   && insn2 == prev_nonnote_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
@@ -473,9 +474,10 @@ create_cands (void)
gcc_assert (REG_P (*id->operand_loc[nop]));
int regno = REGNO (*id->operand_loc[nop]);
gcc_assert (regno >= FIRST_PSEUDO_REGISTER);
-   /* If we're setting an unrenumbered pseudo, make a candidate 
immediately.
-  If it's an output reload register, save it for later; the code 
above
-  looks for output reload insns later on.  */
+   /* If we're setting an unrenumbered pseudo, make a candidate
+  immediately.  If it's a potential output reload register, save
+  it for later; the code above looks for output reload insns later
+  on.  */
if (reg_renumber[regno] < 0)
  create_cand (insn, nop, regno);
else if (regno >= lra_constraint_new_regno_start)
diff --git a/gcc/testsuite/gcc.target/i386/pr115568.c 
b/gcc/testsuite/gcc.target/i386/pr115568.c
new file mode 100644
index ..cedc7ac3843d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115568.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-sink -fno-tree-ter -fschedule-insns" } */
+
+int a, c, d = 1, e, f = 1, h, i, j;
+unsigned b = 1, g;
+int main() {
+  for (; h < 2; h++) {
+int k = ~(b || 0), l = ((~e - j) ^ a % b) % k, m = (b ^ -1) + e;
+unsigned o = ~a % ~1;
+if (f) {
+  l = d;
+  m = 10;
+  i = e;
+  d = -(~e + b);
+  g = o % m;
+  e = -1;
+n:
+  a = a % ~i;
+  b = ~k;
+  if (!g) {
+b = e + o % -1;
+continue;
+  }
+  if (!l)
+break;
+}
+int q = (~d + g) << ~e, p = (~d - q) & a >> b;
+unsigned s = ~((g & e) + (p | (b ^ (d + k;
+int r = (e & s) + p, u = d | ~a,
+t = ((~(q + (~a + (s + e & u) | (-g & (c << d ^ p));
+if (t)
+  if (!r)
+goto n;
+g = m;
+e = i;
+  }
+  return 0;
+}


[gcc r12-11035] rtl-optimization/119689 - compare-debug failure with LRA

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:6675cf3abd09731ec8360ba8ac8928b63b33b7bb

commit r12-11035-g6675cf3abd09731ec8360ba8ac8928b63b33b7bb
Author: Richard Biener 
Date:   Wed Apr 9 14:36:19 2025 +0200

rtl-optimization/119689 - compare-debug failure with LRA

The previous change to fix LRA rematerialization broke compare-debug
for i586 bootstrap.  Fixed by using prev_nonnote_nondebug_insn
instead of prev_nonnote_insn.

PR rtl-optimization/119689
PR rtl-optimization/115568
* lra-remat.cc (create_cands): Use prev_nonnote_nondebug_insn
to check whether insn2 is directly before insn.

* g++.target/i386/pr119689.C: New testcase.

(cherry picked from commit 07de7717a22b1503760e9b79dfbe22a0f428)

Diff:
---
 gcc/lra-remat.cc |  2 +-
 gcc/testsuite/g++.target/i386/pr119689.C | 44 
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index f565fe1d9390..2545fef3f9ac 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -460,7 +460,7 @@ create_cands (void)
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
-   && insn2 == prev_nonnote_insn (insn))
+   && insn2 == prev_nonnote_nondebug_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
diff --git a/gcc/testsuite/g++.target/i386/pr119689.C 
b/gcc/testsuite/g++.target/i386/pr119689.C
new file mode 100644
index ..cdc6d2dade53
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr119689.C
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+// { dg-additional-options "-march=i586 -mtune=generic" { target ia32 } }
+// { dg-additional-options "-fPIC" { target { fpic } } }
+
+enum gimple_code { GIMPLE_ASSIGN, GIMPLE_RETURN };
+bool is_gimple_call();
+int m_sig, m_exp, sreal_new_exp;
+struct sreal {
+  sreal(long long sig) {
+long long __trans_tmp_6 = sig >= 0 ? sig : -(unsigned long long)sig;
+sig = __trans_tmp_6 <<= sreal_new_exp -= m_exp = __trans_tmp_6;
+m_sig = sig;
+  }
+  void operator/(sreal);
+};
+struct ipa_predicate {
+  ipa_predicate(bool = true);
+  void operator&=(ipa_predicate);
+  void operator&(ipa_predicate);
+};
+void add_condition();
+gimple_code eliminated_by_inlining_prob_code;
+static int eliminated_by_inlining_prob() {
+  switch (eliminated_by_inlining_prob_code) {
+  case GIMPLE_RETURN:
+return 2;
+  case GIMPLE_ASSIGN:
+return 1;
+  }
+  return 0;
+}
+void fp_expression_p() {
+  ipa_predicate bb_predicate;
+  for (;;) {
+int prob = eliminated_by_inlining_prob();
+ipa_predicate sra_predicate;
+sra_predicate &= add_condition;
+if (is_gimple_call())
+  sreal(prob) / 2;
+if (prob != 2)
+  bb_predicate & sra_predicate;
+  }
+}


[gcc r15-9414] c++: improve constexpr call caching [PR115639]

2025-04-13 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:5869a881442aa4214d5deed7cfe0d352bcca1fd4

commit r15-9414-g5869a881442aa4214d5deed7cfe0d352bcca1fd4
Author: Patrick Palka 
Date:   Sun Apr 13 11:04:46 2025 -0400

c++: improve constexpr call caching [PR115639]

For the testcase from this PR, checking

  static_assert(0 == big_calc());

takes twice as much time as

  constexpr int ret = big_calc();
  static_assert(0 == ret);

ultimately because in the former, we first constant evaluate big_calc()
with mce_unknown (as part of warning-dependent folding from
cp_build_binary_op).  We then constant evaluate it a second time, with
mce_true, during finish_static_assert.  The result of the first
evaluation isn't reused because of the different mce_value, which in
general can give a different result.

But big_calc() here doesn't depend on mce_value at all (i.e. there's no if
consteval or __builtin_is_constant_evaluated calls, nested or otherwise)
so we should be able to reuse the result in such cases.  Specifically if a
constexpr call with mce_unknown succeeds, we can safely reuse the result
during a subsequent mce_true or mce_false evaluation.

This patch implements this by also caching a successful mce_unknown call
result into the corresponding mce_true and mce_false slots, so that such
a subsequent evaluation effectively reuses the mce_unknown result.  To
make it more convenient to access the cache slot for the same call with
different mce_value, this patch gives each constexpr_call entry three
result slots, one per mce_value, instead of having a distinct
constexpr_call entry for each mce_value.  And we can no longer use
NULL_TREE to denote the call is in progress; instead use unknown_type_node.

After this patch compile time for the above two fragments is the same.

PR c++/115639

gcc/cp/ChangeLog:

* constexpr.cc (struct constexpr_call): Add NSDMIs to each
field.  Replace 'result' data member with 3-element 'results'
array and a 'result' accessor function.  Remove
'manifestly_const_eval' data member.
(constexpr_call_hasher::equal): Adjust after constexpr_call
layout change.
(cxx_eval_call_expression): Likewise.  Define some local
variables closer to their first use.  Use unknown_type_node
instead of NULL_TREE as the "in progress" result.  After
successully evaluating a call with mce_unknown, also cache the
result in the corresponding mce_true and mce_false slots.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/constexpr.cc | 59 +++--
 1 file changed, 35 insertions(+), 24 deletions(-)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 0242425370f4..7e375823d648 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -1119,20 +1119,22 @@ explain_invalid_constexpr_fn (tree fun)
 
 struct GTY((for_user)) constexpr_call {
   /* Description of the constexpr function definition.  */
-  constexpr_fundef *fundef;
+  constexpr_fundef *fundef = nullptr;
   /* Parameter bindings environment.  A TREE_VEC of arguments.  */
-  tree bindings;
-  /* Result of the call.
-   NULL means the call is being evaluated.
+  tree bindings = NULL_TREE;
+  /* Result of the call, indexed by the value of
+ constexpr_ctx::manifestly_const_eval.
+   unknown_type_node means the call is being evaluated.
error_mark_node means that the evaluation was erroneous or otherwise
uncacheable (e.g. because it depends on the caller).
Otherwise, the actual value of the call.  */
-  tree result;
+  tree results[3] = { NULL_TREE, NULL_TREE, NULL_TREE };
   /* The hash of this call; we remember it here to avoid having to
  recalculate it when expanding the hash table.  */
-  hashval_t hash;
-  /* The value of constexpr_ctx::manifestly_const_eval.  */
-  enum mce_value manifestly_const_eval;
+  hashval_t hash = 0;
+
+  /* The result slot corresponding to the given mce_value.  */
+  tree& result (mce_value mce) { return results[1 + int(mce)]; }
 };
 
 struct constexpr_call_hasher : ggc_ptr_hash
@@ -1427,8 +1429,6 @@ constexpr_call_hasher::equal (constexpr_call *lhs, 
constexpr_call *rhs)
 return true;
   if (lhs->hash != rhs->hash)
 return false;
-  if (lhs->manifestly_const_eval != rhs->manifestly_const_eval)
-return false;
   if (!constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef))
 return false;
   return cp_tree_equal (lhs->bindings, rhs->bindings);
@@ -2855,9 +2855,6 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree 
t,
 {
   location_t loc = cp_expr_loc_or_input_loc (t);
   tree fun = get_function_named_in_call (t);
-  constexpr_call new_call
-= { NULL, NULL, NULL, 0, ctx->manifestly_const_eval };
-  int depth_ok;
 
   if (fun == NULL_TREE)
 r

[gcc r14-11599] [PR115568][LRA]: Use more strict output reload check in rematerialization

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:dc93babdcceb4293e4a64c0770786dc8aefc1a4e

commit r14-11599-gdc93babdcceb4293e4a64c0770786dc8aefc1a4e
Author: Vladimir N. Makarov 
Date:   Wed Feb 5 14:23:23 2025 -0500

[PR115568][LRA]: Use more strict output reload check in rematerialization

  In this PR case LRA rematerialized a value from inheritance insn
instead of output reload one.  This resulted in considering a
rematerilization candidate value available when it was actually
not.  As a consequence an insn after rematerliazation used the
unexpected value and this use resulted in fp exception.  The patch
fixes this bug.

gcc/ChangeLog:

PR rtl-optimization/115568
* lra-remat.cc (create_cands): Check that output reload insn is
adjacent to given insn.  Update a comment.

gcc/testsuite/ChangeLog:

PR rtl-optimization/115568
* gcc.target/i386/pr115568.c: New.

(cherry picked from commit 98545441308c2ae4d535f14b108ad6551fd927d5)

Diff:
---
 gcc/lra-remat.cc | 10 +
 gcc/testsuite/gcc.target/i386/pr115568.c | 38 
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index c84bf3c99386..88be1e027957 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -459,7 +459,8 @@ create_cands (void)
if (insn2 != NULL 
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
-   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn))
+   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
+   && insn2 == prev_nonnote_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
@@ -473,9 +474,10 @@ create_cands (void)
gcc_assert (REG_P (*id->operand_loc[nop]));
int regno = REGNO (*id->operand_loc[nop]);
gcc_assert (regno >= FIRST_PSEUDO_REGISTER);
-   /* If we're setting an unrenumbered pseudo, make a candidate 
immediately.
-  If it's an output reload register, save it for later; the code 
above
-  looks for output reload insns later on.  */
+   /* If we're setting an unrenumbered pseudo, make a candidate
+  immediately.  If it's a potential output reload register, save
+  it for later; the code above looks for output reload insns later
+  on.  */
if (reg_renumber[regno] < 0)
  create_cand (insn, nop, regno);
else if (regno >= lra_constraint_new_regno_start)
diff --git a/gcc/testsuite/gcc.target/i386/pr115568.c 
b/gcc/testsuite/gcc.target/i386/pr115568.c
new file mode 100644
index ..cedc7ac3843d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115568.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-sink -fno-tree-ter -fschedule-insns" } */
+
+int a, c, d = 1, e, f = 1, h, i, j;
+unsigned b = 1, g;
+int main() {
+  for (; h < 2; h++) {
+int k = ~(b || 0), l = ((~e - j) ^ a % b) % k, m = (b ^ -1) + e;
+unsigned o = ~a % ~1;
+if (f) {
+  l = d;
+  m = 10;
+  i = e;
+  d = -(~e + b);
+  g = o % m;
+  e = -1;
+n:
+  a = a % ~i;
+  b = ~k;
+  if (!g) {
+b = e + o % -1;
+continue;
+  }
+  if (!l)
+break;
+}
+int q = (~d + g) << ~e, p = (~d - q) & a >> b;
+unsigned s = ~((g & e) + (p | (b ^ (d + k;
+int r = (e & s) + p, u = d | ~a,
+t = ((~(q + (~a + (s + e & u) | (-g & (c << d ^ p));
+if (t)
+  if (!r)
+goto n;
+g = m;
+e = i;
+  }
+  return 0;
+}


[gcc r14-11600] rtl-optimization/119689 - compare-debug failure with LRA

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:31e31bbeea657496eaa2d8bf629f6e61c6cd1266

commit r14-11600-g31e31bbeea657496eaa2d8bf629f6e61c6cd1266
Author: Richard Biener 
Date:   Wed Apr 9 14:36:19 2025 +0200

rtl-optimization/119689 - compare-debug failure with LRA

The previous change to fix LRA rematerialization broke compare-debug
for i586 bootstrap.  Fixed by using prev_nonnote_nondebug_insn
instead of prev_nonnote_insn.

PR rtl-optimization/119689
PR rtl-optimization/115568
* lra-remat.cc (create_cands): Use prev_nonnote_nondebug_insn
to check whether insn2 is directly before insn.

* g++.target/i386/pr119689.C: New testcase.

(cherry picked from commit 07de7717a22b1503760e9b79dfbe22a0f428)

Diff:
---
 gcc/lra-remat.cc |  2 +-
 gcc/testsuite/g++.target/i386/pr119689.C | 44 
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index 88be1e027957..6e553030f22e 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -460,7 +460,7 @@ create_cands (void)
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
-   && insn2 == prev_nonnote_insn (insn))
+   && insn2 == prev_nonnote_nondebug_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
diff --git a/gcc/testsuite/g++.target/i386/pr119689.C 
b/gcc/testsuite/g++.target/i386/pr119689.C
new file mode 100644
index ..cdc6d2dade53
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr119689.C
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+// { dg-additional-options "-march=i586 -mtune=generic" { target ia32 } }
+// { dg-additional-options "-fPIC" { target { fpic } } }
+
+enum gimple_code { GIMPLE_ASSIGN, GIMPLE_RETURN };
+bool is_gimple_call();
+int m_sig, m_exp, sreal_new_exp;
+struct sreal {
+  sreal(long long sig) {
+long long __trans_tmp_6 = sig >= 0 ? sig : -(unsigned long long)sig;
+sig = __trans_tmp_6 <<= sreal_new_exp -= m_exp = __trans_tmp_6;
+m_sig = sig;
+  }
+  void operator/(sreal);
+};
+struct ipa_predicate {
+  ipa_predicate(bool = true);
+  void operator&=(ipa_predicate);
+  void operator&(ipa_predicate);
+};
+void add_condition();
+gimple_code eliminated_by_inlining_prob_code;
+static int eliminated_by_inlining_prob() {
+  switch (eliminated_by_inlining_prob_code) {
+  case GIMPLE_RETURN:
+return 2;
+  case GIMPLE_ASSIGN:
+return 1;
+  }
+  return 0;
+}
+void fp_expression_p() {
+  ipa_predicate bb_predicate;
+  for (;;) {
+int prob = eliminated_by_inlining_prob();
+ipa_predicate sra_predicate;
+sra_predicate &= add_condition;
+if (is_gimple_call())
+  sreal(prob) / 2;
+if (prob != 2)
+  bb_predicate & sra_predicate;
+  }
+}


[gcc r12-11034] [PR115568][LRA]: Use more strict output reload check in rematerialization

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:3232e151654f3998926c8e82a2ffd911c6e74df4

commit r12-11034-g3232e151654f3998926c8e82a2ffd911c6e74df4
Author: Vladimir N. Makarov 
Date:   Wed Feb 5 14:23:23 2025 -0500

[PR115568][LRA]: Use more strict output reload check in rematerialization

  In this PR case LRA rematerialized a value from inheritance insn
instead of output reload one.  This resulted in considering a
rematerilization candidate value available when it was actually
not.  As a consequence an insn after rematerliazation used the
unexpected value and this use resulted in fp exception.  The patch
fixes this bug.

gcc/ChangeLog:

PR rtl-optimization/115568
* lra-remat.cc (create_cands): Check that output reload insn is
adjacent to given insn.  Update a comment.

gcc/testsuite/ChangeLog:

PR rtl-optimization/115568
* gcc.target/i386/pr115568.c: New.

(cherry picked from commit 98545441308c2ae4d535f14b108ad6551fd927d5)

Diff:
---
 gcc/lra-remat.cc | 10 +
 gcc/testsuite/gcc.target/i386/pr115568.c | 38 
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index 5079eb50f28b..f565fe1d9390 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -459,7 +459,8 @@ create_cands (void)
if (insn2 != NULL 
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
-   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn))
+   && BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
+   && insn2 == prev_nonnote_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
@@ -473,9 +474,10 @@ create_cands (void)
gcc_assert (REG_P (*id->operand_loc[nop]));
int regno = REGNO (*id->operand_loc[nop]);
gcc_assert (regno >= FIRST_PSEUDO_REGISTER);
-   /* If we're setting an unrenumbered pseudo, make a candidate 
immediately.
-  If it's an output reload register, save it for later; the code 
above
-  looks for output reload insns later on.  */
+   /* If we're setting an unrenumbered pseudo, make a candidate
+  immediately.  If it's a potential output reload register, save
+  it for later; the code above looks for output reload insns later
+  on.  */
if (reg_renumber[regno] < 0)
  create_cand (insn, nop, regno);
else if (regno >= lra_constraint_new_regno_start)
diff --git a/gcc/testsuite/gcc.target/i386/pr115568.c 
b/gcc/testsuite/gcc.target/i386/pr115568.c
new file mode 100644
index ..cedc7ac3843d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115568.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-sink -fno-tree-ter -fschedule-insns" } */
+
+int a, c, d = 1, e, f = 1, h, i, j;
+unsigned b = 1, g;
+int main() {
+  for (; h < 2; h++) {
+int k = ~(b || 0), l = ((~e - j) ^ a % b) % k, m = (b ^ -1) + e;
+unsigned o = ~a % ~1;
+if (f) {
+  l = d;
+  m = 10;
+  i = e;
+  d = -(~e + b);
+  g = o % m;
+  e = -1;
+n:
+  a = a % ~i;
+  b = ~k;
+  if (!g) {
+b = e + o % -1;
+continue;
+  }
+  if (!l)
+break;
+}
+int q = (~d + g) << ~e, p = (~d - q) & a >> b;
+unsigned s = ~((g & e) + (p | (b ^ (d + k;
+int r = (e & s) + p, u = d | ~a,
+t = ((~(q + (~a + (s + e & u) | (-g & (c << d ^ p));
+if (t)
+  if (!r)
+goto n;
+g = m;
+e = i;
+  }
+  return 0;
+}


[gcc r13-9521] rtl-optimization/119689 - compare-debug failure with LRA

2025-04-13 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:1a2e39a5349a36deea33f5fb078edfe658daaf50

commit r13-9521-g1a2e39a5349a36deea33f5fb078edfe658daaf50
Author: Richard Biener 
Date:   Wed Apr 9 14:36:19 2025 +0200

rtl-optimization/119689 - compare-debug failure with LRA

The previous change to fix LRA rematerialization broke compare-debug
for i586 bootstrap.  Fixed by using prev_nonnote_nondebug_insn
instead of prev_nonnote_insn.

PR rtl-optimization/119689
PR rtl-optimization/115568
* lra-remat.cc (create_cands): Use prev_nonnote_nondebug_insn
to check whether insn2 is directly before insn.

* g++.target/i386/pr119689.C: New testcase.

(cherry picked from commit 07de7717a22b1503760e9b79dfbe22a0f428)

Diff:
---
 gcc/lra-remat.cc |  2 +-
 gcc/testsuite/g++.target/i386/pr119689.C | 44 
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index f56130777b94..38ac4808a236 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -460,7 +460,7 @@ create_cands (void)
&& dst_regno >= FIRST_PSEUDO_REGISTER
&& reg_renumber[dst_regno] < 0
&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
-   && insn2 == prev_nonnote_insn (insn))
+   && insn2 == prev_nonnote_nondebug_insn (insn))
  {
create_cand (insn2, regno_potential_cand[src_regno].nop,
 dst_regno, insn);
diff --git a/gcc/testsuite/g++.target/i386/pr119689.C 
b/gcc/testsuite/g++.target/i386/pr119689.C
new file mode 100644
index ..cdc6d2dade53
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr119689.C
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+// { dg-additional-options "-march=i586 -mtune=generic" { target ia32 } }
+// { dg-additional-options "-fPIC" { target { fpic } } }
+
+enum gimple_code { GIMPLE_ASSIGN, GIMPLE_RETURN };
+bool is_gimple_call();
+int m_sig, m_exp, sreal_new_exp;
+struct sreal {
+  sreal(long long sig) {
+long long __trans_tmp_6 = sig >= 0 ? sig : -(unsigned long long)sig;
+sig = __trans_tmp_6 <<= sreal_new_exp -= m_exp = __trans_tmp_6;
+m_sig = sig;
+  }
+  void operator/(sreal);
+};
+struct ipa_predicate {
+  ipa_predicate(bool = true);
+  void operator&=(ipa_predicate);
+  void operator&(ipa_predicate);
+};
+void add_condition();
+gimple_code eliminated_by_inlining_prob_code;
+static int eliminated_by_inlining_prob() {
+  switch (eliminated_by_inlining_prob_code) {
+  case GIMPLE_RETURN:
+return 2;
+  case GIMPLE_ASSIGN:
+return 1;
+  }
+  return 0;
+}
+void fp_expression_p() {
+  ipa_predicate bb_predicate;
+  for (;;) {
+int prob = eliminated_by_inlining_prob();
+ipa_predicate sra_predicate;
+sra_predicate &= add_condition;
+if (is_gimple_call())
+  sreal(prob) / 2;
+if (prob != 2)
+  bb_predicate & sra_predicate;
+  }
+}


[gcc r15-9415] Fortran: Fix runtime segfault closing negative unit

2025-04-13 Thread Jerry DeLisle via Gcc-cvs
https://gcc.gnu.org/g:ee6173800ed1f9b653a85019ad2fa8e6d883823a

commit r15-9415-gee6173800ed1f9b653a85019ad2fa8e6d883823a
Author: Jerry DeLisle 
Date:   Sat Apr 12 19:51:23 2025 -0700

Fortran: Fix runtime segfault closing negative unit

When closing a UNIT with an invalid negative unit
number, a segfault ensued. This patch adds checks
for these conditions and issues errors.

PR libfortran/119502

libgfortran/ChangeLog:

* io/close.c (st_close): Issue an error and avoid
calling close_share when there is no stream assigned.
* io/open.c (st_open): If there is no stream assigned
to the unit, unlock the unit and issue an error.

gcc/testsuite/ChangeLog:

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

Diff:
---
 gcc/testsuite/gfortran.dg/pr119502.f90 | 15 +++
 libgfortran/io/close.c | 13 +++--
 libgfortran/io/open.c  | 10 ++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/pr119502.f90 
b/gcc/testsuite/gfortran.dg/pr119502.f90
new file mode 100644
index ..80d7c6101656
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr119502.f90
@@ -0,0 +1,15 @@
+! { dg-do run }
+
+! PR119502, negative unit numbers are not allowed without using NEWUNIT
+
+program foo
+  integer :: iun = -1
+  integer :: ios
+  open (iun, iostat=ios)
+  if (ios == 0) stop 1
+  write(iun,*, iostat=ios) "This is a test."
+  if (ios == 0) stop 2
+  close (iun, iostat=ios)
+  if (ios == 0) stop 3
+end
+
diff --git a/libgfortran/io/close.c b/libgfortran/io/close.c
index 81223113dc5d..41d278c002c6 100644
--- a/libgfortran/io/close.c
+++ b/libgfortran/io/close.c
@@ -84,8 +84,17 @@ st_close (st_parameter_close *clp)
 
   if (u != NULL)
 {
-  if (close_share (u) < 0)
-   generate_error (&clp->common, LIBERROR_OS, "Problem in CLOSE");
+  if (u->s == NULL)
+   {
+ if (u->unit_number < 0)
+   generate_error (&clp->common, LIBERROR_BAD_UNIT,
+   "Unit number is negative with no associated file");
+ library_end ();
+ return;
+   }
+  else
+   if (close_share (u) < 0)
+ generate_error (&clp->common, LIBERROR_OS, "Problem in CLOSE");
   if (u->flags.status == STATUS_SCRATCH)
{
  if (status == CLOSE_KEEP)
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 06ddf7f4dc28..e9fb0a7b3b05 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -912,6 +912,16 @@ st_open (st_parameter_open *opp)
  library_end ();
  return;
}
+
+ if (u->s == NULL)
+   {
+ unlock_unit (u);
+ generate_error (&opp->common, LIBERROR_BAD_OPTION,
+   "Unit number is negative and unit was not already "
+   "opened with OPEN(NEWUNIT=...)");
+ library_end ();
+ return;
+   }
}
 
   if (u == NULL)


[gcc r15-9416] cobol: Avoid conflict with OVERFLOW in system headers [PR119217]

2025-04-13 Thread Rainer Orth via Gcc-cvs
https://gcc.gnu.org/g:b0fb746bf2ff533eccf3a4ea7fbbc02a9a1f8b81

commit r15-9416-gb0fb746bf2ff533eccf3a4ea7fbbc02a9a1f8b81
Author: Rainer Orth 
Date:   Sun Apr 13 22:48:44 2025 +0200

cobol: Avoid conflict with OVERFLOW in system headers [PR119217]

parse.h causes the COBOL build to break on Solaris:

cobol/parse.h:356:5: error: expected identifier before numeric constant
  356 | OVERFLOW = 305,/* OVERFLOW  */
  | ^~~~

The problem is that  has

#define OVERFLOW3

To avoid the conflict, this patch renames OVERFLOW to OVERFLOW_kw,
following existing praxis.

Btw., token_names.h has a comment claiming

// generated by ./token_names.h.gen ../../build/gcc/cobol/parse.h

but there's no token_names.h.gen anywhere in the tree, so I've updated
the file manually.

Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.


2025-04-08  Rainer Orth  

gcc/cobol:
PR cobol/119217
* parse.y: Rename OVERFLOW to OVERFLOW_kw.
Specify type name in %token directive.
* scan.l: Likewise.
* token_names.h: Regenerate.

Co-Authored-By: Simon Sobisch 

Diff:
---
 gcc/cobol/parse.y   | 12 ++--
 gcc/cobol/scan.l|  6 +++---
 gcc/cobol/token_names.h |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index d14cc3170b0e..55c26febe7eb 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -338,7 +338,7 @@
 %token  INVALID
 %token  NUMBER NEGATIVE
 %token  NUMSTR"numeric literal"
-%token  OVERFLOW
+%token  OVERFLOW_kw "OVERFLOW"
 %token   COMPUTATIONAL
 
 %token PERFORM BACKWARD
@@ -997,7 +997,7 @@
 DELETE DISPLAY DIVIDE EVALUATE END EOP EXIT FILLER_kw
 GOBACK GOTO
 INITIALIZE INSPECT
-MERGE MOVE MULTIPLY OPEN OVERFLOW PARAGRAPH PERFORM
+MERGE MOVE MULTIPLY OPEN OVERFLOW_kw PARAGRAPH PERFORM
 READ RELEASE RETURN REWRITE
 SEARCH SET SELECT SORT SORT_MERGE
 STRING_kw STOP SUBTRACT START
@@ -9488,7 +9488,7 @@ call_except:EXCEPTION
 std::swap($$.on_error, $$.not_error);
   }
 }
-|   OVERFLOW
+|   OVERFLOW_kw
 {
   $$.not_error = NULL;
   $$.on_error = label_add(LblArith,
@@ -9496,7 +9496,7 @@ call_except:EXCEPTION
   if( !$$.on_error ) YYERROR;
   parser_call_exception( $$.on_error );
 
-  assert( $1 == OVERFLOW || $1 == NOT );
+  assert( $1 == OVERFLOW_kw || $1 == NOT );
   if( $1 == NOT ) {
 std::swap($$.on_error, $$.not_error);
   }
@@ -9751,7 +9751,7 @@ on_overflows:   on_overflow[over] statements %prec ADD
 }
 ;
 
-on_overflow:OVERFLOW
+on_overflow:OVERFLOW_kw
 {
   $$.not_error = NULL;
   $$.on_error = label_add(LblString,
@@ -9759,7 +9759,7 @@ on_overflow:OVERFLOW
   if( !$$.on_error ) YYERROR;
   parser_string_overflow( $$.on_error );
 
-  assert( $1 == OVERFLOW || $1 == NOT );
+  assert( $1 == OVERFLOW_kw || $1 == NOT );
   if( $1 == NOT ) {
 std::swap($$.on_error, $$.not_error);
   }
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index 2cb7d3029f7c..e30634de9552 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -1543,9 +1543,9 @@ USE({SPC}FOR)?{ return USE; }
   NOT{SPC}(ON{SPC})?EXCEPTION {
   yylval.number = NOT;   return EXCEPTION; 
}
 
- (ON{SPC})?OVERFLOW  { yylval.number = OVERFLOW; return OVERFLOW; }
+ (ON{SPC})?OVERFLOW  { yylval.number = OVERFLOW_kw; return OVERFLOW_kw; }
   NOT{SPC}(ON{SPC})?OVERFLOW {
-  yylval.number = NOT;  return OVERFLOW; }
+  yylval.number = NOT;  return 
OVERFLOW_kw; }
 
  (AT{SPC})?END/[[:space:]]{ yylval.number = END;
return END; }
@@ -2312,7 +2312,7 @@ BASIS { yy_push_state(basis); return BASIS; }
   ORGANIZATION { return ORGANIZATION; }
   OTHER{ return OTHER; }
   OUTPUT   { return OUTPUT; }
-  OVERFLOW { return OVERFLOW; }
+  OVERFLOW { return OVERFLOW_kw; }
   OVERRIDE { return OVERRIDE; }
   PACKED-DECIMAL   { return PACKED_DECIMAL; }
   PAGE { return PAGE; }
diff --git a/gcc/cobol/token_names.h b/gcc/cobol/

[gcc r15-9408] s390: Add z17 scheduler description

2025-04-13 Thread Stefan Schulze Frielinghaus via Gcc-cvs
https://gcc.gnu.org/g:171710bec51ebbe859bf3ff008e60dd018738026

commit r15-9408-g171710bec51ebbe859bf3ff008e60dd018738026
Author: Stefan Schulze Frielinghaus 
Date:   Sun Apr 13 10:59:18 2025 +0200

s390: Add z17 scheduler description

gcc/ChangeLog:

* config/s390/s390.cc: Add z17 scheduler description.
* config/s390/s390.h: Ditto.
* config/s390/s390.md: Ditto.
* config/s390/9175.md: New file.

Diff:
---
 gcc/config/s390/9175.md | 316 
 gcc/config/s390/s390.cc |  31 -
 gcc/config/s390/s390.h  |   2 +-
 gcc/config/s390/s390.md |   5 +-
 4 files changed, 348 insertions(+), 6 deletions(-)

diff --git a/gcc/config/s390/9175.md b/gcc/config/s390/9175.md
new file mode 100644
index ..d0ac0e1c9b59
--- /dev/null
+++ b/gcc/config/s390/9175.md
@@ -0,0 +1,316 @@
+;; Scheduling description for z17.
+;; Copyright (C) 2025 Free Software Foundation, Inc.
+
+;; This file is part of GCC.
+
+;; GCC is free software; you can redistribute it and/or modify it under
+;; the terms of the GNU General Public License as published by the Free
+;; Software Foundation; either version 3, or (at your option) any later
+;; version.
+
+;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+;; for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; .
+
+(define_attr "z17_unit_fpd" ""
+ (cond [(eq_attr "mnemonic" "ddb,ddbr,deb,debr,dxbr,sqdb,sqdbr,sqeb,sqebr,\
+sqxbr,vdf,vdg,vdlf,vdlg,vdlq,vdq,vfddb,vfdsb,vfsqdb,vfsqsb,vrf,vrg,vrlf,vrlg,\
+vrlq,vrq,wfddb,wfdsb,wfdxb,wfsqdb,wfsqxb")
+ (const_int 1)] (const_int 0)))
+
+(define_attr "z17_unit_fxa" ""
+ (cond [(eq_attr "mnemonic" 
"a,afi,ag,agf,agfi,agfr,agh,aghi,aghik,agr,agrk,ah,\
+ahi,ahik,ahy,al,alc,alcg,alcgr,alcr,alfi,alg,algf,algfi,algfr,alghsik,algr,\
+algrk,alhsik,alr,alrk,aly,ar,ark,ay,bdepg,bextg,clzg,ctzg,etnd,flogr,ic,icm,\
+icmh,icmy,icy,iihf,iilf,ipm,la,larl,lay,lb,lbr,lcgfr,lcgr,lcr,lgb,lgbr,lgf,\
+lgfi,lgfr,lgfrl,lgh,lghi,lghr,lghrl,lgr,lh,lhi,lhr,lhrl,lhy,llcr,llgcr,llgfr,\
+llghr,llgtr,llhr,llihf,llihh,llihl,llilf,llilh,llill,llxab,llxaf,llxag,llxah,\
+llxaq,lngfr,lngr,lnr,loc,locg,locghi,locgr,lochi,locr,lpgfr,lpgr,lpr,lr,lrv,\
+lrvg,lrvgr,lrvh,lrvr,lt,ltg,ltgf,ltgfr,ltgr,ltr,lxab,lxaf,lxag,lxah,lxaq,m,mfy,\
+mg,mgh,mghi,mgrk,mh,mhi,mhy,ml,mlg,mlgr,mlr,mr,ms,msc,msfi,msg,msgc,msgf,msgfi,\
+msgfr,msgr,msgrkc,msr,msrkc,msy,n,ncgrk,ncrk,ng,ngr,ngrk,nihf,nihh,nihl,nilf,\
+nilh,nill,nngrk,nnrk,nogrk,nork,nr,nrk,nxgrk,nxrk,ny,o,ocgrk,ocrk,og,ogr,ogrk,\
+oihf,oihh,oihl,oilf,oilh,oill,or,ork,oy,pfpo,popcnt,risbg,risbgn,rll,rllg,\
+rnsbg,rosbg,rxsbg,s,selgr,selr,sg,sgf,sgfr,sgh,sgr,sgrk,sh,shy,sl,slb,slbg,\
+slbgr,slbr,sldl,slfi,slg,slgf,slgfi,slgfr,slgr,slgrk,sll,sllg,sllk,slr,slrk,\
+sly,sr,sra,srag,srak,srda,srdl,srk,srl,srlg,srlk,sy,x,xg,xgr,xgrk,xihf,xilf,xr,\
+xrk,xy")
+ (const_int 1)] (const_int 0)))
+
+(define_attr "z17_unit_fxb" ""
+ (cond [(eq_attr "mnemonic" "agsi,algsi,alsi,asi,b,bc,bcr,bi,br,c,cfi,cg,cgf,\
+cgfi,cgfr,cgfrl,cgh,cghi,cghrl,cghsi,cgit,cgr,cgrl,cgrt,ch,chi,chrl,chsi,chy,\
+cit,cl,clfhsi,clfi,clfit,clg,clgf,clgfi,clgfr,clgfrl,clghrl,clghsi,clgit,clgr,\
+clgrl,clgrt,clgt,clhhsi,clhrl,cli,cliy,clm,clmy,clr,clrl,clrt,clt,cly,cr,crl,\
+crt,cy,laa,laag,lan,lang,lao,laog,lat,lax,laxg,lcdfr,ldgr,ldr,lgat,lgdr,lndfr,\
+lpdfr,lxr,lzdr,lzer,lzxr,mvghi,mvhhi,mvhi,mvi,mviy,ni,niy,nop,nopr,ntstg,oi,\
+oiy,ppa,st,stc,stcy,std,stdy,ste,stey,stg,stgrl,sth,sthrl,sthy,stoc,stocg,strl,\
+strv,strvg,strvh,sty,tend,tm,tmh,tmhh,tmhl,tml,tmlh,tmll,tmy,vlgvb,vlgvf,vlgvg,\
+vlgvh,vlr,vlvgb,vlvgf,vlvgg,vlvgh,vlvgp,vscef,vsceg,vst,vstbrf,vstbrg,vstbrh,\
+vstbrq,vstebrf,vstebrg,vstef,vsteg,vsterf,vsterg,vsterh,vstl,vstrl,vstrlr,xi,\
+xiy")
+ (const_int 1)] (const_int 0)))
+
+(define_attr "z17_unit_fxd" ""
+ (cond [(eq_attr "mnemonic" "dlgr,dlr,dr,dsgfr,dsgr")
+ (const_int 1)] (const_int 0)))
+
+(define_attr "z17_unit_lsu" ""
+ (cond [(eq_attr "mnemonic" "clc,ear,l,lam,lcbb,ld,lde,ldy,lg,lgrl,llc,llgc,\
+llgf,llgfrl,llgh,llghrl,llgt,llh,llhrl,lm,lmg,lmy,lpq,lrl,ly,mvcrl,sar,sfpc,\
+tabort,vl,vlbb,vlbrf,vlbrg,vlbrh,vlbrq,vlbrrepf,vlbrrepg,vlbrreph,vlerf,vlerg,\
+vlerh,vll,vllebrzf,vllebrzg,vllebrzh,vllezb,vllezf,vllezg,vllezh,vllezlf,\
+vlrepb,vlrepf,vlrepg,vlreph,vlrl,vlrlr")
+ (const_int 1)] (const_int 0)))
+
+(define_attr "z17_unit_vfu" ""
+ (cond [(eq_attr "mnemonic" "adb,adbr,adtr,aeb,aebr,axbr,axtr,brcl,cdb,cdbr,\
+cdtr,ceb,cebr,cpsdr,cxbr,cxtr,ddtr,dxtr,fidbr,fidbra,fidtr,fiebr,fiebra,fixbr,\
+fixbra,fixtr,j,jg,kdb,kdbr,kdtr,keb,kebr,kxbr,kxtr,lcdbr,lcebr,lcxbr,ldeb,\
+ldebr,ldetr,le,ledbr,ledtr,ler,ley,lndbr,lnebr,lnxbr,lpdbr,lpebr,lpxbr,ltdbr,\
+ltdtr,ltebr,ltxbr,ltxtr,lxd

[gcc r15-9407] s390: Support z17 processor name

2025-04-13 Thread Stefan Schulze Frielinghaus via Gcc-cvs
https://gcc.gnu.org/g:1b290c16e591f6df3c5896d21b610df3444052d9

commit r15-9407-g1b290c16e591f6df3c5896d21b610df3444052d9
Author: Stefan Schulze Frielinghaus 
Date:   Sun Apr 13 10:59:18 2025 +0200

s390: Support z17 processor name

The recently announced IBM z17 processor implements the architecture
already supported as arch15.  This patch adds support for z17 as an
alternative architecture name for arch15.

gcc/ChangeLog:

* common/config/s390/s390-common.cc: Rename arch15 to z17.
* config.gcc: Add z17.
* config/s390/driver-native.cc: Detect z17 machine.
* config/s390/s390-builtins.def (B_VXE3): Rename arch15 to z17.
* config/s390/s390-c.cc (s390_resolve_overloaded_builtin): Ditto.
* config/s390/s390-opts.h (enum processor_type): Ditto.
* config/s390/s390.cc: Ditto.
* config/s390/s390.h: Ditto.
* config/s390/s390.md: Ditto.
* config/s390/s390.opt: Add z17.
* doc/invoke.texi: Ditto.

Diff:
---
 gcc/common/config/s390/s390-common.cc |  4 ++--
 gcc/config.gcc|  2 +-
 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   | 10 +-
 gcc/config/s390/s390.h| 16 
 gcc/config/s390/s390.md   | 34 +-
 gcc/config/s390/s390.opt  |  5 -
 gcc/doc/invoke.texi   |  2 +-
 11 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/gcc/common/config/s390/s390-common.cc 
b/gcc/common/config/s390/s390-common.cc
index 4b0691d5a16f..8a147d7f8043 100644
--- a/gcc/common/config/s390/s390-common.cc
+++ b/gcc/common/config/s390/s390-common.cc
@@ -54,10 +54,10 @@ EXPORTED_CONST int processor_flags_table[] =
 | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196 | PF_ZEC12 | PF_TX
 | PF_Z13 | PF_VX | PF_VXE | PF_Z14 | PF_VXE2 | PF_Z15
 | PF_NNPA | PF_Z16,
-/* arch15 */ PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
+/* z17 */PF_IEEE_FLOAT | PF_ZARCH | PF_LONG_DISPLACEMENT
 | PF_EXTIMM | PF_DFP | PF_Z10 | PF_Z196 | PF_ZEC12 | PF_TX
 | PF_Z13 | PF_VX | PF_VXE | PF_Z14 | PF_VXE2 | PF_Z15
-| PF_NNPA | PF_Z16 | PF_VXE3 | PF_ARCH15
+| PF_NNPA | PF_Z16 | PF_VXE3 | PF_Z17
   };
 
 /* Change optimizations to be performed, depending on the
diff --git a/gcc/config.gcc b/gcc/config.gcc
index f7f2002a45f3..40b50dc969ed 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -5756,7 +5756,7 @@ case "${target}" in
for which in arch tune; do
eval "val=\$with_$which"
case ${val} in
-   "" | native | z900 | z990 | z9-109 | z9-ec | z10 | z196 
| zEC12 | z13 | z14 | z15 | z16 | arch5 | arch6 | arch7 | arch8 | arch9 | 
arch10 | arch11 | arch12 | arch13 | arch14 | arch15 )
+   "" | native | z900 | z990 | z9-109 | z9-ec | z10 | z196 
| zEC12 | z13 | z14 | z15 | z16 | z17 | arch5 | arch6 | arch7 | arch8 | arch9 | 
arch10 | arch11 | arch12 | arch13 | arch14 | arch15 )
# OK
;;
*)
diff --git a/gcc/config/s390/driver-native.cc b/gcc/config/s390/driver-native.cc
index 49e8fa01a19b..7a7ceea9739c 100644
--- a/gcc/config/s390/driver-native.cc
+++ b/gcc/config/s390/driver-native.cc
@@ -127,6 +127,10 @@ s390_host_detect_local_cpu (int argc, const char **argv)
case 0x3932:
  cpu = "arch14";
  break;
+   case 0x9175:
+   case 0x9176:
+ cpu = "arch15";
+ break;
default:
  cpu = "arch15";
  break;
diff --git a/gcc/config/s390/s390-builtins.def 
b/gcc/config/s390/s390-builtins.def
index d9af9b13def1..cee2326e25c8 100644
--- a/gcc/config/s390/s390-builtins.def
+++ b/gcc/config/s390/s390-builtins.def
@@ -300,8 +300,8 @@
 #define B_VXE2  (1 << 4)  /* Builtins requiring the z15 vector extensions.  */
 #define B_DEP   (1 << 5)  /* Builtin has been deprecated and a warning should 
be issued.  */
 #define B_NNPA  (1 << 6)  /* Builtins requiring the NNPA Facility.  */
-#define B_VXE3  (1 << 7)  /* Builtins requiring the arch15 vector extensions.  
*/
-#define B_ARCH15 (1 << 8) /* Builtins requiring arch15.  */
+#define B_VXE3  (1 << 7)  /* Builtins requiring the z17 vector extensions.  */
+#define B_Z17   (1 << 8) /* Builtins requiring z17.  */
 
 /* B_DEF defines a standard (not overloaded) builtin
B_DEF (, , , , , )
@@ -3318,8 +3318,8 @@ B_DEF  (s390_vcnf,   vcnf_v8hi,   
  0,
 
 /* arch 15 builtins */
 
-B_DEF  (s390_bdepg, bdepg,  0

[gcc r15-9413] cobol: Avoid conflict with timespec_t in system headers [PR119217]

2025-04-13 Thread Rainer Orth via Gcc-cvs
https://gcc.gnu.org/g:962c3d69f189f6fa451153faf3ce261c50d23d5a

commit r15-9413-g962c3d69f189f6fa451153faf3ce261c50d23d5a
Author: Rainer Orth 
Date:   Sun Apr 13 12:53:54 2025 +0200

cobol: Avoid conflict with timespec_t in system headers [PR119217]

util.cc doesn't compile on Solaris:

/vol/gcc/src/hg/master/local/gcc/cobol/util.cc:2135:7: error: using 
typedef-name ‘timespec_t’ after ‘class’
 2135 | class timespec_t {
  |   ^~

This happens because  declares timespec_t itself.  In fact,
POSIX.1 reserves every *_t identifier, so this is benign.

To avoid the problem, this patch renames the cobol timespec_t to
cbl_timespec.

Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

2025-04-08  Rainer Orth  

gcc/cobol:
PR cobol/119217
* util.cc (class timespec_t): Rename to cbl_timespec.

Diff:
---
 gcc/cobol/util.cc | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index f7b89b817ccc..f28fddf6c8f7 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -2099,20 +2099,20 @@ cobol_fileline_set( const char line[] ) {
   return file.name;
 }
 
-class timespec_t {
+class cbl_timespec {
   struct timespec now;
  public:
-  timespec_t() {
+  cbl_timespec() {
 clock_gettime(CLOCK_MONOTONIC, &now);
   }
   double ns() const {
 return now.tv_sec * 10 + now.tv_nsec;
   }
-  friend double operator-( const timespec_t& now, const timespec_t& then );
+  friend double operator-( const cbl_timespec& now, const cbl_timespec& then );
 };
 
 double
-operator-( const timespec_t& then, const timespec_t& now ) {
+operator-( const cbl_timespec& then, const cbl_timespec& now ) {
   return (now.ns() - then.ns()) / 10;
 }
 
@@ -2125,11 +2125,11 @@ parse_file( const char filename[] )
 
   parser_enter_file(filename);
 
-  timespec_t start;
+  cbl_timespec start;
 
   int erc = yyparse();
 
-  timespec_t finish;
+  cbl_timespec finish;
   double dt  = finish - start;
   parser_leave_file();