[gcc r15-8283] Mark gcc.target/i386/apx-ndd-tls-1b.c as xfail.

2025-03-18 Thread hongtao Liu via Gcc-cvs
https://gcc.gnu.org/g:be671ec1f30ecd55aaff09048afb2a619018cb8a

commit r15-8283-gbe671ec1f30ecd55aaff09048afb2a619018cb8a
Author: liuhongt 
Date:   Sun Mar 16 22:28:44 2025 -0700

Mark gcc.target/i386/apx-ndd-tls-1b.c as xfail.

It looks like the testcase is fragile, it's supposed to check the
compiler ability of generating code_6_gottpoff_reloc instruction, but
failed since there's a seg_prefixed memory
usage(r14-6242-gd564198f960a2f).

mov r13, QWORD PTR j@gottpoff[rip]
mov r12, QWORD PTR a@gottpoff[rip]
mov rbp, QWORD PTR [rsp+1040]
lea rbx, [rsp+1040]
add r14, QWORD PTR fs:0, r12

gcc/testsuite/ChangeLog:

PR target/117069
* gcc.target/i386/apx-ndd-tls-1b.c: Add xfail.

Diff:
---
 gcc/testsuite/gcc.target/i386/apx-ndd-tls-1b.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/apx-ndd-tls-1b.c 
b/gcc/testsuite/gcc.target/i386/apx-ndd-tls-1b.c
index d0637034f117..afcad0ce3233 100644
--- a/gcc/testsuite/gcc.target/i386/apx-ndd-tls-1b.c
+++ b/gcc/testsuite/gcc.target/i386/apx-ndd-tls-1b.c
@@ -3,7 +3,10 @@
 /* { dg-require-effective-target tls } */
 /* { dg-require-effective-target code_6_gottpoff_reloc } */
 /* { dg-options "-save-temps -std=gnu17 -mapxf -O3 -w" } */
-
+/* The testcase is fragile, it's supposed to check the compiler
+   ability of generating code_6_gottpoff_reloc instruction, but
+   failed since there's a seg_prefixed memory
+   usage(r14-6242-gd564198f960a2f).  */
 #include "apx-ndd-tls-1a.c"
 
-/* { dg-final { scan-assembler-times "addq\[ \t]+%r\[a-z0-9\]+, 
a@gottpoff\\(%rip\\), %r\[a-z0-9\]+" 1 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "addq\[ \t]+%r\[a-z0-9\]+, 
a@gottpoff\\(%rip\\), %r\[a-z0-9\]+" 1 { xfail lp64 } } } */


[gcc r15-8268] d: Update the copyright years of dmd sources to 2025

2025-03-18 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:f2af60465cd129b8deb3283baaf8fbac1a5941d4

commit r15-8268-gf2af60465cd129b8deb3283baaf8fbac1a5941d4
Author: Iain Buclaw 
Date:   Sat Mar 15 16:32:48 2025 +0100

d: Update the copyright years of dmd sources to 2025

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 51be8bb729.

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

Diff:
---
 gcc/d/dmd/MERGE  | 2 +-
 gcc/d/dmd/access.d   | 2 +-
 gcc/d/dmd/aggregate.d| 2 +-
 gcc/d/dmd/aggregate.h| 2 +-
 gcc/d/dmd/aliasthis.d| 2 +-
 gcc/d/dmd/aliasthis.h| 2 +-
 gcc/d/dmd/arrayop.d  | 2 +-
 gcc/d/dmd/arraytypes.d   | 2 +-
 gcc/d/dmd/arraytypes.h   | 2 +-
 gcc/d/dmd/ast_node.d | 2 +-
 gcc/d/dmd/ast_node.h | 2 +-
 gcc/d/dmd/astenums.d | 2 +-
 gcc/d/dmd/attrib.d   | 2 +-
 gcc/d/dmd/attrib.h   | 2 +-
 gcc/d/dmd/attribsem.d| 2 +-
 gcc/d/dmd/blockexit.d| 2 +-
 gcc/d/dmd/builtin.d  | 2 +-
 gcc/d/dmd/canthrow.d | 2 +-
 gcc/d/dmd/chkformat.d| 2 +-
 gcc/d/dmd/clone.d| 2 +-
 gcc/d/dmd/common/bitfields.d | 2 +-
 gcc/d/dmd/common/charactertables.d   | 2 +-
 gcc/d/dmd/common/charactertables.h   | 2 +-
 gcc/d/dmd/common/file.d  | 2 +-
 gcc/d/dmd/common/outbuffer.d | 2 +-
 gcc/d/dmd/common/outbuffer.h | 2 +-
 gcc/d/dmd/common/smallbuffer.d   | 2 +-
 gcc/d/dmd/compiler.d | 2 +-
 gcc/d/dmd/compiler.h | 2 +-
 gcc/d/dmd/cond.d | 2 +-
 gcc/d/dmd/cond.h | 2 +-
 gcc/d/dmd/constfold.d| 2 +-
 gcc/d/dmd/cparse.d   | 2 +-
 gcc/d/dmd/ctfe.h | 2 +-
 gcc/d/dmd/ctfeexpr.d | 2 +-
 gcc/d/dmd/ctorflow.d | 2 +-
 gcc/d/dmd/cxxfrontend.d  | 2 +-
 gcc/d/dmd/dcast.d| 2 +-
 gcc/d/dmd/dclass.d   | 2 +-
 gcc/d/dmd/declaration.d  | 2 +-
 gcc/d/dmd/declaration.h  | 2 +-
 gcc/d/dmd/delegatize.d   | 2 +-
 gcc/d/dmd/denum.d| 2 +-
 gcc/d/dmd/deps.d | 2 +-
 gcc/d/dmd/dimport.d  | 2 +-
 gcc/d/dmd/dinterpret.d   | 2 +-
 gcc/d/dmd/dmacro.d   | 2 +-
 gcc/d/dmd/dmodule.d  | 2 +-
 gcc/d/dmd/doc.d  | 2 +-
 gcc/d/dmd/doc.h  | 2 +-
 gcc/d/dmd/dscope.d   | 2 +-
 gcc/d/dmd/dstruct.d  | 2 +-
 gcc/d/dmd/dsymbol.d  | 2 +-
 gcc/d/dmd/dsymbol.h  | 2 +-
 gcc/d/dmd/dsymbolsem.d   | 2 +-
 gcc/d/dmd/dtemplate.d| 2 +-
 gcc/d/dmd/dtoh.d | 2 +-
 gcc/d/dmd/dversion.d | 2 +-
 gcc/d/dmd/entity.d   | 2 +-
 gcc/d/dmd/enum.h | 2 +-
 gcc/d/dmd/enumsem.d  | 2 +-
 gcc/d/dmd/errors.d   | 2 +-
 gcc/d/dmd/errors.h   | 2 +-
 gcc/d/dmd/errorsink.d| 2 +-
 gcc/d/dmd/escape.d   | 2 +-
 gcc/d/dmd/expression.d   | 2 +-
 gcc/d/dmd/expression.h   | 2 +-
 gcc/d/dmd/expressionsem.d| 2 +-
 gcc/d/dmd/file_manager.d | 2 +-
 gcc/d/dmd/func.d | 2 +-
 gcc/d/dmd/funcsem.d  | 2 +-
 gcc/d/dmd/globals.d  | 4 ++--
 gcc/d/dmd/globals.h  | 2 +-
 gcc/d/dmd/gluelayer.d| 2 +-
 gcc/d/dmd/hdrgen.d   | 2 +-
 gcc/d/dmd/hdrgen.h   | 2 +-
 gcc/d/dmd/iasm.d | 2 +-
 gcc/d/dmd/iasmgcc.d  | 2 +-
 gcc/d/dmd/id.d   | 2 +-
 gcc/d/dmd/id.h   | 2 +-
 gcc/d/dmd/identifier.d   | 2 +-
 gcc/d/dmd/identifier.h   | 2 +-
 gcc/d/dmd/impcnvtab.d| 2 +-
 gcc/d/dmd/imphint.d  | 2 +-
 gcc/d/dmd/import.h   | 2 +-
 gcc/d/dmd/importc.d  | 2 +-
 gcc/d/dmd/init.d  

[gcc r15-8270] d: Add missing Declaration bitfield setters/getters

2025-03-18 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:a03e9d4932713c1696bb2bc134da8e8eac3edb94

commit r15-8270-ga03e9d4932713c1696bb2bc134da8e8eac3edb94
Author: Iain Buclaw 
Date:   Tue Mar 18 18:47:45 2025 +0100

d: Add missing Declaration bitfield setters/getters

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd fde0f8c40a.

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

Diff:
---
 gcc/d/dmd/MERGE | 2 +-
 gcc/d/dmd/declaration.h | 4 
 gcc/d/dmd/func.d| 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 57973b181157..1be4da416f45 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-51be8bb729cfa41ff5af4f5b2a9b7b9902bfdaa1
+fde0f8c40a1b8eb78c3485cb0e940035bfe6fb00
 
 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/declaration.h b/gcc/d/dmd/declaration.h
index c535e4cbb14a..c7e45526084d 100644
--- a/gcc/d/dmd/declaration.h
+++ b/gcc/d/dmd/declaration.h
@@ -128,6 +128,10 @@ public:
 short inuse;// used to detect cycles
 uint8_t bitFields;
 
+LINK _linkage() const;
+LINK _linkage(LINK v);
+bool noUnderscore() const;
+
 const char *kind() const override;
 uinteger_t size(Loc loc) override final;
 
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d
index cc17be741c30..e96c3326b758 100644
--- a/gcc/d/dmd/func.d
+++ b/gcc/d/dmd/func.d
@@ -1006,12 +1006,12 @@ extern (C++) class FuncDeclaration : Declaration
 /**
  * Generate a FuncDeclaration for a runtime library function.
  */
-extern (D) static FuncDeclaration genCfunc(Parameters* fparams, Type 
treturn, const(char)* name, STC stc = STC.none)
+extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type 
treturn, const(char)* name, STC stc = STC.none)
 {
 return genCfunc(fparams, treturn, Identifier.idPool(name[0 .. 
strlen(name)]), stc);
 }
 
-extern (D) static FuncDeclaration genCfunc(Parameters* fparams, Type 
treturn, Identifier id, STC stc = STC.none)
+extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type 
treturn, Identifier id, STC stc = STC.none)
 {
 FuncDeclaration fd;
 TypeFunction tf;


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: improve prelive conditions (USE, TRAP_IF)

2025-03-18 Thread Ondrej Machota via Gcc-cvs
https://gcc.gnu.org/g:a9bdb2c0c422b9d8d054c8dfe33892b85d01bcd3

commit a9bdb2c0c422b9d8d054c8dfe33892b85d01bcd3
Author: Ondřej Machota 
Date:   Tue Mar 18 20:40:21 2025 +0100

rtl-ssa-dce: improve prelive conditions (USE, TRAP_IF)

Diff:
---
 gcc/dce.cc | 31 +--
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index 74c1a6f8a879..6152b985ca31 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -1314,6 +1314,8 @@ bool sets_global_register(const_rtx rtx) {
 
 // We should mark stack registers
 // use HARD_FRAME_POINTER_REGNUM, REGNO_PTR_FRAME_P
+// muzeme mit parallel, ktery ma napr. dva single sety, nebo asm statement
+// pouzit note_pattern_stores nebo note_stores
 bool sets_global_register(rtx_insn* insn) {
   rtx set = single_set(insn);
   if (!set)
@@ -1334,25 +1336,6 @@ bool sets_global_register(rtx_insn* insn) {
   return false;
 }
 
-bool is_control_flow(rtx_code code) {
-  // What about BARRIERs?
-  switch (code) {
-case JUMP_INSN:
-case JUMP_TABLE_DATA: // Be careful with Table jump addresses - ADDR_VEC, 
ADDR_DIFF_VEC, PREFETCH 
-case TRAP_IF:
-case IF_THEN_ELSE: // Also COMPARE?
-case COND_EXEC: // We might want to check the operation that is under this?
-case RETURN:
-case SIMPLE_RETURN:
-case EH_RETURN:
-case LABEL_REF:
-  return true;
-
-default:
-  return false;
-  }
-}
-
 bool side_effects_with_mem (const_rtx x)
 {
   const RTX_CODE code = GET_CODE (x);
@@ -1393,8 +1376,8 @@ bool side_effects_with_mem (const_rtx x)
return true;
 
 // This should rather by RTX_BODY in is_rtx_insn_prelive - like global 
clobber
-case USE:
-  return true;
+// case USE:
+  // return true;
 
 default:
   break;
@@ -1475,6 +1458,9 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   if (GET_CODE(body) == PREFETCH)
 return true;
 
+  if (GET_CODE(body) == USE || GET_CODE(body) == TRAP_IF || GET_CODE(body) == 
UNSPEC)
+return true;
+
   // See deletable_insn_p_1 for UNSPEC. TRAP_IF is caught by 
may_trap_or_fault_p
 
   // may_trap_or_fault_p helps a lot to pass some tests from 
RUNTESTSFLAGS=execute.exp
@@ -1482,7 +1468,8 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   // TODO : debug the testcase
   // It seems that the issue was due to trap_if rtl insn and fixed with 
may_trap_or_fault_p
   // What about can_throw_internal?
-  if (side_effects_with_mem(body) || can_throw_internal(body) || 
may_trap_or_fault_p(body))
+  // || can_throw_internal(body) - testy na ntb prochazi
+  if (side_effects_with_mem(body)) // || may_trap_or_fault_p(body))
 return true;
 
   return false;


[gcc r15-8281] AVR: target/119355 - Fix ICE in pass avr-fuse-move / -mfuse-move.

2025-03-18 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:16065b6239aab2eecfd7a50f58d38324ee6478ba

commit r15-8281-g16065b6239aab2eecfd7a50f58d38324ee6478ba
Author: Georg-Johann Lay 
Date:   Tue Mar 18 21:22:22 2025 +0100

AVR: target/119355 - Fix ICE in pass avr-fuse-move / -mfuse-move.

This ICE only occurred when the compiler is built with, say
CXXFLAGS='-Wp,-D_GLIBCXX_ASSERTIONS'.  The problem was that
a value from an illegal REGNO was read.  The value was not
used in these cases, but the access triggered an assertion
due to reading past std::array.

gcc/
PR target/119355
* config/avr/avr-passes.cc (memento_t::apply): Only
read values[p.arg] when it is actually used.

Diff:
---
 gcc/config/avr/avr-passes.cc | 54 ++--
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc
index e32c46738d81..184619af6cb4 100644
--- a/gcc/config/avr/avr-passes.cc
+++ b/gcc/config/avr/avr-passes.cc
@@ -2205,9 +2205,6 @@ memento_t::apply (const ply_t &p)
 }
   else if (p.size == 1)
 {
-  int x = values[p.regno];
-  int y = values[p.arg];
-
   switch (p.code)
{
default:
@@ -2234,29 +2231,42 @@ memento_t::apply (const ply_t &p)
gcc_unreachable ();
  break;
 
-#define DO_ARITH(n_args, code, expr)   \
+#define DO_ARITH1(code, expr)  \
+ case code:\
+   gcc_assert (knows (p.regno));   \
+   {   \
+ const int x = values[p.regno];\
+ set_value (p.regno, expr);\
+   }   \
+   break
+
+#define DO_ARITH2(code, expr)  \
  case code:\
gcc_assert (knows (p.regno));   \
-   if (n_args == 2)\
- gcc_assert (knows (p.arg));   \
-   set_value (p.regno, expr);  \
+   gcc_assert (knows (p.arg)); \
+   {   \
+ const int x = values[p.regno];\
+ const int y = values[p.arg];  \
+ set_value (p.regno, expr);\
+   }   \
break
 
- DO_ARITH (1, NEG, -x);
- DO_ARITH (1, NOT, ~x);
- DO_ARITH (1, PRE_INC, x + 1);
- DO_ARITH (1, PRE_DEC, x - 1);
- DO_ARITH (1, ROTATE, (x << 4) | (x >> 4));
- DO_ARITH (1, ASHIFT, x << 1);
- DO_ARITH (1, LSHIFTRT, x >> 1);
- DO_ARITH (1, ASHIFTRT, (x >> 1) | (x & 0x80));
-
- DO_ARITH (2, AND, x & y);
- DO_ARITH (2, IOR, x | y);
- DO_ARITH (2, XOR, x ^ y);
- DO_ARITH (2, PLUS, x + y);
- DO_ARITH (2, MINUS, x - y);
-#undef DO_ARITH
+ DO_ARITH1 (NEG, -x);
+ DO_ARITH1 (NOT, ~x);
+ DO_ARITH1 (PRE_INC, x + 1);
+ DO_ARITH1 (PRE_DEC, x - 1);
+ DO_ARITH1 (ROTATE, (x << 4) | (x >> 4));
+ DO_ARITH1 (ASHIFT, x << 1);
+ DO_ARITH1 (LSHIFTRT, x >> 1);
+ DO_ARITH1 (ASHIFTRT, (x >> 1) | (x & 0x80));
+
+ DO_ARITH2 (AND, x & y);
+ DO_ARITH2 (IOR, x | y);
+ DO_ARITH2 (XOR, x ^ y);
+ DO_ARITH2 (PLUS, x + y);
+ DO_ARITH2 (MINUS, x - y);
+#undef DO_ARITH1
+#undef DO_ARITH2
}
 } // size == 1
   else


[gcc r14-11417] c++: ICE with ptr-to-member-fn [PR119344]

2025-03-18 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:0910ebacff1ef3401ee578d947c91e348feb3465

commit r14-11417-g0910ebacff1ef3401ee578d947c91e348feb3465
Author: Marek Polacek 
Date:   Mon Mar 17 17:46:02 2025 -0400

c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of 
save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka 
Reviewed-by: Jason Merrill 
(cherry picked from commit 6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1)

Diff:
---
 gcc/cp/typeck.cc   | 20 ++--
 gcc/testsuite/g++.dg/conversion/ptrmem10.C | 14 ++
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index a3b1e52f2243..6e938f168a4c 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -5431,7 +5431,7 @@ cp_build_binary_op (const op_location_t &location,
   case stv_firstarg:
 {
   op0 = convert (TREE_TYPE (type1), op0);
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
   op0 = build_vector_from_val (type1, op0);
  orig_type0 = type0 = TREE_TYPE (op0);
   code0 = TREE_CODE (type0);
@@ -5441,7 +5441,7 @@ cp_build_binary_op (const op_location_t &location,
   case stv_secondarg:
 {
   op1 = convert (TREE_TYPE (type0), op1);
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
   op1 = build_vector_from_val (type0, op1);
  orig_type1 = type1 = TREE_TYPE (op1);
   code1 = TREE_CODE (type1);
@@ -5965,9 +5965,9 @@ cp_build_binary_op (const op_location_t &location,
return error_mark_node;
 
  if (TREE_SIDE_EFFECTS (op0))
-   op0 = save_expr (op0);
+   op0 = cp_save_expr (op0);
  if (TREE_SIDE_EFFECTS (op1))
-   op1 = save_expr (op1);
+   op1 = cp_save_expr (op1);
 
  pfn0 = pfn_from_ptrmemfunc (op0);
  pfn0 = cp_fully_fold (pfn0);
@@ -6203,8 +6203,8 @@ cp_build_binary_op (const op_location_t &location,
  && !processing_template_decl
  && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
{
- op0 = save_expr (op0);
- op1 = save_expr (op1);
+ op0 = cp_save_expr (op0);
+ op1 = cp_save_expr (op1);
 
  tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
  instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
@@ -6464,14 +6464,14 @@ cp_build_binary_op (const op_location_t &location,
return error_mark_node;
  if (first_complex)
{
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
  real = cp_build_unary_op (REALPART_EXPR, op0, true, complain);
  imag = cp_build_unary_op (IMAGPART_EXPR, op0, true, complain);
  switch (code)
{
case MULT_EXPR:
case TRUNC_DIV_EXPR:
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
  imag = build2 (resultcode, real_type, imag, op1);
  /* Fall through.  */
case PLUS_EXPR:
@@ -6484,13 +6484,13 @@ cp_build_binary_op (const op_location_t &location,
}
  else
{
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
  real = cp_build_unary_op (REALPART_EXPR, op1, true, complain);
  imag = cp_build_unary_op (IMAGPART_EXPR, op1, true, complain);
  switch (code)
{
case MULT_EXPR:
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
  imag = build2 (resultcode, real_type, op0, imag);
  /* Fall through.  */
case PLUS_EXPR:
diff --git a/gcc/testsuite/g++.dg/conversion/ptrmem10.C 
b/gcc/testsuite/g++.dg/conversion/ptrmem10.C
new file mode 100644
index ..b5fc050ee814
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/ptrmem10.C
@@ -0,0 +1,14 @@
+// PR c++/119344
+// { dg-do compile { target c++11 } }
+
+struct S {
+void fn();
+};
+typedef void (S::*T)(void);
+template 
+struct s
+{
+  static const bool t = Ptr != T();
+};
+
+int t1 = s<&S::fn>::t;


[gcc r15-8280] c++: ICE with ptr-to-member-fn [PR119344]

2025-03-18 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1

commit r15-8280-g6fc1f70f0b7b50fd85aa58a0f29dd1e17f2113d1
Author: Marek Polacek 
Date:   Mon Mar 17 17:46:02 2025 -0400

c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of 
save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka 
Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/typeck.cc   | 20 ++--
 gcc/testsuite/g++.dg/conversion/ptrmem10.C | 14 ++
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 4b382b95de17..c8e4441fb8b4 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -5480,7 +5480,7 @@ cp_build_binary_op (const op_location_t &location,
   case stv_firstarg:
 {
   op0 = convert (TREE_TYPE (type1), op0);
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
   op0 = build_vector_from_val (type1, op0);
  orig_type0 = type0 = TREE_TYPE (op0);
   code0 = TREE_CODE (type0);
@@ -5490,7 +5490,7 @@ cp_build_binary_op (const op_location_t &location,
   case stv_secondarg:
 {
   op1 = convert (TREE_TYPE (type0), op1);
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
   op1 = build_vector_from_val (type0, op1);
  orig_type1 = type1 = TREE_TYPE (op1);
   code1 = TREE_CODE (type1);
@@ -6019,9 +6019,9 @@ cp_build_binary_op (const op_location_t &location,
return error_mark_node;
 
  if (TREE_SIDE_EFFECTS (op0))
-   op0 = save_expr (op0);
+   op0 = cp_save_expr (op0);
  if (TREE_SIDE_EFFECTS (op1))
-   op1 = save_expr (op1);
+   op1 = cp_save_expr (op1);
 
  pfn0 = pfn_from_ptrmemfunc (op0);
  pfn0 = cp_fully_fold (pfn0);
@@ -6262,8 +6262,8 @@ cp_build_binary_op (const op_location_t &location,
  && !processing_template_decl
  && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
{
- op0 = save_expr (op0);
- op1 = save_expr (op1);
+ op0 = cp_save_expr (op0);
+ op1 = cp_save_expr (op1);
 
  tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
  instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
@@ -6523,14 +6523,14 @@ cp_build_binary_op (const op_location_t &location,
return error_mark_node;
  if (first_complex)
{
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
  real = cp_build_unary_op (REALPART_EXPR, op0, true, complain);
  imag = cp_build_unary_op (IMAGPART_EXPR, op0, true, complain);
  switch (code)
{
case MULT_EXPR:
case TRUNC_DIV_EXPR:
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
  imag = build2 (resultcode, real_type, imag, op1);
  /* Fall through.  */
case PLUS_EXPR:
@@ -6543,13 +6543,13 @@ cp_build_binary_op (const op_location_t &location,
}
  else
{
- op1 = save_expr (op1);
+ op1 = cp_save_expr (op1);
  real = cp_build_unary_op (REALPART_EXPR, op1, true, complain);
  imag = cp_build_unary_op (IMAGPART_EXPR, op1, true, complain);
  switch (code)
{
case MULT_EXPR:
- op0 = save_expr (op0);
+ op0 = cp_save_expr (op0);
  imag = build2 (resultcode, real_type, op0, imag);
  /* Fall through.  */
case PLUS_EXPR:
diff --git a/gcc/testsuite/g++.dg/conversion/ptrmem10.C 
b/gcc/testsuite/g++.dg/conversion/ptrmem10.C
new file mode 100644
index ..b5fc050ee814
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/ptrmem10.C
@@ -0,0 +1,14 @@
+// PR c++/119344
+// { dg-do compile { target c++11 } }
+
+struct S {
+void fn();
+};
+typedef void (S::*T)(void);
+template 
+struct s
+{
+  static const bool t = Ptr != T();
+};
+
+int t1 = s<&S::fn>::t;


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: mark global regs as prelive with ssa

2025-03-18 Thread Ondrej Machota via Gcc-cvs
https://gcc.gnu.org/g:675ceb0fa20e7a1a3800e54dde2686d7ad8c5997

commit 675ceb0fa20e7a1a3800e54dde2686d7ad8c5997
Author: Ondřej Machota 
Date:   Tue Mar 18 22:55:02 2025 +0100

rtl-ssa-dce: mark global regs as prelive with ssa

Diff:
---
 gcc/dce.cc | 100 -
 1 file changed, 45 insertions(+), 55 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index 6152b985ca31..5cc9f3129067 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -1303,15 +1303,6 @@ public:
 
 } // namespace
 
-
-bool sets_global_register(const_rtx rtx) {
-  auto code = GET_CODE(rtx);
-  if (GET_RTX_CLASS(code) != RTX_INSN)
-return false;
-
-  return sets_global_register(static_cast(rtx));
-}
-
 // We should mark stack registers
 // use HARD_FRAME_POINTER_REGNUM, REGNO_PTR_FRAME_P
 // muzeme mit parallel, ktery ma napr. dva single sety, nebo asm statement
@@ -1324,12 +1315,12 @@ bool sets_global_register(rtx_insn* insn) {
   rtx dest = SET_DEST(set);
 
   // TODO : rewrite to simple return
-  //std::cerr << "first pseudo: " << FIRST_PSEUDO_REGISTER << '\n';
+  std::cerr << "first pseudo: " << FIRST_PSEUDO_REGISTER << '\n';
   //std::cerr << "register: " << REGNO(dest) << "\n";
   //debug(insn);
   // If I understand correctly, global_regs[i] is 1 iff reg i is used
   if (REG_P(dest) && HARD_REGISTER_NUM_P(REGNO(dest))) { // && 
global_regs[REGNO(dest)]
-//std::cerr << "sets_global_register: true\n";
+std::cerr << "sets_global_register: true\n";
 return true;
   }
 
@@ -1375,10 +1366,6 @@ bool side_effects_with_mem (const_rtx x)
 case ASM_OPERANDS:
return true;
 
-// This should rather by RTX_BODY in is_rtx_insn_prelive - like global 
clobber
-// case USE:
-  // return true;
-
 default:
   break;
 }
@@ -1448,8 +1435,8 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
 return true;
 
   // Mark set of a global register
-  if (sets_global_register(insn)) // check rtx_class with GET_RTX_CLASS if 
RTX_ISNS and convert if needed
-return true;
+  // if (sets_global_register(insn)) // check rtx_class with GET_RTX_CLASS if 
RTX_ISNS and convert if needed
+  //   return true;
 
   rtx body = PATTERN(insn);
   if (GET_CODE(body) == CLOBBER) // 
gcc/gcc/testsuite/gcc.c-torture/compile/2605-1.c
@@ -1469,7 +1456,7 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   // It seems that the issue was due to trap_if rtl insn and fixed with 
may_trap_or_fault_p
   // What about can_throw_internal?
   // || can_throw_internal(body) - testy na ntb prochazi
-  if (side_effects_with_mem(body)) // || may_trap_or_fault_p(body))
+  if (side_effects_with_mem(body)) // || may_trap_or_fault_p(body)) // 
replaced by TRAP_IF
 return true;
 
   return false;
@@ -1503,39 +1490,28 @@ bool is_prelive(insn_info *insn)
   gcc_assert (insn->is_real());
   auto rtl = insn->rtl();
 
-  if (!INSN_P(rtl)) // This might be useless
-return false;
+  for (auto&& __def : insn->defs()) {
+def_info * def = __def;
+if (!def->is_reg()) {
+  continue;
+}
+
+// this ignore clobbers, which is probably fine
+if (def->kind() == access_kind::SET && HARD_REGISTER_NUM_P(def->regno())) {
+  // We might try to write something like def->regno() == REGNO 
(pic_offset_table_rtx) ...
+  // TODO : else if (DF_REF_REG (def) == pic_offset_table_rtx && REGNO 
(pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
+  // std::cerr << "hello, dear hard register! regno: " << def->regno() << 
"\n";
+  // debug(rtl);
+  return true;
+}
+  }
 
-  auto res = is_rtx_insn_prelive(rtl);
+  // auto res = is_rtx_insn_prelive(rtl);
   //std::cerr << "Trying to mark insn: " << insn->uid() << " as prelive: " << 
res << '\n';
 
   return is_rtx_insn_prelive(rtl);
 }
 
-static void
-rtl_ssa_dce_init()
-{
-  // internal compiler error: gcc.c-torture/execute/20040811-1.c - 
rtl_ssa::function_info::add_phi_nodes
-
-  calculate_dominance_info(CDI_DOMINATORS);
-  // here we create ssa form for function
-  crtl->ssa = new rtl_ssa::function_info(cfun);
-}
-
-static void
-rtl_ssa_dce_done()
-{
-  free_dominance_info(CDI_DOMINATORS);
-  if (crtl->ssa->perform_pending_updates())
-cleanup_cfg(0);
-
-  delete crtl->ssa;
-  crtl->ssa = nullptr;
-
-  if (dump_file)
-fprintf(dump_file, "\nFinished running rtl_ssa_dce\n\n");
-}
-
 static void
 rtl_ssa_dce_mark_live(insn_info *info, vec &worklist, 
std::unordered_set &marked)
 {
@@ -1555,18 +1531,8 @@ rtl_ssa_dce_prelive(std::unordered_set 
&marked)
   for (insn_info *insn = crtl->ssa->first_insn(); insn; insn = next)
   {
 next = insn->next_any_insn();
-/*
-I would like to mark visited instruction with something like plf (Pass 
local flags) as in gimple
-
-This file contains some useful functions: e.g. marked_insn_p, mark_insn
-mark_insn does much more than I want now...
-It does quite a useful job. If rtl_insn is a call and it is obsolete, it 
will find call arguments.
-*/
-
 if (is_prelive

[gcc r14-11418] c++: constexpr ref template arg [PR119194]

2025-03-18 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:49ccf5238b82f8bfc9d60c963710081f78fad6e9

commit r14-11418-g49ccf5238b82f8bfc9d60c963710081f78fad6e9
Author: Jason Merrill 
Date:   Tue Mar 18 14:44:08 2025 -0400

c++: constexpr ref template arg [PR119194]

Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

PR c++/119194

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

* g++.dg/template/linkage7.C: New test.

(cherry picked from commit 145c90720640ec6711ed3e5aa4152bbe1ee21751)

Diff:
---
 gcc/cp/decl2.cc  | 22 +-
 gcc/testsuite/g++.dg/template/linkage7.C | 17 +
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index bf8f566b8e37..19d3fd3287d6 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -2710,6 +2710,14 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void 
*data)
   tpvis = type_visibility (TREE_TYPE (t));
   break;
 
+case ADDR_EXPR:
+  t = TREE_OPERAND (t, 0);
+  if (VAR_P (t))
+   /* If a variable has its address taken, the lvalue-rvalue conversion is
+  not applied, so skip that case.  */
+   goto addressable;
+  break;
+
 case TEMPLATE_DECL:
   if (DECL_ALIAS_TEMPLATE_P (t) || standard_concept_p (t))
/* FIXME: We don't maintain TREE_PUBLIC / DECL_VISIBILITY for
@@ -2723,11 +2731,15 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void 
*data)
   if (decl_constant_var_p (t))
/* The ODR allows definitions in different TUs to refer to distinct
   constant variables with internal or no linkage, so such a reference
-  shouldn't affect visibility (PR110323).  FIXME but only if the
-  lvalue-rvalue conversion is applied.  We still want to restrict
-  visibility according to the type of the declaration however.  */
-   tpvis = type_visibility (TREE_TYPE (t));
-  else if (! TREE_PUBLIC (t))
+  shouldn't affect visibility if the lvalue-rvalue conversion is
+  applied (PR110323).  We still want to restrict visibility according
+  to the type of the declaration however.  */
+   {
+ tpvis = type_visibility (TREE_TYPE (t));
+ break;
+   }
+addressable:
+  if (! TREE_PUBLIC (t))
tpvis = VISIBILITY_ANON;
   else
tpvis = DECL_VISIBILITY (t);
diff --git a/gcc/testsuite/g++.dg/template/linkage7.C 
b/gcc/testsuite/g++.dg/template/linkage7.C
new file mode 100644
index ..6686a0e5e511
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/linkage7.C
@@ -0,0 +1,17 @@
+// PR c++/119194
+// { dg-do compile { target c++11 } }
+
+template 
+[[gnu::noipa]]
+int get_length() {
+return Str;
+}
+static constexpr int s{ 3};
+int main() {
+   if (get_length() != s)
+ __builtin_abort();
+return 0;
+}
+
+// { dg-final { scan-assembler {_Z10get_lengthIL_ZL5sEEiv} } }
+// { dg-final { scan-assembler-not 
{(weak|glob)[^\n]*_Z10get_lengthIL_Z5sEEiv} } }


[gcc r15-8261] cobol: Bring the code base into compliance with C++14

2025-03-18 Thread Robert Dubner via Gcc-cvs
https://gcc.gnu.org/g:c49382fd221fd40bce35a954d64bbda0fd14edef

commit r15-8261-gc49382fd221fd40bce35a954d64bbda0fd14edef
Author: Bob Dubner 
Date:   Tue Mar 18 07:47:39 2025 -0400

cobol: Bring the code base into compliance with C++14

gcc/cobol

* cdf.y: Make compatible with C++14.
* copybook.h: Likewise.
* dts.h: Likewise.
* except.cc: Likewise.
* genapi.cc: Likewise.
* genutil.cc: Likewise.
* genutil.h: Likewise.
* lexio.cc: Likewise.
* parse.y: Likewise.
* parse_ante.h: Likewise.
* show_parse.h: Likewise.
* symbols.cc: Likewise.
* symbols.h: Likewise.
* util.cc: Likewise.

Diff:
---
 gcc/cobol/cdf.y|  12 +-
 gcc/cobol/copybook.h   |  21 +--
 gcc/cobol/dts.h|   6 +-
 gcc/cobol/except.cc|   9 +-
 gcc/cobol/genapi.cc|  79 +-
 gcc/cobol/genutil.cc   |   3 +
 gcc/cobol/genutil.h|   4 +
 gcc/cobol/lexio.cc |  23 +--
 gcc/cobol/parse.y  | 406 -
 gcc/cobol/parse_ante.h |  79 +-
 gcc/cobol/show_parse.h |   2 +-
 gcc/cobol/symbols.cc   | 268 
 gcc/cobol/symbols.h| 230 +---
 gcc/cobol/util.cc  |  66 
 14 files changed, 724 insertions(+), 484 deletions(-)

diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y
index beb4697b8419..12d11e78116e 100644
--- a/gcc/cobol/cdf.y
+++ b/gcc/cobol/cdf.y
@@ -702,7 +702,9 @@ suppress:   %empty
;
 
 name_any:  namelit
-   |   PSEUDOTEXT { $$ = (cdf_arg_t){YDF_PSEUDOTEXT, $1}; }
+   |   PSEUDOTEXT {
+ $$ = cdf_arg_t{YDF_PSEUDOTEXT, $1};
+   }
;
 
 name_one:  NAME
@@ -715,8 +717,8 @@ name_one:   NAME
  }
  $$ = arg;
}
-   |   NUMSTR  { $$ = (cdf_arg_t){YDF_NUMSTR, $1}; }
-   |   LITERAL { $$ = (cdf_arg_t){YDF_LITERAL, $1}; }
+   |   NUMSTR  { $$ = cdf_arg_t{YDF_NUMSTR, $1}; }
+   |   LITERAL { $$ = cdf_arg_t{YDF_LITERAL, $1}; }
;
 
 namelit:   name
@@ -738,8 +740,8 @@ namelit:name
  cdf_arg_t arg = { YDF_NAME, s };
  $$ = arg;
}
-   |   NUMSTR  { $$ = (cdf_arg_t){YDF_NUMSTR, $1}; }
-   |   LITERAL { $$ = (cdf_arg_t){YDF_LITERAL, $1}; }
+   |   NUMSTR  { $$ = cdf_arg_t{YDF_NUMSTR, $1}; }
+   |   LITERAL { $$ = cdf_arg_t{YDF_LITERAL, $1}; }
;
 
 name:  NAME
diff --git a/gcc/cobol/copybook.h b/gcc/cobol/copybook.h
index 3e2cf9d934e8..e509bf35bb72 100644
--- a/gcc/cobol/copybook.h
+++ b/gcc/cobol/copybook.h
@@ -128,25 +128,28 @@ private:
   char *regex_text;
 };
 
+class uppername_t {
+  std::string upper;
+ public:
+  uppername_t( const std::string input ) : upper(input) {
+std::transform(input.begin(), input.end(), upper.begin(), 
+  []( char ch ) { return TOUPPER(ch); } );
+  }
+  const char *data() const { return upper.data(); }
+};
+
 class copybook_t {
   std::list directories;
   copybook_elem_t book;
 
   // Take copybook name from the environment, if defined, else use it verbatim.
   static const char * transform_name( const char name[] ) {
-char uname[ strlen(name) ];
+uppername_t uname(name);
 const char *value = getenv(name);
 if( !value ) {
-  auto ename = name + strlen(name);
-  std::transform( name, ename, uname,
-  []( char ch ) { return TOUPPER(ch); } );
-  value = getenv(uname); // try uppercase of envar name
+  value = getenv(uname.data()); // try uppercase of envar name
   if( !value ) value = name; // keep original unmodified
 }
-if( false && value != uname ) {
-  dbgmsg("using copybook file '%s' from environment variable '%s'",
- value, name);
-}
 return xstrdup(value);
   }
 
diff --git a/gcc/cobol/dts.h b/gcc/cobol/dts.h
index 618f649c2e1e..c345dc7e64ab 100644
--- a/gcc/cobol/dts.h
+++ b/gcc/cobol/dts.h
@@ -93,12 +93,12 @@ namespace dts {
 if( eoinput == NULL ) eoinput = strchr(input, '\0');
 auto ncm = re.size();
 cm.resize(ncm);
-regmatch_t cms[ncm];
+std::vector  cms(ncm);
 
 
-int erc = regexec( &re, input, ncm, cms, 0 );
+int erc = regexec( &re, input, ncm, cms.data(), 0 );
 if( erc != 0 ) return false;
-std::transform( cms, cms+ncm, cm.begin(),
+std::transform( cms.begin(), cms.end(), cm.begin(),
 [input]( const regmatch_t& m ) {
   return csub_match( input, m );
 } );
diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc
index 3510ca3ac218..5374201b4c82 100644
--- a/gcc/cobol/except.cc
+++ b/gcc/cobol/except.cc
@@ -279,10 +279,11 @@ symbol_declaratives_add( size_t program,
   char achBlob[32];
   sprintf(achBlob, "_DECL

[gcc r15-8252] libstdc++: Add P1206R7 from_range members to ordered sets [PR111055]

2025-03-18 Thread Tomasz Kaminski via Gcc-cvs
https://gcc.gnu.org/g:5c2c0155385d8a9ed23bf5d754481e7f945b9702

commit r15-8252-g5c2c0155385d8a9ed23bf5d754481e7f945b9702
Author: Tomasz Kamiński 
Date:   Thu Mar 13 18:24:38 2025 +0100

libstdc++: Add P1206R7 from_range members to ordered sets [PR111055]

This is another piece of P1206R7, adding new members to std::set
and std::multiset.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/stl_multiset.h: (inser_range)
(multiset(from_range_t, _Rg&&, const _Compare&, const _Alloc&))
(multiset(from_range_t, _Rg&&, const _Alloc&)): Define.
* include/bits/stl_set.h: (set(from_range_t, _Rg&&, const _Alloc&))
(set(from_range_t, _Rg&&, const _Compare&, const _Alloc&), 
insert_range):
Define.
* testsuite/23_containers/multiset/cons/from_range.cc: New test.
* testsuite/23_containers/multiset/modifiers/insert/insert_range.cc:
New test.
* testsuite/23_containers/set/cons/from_range.cc: New test.
* testsuite/23_containers/set/modifiers/insert/insert_range.cc:
New test.

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

Diff:
---
 libstdc++-v3/include/bits/stl_multiset.h   |  52 +
 libstdc++-v3/include/bits/stl_set.h|  55 ++
 .../23_containers/multiset/cons/from_range.cc  | 118 +
 .../multiset/modifiers/insert/insert_range.cc  |  76 +
 .../testsuite/23_containers/set/cons/from_range.cc | 117 
 .../set/modifiers/insert/insert_range.cc   |  79 ++
 6 files changed, 497 insertions(+)

diff --git a/libstdc++-v3/include/bits/stl_multiset.h 
b/libstdc++-v3/include/bits/stl_multiset.h
index 57caf6e8cc41..7030f286750d 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -60,6 +60,9 @@
 #if __cplusplus >= 201103L
 #include 
 #endif
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::begin, ranges::distance etc.
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -271,6 +274,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: _M_t(_Key_alloc_type(__a))
{ _M_t._M_insert_range_equal(__first, __last); }
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   * @brief Builds a %multiset from a range.
+   * @since C++23
+   */
+  template<__detail::__container_compatible_range<_Key> _Rg>
+   multiset(from_range_t, _Rg&& __rg,
+const _Compare& __comp,
+const _Alloc& __a = _Alloc())
+   : _M_t(__comp, _Key_alloc_type(__a))
+   { insert_range(std::forward<_Rg>(__rg)); }
+
+  /// Allocator-extended range constructor.
+  template<__detail::__container_compatible_range<_Key> _Rg>
+   multiset(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc())
+   : _M_t(_Key_alloc_type(__a))
+   { insert_range(std::forward<_Rg>(__rg)); }
+#endif
+
   /**
*  The dtor only erases the elements, and note that if the elements
*  themselves are pointers, the pointed-to memory is not touched in any
@@ -566,6 +588,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   { this->insert(__l.begin(), __l.end()); }
 #endif
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   *  @brief Inserts a range of elements.
+   *  @since C++23
+   *  @param  __rg An input range of elements that can be converted to
+   *   the set's value type.
+   */
+  template<__detail::__container_compatible_range<_Key> _Rg>
+   void
+   insert_range(_Rg&& __rg)
+   {
+ auto __first = ranges::begin(__rg);
+ const auto __last = ranges::end(__rg);
+ for (; __first != __last; ++__first)
+   _M_t._M_emplace_equal(*__first);
+   }
+#endif
+
+
 #ifdef __glibcxx_node_extract // >= C++17
   /// Extract a node.
   node_type
@@ -955,6 +996,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 multiset(initializer_list<_Key>, _Allocator)
 -> multiset<_Key, less<_Key>, _Allocator>;
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  template>,
+  __allocator_like _Alloc = std::allocator>>
+multiset(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
+  -> multiset, _Compare, _Alloc>;
+
+  template
+multiset(from_range_t, _Rg&&, _Alloc)
+  -> multiset, 
less>, _Alloc>;
+#endif
 #endif // deduction guides
 
   /**
diff --git a/libstdc++-v3/include/bits/stl_set.h 
b/libstdc++-v3/include/bits/stl_set.h
index f32323db3687..124237edf8ed 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -60,6 +60,9 @@
 #if __cplusplus >= 201103L
 #include 
 #endif
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::begin, ranges::distance etc.
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -275,6 +

[gcc r15-8253] lra: Handle SUBREG in lra_rtx_hash [PR119307]

2025-03-18 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:ded45b72aaa43bbd8aa7c67f26a874cea8a18492

commit r15-8253-gded45b72aaa43bbd8aa7c67f26a874cea8a18492
Author: Jakub Jelinek 
Date:   Tue Mar 18 14:57:41 2025 +0100

lra: Handle SUBREG in lra_rtx_hash [PR119307]

The following testcase ICEs starting with r15-3213 in
decompose_normal_address and starting with r15-3288 ICEs
in lra_rtx_hash, which since r8-5466 can't handle SUBREG
(previously SUBREG was "ei" and lra_rtx_hash can handle
that through
val += lra_rtx_hash (XEXP (x, i));
for e and
val += XINT (x, i);
for i, now it is "ep" where p stands for poly_uint16).

The following patch fixes it by handling SUBREG directly, a variant
could be instead add
case 'p':
  for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
val += SUBREG_BYTE (x).coeffs[i];
  break;
if you prefer that more (p is used solely for SUBREG and e.g. rtx_equal_p
has
case 'p':
  if (maybe_ne (SUBREG_BYTE (x), SUBREG_BYTE (y)))
return false;
  break;
).  Given the above rtx_equal_p snippet and that lra_rtx_hash
is solely used in invariant_hash (and recursion) and invariant_eq_p
uses rtx_equal_p we'll never consider different SUBREGs of the same thing
as the same invariant.

2025-03-18  Jakub Jelinek  

PR rtl-optimization/119307
* lra.cc (lra_rtx_hash): Handle SUBREG.

* gcc.target/i386/pr119307.c: New test.

Diff:
---
 gcc/lra.cc   |  6 ++
 gcc/testsuite/gcc.target/i386/pr119307.c | 14 ++
 2 files changed, 20 insertions(+)

diff --git a/gcc/lra.cc b/gcc/lra.cc
index 8f30284e9daa..8c6991751e5c 100644
--- a/gcc/lra.cc
+++ b/gcc/lra.cc
@@ -1730,6 +1730,12 @@ lra_rtx_hash (rtx x)
 case CONST_INT:
   return val + UINTVAL (x);
 
+case SUBREG:
+  val += lra_rtx_hash (SUBREG_REG (x));
+  for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
+   val += SUBREG_BYTE (x).coeffs[i];
+  return val;
+
 default:
   break;
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr119307.c 
b/gcc/testsuite/gcc.target/i386/pr119307.c
new file mode 100644
index ..6b56f6b0ec1c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr119307.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/119307 */
+/* { dg-do compile { target x32 } } */
+/* { dg-require-profiling "-fprofile-generate" } */
+/* { dg-options "-Os -maddress-mode=long -fprofile-generate -ftrapv" } */
+
+_Complex int x;
+__int128 y;
+long n;
+
+void
+foo (void)
+{
+  x *= *(__int128 *) __builtin_memmove (&y, &x, n);
+}


[gcc r15-8255] libstdc++: Add P1206R7 from_range members to unordered maps [PR111055]

2025-03-18 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:453d42046c461a8aa8ed68a88b94dac2d4dde73b

commit r15-8255-g453d42046c461a8aa8ed68a88b94dac2d4dde73b
Author: Tomasz Kamiński 
Date:   Tue Mar 18 11:08:19 2025 +0100

libstdc++: Add P1206R7 from_range members to unordered maps [PR111055]

This is another piece of P1206R7, adding new members to std::unordered_map
and std::unordered_multimap.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h (unordered_map): Define from_range
constructors and insert_range member.
(unordered_multimap): Likewise.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New test.
* 
testsuite/23_containers/unordered_multimap/modifiers/insert_range.cc:
New test.
* testsuite/23_containers/unordered_map/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_map/modifiers/insert_range.cc:
New test.

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

Diff:
---
 libstdc++-v3/include/bits/unordered_map.h  | 203 ++
 .../23_containers/unordered_map/cons/from_range.cc | 232 
 .../unordered_map/modifiers/insert_range.cc|  79 +++
 .../unordered_multimap/cons/from_range.cc  | 238 +
 .../unordered_multimap/modifiers/insert_range.cc   |  76 +++
 5 files changed, 828 insertions(+)

diff --git a/libstdc++-v3/include/bits/unordered_map.h 
b/libstdc++-v3/include/bits/unordered_map.h
index 9f205f7521d3..5c9304871907 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -34,6 +34,9 @@
 #include 
 #include  // hash
 #include // equal_to
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::begin, ranges::distance etc.
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -274,6 +277,42 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   : unordered_map(__l, __n, __hf, key_equal(), __a)
   { }
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   *  @brief  Builds an %unordered_map from a range.
+   *  @since C++23
+   *  @param  __rg An input range of elements that can be converted to
+   *   the maps's value type.
+   *  @param __n  Minimal initial number of buckets.
+   *  @param __hf  A hash functor.
+   *  @param __eql  A key equality functor.
+   *  @param  __a  An allocator object.
+   *
+   *  Create an %unordered_map consisting of copies of the elements in the
+   *  range. This is linear in N (where N is `std::ranges::size(__rg)`).
+   */
+   template<__detail::__container_compatible_range _Rg>
+unordered_map(from_range_t, _Rg&& __rg,
+  size_type __n = 0,
+  const hasher& __hf = hasher(),
+  const key_equal& __eql = key_equal(),
+  const allocator_type& __a = allocator_type())
+ : _M_h(__n, __hf, __eql, __a)
+ { insert_range(std::forward<_Rg>(__rg)); }
+
+   template<__detail::__container_compatible_range _Rg>
+unordered_map(from_range_t, _Rg&& __rg, size_type __n,
+  const allocator_type& __a)
+ : _M_h(__n, hasher(), key_equal(), __a)
+ { insert_range(std::forward<_Rg>(__rg)); }
+
+   template<__detail::__container_compatible_range _Rg>
+unordered_map(from_range_t, _Rg&& __rg, size_type __n,
+  const hasher& __hf, const allocator_type& __a)
+ : _M_h(__n, __hf, key_equal(), __a)
+ { insert_range(std::forward<_Rg>(__rg)); }
+#endif
+
   /// Copy assignment operator.
   unordered_map&
   operator=(const unordered_map&) = default;
@@ -635,6 +674,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   insert(initializer_list __l)
   { _M_h.insert(__l); }
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   *  @brief Inserts a range of elements.
+   *  @since C++23
+   *  @param  __rg An input range of elements that can be converted to
+   *   the map's value type.
+   */
+  template<__detail::__container_compatible_range _Rg>
+   void
+   insert_range(_Rg&& __rg)
+   {
+ auto __first = ranges::begin(__rg);
+ const auto __last = ranges::end(__rg);
+ for (; __first != __last; ++__first)
+   _M_h.emplace(*__first);
+   }
+#endif
 
 #ifdef __glibcxx_unordered_map_try_emplace // >= C++17 && HOSTED
   /**
@@ -1228,6 +1284,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
  _Hash, _Allocator)
 -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  template>,
+  __not_allocator_like _Pred = 
equal_to<__detail::__range_key_type<_Rg>>,
+  __allocator_like _Allocator =

[gcc r15-8256] SCC-Copy: Add More Debug dumps

2025-03-18 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:cfbabe10ddaba3f200f58910d49aa041d2abde8c

commit r15-8256-gcfbabe10ddaba3f200f58910d49aa041d2abde8c
Author: Andrew Pinski 
Date:   Mon Mar 17 11:28:16 2025 -0700

SCC-Copy: Add More Debug dumps

While debugging a failure, I noticed that SCC copy didn't print
out what it was doing, e.g. replacing name1 with name 2.
This adds that dump.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (scc_copy_prop::replace_scc_by_value): Dump
what is being replaced with what.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/gimple-ssa-sccopy.cc | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/gcc/gimple-ssa-sccopy.cc b/gcc/gimple-ssa-sccopy.cc
index 7ffb5718ab6b..298feb055711 100644
--- a/gcc/gimple-ssa-sccopy.cc
+++ b/gcc/gimple-ssa-sccopy.cc
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "tree-ssa-dce.h"
 #include "fold-const.h"
+#include "tree-pretty-print.h"
 
 /* Strongly connected copy propagation pass.
 
@@ -485,6 +486,15 @@ scc_copy_prop::replace_scc_by_value (vec scc, 
tree val)
   for (gimple *stmt : scc)
 {
   tree name = gimple_get_lhs (stmt);
+  if (dump_file && (dump_flags & TDF_DETAILS))
+   {
+ fprintf (dump_file, "Replacing ");
+ print_generic_expr (dump_file, name);
+ fprintf (dump_file, " with ");
+ print_generic_expr (dump_file, val);
+ fprintf (dump_file, "\n");
+ 
+   }
   replace_uses_by (name, val);
   bitmap_set_bit (dead_stmts, SSA_NAME_VERSION (name));
 }


[gcc r15-8257] cobol: Avoid a use of auto.

2025-03-18 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:26884504503093e5019708f50816897c5d3a4958

commit r15-8257-g26884504503093e5019708f50816897c5d3a4958
Author: Iain Sandoe 
Date:   Mon Mar 17 10:04:52 2025 +

cobol: Avoid a use of auto.

In this case the deduction for Darwin's implementation is 'char *' which
then conflicts with the second use of data.initial in the find_if
callback.  Let's just specify it as 'const char *'.

gcc/cobol/ChangeLog:

* util.cc (cbl_field_t::report_invalid_initial_value): Avoid
auto here and specify const char *.

Signed-off-by: Iain Sandoe 

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

diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 9f746a388081..3872f57aeb0a 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -850,7 +850,7 @@ cbl_field_t::report_invalid_initial_value(const YYLTYPE& 
loc) const {
 /*
  * Check fraction for excess precision
  */
-auto p = strchr(data.initial, symbol_decimal_point());
+const char *p = strchr(data.initial, symbol_decimal_point());
 if( p ) {
   auto pend = std::find(p, p + strlen(p), 0x20);
   int n = std::count_if( ++p, pend, isdigit );


[gcc r15-8248] cobol: Do not include C++ headers after system.h.

2025-03-18 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:7865869b44d207ce7554305ce3368e1143028cf7

commit r15-8248-g7865869b44d207ce7554305ce3368e1143028cf7
Author: Iain Sandoe 
Date:   Sat Mar 15 09:20:13 2025 +

cobol: Do not include C++ headers after system.h.

The headers mentioned in parse.y are already unconditionally included
by system.h (via cobol-system.h).

gcc/cobol/ChangeLog:

* parse.y: Remove c++ header includes appearing after
system.h.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/cobol/parse.y | 6 --
 1 file changed, 6 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index c901bd66629b..d8f5175adcb8 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -30,9 +30,6 @@
 %code requires {
   #include   // Before cobol-system because it uses poisoned functions
   #include "cobol-system.h"
-  #include 
-  #include 
-  #include 
   #include "../../libgcobol/io.h"
   #include "../../libgcobol/ec.h"
 
@@ -216,9 +213,6 @@
   new_literal( const char initial[], enum radix_t radix );
 #pragma GCC diagnostic pop
 
-
-  #include 
-
   enum select_clause_t {
 access_clause_e= 0x0001,
 alt_key_clause_e   = 0x0002,


[gcc r15-8250] cobol: use ldirname in cdf-copy.cc

2025-03-18 Thread Jose E. Marchesi via Gcc-cvs
https://gcc.gnu.org/g:260e0a389a70994d2728b389e6865528557e3933

commit r15-8250-g260e0a389a70994d2728b389e6865528557e3933
Author: Jose E. Marchesi 
Date:   Mon Mar 17 16:51:31 2025 +0100

cobol: use ldirname in cdf-copy.cc

This patch changes gcc/cobol/cdf-copy.cc to use the new ldirname from
libibertay rather than the host's dirname.  This removes an include
for libgen.h.

Regtested in x86_64-linux-gnu by running make check-cobol.

gcc/cobol/ChangeLog

* cdf-copy.cc (copybook_elem_t::open_file): Use ldirname rather
than dirname.

Diff:
---
 gcc/cobol/cdf-copy.cc | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/gcc/cobol/cdf-copy.cc b/gcc/cobol/cdf-copy.cc
index dfa3f57315db..179dbacea930 100644
--- a/gcc/cobol/cdf-copy.cc
+++ b/gcc/cobol/cdf-copy.cc
@@ -40,7 +40,6 @@
 #include "copybook.h"
 
 #include 
-#include 
 
 #define COUNT_OF(X) (sizeof(X) / sizeof(X[0]))
 
@@ -268,24 +267,33 @@ int
 copybook_elem_t::open_file( const char directory[], bool literally ) {
   int erc;
   char  *pattern, *copier = xstrdup(cobol_filename());
-  if( ! directory ) {
-directory = dirname(copier);
-if( 0 == strcmp(".", directory) ) directory = NULL;
+  char *dname = NULL;
+
+  if ( directory ) {
+dname = xstrdup(directory);
+  } else {
+dname = ldirname(copier);
+gcc_assert (dname != NULL); /* out of memory  */
+if( '\0' == dname[0] ) {
+  free (dname);
+  dname = NULL;
+}
   }
 
   char *path = NULL;
 
-  if( directory || library.name ) {
-if( directory && library.name ) {
-  path = xasprintf( "%s/%s/%s", directory, library.name, source.name );
+  if( dname || library.name ) {
+if( dname && library.name ) {
+  path = xasprintf( "%s/%s/%s", dname, library.name, source.name );
 } else {
-  const char *dir = directory? directory : library.name;
+  const char *dir = dname? dname : library.name;
   path = xasprintf( "%s/%s", dir, source.name );
 }
   } else {
 path = xasprintf( "%s", source.name );
   }
 
+  free(dname);
   gcc_assert(path);
 
   if( literally ) {


[gcc r15-8251] libstdc++: Add P1206R7 from_range members to ordered maps [PR111055]

2025-03-18 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:8744d53db1b6816586dac102942c00c105524172

commit r15-8251-g8744d53db1b6816586dac102942c00c105524172
Author: Tomasz Kamiński 
Date:   Fri Mar 14 16:04:11 2025 +0100

libstdc++: Add P1206R7 from_range members to ordered maps [PR111055]

This is another piece of P1206R7, adding new members to std::map
and std::multimap.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (__detail::__range_to_alloc_type):
Define.
* include/bits/stl_multimap.h: (inser_range)
(multimap(from_range_t, _Rg&&, const _Compare&, const _Alloc&))
(multimap(from_range_t, _Rg&&, const _Alloc&)): Define.
* include/bits/stl_map.h: (map(from_range_t, _Rg&&, const _Alloc&)) 
i
(map(from_range_t, _Rg&&, const _Compare&, const _Alloc&), 
insert_range):
Define.
* testsuite/23_containers/multimap/cons/from_range.cc: New test.
* 
testsuite/23_containers/multimap/modifiers/insert/insert_range.cc: New test.
* testsuite/23_containers/map/cons/from_range.cc: New test.
* testsuite/23_containers/map/modifiers/insert/insert_range.cc: New 
test.

Diff:
---
 libstdc++-v3/include/bits/ranges_base.h|   8 ++
 libstdc++-v3/include/bits/stl_map.h|  59 
 libstdc++-v3/include/bits/stl_multimap.h   |  60 
 .../testsuite/23_containers/map/cons/from_range.cc | 155 +
 .../map/modifiers/insert/insert_range.cc   | 102 ++
 .../23_containers/multimap/cons/from_range.cc  | 155 +
 .../multimap/modifiers/insert/insert_range.cc  |  99 +
 7 files changed, 638 insertions(+)

diff --git a/libstdc++-v3/include/bits/ranges_base.h 
b/libstdc++-v3/include/bits/ranges_base.h
index 516d04afdab2..c9687c256e99 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -1083,6 +1083,9 @@ namespace ranges
   inline constexpr from_range_t from_range{};
 
 /// @cond undocumented
+  template
+struct pair;
+
 namespace __detail
 {
   template
@@ -1097,6 +1100,11 @@ namespace __detail
   template
 using __range_mapped_type
   = typename ranges::range_value_t<_Range>::second_type;
+
+  // The allocator's value_type for map-like containers.
+  template
+using __range_to_alloc_type
+  = pair, __range_mapped_type<_Range>>;
 }
 /// @endcond
 #endif
diff --git a/libstdc++-v3/include/bits/stl_map.h 
b/libstdc++-v3/include/bits/stl_map.h
index d2d0b524cceb..9381a7930af7 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -62,6 +62,9 @@
 #include 
 #include 
 #endif
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::begin, ranges::distance etc.
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -305,6 +308,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: _M_t(__comp, _Pair_alloc_type(__a))
{ _M_t._M_insert_range_unique(__first, __last); }
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   * @brief Builds a %map from a range.
+   * @since C++23
+   */
+  template<__detail::__container_compatible_range _Rg>
+   map(from_range_t, _Rg&& __rg,
+   const _Compare& __comp,
+   const _Alloc& __a = _Alloc())
+   : _M_t(__comp, _Pair_alloc_type(__a))
+   { insert_range(std::forward<_Rg>(__rg)); }
+
+  /// Allocator-extended range constructor.
+  template<__detail::__container_compatible_range _Rg>
+   map(from_range_t, _Rg&& __rg, const _Alloc& __a = _Alloc())
+   : _M_t(_Pair_alloc_type(__a))
+   { insert_range(std::forward<_Rg>(__rg)); }
+#endif
+
+
 #if __cplusplus >= 201103L
   /**
*  The dtor only erases the elements, and note that if the elements
@@ -880,6 +903,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   { insert(__list.begin(), __list.end()); }
 #endif
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   *  @brief Inserts a range of elements.
+   *  @since C++23
+   *  @param  __rg An input range of elements that can be converted to
+   *   the map's value type.
+   */
+  template<__detail::__container_compatible_range _Rg>
+   void
+   insert_range(_Rg&& __rg)
+   {
+ auto __first = ranges::begin(__rg);
+ const auto __last = ranges::end(__rg);
+ for (; __first != __last; ++__first)
+   insert(*__first);
+   }
+#endif
+
   /**
*  @brief Attempts to insert a std::pair into the %map.
*  @param  __position  An iterator that serves as a hint as to where the
@@ -1495,6 +1536,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 map(initializer_list>, _Allocator)
 -> map<_Key, _Tp, less<_Key>, _Allocator>;
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  template>,
+  __allocator_like _Alloc =
+

[gcc r15-8262] doc: regenerate rs6000/rs6000.opt.urls

2025-03-18 Thread Michael Matz via Gcc-cvs
https://gcc.gnu.org/g:8333f1c7e699419a4e428fa1d66156d7bad69c9f

commit r15-8262-g8333f1c7e699419a4e428fa1d66156d7bad69c9f
Author: Michael Matz 
Date:   Tue Mar 18 17:21:23 2025 +0100

doc: regenerate rs6000/rs6000.opt.urls

which I forgot and the autobuilder complained.

* config/rs6000/rs6000.opt.urls: Regenerate.

Diff:
---
 gcc/config/rs6000/rs6000.opt.urls | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.opt.urls 
b/gcc/config/rs6000/rs6000.opt.urls
index c7c1cefe22cd..0b418c09a083 100644
--- a/gcc/config/rs6000/rs6000.opt.urls
+++ b/gcc/config/rs6000/rs6000.opt.urls
@@ -98,6 +98,9 @@ 
UrlSuffix(gcc/RS_002f6000-and-PowerPC-Options.html#index-mminimal-toc)
 mfull-toc
 UrlSuffix(gcc/RS_002f6000-and-PowerPC-Options.html#index-mfull-toc)
 
+msplit-patch-nops
+UrlSuffix(gcc/RS_002f6000-and-PowerPC-Options.html#index-msplit-patch-nops)
+
 mvrsave
 UrlSuffix(gcc/RS_002f6000-and-PowerPC-Options.html#index-mvrsave)


[gcc r15-8263] cobol: Fifteen new cobol.dg testscases.

2025-03-18 Thread Robert Dubner via Gcc-cvs
https://gcc.gnu.org/g:82bb1890aeab275541f8d3606641e8c0cadc9659

commit r15-8263-g82bb1890aeab275541f8d3606641e8c0cadc9659
Author: Bob Dubner 
Date:   Mon Mar 17 21:47:05 2025 -0400

cobol: Fifteen new cobol.dg testscases.

gcc/testsuite

* cobol.dg/group1/check_88.cob: New testcase.
* cobol.dg/group1/comp5.cob: Likewise.
* cobol.dg/group1/declarative_1.cob: Likewise.
* cobol.dg/group1/display.cob: Likewise.
* cobol.dg/group1/display2.cob: Likewise.
* cobol.dg/group1/line-sequential.cob: Likewise.
* cobol.dg/group1/multiple-compares.cob: Likewise.
* cobol.dg/group1/multiply2.cob: Likewise.
* cobol.dg/group1/packed.cob: Likewise.
* cobol.dg/group1/perform-nested-exit.cob: Likewise.
* cobol.dg/group1/pointer1.cob: Likewise.
* cobol.dg/group1/simple-arithmetic.cob: Likewise.
* cobol.dg/group1/simple-classes.cob: Likewise.
* cobol.dg/group1/simple-if.cob: Likewise.
* cobol.dg/group1/simple-perform.cob: Likewise.

Diff:
---
 gcc/testsuite/cobol.dg/group1/check_88.cob | 101 +++
 gcc/testsuite/cobol.dg/group1/comp5.cob|  72 
 gcc/testsuite/cobol.dg/group1/declarative_1.cob| 116 +
 gcc/testsuite/cobol.dg/group1/display.cob  |  14 ++
 gcc/testsuite/cobol.dg/group1/display2.cob |   7 +
 gcc/testsuite/cobol.dg/group1/line-sequential.cob  |  34 
 .../cobol.dg/group1/multiple-compares.cob  | 192 +
 gcc/testsuite/cobol.dg/group1/multiply2.cob|  68 
 gcc/testsuite/cobol.dg/group1/packed.cob   |  73 
 .../cobol.dg/group1/perform-nested-exit.cob|  84 +
 gcc/testsuite/cobol.dg/group1/pointer1.cob |  98 +++
 .../cobol.dg/group1/simple-arithmetic.cob  |  61 +++
 gcc/testsuite/cobol.dg/group1/simple-classes.cob   |  68 
 gcc/testsuite/cobol.dg/group1/simple-if.cob| 143 +++
 gcc/testsuite/cobol.dg/group1/simple-perform.cob   |  52 ++
 15 files changed, 1183 insertions(+)

diff --git a/gcc/testsuite/cobol.dg/group1/check_88.cob 
b/gcc/testsuite/cobol.dg/group1/check_88.cob
new file mode 100644
index ..4a7723eb92a3
--- /dev/null
+++ b/gcc/testsuite/cobol.dg/group1/check_88.cob
@@ -0,0 +1,101 @@
+*> { dg-do run }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output {\->   <\-(\n|\r\n|\r)} }
+*> { dg-output {\->"""<\-(\n|\r\n|\r)} }
+*> { dg-output {\->000<\-(\n|\r\n|\r)} }
+*> { dg-output {\->ÿÿÿ<\-(\n|\r\n|\r)} }
+*> { dg-output { (\n|\r\n|\r)} }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output {\-><\-(\n|\r\n|\r)} }
+*> { dg-output { (\n|\r\n|\r)} }
+*> { dg-output {There should be no garbage after character 32(\n|\r\n|\r)} }
+*> { dg-output 
{\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\*\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-(\n|\r\n|\r)}
 }
+*> { dg-output {üüü Bundesstraße   
 (\n|\r\n|\r)} }
+*> { dg-output {üüü Bundesstraße   
 (\n|\r\n|\r)} }
+*> { dg-output { (\n|\r\n|\r)} }
+*> { dg-output {There should be no spaces before the final quote(\n|\r\n|\r)} }
+*> { dg-output {"üüü Bundesstraße"(\n|\r\n|\r)} }
+*> { dg-output { (\n|\r\n|\r)} }
+*> { dg-output {   IsLow   ""(\n|\r\n|\r)} }
+*> { dg-output {   IsZero  "000"(\n|\r\n|\r)} }
+*> { dg-output {   IsHi"ÿÿÿ"(\n|\r\n|\r)} }
+*> { dg-output {   IsBob   "bob"(\n|\r\n|\r)} }
+*> { dg-output {   IsQuote "(\n|\r\n|\r)} }
+*> { dg-output {   IsSpace "   "(\n|\r\n|\r)} }
+*> { dg-output { (\n|\r\n|\r)} }
+*> { dg-output {CheckBinary Properly True(\n|\r\n|\r)} }
+*> { dg-output {CheckBinary Properly False} }
+IDENTIFICATION DIVISION.
+PROGRAM-ID. check88.
+DATA DIVISION.
+WORKING-STORAGE SECTION.
+01 Check88 PIC XXX VALUE SPACE.
+   88  CheckSpace  VALUE SPACE.
+   88  CheckHi VALUE HIGH-VALUES.
+   88  CheckLo VALUE LOW-VALUES.
+   88  CheckZero   VALUE ZERO.
+   88  CheckQuotes VALUE QUOTE.
+   88  CheckBobVALUE "bob".
+   88  CheckBinary VALUE X"000102". *> { dg-warning embedded }
+01 000VARL PIC XXX VALUE LOW-VALUE.
+01 000VARS PIC XXX VALUE SPACE.
+01 000VARQ PIC XXX VALUE QUOTE.
+01 000VARZ PIC XXX VALUE ZERO.
+01 000VARH PIC XXX VALUE HIGH-VALUE.
+01 MOVE-TARGET PIC .
+01 VAR-UTF8 PIC X(64) VALUE "üüü Bundesstraße".
+  *>  01 VAR20 PIC 9V9(20) value "1.1".
+01 VAR99   PIC 999 VALUE ZERO.
+PROCEDURE DIVISION.
+DISPLAY "->" 000VARL "<-"
+DISPLAY "->" 0

[gcc r15-8247] debug/101533 - ICE with variant typedef DIE generation

2025-03-18 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:99a3f013c3bb8bc022ca488b40aa18fd97b5224d

commit r15-8247-g99a3f013c3bb8bc022ca488b40aa18fd97b5224d
Author: Richard Biener 
Date:   Wed Mar 5 14:24:50 2025 +0100

debug/101533 - ICE with variant typedef DIE generation

There's a sanity check in gen_type_die_with_usage that trips
unnecessarily for a case where the relevant DIE has already been
generated successfully in other ways.  The following keys the
existing TREE_ASM_WRITTEN check on the correct object, honoring
this and does nothing instead of ICEing for the testcase at hand.

PR debug/101533
* dwarf2out.cc (gen_type_die_with_usage): When we have
output the typedef already do nothing for a typedef variant.
Do not set TREE_ASM_WRITTEN on the type.

* g++.dg/debug/pr101533.C: New testcase.

Diff:
---
 gcc/dwarf2out.cc  |  6 ++
 gcc/testsuite/g++.dg/debug/pr101533.C | 11 +++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index e1c353258891..a2acfd1d3565 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -26424,10 +26424,10 @@ gen_type_die_with_usage (tree type, dw_die_ref 
context_die,
  for the parent typedef which TYPE is a type of.  */
   if (typedef_variant_p (type))
 {
-  if (TREE_ASM_WRITTEN (type))
+  tree name = TYPE_NAME (type);
+  if (TREE_ASM_WRITTEN (name))
return;
 
-  tree name = TYPE_NAME (type);
   tree origin = decl_ultimate_origin (name);
   if (origin != NULL && origin != name)
{
@@ -26441,8 +26441,6 @@ gen_type_die_with_usage (tree type, dw_die_ref 
context_die,
   /* Give typedefs the right scope.  */
   context_die = scope_die_for (type, context_die);
 
-  TREE_ASM_WRITTEN (type) = 1;
-
   gen_decl_die (name, NULL, NULL, context_die);
   return;
 }
diff --git a/gcc/testsuite/g++.dg/debug/pr101533.C 
b/gcc/testsuite/g++.dg/debug/pr101533.C
new file mode 100644
index ..fc1e2e742a1d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr101533.C
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-g" }
+
+template  class T
+{
+  typedef struct {} a __attribute__((aligned));
+};
+void f ()
+{
+  T();
+}


[gcc r15-8259] c++: memfn pointer as NTTP argument considered unused [PR119233]

2025-03-18 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:51b1c0a2dde8ada0856c8a8cf2c1d26ac1657787

commit r15-8259-g51b1c0a2dde8ada0856c8a8cf2c1d26ac1657787
Author: Patrick Palka 
Date:   Tue Mar 18 11:38:33 2025 -0400

c++: memfn pointer as NTTP argument considered unused [PR119233]

This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

PR c++/119233

gcc/cp/ChangeLog:

* pt.cc (mark_template_arguments_used): Also handle member
function pointers.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr5.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/pt.cc|  6 ++
 gcc/testsuite/g++.dg/template/fn-ptr5.C | 28 
 2 files changed, 34 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 8aaae4468687..50eda189c43a 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22491,6 +22491,12 @@ mark_template_arguments_used (tree tmpl, tree args)
  gcc_checking_assert (ok || seen_error ());
}
}
+  /* A member function pointer.  */
+  else if (TREE_CODE (arg) == PTRMEM_CST)
+   {
+ bool ok = mark_used (PTRMEM_CST_MEMBER (arg), tf_none);
+ gcc_checking_assert (ok || seen_error ());
+   }
   /* A class NTTP argument.  */
   else if (VAR_P (arg)
   && DECL_NTTP_OBJECT_P (arg))
diff --git a/gcc/testsuite/g++.dg/template/fn-ptr5.C 
b/gcc/testsuite/g++.dg/template/fn-ptr5.C
new file mode 100644
index ..db3113109ef9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/fn-ptr5.C
@@ -0,0 +1,28 @@
+// PR c++/119233
+// A version of fn-ptr3a.C using member instead of non-member function
+// pointers.
+
+struct B {
+  template
+  void f(T) { T::fail; } // { dg-error "fail" }
+};
+
+template
+struct A {
+  // P not called
+};
+
+template
+void wrap() {
+  // P not called
+}
+
+template
+void g() {
+  A<&B::f> a; // { dg-message "required from" }
+  wrap<&B::f>(); // { dg-message "required from" }
+}
+
+int main() {
+  g<0>();
+}


[gcc r15-8254] libstdc++: Add P1206R7 from_range members to unordered sets [PR111055]

2025-03-18 Thread Tomasz Kaminski via Gcc-cvs
https://gcc.gnu.org/g:5f033bf16458e250e6b7cda8e27d0100197cba14

commit r15-8254-g5f033bf16458e250e6b7cda8e27d0100197cba14
Author: Tomasz Kamiński 
Date:   Mon Mar 17 14:30:35 2025 +0100

libstdc++: Add P1206R7 from_range members to unordered sets [PR111055]

This is another piece of P1206R7, adding new members to std::unordered_set
and std::unordered_multiset.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h (_M_rehash_insert)
(_M_insert_range_multi): Extracted rehashing for range insertion
to separate function.
* include/bits/unordered_set.h (unordered_set): Define from_range
constructors and insert_range member.
(unordered_multiset) Likewise.
* testsuite/23_containers/unordered_multiset/cons/from_range.cc:
New test.
* 
testsuite/23_containers/unordered_multiset/modifiers/insert_range.cc:
New test.
* testsuite/23_containers/unordered_set/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_set/modifiers/insert_range.cc:
New test.

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

Diff:
---
 libstdc++-v3/include/bits/hashtable.h  |  43 +++--
 libstdc++-v3/include/bits/unordered_set.h  | 193 
 .../unordered_multiset/cons/from_range.cc  | 201 +
 .../unordered_multiset/modifiers/insert_range.cc   |  62 +++
 .../23_containers/unordered_set/cons/from_range.cc | 201 +
 .../unordered_set/modifiers/insert_range.cc|  65 +++
 6 files changed, 749 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/include/bits/hashtable.h 
b/libstdc++-v3/include/bits/hashtable.h
index 246e62afc6af..20f9bd98d5b7 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -798,6 +798,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_equal_range_tr(const _Kt& __k) const;
 #endif // __glibcxx_generic_unordered_lookup
 
+  void _M_rehash_insert(size_type __n);
+
 private:
   // Bucket index computation helpers.
   size_type
@@ -2388,6 +2390,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __pos;
   }
 
+  template
+   void
+  _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal,
+_Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::
+  _M_rehash_insert(size_type __n)
+  {
+using __pair_type = std::pair;
+if (__n == 0)
+  return;
+
+__rehash_guard_t __rehash_guard(_M_rehash_policy);
+__pair_type __do_rehash
+  = _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, 
__n);
+
+if (__do_rehash.first)
+  _M_rehash(__do_rehash.second, false_type{});
+
+__rehash_guard._M_guarded_obj = nullptr;
+  }
+
+
   template::
   _M_insert_range_multi(_InputIterator __first, _InputIterator __last)
   {
-   using __pair_type = std::pair;
-
-   size_type __n_elt = __detail::__distance_fw(__first, __last);
-   if (__n_elt == 0)
- return;
-
-   __rehash_guard_t __rehash_guard(_M_rehash_policy);
-   __pair_type __do_rehash
- = _M_rehash_policy._M_need_rehash(_M_bucket_count,
-   _M_element_count,
-   __n_elt);
-
-   if (__do_rehash.first)
- _M_rehash(__do_rehash.second, false_type{});
-
-   __rehash_guard._M_guarded_obj = nullptr;
+   _M_rehash_insert(__detail::__distance_fw(__first, __last));
for (; __first != __last; ++__first)
  _M_emplace_multi(cend(), *__first);
   }
diff --git a/libstdc++-v3/include/bits/unordered_set.h 
b/libstdc++-v3/include/bits/unordered_set.h
index fc9d584c0365..21ffdaf50a02 100644
--- a/libstdc++-v3/include/bits/unordered_set.h
+++ b/libstdc++-v3/include/bits/unordered_set.h
@@ -34,6 +34,9 @@
 #include 
 #include  // hash
 #include // equal_to
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::begin, ranges::distance etc.
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -268,6 +271,42 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   : unordered_set(__l, __n, __hf, key_equal(), __a)
   { }
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   *  @brief  Builds an %unordered_set from a range.
+   *  @since C++23
+   *  @param  __rg An input range of elements that can be converted to
+   *   the set's value type.
+   *  @param __n  Minimal initial number of buckets.
+   *  @param __hf  A hash functor.
+   *  @param __eql  A key equality functor.
+   *  @param  __a  An allocator object.
+   *
+   *  Create an %unordered_set consisting of copies of the elements in the
+   *  range. This is linear in N (where N is `std::ranges::size(__rg)`).
+   */
+   template<__detail:

[gcc r14-11414] libstdc++: Fix constraint recursion in basic_const_iterator relops [PR112490]

2025-03-18 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:a3c01af5e34801aaf65ba76f4afce753e443a99c

commit r14-11414-ga3c01af5e34801aaf65ba76f4afce753e443a99c
Author: Patrick Palka 
Date:   Fri Feb 28 09:39:57 2025 -0500

libstdc++: Fix constraint recursion in basic_const_iterator relops 
[PR112490]

Here for

  using RCI = reverse_iterator::iterator>>
  static_assert(std::totally_ordered);

we effectively need to check the requirement

  requires (RCI x) { x RELOP x; }  for each RELOP in {<, >, <=, >=}

which we expect to be straightforwardly satisfied by reverse_iterator's
namespace-scope relops.  But due to ADL we find ourselves also
considering the basic_const_iterator relop friends, which before CWG
2369 would be quickly discarded since RCI clearly isn't convertible to
basic_const_iterator.  After CWG 2369 though we must first check these
relops' constraints (with _It = vector::iterator and _It2 = RCI),
which entails checking totally_ordered recursively.

This patch fixes this by turning the problematic non-dependent function
parameters of type basic_const_iterator<_It> into dependent ones of
type basic_const_iterator<_It3> where _It3 is constrained to match _It.
Thus the basic_const_iterator relop friends now get quickly discarded
during deduction and before the constraint check if the second operand
isn't a specialization of basic_const_iterator (or derived from one)
like before CWG 2369.

PR libstdc++/112490

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (basic_const_iterator::operator<):
Replace non-dependent basic_const_iterator function parameter with
a dependent one of type basic_const_iterator<_It3> where _It3
matches _It.
(basic_const_iterator::operator>): Likewise.
(basic_const_iterator::operator<=): Likewise.
(basic_const_iterator::operator>=): Likewise.
* testsuite/24_iterators/const_iterator/112490.cc: New test.

Reviewed-by: Jonathan Wakely 
(cherry picked from commit 4342c50ca84ae5448c0128c52120f4fe9005f203)

Diff:
---
 libstdc++-v3/include/bits/stl_iterator.h | 16 
 .../testsuite/24_iterators/const_iterator/112490.cc  | 12 
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_iterator.h 
b/libstdc++-v3/include/bits/stl_iterator.h
index fff5f4015330..5e1fe30135ef 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -2865,30 +2865,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& three_way_comparable_with<_It, _It2>
   { return _M_current <=> __y; }
 
-template<__detail::__not_a_const_iterator _It2>
+template<__detail::__not_a_const_iterator _It2, same_as<_It> _It3>
   friend constexpr bool
-  operator<(const _It2& __x, const basic_const_iterator& __y)
+  operator<(const _It2& __x, const basic_const_iterator<_It3>& __y)
   noexcept(noexcept(__x < __y._M_current))
   requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
   { return __x < __y._M_current; }
 
-template<__detail::__not_a_const_iterator _It2>
+template<__detail::__not_a_const_iterator _It2, same_as<_It> _It3>
   friend constexpr bool
-  operator>(const _It2& __x, const basic_const_iterator& __y)
+  operator>(const _It2& __x, const basic_const_iterator<_It3>& __y)
   noexcept(noexcept(__x > __y._M_current))
   requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
   { return __x > __y._M_current; }
 
-template<__detail::__not_a_const_iterator _It2>
+template<__detail::__not_a_const_iterator _It2, same_as<_It> _It3>
   friend constexpr bool
-  operator<=(const _It2& __x, const basic_const_iterator& __y)
+  operator<=(const _It2& __x, const basic_const_iterator<_It3>& __y)
   noexcept(noexcept(__x <= __y._M_current))
   requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
   { return __x <= __y._M_current; }
 
-template<__detail::__not_a_const_iterator _It2>
+template<__detail::__not_a_const_iterator _It2, same_as<_It> _It3>
   friend constexpr bool
-  operator>=(const _It2& __x, const basic_const_iterator& __y)
+  operator>=(const _It2& __x, const basic_const_iterator<_It3>& __y)
   noexcept(noexcept(__x >= __y._M_current))
   requires random_access_iterator<_It> && totally_ordered_with<_It, _It2>
   { return __x >= __y._M_current; }
diff --git a/libstdc++-v3/testsuite/24_iterators/const_iterator/112490.cc 
b/libstdc++-v3/testsuite/24_iterators/const_iterator/112490.cc
new file mode 100644
index ..9bb154847cff
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/const_iterator/112490.cc
@@ -0,0 +1,12 @@
+// { dg-do compile { target c++23 } }
+
+// PR libstdc++/112490 - infinite meta

[gcc r15-8246] i386: Remove XFAIL for pr103750 testcases

2025-03-18 Thread Haochen Jiang via Gcc-cvs
https://gcc.gnu.org/g:289867bb298507d7c99a30f92d650a86df99225f

commit r15-8246-g289867bb298507d7c99a30f92d650a86df99225f
Author: Haochen Jiang 
Date:   Tue Mar 11 10:52:46 2025 +0800

i386: Remove XFAIL for pr103750 testcases

After commit r15-4510, the following testcases also do not need XFAIL.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512f-pr103750-1.c: Remove XFAIL.
* gcc.target/i386/avx512f-pr103750-2.c: Ditto.
* gcc.target/i386/avx512fp16-pr103750-1.c: Ditto.
* gcc.target/i386/avx512fp16-pr103750-2.c: Ditto.

Diff:
---
 gcc/testsuite/gcc.target/i386/avx512f-pr103750-1.c| 3 +--
 gcc/testsuite/gcc.target/i386/avx512f-pr103750-2.c| 3 +--
 gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-1.c | 3 +--
 gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-2.c | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr103750-1.c 
b/gcc/testsuite/gcc.target/i386/avx512f-pr103750-1.c
index 613efe0f9263..904432558f61 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-pr103750-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-pr103750-1.c
@@ -1,8 +1,7 @@
 /* PR target/103750 */
 /* { dg-do compile }  */
 /* { dg-options "-O2 -mavx512f -mavx512vl -mavx512bw" } */
-/* { dg-final { scan-assembler-not "kmov" { xfail ia32 } } } */
-/* xfail need to be fixed.  */
+/* { dg-final { scan-assembler-not "kmov" } } */
 
 #include 
 extern __m128i* pi128;
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr103750-2.c 
b/gcc/testsuite/gcc.target/i386/avx512f-pr103750-2.c
index a6c2b06747d4..f6ac35fbe49d 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-pr103750-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-pr103750-2.c
@@ -1,8 +1,7 @@
 /* PR target/103750 */
 /* { dg-do compile }  */
 /* { dg-options "-O2 -mavx512dq -mavx512vl -mavx512bw" } */
-/* { dg-final { scan-assembler-not "kmov" { xfail ia32 } } } */
-/* xfail need to be fixed.  */
+/* { dg-final { scan-assembler-not "kmov" } } */
 
 #include 
 extern __m128i* pi128;
diff --git a/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-1.c 
b/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-1.c
index eaf6d1e9819f..5d5ec51a2b75 100644
--- a/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-1.c
@@ -1,8 +1,7 @@
 /* PR target/103750 */
 /* { dg-do compile }  */
 /* { dg-options "-O2 -mavx512fp16 -mavx512vl" } */
-/* { dg-final { scan-assembler-not "kmov" { xfail ia32 } } } */
-/* xfail need to be fixed.  */
+/* { dg-final { scan-assembler-not "kmov" } } */
 
 #include 
 extern __m128h* ph128;
diff --git a/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-2.c 
b/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-2.c
index 3d3a033fe64c..b1bf3413af46 100644
--- a/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx512fp16-pr103750-2.c
@@ -1,8 +1,7 @@
 /* PR target/103750 */
 /* { dg-do compile }  */
 /* { dg-options "-O2 -mavx512fp16 -mavx512vl -mavx512dq" } */
-/* { dg-final { scan-assembler-not "kmov" { xfail ia32 } } } */
-/* xfail need to be fixed.  */
+/* { dg-final { scan-assembler-not "kmov" } } */
 
 #include 
 extern __m128h* ph128;


[gcc r15-8266] c, c++: Support musttail attribute even using __attribute__ form [PR116545]

2025-03-18 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:1d7f57da583782ae5d56655a3ac413bdf259838a

commit r15-8266-g1d7f57da583782ae5d56655a3ac413bdf259838a
Author: Jakub Jelinek 
Date:   Tue Mar 18 18:48:14 2025 +0100

c, c++: Support musttail attribute even using __attribute__ form [PR116545]

Apparently some programs in the wild use
 #if __has_attribute(musttail)
   __attribute__((musttail)) return foo ();
 #else
   return foo ();
 #endif
clang supports musttail both as a standard attribute ([[clang::musttail]]
which we also support for compatibility) and the above worked just
fine with GCC 14 which had __has_attribute(musttail) 0.  Now that it is
0, this doesn't compile anymore.
So, either we need to ensure that __has_attribute(musttail) is 0
and just __has_c{,pp}_attribute({gnu,clang}::musttail) are non-zero,
or IMHO better we just make it work in the attribute form, especially for
C < C23 I can see why some projects would prefer that form.
While [[gnu::musttail]] is rejected as an error in C11 etc. before GCC 15,
rather than just handled as an unknown attribute.
I view this as both a regression and compatibility issue.
The patch handles it in similar spots to fallthrough/assume attributes
inside of __attribute__ for C, and for C++ enables mixing of standard [[]]
and GNU __attribute__(()) attributes at the start of statements in any 
order.

While working on it, I've noticed we weren't diagnosing arguments to the
clang::musttail attribute (fixed by the c-attribs.cc hunk) and newly
on the __attribute__ form attribute (in that case the arguments aren't just
skipped, they are always parsed and because we don't call decl_attributes
etc., it wouldn't be diagnosed without a manual check).

2025-03-18  Jakub Jelinek  

PR c/116545
gcc/
* doc/extend.texi (musttail statement attribute): Document
that musttail GNU attribute can be used as well.
gcc/c-family/
* c-attribs.cc (c_common_clang_attributes): Add musttail.
gcc/c/
* c-parser.cc (c_parser_declaration_or_fndef): Parse
__attribute__((musttail)) return.
(c_parser_handle_musttail): Diagnose attribute arguments.
(c_parser_statement_after_labels): Parse
__attribute__((musttail)) return.
gcc/cp/
* parser.cc (cp_parser_statement): Call cp_parser_attributes_opt
rather than cp_parser_std_attribute_spec_seq.
(cp_parser_jump_statement): Diagnose gnu::musttail attributes
with no arguments.
gcc/testsuite/
* c-c++-common/attr-fallthrough-2.c: Adjust expected diagnostics
for C++.
* c-c++-common/musttail15.c: New test.
* c-c++-common/musttail16.c: New test.
* c-c++-common/musttail17.c: New test.
* c-c++-common/musttail18.c: New test.
* c-c++-common/musttail19.c: New test.
* c-c++-common/musttail20.c: New test.
* c-c++-common/musttail21.c: New test.
* c-c++-common/musttail22.c: New test.
* c-c++-common/musttail23.c: New test.
* c-c++-common/musttail24.c: New test.
* g++.dg/musttail7.C: New test.
* g++.dg/musttail8.C: New test.
* g++.dg/musttail12.C: New test.
* g++.dg/musttail13.C: New test.
* g++.dg/musttail14.C: New test.
* g++.dg/ext/pr116545.C: New test.

Diff:
---
 gcc/c-family/c-attribs.cc   |  4 +-
 gcc/c/c-parser.cc   | 50 +-
 gcc/cp/parser.cc|  9 ++-
 gcc/doc/extend.texi | 16 +++--
 gcc/testsuite/c-c++-common/attr-fallthrough-2.c |  4 +-
 gcc/testsuite/c-c++-common/musttail15.c | 14 
 gcc/testsuite/c-c++-common/musttail16.c | 33 +
 gcc/testsuite/c-c++-common/musttail17.c | 17 +
 gcc/testsuite/c-c++-common/musttail18.c | 14 
 gcc/testsuite/c-c++-common/musttail19.c | 17 +
 gcc/testsuite/c-c++-common/musttail20.c | 15 +
 gcc/testsuite/c-c++-common/musttail21.c |  5 ++
 gcc/testsuite/c-c++-common/musttail22.c | 90 +
 gcc/testsuite/c-c++-common/musttail23.c | 45 +
 gcc/testsuite/c-c++-common/musttail24.c | 21 ++
 gcc/testsuite/g++.dg/ext/pr116545.C | 39 +++
 gcc/testsuite/g++.dg/musttail12.C   | 40 +++
 gcc/testsuite/g++.dg/musttail13.C   | 33 +
 gcc/testsuite/g++.dg/musttail14.C   | 65 ++
 gcc/testsuite/g++.dg/musttail7.C| 60 +
 gcc/testsuite/g++.dg/musttail8.C| 10 +++
 21 files changed, 588 insertions(+), 13 deletions(-)

diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 050

[gcc r15-8269] libphobos: Merge changes in upstream druntime testsuite

2025-03-18 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:b3b54f9c9a74909a41ea566c2135c9e01121994c

commit r15-8269-gb3b54f9c9a74909a41ea566c2135c9e01121994c
Author: Iain Buclaw 
Date:   Sat Mar 15 16:32:48 2025 +0100

libphobos: Merge changes in upstream druntime testsuite

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime d2ee11364c.
* testsuite/libphobos.aa/test_aa.d: Add new test.
* testsuite/libphobos.betterc/test19933.d: Adjust imports.
* testsuite/libphobos.config/test22523.d: Likewise.
* testsuite/libphobos.exceptions/assert_fail.d: Adjust test.
* testsuite/libphobos.exceptions/chain.d: Adjust imports.
* testsuite/libphobos.exceptions/future_message.d: Likewise.
* testsuite/libphobos.exceptions/line_trace.d: Likewise.
* testsuite/libphobos.exceptions/long_backtrace_trunc.d: Likewise.
* testsuite/libphobos.exceptions/static_dtor.d: Likewise.
* testsuite/libphobos.gc/forkgc.d: Likewise.
* testsuite/libphobos.gc/precisegc.d: Likewise.
* testsuite/libphobos.gc/recoverfree.d: Likewise.
* testsuite/libphobos.hash/test_hash.d: Likewise.
* testsuite/libphobos.init_fini/custom_gc.d: Likewise.
* testsuite/libphobos.init_fini/thread_join.d: Likewise.
* testsuite/libphobos.thread/external_threads.d: Likewise.
* testsuite/libphobos.thread/fiber_guard_page.d: Likewise.
* testsuite/libphobos.thread/tlsgc_sections.d: Likewise.
* testsuite/libphobos.thread/tlsstack.d: Likewise.
* testsuite/libphobos.unittest/customhandler.d: Likewise.

Diff:
---
 libphobos/libdruntime/MERGE|  2 +-
 libphobos/testsuite/libphobos.aa/test_aa.d | 44 +-
 libphobos/testsuite/libphobos.betterc/test19933.d  |  2 +-
 libphobos/testsuite/libphobos.config/test22523.d   |  2 +-
 .../testsuite/libphobos.exceptions/assert_fail.d   |  8 
 libphobos/testsuite/libphobos.exceptions/chain.d   |  2 +-
 .../libphobos.exceptions/future_message.d  |  2 +-
 .../testsuite/libphobos.exceptions/line_trace.d|  2 +-
 .../libphobos.exceptions/long_backtrace_trunc.d|  2 +-
 .../testsuite/libphobos.exceptions/static_dtor.d   |  2 +-
 libphobos/testsuite/libphobos.gc/forkgc.d  |  2 +-
 libphobos/testsuite/libphobos.gc/precisegc.d   |  2 +-
 libphobos/testsuite/libphobos.gc/recoverfree.d |  1 -
 libphobos/testsuite/libphobos.hash/test_hash.d |  4 +-
 .../testsuite/libphobos.init_fini/custom_gc.d  |  4 +-
 .../testsuite/libphobos.init_fini/thread_join.d|  1 -
 .../testsuite/libphobos.thread/external_threads.d  |  3 +-
 .../testsuite/libphobos.thread/fiber_guard_page.d  |  4 +-
 .../testsuite/libphobos.thread/tlsgc_sections.d|  2 +-
 libphobos/testsuite/libphobos.thread/tlsstack.d|  2 +-
 .../testsuite/libphobos.unittest/customhandler.d   |  2 +-
 21 files changed, 71 insertions(+), 24 deletions(-)

diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 070d9fec28b9..18c9d1190ced 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-603225372b211bb66dd0ea1a939043ace5a650cf
+d2ee11364c25ca8865eb0acb9596a6147532ef41
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/libphobos/testsuite/libphobos.aa/test_aa.d 
b/libphobos/testsuite/libphobos.aa/test_aa.d
index 11ad2f90ff1d..5c3ba05d83d3 100644
--- a/libphobos/testsuite/libphobos.aa/test_aa.d
+++ b/libphobos/testsuite/libphobos.aa/test_aa.d
@@ -40,6 +40,7 @@ void main()
 testZeroSizedValue();
 testTombstonePurging();
 testClear();
+testTypeInfoCollect();
 }
 
 void testKeysValues1()
@@ -585,8 +586,6 @@ void issue13078() nothrow pure
 
 void issue14104()
 {
-import core.stdc.stdio;
-
 alias K = const(ubyte)*;
 size_t[K] aa;
 immutable key = cast(K)(cast(size_t) uint.max + 1);
@@ -907,3 +906,44 @@ void testClear()
 assert(aa.length == 1);
 assert(aa[5] == 6);
 }
+
+// https://github.com/dlang/dmd/issues/17503
+void testTypeInfoCollect()
+{
+import core.memory;
+
+static struct S
+{
+int x;
+~this() {}
+}
+
+static struct AAHolder
+{
+S[int] aa;
+}
+
+static S* getBadS()
+{
+auto aaholder = new AAHolder;
+aaholder.aa[0] = S();
+auto s = 0 in aaholder.aa; // keep a pointer to the entry
+GC.free(aaholder); // but not a pointer to the AA.
+return s;
+}
+
+static void stackStomp()
+{
+import core.stdc.string : memset;
+ubyte[4 * 4096] x;
+memset(x.ptr, 0, x.sizeof);
+}
+
+auto s = getBadS();
+stackStomp(); // destroy any stale references to the AA or s except in the 
current frame;
+GC.collect(); // BUG: this used to invalidate the fake type info, should

[gcc r15-8271] Fortran: check type-spec in ALLOCATE of dummy with assumed length [PR119338]

2025-03-18 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:6cbeab134f048d65ed615ed587f6ae0b01d1c336

commit r15-8271-g6cbeab134f048d65ed615ed587f6ae0b01d1c336
Author: Harald Anlauf 
Date:   Mon Mar 17 22:34:19 2025 +0100

Fortran: check type-spec in ALLOCATE of dummy with assumed length [PR119338]

PR fortran/119338

gcc/fortran/ChangeLog:

* resolve.cc (resolve_allocate_expr): Check F2003:C626: Type-spec
in ALLOCATE of an assumed-length character dummy argument shall be
an asterisk.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_18.f90: Adjust testcase.
* gfortran.dg/allocate_assumed_charlen_5.f90: New test.

Diff:
---
 gcc/fortran/resolve.cc  | 16 
 .../gfortran.dg/allocate_assumed_charlen_5.f90  | 17 +
 gcc/testsuite/gfortran.dg/deferred_character_18.f90 |  3 ++-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index d64edff85079..ddd982702309 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -8987,6 +8987,22 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool 
*array_alloc_wo_spec)
   goto failure;
 }
 
+  /* F2003:C626 (R623) A type-param-value in a type-spec shall be an asterisk
+ if and only if each allocate-object is a dummy argument for which the
+ corresponding type parameter is assumed.  */
+  if (code->ext.alloc.ts.type == BT_CHARACTER
+  && code->ext.alloc.ts.u.cl->length != NULL
+  && e->ts.type == BT_CHARACTER && !e->ts.deferred
+  && e->ts.u.cl->length == NULL
+  && e->symtree->n.sym->attr.dummy)
+{
+  gfc_error ("The type parameter in ALLOCATE statement with type-spec "
+"shall be an asterisk as allocate object %qs at %L is a "
+"dummy argument with assumed type parameter",
+sym->name, &e->where);
+  goto failure;
+}
+
   /* Check F08:C632.  */
   if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred
   && !UNLIMITED_POLY (e))
diff --git a/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_5.f90 
b/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_5.f90
new file mode 100644
index ..bc75dbe47ade
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_5.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! PR fortran/119338 - check F2003:C626
+
+module m
+  implicit none
+contains
+  subroutine sub (s, c)
+character(len=*), allocatable, intent(out) :: s(:)
+character(len=*), allocatable, intent(out) :: c
+allocate(s(5))  ! OK
+allocate(c) ! OK
+allocate(character(len=*)  :: s(5)) ! OK
+allocate(character(len=*)  :: c)! OK
+allocate(character(len=10) :: s(5)) ! { dg-error "shall be an asterisk" }
+allocate(character(len=10) :: c)! { dg-error "shall be an asterisk" }
+  end subroutine sub
+end module m
diff --git a/gcc/testsuite/gfortran.dg/deferred_character_18.f90 
b/gcc/testsuite/gfortran.dg/deferred_character_18.f90
index 1b1457fa293c..b1229c2485e7 100644
--- a/gcc/testsuite/gfortran.dg/deferred_character_18.f90
+++ b/gcc/testsuite/gfortran.dg/deferred_character_18.f90
@@ -11,7 +11,8 @@ contains
 character(*), allocatable, intent(out) :: str
 !  Note: Star ^ should have been a colon (:)
 
-allocate (character(n)::str)
+!   allocate (character(n)::str) ! original invalid version from pr82367
+allocate (character(*)::str) ! corrected (see F2003:C626 and pr119338)
 
   end subroutine


[gcc r15-8267] c: Fix handling of [[gnu::musttail] return in if and else bodies [PR119311]

2025-03-18 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:53d8ed13bb5a6972efab7c56c066010cd1f78b35

commit r15-8267-g53d8ed13bb5a6972efab7c56c066010cd1f78b35
Author: Jakub Jelinek 
Date:   Tue Mar 18 18:51:48 2025 +0100

c: Fix handling of [[gnu::musttail] return in if and else bodies [PR119311]

The following new testcase FAILs with C (and succeeds with C++).
c_parser_handle_musttail is used in c_parser_compound_statement_nostart
where it is directly passed to c_parser_statement_after_labels, and in
c_parser_all_labels where it is returned.  Now, out of the 3
c_parser_all_labels callers, c_parser_statement passes it down to
c_parser_statement_after_labels, but c_parser_if_body and c_parser_else_body
don't, so if there are return statements with [[gnu::musttail]] or
[[clang::musttail]] directly in if or else bodies rather than wrapped with
{}s, we throw that information away.

2025-03-18  Jakub Jelinek  

PR c/119311
* c-parser.cc (c_parser_if_body): Pass result of c_parser_all_labels
as last argument to c_parser_statement_after_labels.
(c_parser_else_body): Likewise.

* c-c++-common/musttail14.c: Use * instead of \* in the regexps.
* c-c++-common/musttail25.c: New test.

Diff:
---
 gcc/c/c-parser.cc   |  8 
 gcc/testsuite/c-c++-common/musttail14.c |  6 +++---
 gcc/testsuite/c-c++-common/musttail25.c | 28 
 3 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 93233a87b0a4..d49d5c58659f 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -8545,8 +8545,8 @@ c_parser_if_body (c_parser *parser, bool *if_p,
   token_indent_info body_tinfo
 = get_token_indent_info (c_parser_peek_token (parser));
   tree before_labels = get_before_labels ();
+  attr_state a = c_parser_all_labels (parser);
 
-  c_parser_all_labels (parser);
   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
 {
   location_t loc = c_parser_peek_token (parser)->location;
@@ -8561,7 +8561,7 @@ c_parser_if_body (c_parser *parser, bool *if_p,
   else
 {
   body_loc_after_labels = c_parser_peek_token (parser)->location;
-  c_parser_statement_after_labels (parser, if_p, before_labels);
+  c_parser_statement_after_labels (parser, if_p, before_labels, NULL, a);
 }
 
   token_indent_info next_tinfo
@@ -8590,8 +8590,8 @@ c_parser_else_body (c_parser *parser, const 
token_indent_info &else_tinfo,
 = get_token_indent_info (c_parser_peek_token (parser));
   location_t body_loc_after_labels = UNKNOWN_LOCATION;
   tree before_labels = get_before_labels ();
+  attr_state a = c_parser_all_labels (parser);
 
-  c_parser_all_labels (parser);
   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
 {
   location_t loc = c_parser_peek_token (parser)->location;
@@ -8605,7 +8605,7 @@ c_parser_else_body (c_parser *parser, const 
token_indent_info &else_tinfo,
 {
   if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
body_loc_after_labels = c_parser_peek_token (parser)->location;
-  c_parser_statement_after_labels (parser, NULL, before_labels, chain);
+  c_parser_statement_after_labels (parser, NULL, before_labels, chain, a);
 }
 
   token_indent_info next_tinfo
diff --git a/gcc/testsuite/c-c++-common/musttail14.c 
b/gcc/testsuite/c-c++-common/musttail14.c
index e95bc9bc7688..56a52b8638bd 100644
--- a/gcc/testsuite/c-c++-common/musttail14.c
+++ b/gcc/testsuite/c-c++-common/musttail14.c
@@ -1,9 +1,9 @@
 /* PR tree-optimization/118430 */
 /* { dg-do compile { target musttail } } */
 /* { dg-options "-O2 -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]\*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = freddy \\\(\[^\n\r]\*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
-/* { dg-final { scan-tree-dump-not "  (?:bar|freddy) \\\(\[^\n\r]\*\\\); 
\\\[tail call\\\]" "optimized" } } */
+/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = freddy \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "  (?:bar|freddy) \\\(\[^\n\r]*\\\); 
\\\[tail call\\\]" "optimized" } } */
 
 __attribute__ ((noipa)) void
 foo (int x)
diff --git a/gcc/testsuite/c-c++-common/musttail25.c 
b/gcc/testsuite/c-c++-common/musttail25.c
new file mode 100644
index ..ab286984fc69
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail25.c
@@ -0,0 +1,28 @@
+/* PR c/119311 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "  \[^\n\r]* = bar \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must t

[gcc/devel/omp/gcc-14] OpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579]

2025-03-18 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:9b3a935f2cbab875bd72298574ca42c95deb9d92

commit 9b3a935f2cbab875bd72298574ca42c95deb9d92
Author: Sandra Loosemore 
Date:   Tue Mar 11 16:36:22 2025 +

OpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579]

This patch is the C equivalent of commit r15-6512-gcf94ba812ca496 for C++,
to improve the location information for individual items in an OpenMP
variable list.

gcc/c/ChangeLog
PR c/118579
* c-parser.cc (c_parser_omp_variable_list): Capture location
information when KIND is OMP_CLAUSE_ERROR.
(c_parser_oacc_data_clause_deviceptr): Use the improved location
for diagnostics, and remove the FIXME.
(c_finish_omp_declare_variant): Likewise.
(c_parser_omp_threadprivate): Likewise.

gcc/testsuite/ChangeLog
PR c/118579
* c-c++-common/gomp/pr118579.c: New testcase.

(cherry picked from commit f74ed83e287dbaa20e9649df6cda631ee461ecf5)

Diff:
---
 gcc/c/ChangeLog.omp| 13 +++
 gcc/c/c-parser.cc  | 36 --
 gcc/testsuite/ChangeLog.omp|  8 +++
 gcc/testsuite/c-c++-common/gomp/pr118579.c | 25 +
 4 files changed, 60 insertions(+), 22 deletions(-)

diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index 4f0e16d4e0bc..33b2c5b9f0d4 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,16 @@
+2025-03-18  Sandra Loosemore  
+
+   Backported from master:
+   2025-03-11  Sandra Loosemore  
+
+   PR c/118579
+   * c-parser.cc (c_parser_omp_variable_list): Capture location
+   information when KIND is OMP_CLAUSE_ERROR.
+   (c_parser_oacc_data_clause_deviceptr): Use the improved location
+   for diagnostics, and remove the FIXME.
+   (c_finish_omp_declare_variant): Likewise.
+   (c_parser_omp_threadprivate): Likewise.
+
 2025-01-30  Tobias Burnus  
 
Backported from master:
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 23e59b69a7a1..f79131a5274f 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -15479,8 +15479,9 @@ c_array_type_nelts_total (tree type)
decl in OMP_CLAUSE_DECL and add the node to the head of the list.
If KIND is nonzero, CLAUSE_LOC is the location of the clause.
 
-   If KIND is zero, create a TREE_LIST with the decl in TREE_PURPOSE;
-   return the list created.
+   If KIND is zero (= OMP_CLAUSE_ERROR), create a TREE_LIST with the decl
+   in TREE_PURPOSE and the location in TREE_VALUE (accessible using
+   EXPR_LOCATION); return the list created.
 
The optional MAP_LVALUE argument is true if list items can use the deref
(->) operator.  */
@@ -15511,6 +15512,7 @@ c_parser_omp_variable_list (c_parser *parser,
   while (1)
 {
   tree t = NULL_TREE;
+  location_t tloc = c_parser_peek_token (parser)->location;
 
   if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY)
{
@@ -15838,7 +15840,7 @@ c_parser_omp_variable_list (c_parser *parser,
 
   if (t == error_mark_node)
;
-  else if (kind != 0)
+  else if (kind != 0)  /* kind != OMP_CLAUSE_ERROR */
{
  switch (kind)
{
@@ -16014,8 +16016,8 @@ c_parser_omp_variable_list (c_parser *parser,
  list = u;
}
}
-  else
-   list = tree_cons (t, NULL_TREE, list);
+  else  /* kind == OMP_CLAUSE_ERROR */
+   list = tree_cons (t, build_empty_stmt (tloc), list);
 
   if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY)
{
@@ -16179,7 +16181,6 @@ c_parser_oacc_data_clause (c_parser *parser, 
pragma_omp_clause c_kind,
 static tree
 c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list)
 {
-  location_t loc = c_parser_peek_token (parser)->location;
   tree vars, t;
 
   /* Can't use OMP_CLAUSE_MAP here (that is, can't use the generic
@@ -16190,12 +16191,7 @@ c_parser_oacc_data_clause_deviceptr (c_parser *parser, 
tree list)
   for (t = vars; t && t; t = TREE_CHAIN (t))
 {
   tree v = TREE_PURPOSE (t);
-
-  /* FIXME diagnostics: Ideally we should keep individual
-locations for all the variables in the var list to make the
-following errors more precise.  Perhaps
-c_parser_omp_var_list_parens() should construct a list of
-locations to go along with the var list.  */
+  location_t loc = EXPR_LOCATION (TREE_VALUE (t));
 
   if (!VAR_P (v) && TREE_CODE (v) != PARM_DECL)
error_at (loc, "%qD is not a variable", v);
@@ -26855,6 +26851,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree 
fndecl, tree parms)
for (tree c = list; c != NULL_TREE; c = TREE_CHAIN (c))
  {
tree decl = TREE_PURPOSE (c);
+   location_t arg_loc = EXPR_LOCATION (TREE_VALUE (c));
int idx

[gcc/devel/omp/gcc-14] Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ [PR115271]

2025-03-18 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:50c8e357a1ed6f97d227ffdb7d9498c38a549bc8

commit 50c8e357a1ed6f97d227ffdb7d9498c38a549bc8
Author: Tobias Burnus 
Date:   Mon Mar 17 10:12:44 2025 +0100

Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ 
[PR115271]

The test is a supposed to be a compile-only test but as 
dg-additional-sources
does not work with dg-compile (due to compiling with '-o'), dg-link had to
be used; as the code actually compiles (no diagnostic error), the linker
is actually invoked, which fails unless the system compiler by chance
provides the required files. Solution: move the test to libgomp.

PR fortran/115271

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-variant-mod-1-use.f90: Move to
libgomp/testsuite/libgomp.fortran/.
* gfortran.dg/gomp/declare-variant-mod-1.f90: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/declare-variant-mod-1-use.f90: Moved
from gcc/testsuite/gfortran.dg/gomp/.
* testsuite/libgomp.fortran/declare-variant-mod-1.f90: Likewise.

(cherry picked from commit 2d5c1e5149809f978ea2c07517de13fdbb925de6)

Diff:
---
 gcc/testsuite/ChangeLog.omp| 10 ++
 libgomp/ChangeLog.omp  | 10 ++
 .../testsuite/libgomp.fortran}/declare-variant-mod-1-use.f90   |  0
 .../testsuite/libgomp.fortran}/declare-variant-mod-1.f90   |  0
 4 files changed, 20 insertions(+)

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index fae6e733bf7a..6ca93eadb09a 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,13 @@
+2025-03-18  Tobias Burnus  
+
+   Backported from master:
+   2025-03-17  Tobias Burnus  
+
+   PR fortran/115271
+   * gfortran.dg/gomp/declare-variant-mod-1-use.f90: Move to
+   libgomp/testsuite/libgomp.fortran/.
+   * gfortran.dg/gomp/declare-variant-mod-1.f90: Likewise.
+
 2025-03-18  Tobias Burnus  
 
Backported from master:
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 2b4d34806dee..894a9f54869d 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,13 @@
+2025-03-18  Tobias Burnus  
+
+   Backported from master:
+   2025-03-17  Tobias Burnus  
+
+   PR fortran/115271
+   * testsuite/libgomp.fortran/declare-variant-mod-1-use.f90: Moved
+   from gcc/testsuite/gfortran.dg/gomp/.
+   * testsuite/libgomp.fortran/declare-variant-mod-1.f90: Likewise.
+
 2025-01-30  Tobias Burnus  
 
Backported from master:
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1-use.f90 
b/libgomp/testsuite/libgomp.fortran/declare-variant-mod-1-use.f90
similarity index 100%
rename from gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1-use.f90
rename to libgomp/testsuite/libgomp.fortran/declare-variant-mod-1-use.f90
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1.f90 
b/libgomp/testsuite/libgomp.fortran/declare-variant-mod-1.f90
similarity index 100%
rename from gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1.f90
rename to libgomp/testsuite/libgomp.fortran/declare-variant-mod-1.f90


[gcc r15-8273] rust: force cargo to build offline

2025-03-18 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:d4fe08c2d4725c6b6024c08b330a7e8e9496c7c5

commit r15-8273-gd4fe08c2d4725c6b6024c08b330a7e8e9496c7c5
Author: Marc Poulhiès 
Date:   Mon Mar 17 19:23:50 2025 +0100

rust: force cargo to build offline

gcc/rust/Changelog:
PR rust/119333

* Make-lang.in: Force offline mode for cargo

Signed-off-by: Marc Poulhiès 

Diff:
---
 gcc/rust/Make-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index efa630927fab..c892fa3091e3 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -503,5 +503,5 @@ rust/%.o: rust/metadata/%.cc
 rust/libffi_polonius.a: \
rust/checks/errors/borrowck/ffi-polonius/Cargo.toml \
$(wildcard $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/src/*)
-   cargo build --manifest-path 
$(srcdir)/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml --release 
--target-dir rust/ffi-polonius
+   cd $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/ && cargo build 
--offline --release --target-dir $(objdir)/rust/ffi-polonius
cp rust/ffi-polonius/release/libffi_polonius.a rust/libffi_polonius.a


[gcc r15-8260] testsuite: Add support for dg-output-file directive

2025-03-18 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:563e6d926d9826d76895086d0c40a29dc90d66e5

commit r15-8260-g563e6d926d9826d76895086d0c40a29dc90d66e5
Author: Jakub Jelinek 
Date:   Tue Mar 18 16:50:05 2025 +0100

testsuite: Add support for dg-output-file directive

The COBOL tests has many tests which just dump emit lots of output
to stdout and want to compare it against expected output.
We have the dg-output directive, but if one needs more than dozens
of lines in the output, adding hundreds of dg-output directives to
each source uses too much memory and is harder to maintain.

The following patch offers an alternative, dg-output-file
directive where one can supply a text file with expected output
(no regexp matching in that case, just exact output, except that it
handles different line ending styles (for the expected file
using tcl gets, for the actual output skips over \n, \r\n or \r).
And a newline at the end of the whole output is optional (in the actual
output, because I think some boards get it eaten).

Also tested with addition or subtraction of some characters from the
expected output files and saw FAILs with appropriate messages.

2025-03-18  Jakub Jelinek  

* doc/sourcebuild.texi (dg-output-file): Document.

* lib/gcc-dg.exp (${tool}-load): If output-file is set, compare
combined output against content of the [lindex ${output-file} 1]
file.
(dg-output-file): New directive.
* lib/dg-test-cleanup.exp (cleanup-after-saved-dg-test): Clear
output-file variable.
* gcc.dg/dg-output-file-1.c: New test.
* gcc.dg/dg-output-file-1-lp64.txt: New test.
* gcc.dg/dg-output-file-1-ilp32.txt: New test.

Diff:
---
 gcc/doc/sourcebuild.texi|  4 +
 gcc/testsuite/gcc.dg/dg-output-file-1-ilp32.txt |  3 +
 gcc/testsuite/gcc.dg/dg-output-file-1-lp64.txt  |  3 +
 gcc/testsuite/gcc.dg/dg-output-file-1.c | 13 
 gcc/testsuite/lib/dg-test-cleanup.exp   |  4 +
 gcc/testsuite/lib/gcc-dg.exp| 99 +
 6 files changed, 126 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 11420392e322..84fd2735c677 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1315,6 +1315,10 @@ Prune messages matching @var{regexp} from the test 
output.
 @item @{ dg-output @var{regexp} [@{ target/xfail @var{selector} @}] @}
 This DejaGnu directive compares @var{regexp} to the combined output
 that the test executable writes to @file{stdout} and @file{stderr}.
+
+@item @{ dg-output-file @var{file} [@{ target/xfail @var{selector} @}] @}
+Compares the content of @var{file} against the combined output that the
+test executable writes to @file{stdout} and @file{stderr}.
 @end table
 
 @subsubsection Specify environment variables for a test
diff --git a/gcc/testsuite/gcc.dg/dg-output-file-1-ilp32.txt 
b/gcc/testsuite/gcc.dg/dg-output-file-1-ilp32.txt
new file mode 100644
index ..0255ead56935
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dg-output-file-1-ilp32.txt
@@ -0,0 +1,3 @@
+This is a test output for ilp32 target
+to verify
+dg-output-file directive
diff --git a/gcc/testsuite/gcc.dg/dg-output-file-1-lp64.txt 
b/gcc/testsuite/gcc.dg/dg-output-file-1-lp64.txt
new file mode 100644
index ..e6d9c8ead41d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dg-output-file-1-lp64.txt
@@ -0,0 +1,3 @@
+This is a test output for lp64 target
+to verify
+dg-output-file directive
diff --git a/gcc/testsuite/gcc.dg/dg-output-file-1.c 
b/gcc/testsuite/gcc.dg/dg-output-file-1.c
new file mode 100644
index ..5ad632c4e351
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dg-output-file-1.c
@@ -0,0 +1,13 @@
+/* { dg-do run { target { lp64 || ilp32 } } } */
+/* { dg-options "-O2" } */
+/* { dg-output-file "dg-output-file-1-lp64.txt" { target lp64 } } */
+/* { dg-output-file "dg-output-file-1-ilp32.txt" { target ilp32 } } */
+
+int
+main ()
+{
+  __builtin_printf ("This is a test output for %s target\n"
+   "to verify\n"
+   "dg-output-file directive\n",
+   __SIZEOF_LONG__ * __CHAR_BIT__ == 64 ? "lp64" : "ilp32");
+}
diff --git a/gcc/testsuite/lib/dg-test-cleanup.exp 
b/gcc/testsuite/lib/dg-test-cleanup.exp
index 27b1eb3da20e..308ee002ef47 100644
--- a/gcc/testsuite/lib/dg-test-cleanup.exp
+++ b/gcc/testsuite/lib/dg-test-cleanup.exp
@@ -45,6 +45,7 @@ if { [info procs saved-dg-test] == [list] } {
global multiline_expected_outputs
global freeform_regexps
global save_linenr_varnames
+   global output-file
 
set additional_files ""
set additional_sources ""
@@ -70,6 +71,9 @@ if { [info procs saved-dg-test] == [list] } {
if [info exists testname_with_flags] {
unset testname_with_flags
}
+   if [info exists output-file] {
+   u

[gcc r15-8276] gcc, cobol: Check for get_current_dir_name [PR119301]

2025-03-18 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:544a9d9e49a1ff1d031cf9c85518f7c95179834a

commit r15-8276-g544a9d9e49a1ff1d031cf9c85518f7c95179834a
Author: Iain Sandoe 
Date:   Sat Mar 15 09:43:36 2025 +

gcc, cobol: Check for get_current_dir_name [PR119301]

This adds a configure check for get_current_dir_name and falls back
to getcwd() if it is not available on the host.

PR cobol/119301

gcc/cobol/ChangeLog:

* util.cc: Check for the availability of get_current_dir_name
snf fall back to getcwd() if it is not present on the host.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add check for get_current_dir_name.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/cobol/util.cc | 19 +++
 gcc/config.in |  6 ++
 gcc/configure |  2 +-
 gcc/configure.ac  |  2 +-
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 62ecd98e9ef8..101a0a0d8030 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -72,6 +72,25 @@ extern int yyparse(void);
 
 extern int demonstration_administrator(int N);
 
+#if !defined (HAVE_GET_CURRENT_DIR_NAME)
+/* Posix platforms might not have get_current_dir_name but should have
+   getcwd() and PATH_MAX.  */
+#if __has_include ()
+# include 
+#endif
+/* The Hurd doesn't define PATH_MAX.  */
+#if !defined (PATH_MAX) && defined(__GNU__)
+# define PATH_MAX 4096
+#endif
+static inline char *
+get_current_dir_name ()
+{
+  /* Use libiberty's allocator here.  */
+  char *buf = (char *) xmalloc (PATH_MAX);
+  return getcwd (buf, PATH_MAX);
+}
+#endif
+
 const char *
 symbol_type_str( enum symbol_type_t type )
 {
diff --git a/gcc/config.in b/gcc/config.in
index 0b46faa1e512..bc60d36a6352 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1624,6 +1624,12 @@
 #endif
 
 
+/* Define to 1 if you have the `get_current_dir_name' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GET_CURRENT_DIR_NAME
+#endif
+
+
 /* Define to 1 if using GNU as. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GNU_AS
diff --git a/gcc/configure b/gcc/configure
index 0ef47a937603..ae1d34971e42 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10640,7 +10640,7 @@ for ac_func in times clock kill getrlimit setrlimit 
atoq \
popen sysconf strsignal getrusage nl_langinfo \
gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked 
fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked 
fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked  
 putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \
-   clock_gettime munmap msync
+   clock_gettime munmap msync get_current_dir_name
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 4ac419a8a94e..8ef11e36210b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1574,7 +1574,7 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
popen sysconf strsignal getrusage nl_langinfo \
gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \
-   clock_gettime munmap msync)
+   clock_gettime munmap msync get_current_dir_name)
 
 # At least for glibc, clock_gettime is in librt.  But don't pull that
 # in if it still doesn't give us the function we want.


[gcc r15-8277] cobol: Remove dead code from the driver.

2025-03-18 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:57d1424efe934caeda222174a3e8bbc1e5ba65f4

commit r15-8277-g57d1424efe934caeda222174a3e8bbc1e5ba65f4
Author: Iain Sandoe 
Date:   Sun Mar 16 10:31:44 2025 +

cobol: Remove dead code from the driver.

EXEC_LIB is no longer defined anywhere, so that the dependent code is
now dead.  The rpath code (if required) would need to be conditional
since rpath support is not available on all hosts.  Remove now and then
address if/when it is needed (other drivers do not do this).

gcc/cobol/ChangeLog:

* gcobolspec.cc (append_rpath): Remove.
(lang_specific_driver): Remove hard-wired rpath and library
names.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/cobol/gcobolspec.cc | 38 +-
 1 file changed, 1 insertion(+), 37 deletions(-)

diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 5bd68531bc4b..4ae8e2cfd9e4 100644
--- a/gcc/cobol/gcobolspec.cc
+++ b/gcc/cobol/gcobolspec.cc
@@ -140,21 +140,6 @@ append_rdynamic()
   return;
   }
 
-static void
-append_rpath()
-  {
-#ifdef EXEC_LIB
-  // Handing append_option() something on the stack Just Doesn't Work
-  if( strlen(EXEC_LIB) )
-{
-static char ach[256];
-snprintf(ach, sizeof(ach), "-rpath=%s", EXEC_LIB);
-append_option (OPT_Wl_, ach, 1);
-}
-#endif
-  return;
-  }
-
 static void
 append_allow_multiple_definition()
   {
@@ -250,9 +235,6 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 
   int index_libgcobol_a = 0;
 
-  // This is for the -Wl,-rpath=
-  bool need_rpath = true;
-
   bool no_files_error = true;
 
 #ifdef NOISY
@@ -339,16 +321,6 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
   {
   need_allow_multiple_definition = false;
   }
-if( strstr(decoded_options[i].orig_option_with_args_text, "-rpath") )
-  {
-  // The caller is doing something with -rpath.  Assume they know what
-  // they are doing
-
-  // On second thought, always install our rpath.  It goes at the end,
-  // so if the user specifies and rpath that they prefer, it'll get
-  // taken first.
-  need_rpath = true;
-  }
 break;
 
   case OPT_nostdlib:
@@ -616,12 +588,9 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 
   if( need_libgcobol )
 {
-#ifdef EXEC_LIB
-append_option(OPT_L, EXEC_LIB, 1);
-#endif
 add_arg_lib(COBOL_LIBRARY, static_libgcobol);
 }
-  if( need_libmath   )
+  if( need_libmath)
 {
 add_arg_lib(MATH_LIBRARY, static_in_general);
 }
@@ -649,11 +618,6 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
 append_allow_multiple_definition();
 }
 
-  if( need_rpath && (n_infiles || n_outfiles) )
-{
-append_rpath();
-}
-
   if( prior_main )
 {
 char ach[] = "\"-main\" without a source file";


[gcc r14-11415] c++: tweak for -Wrange-loop-construct [PR116731]

2025-03-18 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:a9f88741a99ba09b29cc0021499c63ca445393f0

commit r14-11415-ga9f88741a99ba09b29cc0021499c63ca445393f0
Author: Marek Polacek 
Date:   Tue Sep 17 16:58:37 2024 -0400

c++: tweak for -Wrange-loop-construct [PR116731]

This PR reports that the warning would be better off using a check
for trivially constructible rather than trivially copyable.

LLVM accepted a similar fix:
https://github.com/llvm/llvm-project/issues/47355

PR c++/116731

gcc/cp/ChangeLog:

* parser.cc (warn_for_range_copy): Check if TYPE is trivially
constructible, not copyable.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wrange-loop-construct3.C: New test.

Reviewed-by: Jason Merrill 
(cherry picked from commit 6ac4e2f4b2ca9980670e7d3815a9140730df1005)

Diff:
---
 gcc/cp/parser.cc   |  8 +--
 gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C | 57 ++
 2 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index aeb36d1e4831..052355fe9c15 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -14316,11 +14316,13 @@ warn_for_range_copy (tree decl, tree expr)
   else if (!CP_TYPE_CONST_P (type))
 return;
 
-  /* Since small trivially copyable types are cheap to copy, we suppress the
- warning for them.  64B is a common size of a cache line.  */
+  /* Since small trivially constructible types are cheap to construct, we
+ suppress the warning for them.  64B is a common size of a cache line.  */
+  tree vec = make_tree_vec (1);
+  TREE_VEC_ELT (vec, 0) = TREE_TYPE (expr);
   if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST
   || (tree_to_uhwi (TYPE_SIZE_UNIT (type)) <= 64
- && trivially_copyable_p (type)))
+ && is_trivially_xible (INIT_EXPR, type, vec)))
 return;
 
   /* If we can initialize a reference directly, suggest that to avoid the
diff --git a/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C 
b/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C
new file mode 100644
index ..3d9d0c9088e6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wrange-loop-construct3.C
@@ -0,0 +1,57 @@
+// PR c++/116731
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wrange-loop-construct" }
+
+void
+f0 ()
+{
+  struct S {
+char a[64];
+S& operator=(const S&) { return *this; };
+  };
+
+  S arr[8];
+  for (const auto r : arr)
+(void) r;
+}
+
+void
+f1 ()
+{
+  struct S {
+char a[65];
+S& operator=(const S&) { return *this; };
+  };
+
+  S arr[8];
+  for (const auto r : arr) // { dg-warning "creates a copy" }
+(void) r;
+}
+
+void
+f2 ()
+{
+  struct S {
+char a[64];
+S& operator=(const S&) { return *this; };
+~S() { }
+  };
+
+  S arr[8];
+  for (const auto r : arr) // { dg-warning "creates a copy" }
+(void) r;
+}
+
+void
+f3 ()
+{
+  struct S {
+char a[65];
+S& operator=(const S&) { return *this; };
+~S() { }
+  };
+
+  S arr[8];
+  for (const auto r : arr) // { dg-warning "creates a copy" }
+(void) r;
+}


[gcc r15-8264] Populate -original dump for Cobol

2025-03-18 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:9c9d2fdaa5b4fc0bcfd71e9886143756e41a8fe9

commit r15-8264-g9c9d2fdaa5b4fc0bcfd71e9886143756e41a8fe9
Author: Richard Biener 
Date:   Tue Mar 11 13:19:55 2025 +0100

Populate -original dump for Cobol

The following implements -fdump-tree-original dumping for cobol,
mimicing what the D frontend does.

gcc/cobol/
* gengen.cc (gg_finalize_function): Dump to TDI_original.

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

diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc
index d0601e0c6c45..2796b7facdbd 100644
--- a/gcc/cobol/gengen.cc
+++ b/gcc/cobol/gengen.cc
@@ -102,6 +102,7 @@
 #include "cbldiag.h"
 #include "symbols.h"
 #include "gengen.h"
+#include "dumpfile.h"
 
 // We are limiting the programmer to functions with 512 or fewer arguments.
 // Don't like it?  Cry me a river.
@@ -2926,6 +2927,8 @@ gg_finalize_function()
 cgraph_node::finalize_function (current_function->function_decl, true);
 }
 
+  dump_function (TDI_original, current_function->function_decl);
+
   if( gg_trans_unit.function_stack.back().context_count )
 {
 cbl_internal_error("Residual context count!");


[gcc r15-8274] libphobos: Avoid setting union members in std.json, set the whole union instead

2025-03-18 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:ef4248460d53dc9b43a59f8b7c782a9d9f9b2754

commit r15-8274-gef4248460d53dc9b43a59f8b7c782a9d9f9b2754
Author: Iain Buclaw 
Date:   Tue Mar 18 19:12:14 2025 +0100

libphobos: Avoid setting union members in std.json, set the whole union 
instead

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos cafe86453.

Reviewed-on: https://github.com/dlang/phobos/pull/10683

Diff:
---
 libphobos/src/MERGE  |  2 +-
 libphobos/src/std/json.d | 44 
 2 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index a5a685de2362..93b7a4d1ac2c 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-0faae92d62bdc1cc1982f0e9c65830ece1677289
+cafe8645336bfc60be03b5a558164b3bc7df79ef
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/json.d b/libphobos/src/std/json.d
index 7182f6ee8072..eb08de8f048d 100644
--- a/libphobos/src/std/json.d
+++ b/libphobos/src/std/json.d
@@ -562,8 +562,7 @@ struct JSONValue
 else static if (is(T : string))
 {
 type_tag = JSONType.string;
-string t = arg;
-() @trusted { store.str = t; }();
+store = Store(str: arg);
 }
 // https://issues.dlang.org/show_bug.cgi?id=15884
 else static if (isSomeString!T)
@@ -572,7 +571,7 @@ struct JSONValue
 // FIXME: std.Array.Array(Range) is not deduced as 'pure'
 () @trusted {
 import std.utf : byUTF;
-store.str = cast(immutable)(arg.byUTF!char.array);
+store = Store(str: cast(immutable)(arg.byUTF!char.array));
 }();
 }
 else static if (is(T : bool))
@@ -582,17 +581,17 @@ struct JSONValue
 else static if (is(T : ulong) && isUnsigned!T)
 {
 type_tag = JSONType.uinteger;
-store.uinteger = arg;
+store = Store(uinteger: arg);
 }
 else static if (is(T : long))
 {
 type_tag = JSONType.integer;
-store.integer = arg;
+store = Store(integer: arg);
 }
 else static if (isFloatingPoint!T)
 {
 type_tag = JSONType.float_;
-store.floating = arg;
+store = Store(floating: arg);
 }
 else static if (is(T : Value[Key], Key, Value))
 {
@@ -600,45 +599,34 @@ struct JSONValue
 type_tag = JSONType.object;
 static if (is(Value : JSONValue))
 {
-JSONValue[string] t = arg;
-() @trusted {
-store.object.isOrdered = false;
-store.object.unordered = t;
-}();
+store = Store(object: Store.Object(false, unordered: arg));
 }
 else
 {
 JSONValue[string] aa;
 foreach (key, value; arg)
 aa[key] = JSONValue(value);
-() @trusted {
-store.object.isOrdered = false;
-store.object.unordered = aa;
-}();
+store = Store(object: Store.Object(false, unordered: aa));
 }
 }
 else static if (is(T : OrderedObjectMember[]))
 {
 type_tag = JSONType.object;
-() @trusted {
-store.object.isOrdered = true;
-store.object.ordered = arg;
-}();
+store = Store(object: Store.Object(true, ordered: arg));
 }
 else static if (isArray!T)
 {
 type_tag = JSONType.array;
 static if (is(ElementEncodingType!T : JSONValue))
 {
-JSONValue[] t = arg;
-() @trusted { store.array = t; }();
+store = Store(array: arg);
 }
 else
 {
 JSONValue[] new_arg = new JSONValue[arg.length];
 foreach (i, e; arg)
 new_arg[i] = JSONValue(e);
-() @trusted { store.array = new_arg; }();
+store = Store(array: new_arg);
 }
 }
 else static if (is(T : JSONValue))
@@ -658,14 +646,14 @@ struct JSONValue
 type_tag = JSONType.array;
 static if (is(ElementEncodingType!T : JSONValue))
 {
-store.array = arg;
+store = Store(array: arg);
 }
 else
 {
 JSONValue[] new_arg = new JSONValue[arg.length];
 foreach (i, e; arg)
 new_arg[i] = JSONValue(e);
-store.array = new_arg;
+store = Store(array: new_arg);
 }
 }
 
@@ -1616,13 +1604,13 @@ if (isSomeFiniteCharInputRange!T)
 if (isFloat)
   

[gcc r15-8275] libphobos: Fix std.getopt doesn't accept const(string)[] anymore

2025-03-18 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:1ad1bcc991b32d72d4de4758c0dcac611f20cda8

commit r15-8275-g1ad1bcc991b32d72d4de4758c0dcac611f20cda8
Author: Iain Buclaw 
Date:   Tue Mar 18 19:15:40 2025 +0100

libphobos: Fix std.getopt doesn't accept const(string)[] anymore

Instead of passing receiver into the conversion function, just return
the value and assign it to the receiver. Renamed the conversion function
and also cleaned up all the `typeof' calls, which were very verbose.

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos 79cbde1ab.

Reviewed-on: https://github.com/dlang/phobos/pull/10684

Diff:
---
 libphobos/src/MERGE|  2 +-
 libphobos/src/std/getopt.d | 73 +-
 2 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index 93b7a4d1ac2c..a4888fc96180 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-cafe8645336bfc60be03b5a558164b3bc7df79ef
+79cbde1ab69bae9372f310d663edfc43166095e3
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/getopt.d b/libphobos/src/std/getopt.d
index 1a9072207f5d..fc5cdac73cec 100644
--- a/libphobos/src/std/getopt.d
+++ b/libphobos/src/std/getopt.d
@@ -610,14 +610,14 @@ private template optionValidator(A...)
 alias optionValidator = message;
 }
 
-private void handleConversion(R)(string option, string value, R* receiver,
+private auto getoptTo(R)(string option, string value,
 size_t idx, string file = __FILE__, size_t line = __LINE__)
 {
 import std.conv : to, ConvException;
 import std.format : format;
 try
 {
-*receiver = to!(typeof(*receiver))(value);
+return to!R(value);
 }
 catch (ConvException e)
 {
@@ -876,12 +876,18 @@ private bool handleOption(R)(string option, R receiver, 
ref string[] args,
 // (and potentially args[i + 1] too, but that comes later)
 args = args[0 .. i] ~ args[i + 1 .. $];
 
-static if (is(typeof(*receiver) == bool))
+static if (is(typeof(*receiver)))
+alias Target = typeof(*receiver);
+else
+// delegate
+alias Target = void;
+
+static if (is(Target == bool))
 {
 if (val.length)
 {
 // parse '--b=true/false'
-handleConversion(option, val, receiver, i);
+*receiver = getoptTo!(Target)(option, val, i);
 }
 else
 {
@@ -894,23 +900,23 @@ private bool handleOption(R)(string option, R receiver, 
ref string[] args,
 import std.exception : enforce;
 // non-boolean option, which might include an argument
 enum isCallbackWithLessThanTwoParameters =
-(is(typeof(receiver) == delegate) || is(typeof(*receiver) == 
function)) &&
+(is(R == delegate) || is(Target == function)) &&
 !is(typeof(receiver("", "")));
 if (!isCallbackWithLessThanTwoParameters && !(val.length) && 
!incremental)
 {
 // Eat the next argument too.  Check to make sure there's one
 // to be eaten first, though.
 enforce!GetOptException(i < args.length,
-"Missing value for argument " ~ a ~ ".");
+"Missing value for argument " ~ a ~ ".");
 val = args[i];
 args = args[0 .. i] ~ args[i + 1 .. $];
 }
-static if (is(typeof(*receiver) == enum) ||
-is(typeof(*receiver) == string))
+static if (is(Target == enum) ||
+is(Target == string))
 {
-handleConversion(option, val, receiver, i);
+*receiver = getoptTo!Target(option, val, i);
 }
-else static if (is(typeof(*receiver) : real))
+else static if (is(Target : real))
 {
 // numeric receiver
 if (incremental)
@@ -919,16 +925,16 @@ private bool handleOption(R)(string option, R receiver, 
ref string[] args,
 }
 else
 {
-handleConversion(option, val, receiver, i);
+*receiver = getoptTo!Target(option, val, i);
 }
 }
-else static if (is(typeof(*receiver) == string))
+else static if (is(Target == string))
 {
 // string receiver
-*receiver = to!(typeof(*receiver))(val);
+*receiver = getoptTo!(Target)(option, val, i);
 }
-else static if (is(typeof(receiver) == delegate) ||
-is(typeof(*receiver) == function))
+else static if (is(R == delegate) ||
+is(Target =

[gcc r15-8265] Update cpplib fr.po, sv.po

2025-03-18 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:05e20b78416230f6e6d5939d5920a7d21f18fdb8

commit r15-8265-g05e20b78416230f6e6d5939d5920a7d21f18fdb8
Author: Joseph Myers 
Date:   Tue Mar 18 17:48:07 2025 +

Update cpplib fr.po, sv.po

* fr.po, sv.po: Update.

Diff:
---
 libcpp/po/fr.po | 17 +++--
 libcpp/po/sv.po | 17 +++--
 2 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/libcpp/po/fr.po b/libcpp/po/fr.po
index 24756d9f8724..f1fafe2112c9 100644
--- a/libcpp/po/fr.po
+++ b/libcpp/po/fr.po
@@ -120,10 +120,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: GNU cpplib-15-b20250216\n"
+"Project-Id-Version: GNU cpplib-15.1-b20250316\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n";
 "POT-Creation-Date: 2025-03-14 22:05+\n"
-"PO-Revision-Date: 2025-03-01 12:46+0100\n"
+"PO-Revision-Date: 2025-03-18 07:19+0100\n"
 "Last-Translator: Frédéric Marchal \n"
 "Language-Team: French \n"
 "Language: fr\n"
@@ -324,8 +324,7 @@ msgid "hex escape sequence out of range"
 msgstr "séquence d’échappement hexadécimale hors intervalle"
 
 #: charset.cc:2247
-#, fuzzy, gcc-internal-format
-#| msgid "%<\\o%> not followed by %<}%>"
+#, gcc-internal-format
 msgid "%<\\o%> not followed by %<{%>"
 msgstr "%<\\o%> n’est pas suivi de %<{%>"
 
@@ -577,16 +576,14 @@ msgid "%<#embed%> not supported in traditional C"
 msgstr "%<#embed%> n'est pas supporté en C traditionnel"
 
 #: directives.cc:1370
-#, fuzzy, gcc-internal-format
-#| msgid "%<#%s%> before C++23 is a GCC extension"
+#, gcc-internal-format
 msgid "%<#%s%> before C++26 is a GCC extension"
-msgstr "%<#%s%> avant C++23 est une extension GCC"
+msgstr "%<#%s%> avant C++26 est une extension GCC"
 
 #: directives.cc:1379
-#, fuzzy, gcc-internal-format
-#| msgid "%<#%s%> is a GCC extension"
+#, gcc-internal-format
 msgid "%<#%s%> is a C23 feature"
-msgstr "%<#%s%> est une extension GCC"
+msgstr "%<#%s%> est une fonctionnalité de C23"
 
 #: directives.cc:1436
 #, gcc-internal-format
diff --git a/libcpp/po/sv.po b/libcpp/po/sv.po
index 536921d9120a..7ccf006d9db0 100644
--- a/libcpp/po/sv.po
+++ b/libcpp/po/sv.po
@@ -7,10 +7,10 @@
 # Remember: The GCC team does not want RCS keywords in the header!
 msgid ""
 msgstr ""
-"Project-Id-Version: cpplib 15-b20250216\n"
+"Project-Id-Version: cpplib 15.1-b20250316\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n";
 "POT-Creation-Date: 2025-03-14 22:05+\n"
-"PO-Revision-Date: 2025-02-25 09:36+0100\n"
+"PO-Revision-Date: 2025-03-18 09:15+0100\n"
 "Last-Translator: Göran Uddeborg \n"
 "Language-Team: Swedish \n"
 "Language: sv\n"
@@ -208,8 +208,7 @@ msgid "hex escape sequence out of range"
 msgstr "hexadecimal specialsekvens utanför intervallet"
 
 #: charset.cc:2247
-#, fuzzy, gcc-internal-format
-#| msgid "%<\\o%> not followed by %<}%>"
+#, gcc-internal-format
 msgid "%<\\o%> not followed by %<{%>"
 msgstr "%<\\o%> inte följt av %<{%>"
 
@@ -461,16 +460,14 @@ msgid "%<#embed%> not supported in traditional C"
 msgstr "%<#embed%> stödjs inte i traditionell C"
 
 #: directives.cc:1370
-#, fuzzy, gcc-internal-format
-#| msgid "%<#%s%> before C++23 is a GCC extension"
+#, gcc-internal-format
 msgid "%<#%s%> before C++26 is a GCC extension"
-msgstr "%<#%s%> före C++23 är en GCC-utvidgning"
+msgstr "%<#%s%> före C++26 är en GCC-utvidgning"
 
 #: directives.cc:1379
-#, fuzzy, gcc-internal-format
-#| msgid "%<#%s%> is a GCC extension"
+#, gcc-internal-format
 msgid "%<#%s%> is a C23 feature"
-msgstr "%<#%s%> är en GCC-utvidgning"
+msgstr "%<#%s%> är en C23-funktion"
 
 #: directives.cc:1436
 #, gcc-internal-format


[gcc/devel/omp/gcc-14] (113 commits) Merge remote-tracking branch 'origin/releases/gcc-14' into

2025-03-18 Thread Tobias Burnus via Gcc-cvs
The branch 'devel/omp/gcc-14' was updated to point to:

 0d5021e1d8ee... Merge remote-tracking branch 'origin/releases/gcc-14' into 

It previously pointed to:

 50c8e357a1ed... Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp

Diff:

Summary of changes (added commits):
---

  0d5021e... Merge remote-tracking branch 'origin/releases/gcc-14' into 
  a3c01af... libstdc++: Fix constraint recursion in basic_const_iterator (*)
  3d99c22... Daily bump. (*)
  5ef1aa4... Daily bump. (*)
  bf9c2ee... Daily bump. (*)
  f8504e3... Daily bump. (*)
  158987a... Daily bump. (*)
  1016eea... Plug small loophole in the pattern matching done by -fdump- (*)
  6fcad2b... Daily bump. (*)
  a27b24c... c++: ICE with aligned member and trivial assign op [PR11751 (*)
  e5ae0a0... c++: ICE with lambda in fold expression in requires [PR1191 (*)
  de08b13... arm: testsuite: fix arm_neon_h checks with conflicting cpu/ (*)
  f1dd3a1... arm: testsuite: improve guard checks for arm_neon.h (*)
  3a07660... Daily bump. (*)
  af69315... d: Fix regression returning from function with invariants [ (*)
  79366d9... Daily bump. (*)
  ca0ea3d... libphobos: Default to libc closefrom in spawnProcessPosix [ (*)
  5cb69a5... Fortran: ICE in gfc_conv_expr_present w. defined assignment (*)
  89fa4d8... Daily bump. (*)
  f6f90e0... Fortran: Fix segmentation fault in defined assignment [PR10 (*)
  e4f886c... Fortran: Fix ICE in resolve.cc with -pedantic (*)
  c6b2a35... Fortran: Fix gimplification error on assignment to pointer  (*)
  2b9cfa7... Daily bump. (*)
  9608070... Daily bump. (*)
  1c99a8f... arm: Handle fixed PIC register in require_pic_register (PR  (*)
  fa76306... Daily bump. (*)
  43d7770... LoongArch: Fix incorrect reorder of __lsx_vldx and __lasx_x (*)
  844f5f1... Daily bump. (*)
  8c63507... c++: disable -Wnonnull in unevaluated context [PR115580] (*)
  1a4f1e5... aarch64: Check for invalid use arrays in ldp_fusion [PR1183 (*)
  6e17b35... arm: Fix signedness of vld1q intrinsic parms [PR118942] (*)
  750d691... libstdc++: Fix subrange conversion to pair-like [PR119121] (*)
  e834308... Daily bump. (*)
  2ed3759... c++: generic lambda, implicit 'this' capture, xobj memfn [P (*)
  df9c10d... aarch64: Add missing simd requirements for INS [PR118531] (*)
  aa8793d... Fix folding of BIT_NOT_EXPR for POLY_INT_CST [PR118976] (*)
  7fb1d7b... arm: xfail gcc.target/arm/unsigned-extend-1.c for thumb1 (*)
  a42ef09... testsuite: arm: Use effective-target for pr68674.c test (*)
  e79fc5a... testsuite: Add tests for already fixed PR [PR119071] (*)
  b7b8307... combine: Discard REG_UNUSED note in i2 when register is als (*)
  455ea90... ipa-sra: Avoid clashes with ipa-cp when pulling accesses ac (*)
  dd09f67... Daily bump. (*)
  6ffbc71... gimple: sccopy: Prune removed statements from SCCs [PR11791 (*)
  19cf198... Daily bump. (*)
  c1535f2... [PR target/116720] Fix test for valid mempair operands (*)
  04b5c8b... d: Fix comparing uninitialized memory in dstruct.d [PR11696 (*)
  faa15a3... Daily bump. (*)
  4517919... Daily bump. (*)
  3a8d05b... libstdc++: Use init_priority attribute for tzdb globals [PR (*)
  9c02bad... libstdc++: Hide std::tuple internals from Doxygen docs (*)
  2b9449c... libstdc++: Fix outdated comment in  (*)
  85f4136... libstdc++: Reuse temporary buffer utils in  (*)
  8443a90... libstdc++: Optimize std::basic_string_view::starts_with (*)
  3b9885a... libstdc++: Do not use C++11 alignof in C++98 mode [PR104395 (*)
  c795413... libstdc++: Fix warning regressions in  (*)
  fb9a2af... libstdc++: Handle extended alignment in std::get_temporary_ (*)
  f83bc0e... libstdc++: fix a dangling reference crash in ranges::is_per (*)
  6561de3... libstdc++: Qualify calls in  to p (*)
  70452d2... libstdc++: Add missing character to __to_wstring_numeric ma (*)
  6e97d60... libstdc++: Add missing equality comparison in new tests [PR (*)
  dd8866d... libstdc++: Use ADL swap for containers' function objects [P (*)
  1921b0c... libstdc++: Add debug assertions to std::list and std::forwa (*)
  a66d975... libstdc++: Implement LWG 2937 for std::filesystem::equivale (*)
  ac47b3b... Daily bump. (*)
  59b0946... testsuite: limit concepts-pr67774.C to C++20 (*)
  7e7a1b6... c++: NRVO, constexpr, lambda [PR118053] (*)
  a72e782... c++: disable initializer_list transformation (*)
  19bf273... c++: Update const_decl handling after r15-7259 [PR118673]. (*)
  b4f66a7... c++: init-list opt and lvalue initializers [PR118673] (*)
  3003d40... c++: constexpr VEC_INIT_EXPR [PR118285] (*)
  ba488a3... i386: Treat Granite Rapids/Granite Rapids-D similar as Sapp (*)
  460a803... Daily bump. (*)
  d13602d... Daily bump. (*)
  ce4cb48... s390: Fix s390_valid_shift_count() for TI mode [PR118835] (*)
  09cc01c... jit/118780 - make sure to include dlfcn.h when plugin suppo (*)
  dbb91c3... Daily bump. (*)
  93e7442... tree-optimization/118717 - store commoning vs. abnormals (*)
  422f65a... tree-optimization/118653 - ICE 

[gcc/devel/omp/gcc-14] Merge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14

2025-03-18 Thread Tobias Burnus via Libstdc++-cvs
https://gcc.gnu.org/g:0d5021e1d8ee8c943925ad23c305b6c84962e4b8

commit 0d5021e1d8ee8c943925ad23c305b6c84962e4b8
Merge: 50c8e357a1ed a3c01af5e348
Author: Tobias Burnus 
Date:   Tue Mar 18 19:43:23 2025 +0100

Merge remote-tracking branch 'origin/releases/gcc-14' into devel/omp/gcc-14

Merge up to r14-11414-ga3c01af5e34801 (18th March 2025)

Diff:

 gcc/ChangeLog  | 312 
 gcc/DATESTAMP  |   2 +-
 gcc/c-family/ChangeLog |  15 +
 gcc/c-family/c-ada-spec.cc |   4 +-
 gcc/c-family/c-common.cc   |   3 +
 gcc/combine.cc |  20 +-
 gcc/common/config/i386/i386-common.cc  |  15 +-
 gcc/common/config/i386/i386-isas.h |   1 -
 gcc/config/aarch64/aarch64-freebsd.h   |   1 +
 gcc/config/aarch64/aarch64-ldp-fusion.cc   |  31 +-
 gcc/config/aarch64/aarch64.cc  |  11 +
 gcc/config/aarch64/aarch64.md  |   9 +-
 gcc/config/arm/arm.cc  |   5 +-
 gcc/config/arm/arm_neon.h  |   8 +-
 gcc/config/arm/freebsd.h   |   1 +
 gcc/config/freebsd-spec.h  |  18 +-
 gcc/config/i386/freebsd.h  |   1 +
 gcc/config/i386/freebsd64.h|   1 +
 gcc/config/i386/i386-options.cc|   4 +-
 gcc/config/i386/i386.opt   |   5 -
 gcc/config/i386/i386.opt.urls  |   3 -
 gcc/config/i386/x86-tune.def   |  13 +-
 gcc/config/loongarch/lasx.md   |  13 -
 gcc/config/loongarch/loongarch-c.cc|   7 +-
 gcc/config/loongarch/lsx.md|  13 -
 gcc/config/loongarch/simd.md   |  10 +
 gcc/config/riscv/freebsd.h |   1 +
 gcc/config/riscv/thead.cc  |  20 +-
 gcc/config/rs6000/freebsd64.h  |   1 +
 gcc/config/rs6000/sysv4.h  |   1 +
 gcc/config/s390/s390.cc|  35 +-
 gcc/cp/ChangeLog   |  71 
 gcc/cp/call.cc |  20 +-
 gcc/cp/constexpr.cc|  28 +-
 gcc/cp/cp-tree.h   |   4 +-
 gcc/cp/decl2.cc|   4 +-
 gcc/cp/lambda.cc   |   7 +-
 gcc/cp/pt.cc   |   1 +
 gcc/cp/tree.cc |  21 +-
 gcc/cp/typeck.cc   |   6 +-
 gcc/d/ChangeLog|  29 ++
 gcc/d/d-codegen.cc |   6 +-
 gcc/d/d-ctfloat.cc |   6 +-
 gcc/d/d-longdouble.cc  |  12 +-
 gcc/d/d-port.cc|   4 +-
 gcc/d/decl.cc  |   2 +-
 gcc/doc/extend.texi|  11 +-
 gcc/doc/invoke.texi|   4 +-
 gcc/doc/sourcebuild.texi   |   5 +-
 gcc/fold-const.cc  |   2 +-
 gcc/fortran/ChangeLog  |  71 
 gcc/fortran/gfortran.texi  |   3 +-
 gcc/fortran/resolve.cc |  14 +-
 gcc/fortran/trans-decl.cc  |   8 +-
 gcc/fortran/trans-expr.cc  |  63 ++--
 gcc/fortran/trans-types.cc |   5 +-
 gcc/gcc.cc |  20 +-
 gcc/gimple-loop-jam.cc |  12 +-
 gcc/gimple-ssa-sccopy.cc   |  13 +
 gcc/ipa-free-lang-data.cc  |   3 +-
 gcc/ipa-sra.cc |  38 +-
 gcc/jit/ChangeLog  |   9 +
 gcc/jit/jit-playback.cc|   1 +
 gcc/jit/jit-result.cc  |   1 +
 gcc/m2/ChangeLog   |  46 +++
 gcc/m2/gm2-compiler/M2Quads.mod|  64 ++--
 gcc/m2/gm2-gcc/m2builtins.cc   |  36 ++
 gcc/m2/gm2-libs/Builtins.def   |   5 +
 gcc/m2/gm2-libs/Builtins.mod   |  20 +
 gcc/m2/gm2-libs/cbuiltin.def   |  11 +-
 gcc/m2/gm2spec.cc  |   6 +
 gcc/plugin.cc  |   1 +
 gcc/system.h   |   2 +-
 gcc/testsuite/ChangeLog| 409 +
 gcc/testsuite/c-c++-common/fhardened-16.c  |   5 +
 gcc/testsuite/c-c++-common/fhardened-17.c 

[gcc/devel/omp/gcc-14] Fortran: Store OpenMP's 'declare variant' in module file [PR115271]

2025-03-18 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:30938d787b737214fd287004b89269bcea4b13e1

commit 30938d787b737214fd287004b89269bcea4b13e1
Author: Tobias Burnus 
Date:   Sat Mar 15 08:28:11 2025 +0100

Fortran: Store OpenMP's 'declare variant' in module file [PR115271]

Write the 'omp declare variant' data into the .mod file: Base function,
variant function(s), supporting the clauses match, append_args, and
adjust_args.

PR fortran/115271

gcc/fortran/ChangeLog:

* module.cc (mio_omp_declare_simd_clauses): New, moved from ...
(mio_omp_declare_simd): ... here. Update call, write empty '( )'
if there is no declare simd but a declare variant.
(mio_omp_declare_variant): New.
(mio_symbol): Call it.
* openmp.cc (gfc_match_omp_context_selector): Add comment about
module.cc to TODO note.
* trans-stmt.h (gfc_trans_omp_declare_variant): Take additional
parent_ns argument.
* trans-decl.cc (create_function_arglist,
gfc_create_function_decl): Update call.
* trans-openmp.cc (gfc_trans_omp_declare_variant): Take new
argument, add some special case handling for attr.use_assoc.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-variant-mod-1-use.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-1.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-2-use.f90: New test.
* gfortran.dg/gomp/declare-variant-mod-2.f90: New test.

(cherry picked from commit 6f3bca0db8645c2556e5a01669af4384bb230d87)

Diff:
---
 gcc/fortran/ChangeLog.omp  |  20 +
 gcc/fortran/module.cc  | 405 ++---
 gcc/fortran/openmp.cc  |   3 +-
 gcc/fortran/trans-decl.cc  |   4 +-
 gcc/fortran/trans-openmp.cc|  17 +-
 gcc/fortran/trans-stmt.h   |   2 +-
 gcc/testsuite/ChangeLog.omp|  11 +
 .../gfortran.dg/gomp/declare-variant-mod-1-use.f90 |  81 +
 .../gfortran.dg/gomp/declare-variant-mod-1.f90 |  83 +
 .../gfortran.dg/gomp/declare-variant-mod-2-use.f90 |  47 +++
 .../gfortran.dg/gomp/declare-variant-mod-2.f90 |  74 
 11 files changed, 681 insertions(+), 66 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index f0a2a48f7cf7..eeecc908673c 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,23 @@
+2025-03-18  Tobias Burnus  
+
+   Backported from master:
+   2025-03-15  Tobias Burnus  
+
+   PR fortran/115271
+   * module.cc (mio_omp_declare_simd_clauses): New, moved from ...
+   (mio_omp_declare_simd): ... here. Update call, write empty '( )'
+   if there is no declare simd but a declare variant.
+   (mio_omp_declare_variant): New.
+   (mio_symbol): Call it.
+   * openmp.cc (gfc_match_omp_context_selector): Add comment about
+   module.cc to TODO note.
+   * trans-stmt.h (gfc_trans_omp_declare_variant): Take additional
+   parent_ns argument.
+   * trans-decl.cc (create_function_arglist,
+   gfc_create_function_decl): Update call.
+   * trans-openmp.cc (gfc_trans_omp_declare_variant): Take new
+   argument, add some special case handling for attr.use_assoc.
+
 2025-02-18  Tobias Burnus  
 
Backported from master:
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index 96867f889b45..e5c14d76f9c3 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -4383,75 +4383,58 @@ static const mstring omp_declare_simd_clauses[] =
 minit (NULL, -1)
 };
 
-/* Handle !$omp declare simd.  */
+/* Handle OpenMP's declare-simd clauses.  */
 
 static void
-mio_omp_declare_simd (gfc_namespace *ns, gfc_omp_declare_simd **odsp)
+mio_omp_declare_simd_clauses (gfc_omp_clauses **clausesp)
 {
   if (iomode == IO_OUTPUT)
 {
-  if (*odsp == NULL)
-   return;
-}
-  else if (peek_atom () != ATOM_LPAREN)
-return;
-
-  gfc_omp_declare_simd *ods = *odsp;
+  gfc_omp_clauses *clauses = *clausesp;
+  gfc_omp_namelist *n;
 
-  mio_lparen ();
-  if (iomode == IO_OUTPUT)
-{
   write_atom (ATOM_NAME, "OMP_DECLARE_SIMD");
-  if (ods->clauses)
+  if (clauses->inbranch)
+   mio_name (0, omp_declare_simd_clauses);
+  if (clauses->notinbranch)
+   mio_name (1, omp_declare_simd_clauses);
+  if (clauses->simdlen_expr)
{
- gfc_omp_namelist *n;
-
- if (ods->clauses->inbranch)
-   mio_name (0, omp_declare_simd_clauses);
- if (ods->clauses->notinbranch)
-   mio_name (1, omp_declare_simd_clauses);
- if (ods->clauses->simdlen_expr)
-   {
- mio_name (2, omp_declare_simd_clauses);
- mio_expr (&ods->clauses->simdlen_expr);
-   }
- for (n = ods->c

[gcc r13-9435] c++: ICE when substituting packs into type aliases [PR118104]

2025-03-18 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:0cf6e652bebc47c0e2cdb605172837595e14cdf8

commit r13-9435-g0cf6e652bebc47c0e2cdb605172837595e14cdf8
Author: Marek Polacek 
Date:   Mon Mar 17 12:56:40 2025 -0400

c++: ICE when substituting packs into type aliases [PR118104]

r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> , Us ->  }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

PR c++/118104

gcc/cp/ChangeLog:

* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

Reviewed-by: Jason Merrill 
(cherry picked from commit 6751bd4ac48a8529e2476a6848a77e81de540814)

Diff:
---
 gcc/cp/pt.cc  | 11 ++-
 gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C | 22 ++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 54b145cedc4b..bb60b6f1fd9b 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -12820,7 +12820,16 @@ use_pack_expansion_extra_args_p (tree t,
 
   if (has_expansion_arg && has_non_expansion_arg)
{
- gcc_checking_assert (false);
+ /* We can get here with:
+
+ template  struct X {
+   template  using Y = Z;
+ };
+ template 
+ using foo = X::Y;
+
+where we compare int and A and then the second int and P...,
+whose expansion-ness doesn't match, but that's OK.  */
  return true;
}
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C 
b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C
new file mode 100644
index ..077f033d545e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C
@@ -0,0 +1,22 @@
+// PR c++/118104
+// { dg-do compile { target c++11 } }
+
+template struct Z { };
+
+template  struct X {
+  template  using W = Z;
+  template  using Y = X;
+};
+
+template 
+using foo = X::W;
+
+template 
+using bar = X::Y;
+
+void
+g ()
+{
+  foo f;
+  bar b;
+}


[gcc r15-8278] c++: ICE when substituting packs into type aliases [PR118104]

2025-03-18 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:6751bd4ac48a8529e2476a6848a77e81de540814

commit r15-8278-g6751bd4ac48a8529e2476a6848a77e81de540814
Author: Marek Polacek 
Date:   Mon Mar 17 12:56:40 2025 -0400

c++: ICE when substituting packs into type aliases [PR118104]

r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> , Us ->  }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

PR c++/118104

gcc/cp/ChangeLog:

* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/pt.cc  | 11 ++-
 gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C | 22 ++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 50eda189c43a..538ff220d745 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -13180,7 +13180,16 @@ use_pack_expansion_extra_args_p (tree t,
 
   if (has_expansion_arg && has_non_expansion_arg)
{
- gcc_checking_assert (false);
+ /* We can get here with:
+
+ template  struct X {
+   template  using Y = Z;
+ };
+ template 
+ using foo = X::Y;
+
+where we compare int and A and then the second int and P...,
+whose expansion-ness doesn't match, but that's OK.  */
  return true;
}
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C 
b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C
new file mode 100644
index ..077f033d545e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic3.C
@@ -0,0 +1,22 @@
+// PR c++/118104
+// { dg-do compile { target c++11 } }
+
+template struct Z { };
+
+template  struct X {
+  template  using W = Z;
+  template  using Y = X;
+};
+
+template 
+using foo = X::W;
+
+template 
+using bar = X::Y;
+
+void
+g ()
+{
+  foo f;
+  bar b;
+}


[gcc r15-8279] c++: constexpr ref template arg [PR119194]

2025-03-18 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:145c90720640ec6711ed3e5aa4152bbe1ee21751

commit r15-8279-g145c90720640ec6711ed3e5aa4152bbe1ee21751
Author: Jason Merrill 
Date:   Tue Mar 18 14:44:08 2025 -0400

c++: constexpr ref template arg [PR119194]

Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

PR c++/119194

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

* g++.dg/template/linkage7.C: New test.

Diff:
---
 gcc/cp/decl2.cc  | 22 +-
 gcc/testsuite/g++.dg/template/linkage7.C | 17 +
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 4a9fb1c3c00c..a3149f266030 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -2843,16 +2843,28 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void 
*data)
   tpvis = type_visibility (TREE_TYPE (t));
   break;
 
+case ADDR_EXPR:
+  t = TREE_OPERAND (t, 0);
+  if (VAR_P (t))
+   /* If a variable has its address taken, the lvalue-rvalue conversion is
+  not applied, so skip that case.  */
+   goto addressable;
+  break;
+
 case VAR_DECL:
 case FUNCTION_DECL:
   if (decl_constant_var_p (t))
/* The ODR allows definitions in different TUs to refer to distinct
   constant variables with internal or no linkage, so such a reference
-  shouldn't affect visibility (PR110323).  FIXME but only if the
-  lvalue-rvalue conversion is applied.  We still want to restrict
-  visibility according to the type of the declaration however.  */
-   tpvis = type_visibility (TREE_TYPE (t));
-  else if (! TREE_PUBLIC (t))
+  shouldn't affect visibility if the lvalue-rvalue conversion is
+  applied (PR110323).  We still want to restrict visibility according
+  to the type of the declaration however.  */
+   {
+ tpvis = type_visibility (TREE_TYPE (t));
+ break;
+   }
+addressable:
+  if (! TREE_PUBLIC (t))
tpvis = VISIBILITY_ANON;
   else
tpvis = DECL_VISIBILITY (t);
diff --git a/gcc/testsuite/g++.dg/template/linkage7.C 
b/gcc/testsuite/g++.dg/template/linkage7.C
new file mode 100644
index ..6686a0e5e511
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/linkage7.C
@@ -0,0 +1,17 @@
+// PR c++/119194
+// { dg-do compile { target c++11 } }
+
+template 
+[[gnu::noipa]]
+int get_length() {
+return Str;
+}
+static constexpr int s{ 3};
+int main() {
+   if (get_length() != s)
+ __builtin_abort();
+return 0;
+}
+
+// { dg-final { scan-assembler {_Z10get_lengthIL_ZL5sEEiv} } }
+// { dg-final { scan-assembler-not 
{(weak|glob)[^\n]*_Z10get_lengthIL_Z5sEEiv} } }


[gcc r15-8284] LoongArch: Add ABI names for FPR

2025-03-18 Thread Xi Ruoyao via Gcc-cvs
https://gcc.gnu.org/g:d0110185eb78f14a8e485f410bee237c9c71548d

commit r15-8284-gd0110185eb78f14a8e485f410bee237c9c71548d
Author: Xi Ruoyao 
Date:   Sun Mar 16 14:19:53 2025 +0800

LoongArch: Add ABI names for FPR

We already allow the ABI names for GPR in inline asm clobber list, so
for consistency allow the ABI names for FPR as well.

Reported-by: Yao Zi 

gcc/ChangeLog:

* config/loongarch/loongarch.h (ADDITIONAL_REGISTER_NAMES): Add
fa0-fa7, ft0-ft16, and fs0-fs7.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/regname-float-abi.c: New test.

Diff:
---
 gcc/config/loongarch/loongarch.h   | 32 ++
 .../gcc.target/loongarch/regname-float-abi.c   | 14 ++
 2 files changed, 46 insertions(+)

diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
index 42a38a44efeb..d8977634b71a 100644
--- a/gcc/config/loongarch/loongarch.h
+++ b/gcc/config/loongarch/loongarch.h
@@ -941,6 +941,38 @@ typedef struct {
   { "s6",  29 + GP_REG_FIRST },\
   { "s7",  30 + GP_REG_FIRST },\
   { "s8",  31 + GP_REG_FIRST },\
+  { "fa0",  0 + FP_REG_FIRST },\
+  { "fa1",  1 + FP_REG_FIRST },\
+  { "fa2",  2 + FP_REG_FIRST },\
+  { "fa3",  3 + FP_REG_FIRST },\
+  { "fa4",  4 + FP_REG_FIRST },\
+  { "fa5",  5 + FP_REG_FIRST },\
+  { "fa6",  6 + FP_REG_FIRST },\
+  { "fa7",  7 + FP_REG_FIRST },\
+  { "ft0",  8 + FP_REG_FIRST },\
+  { "ft1",  9 + FP_REG_FIRST },\
+  { "ft2", 10 + FP_REG_FIRST },\
+  { "ft3", 11 + FP_REG_FIRST },\
+  { "ft4", 12 + FP_REG_FIRST },\
+  { "ft5", 13 + FP_REG_FIRST },\
+  { "ft6", 14 + FP_REG_FIRST },\
+  { "ft7", 15 + FP_REG_FIRST },\
+  { "ft8", 16 + FP_REG_FIRST },\
+  { "ft9", 17 + FP_REG_FIRST },\
+  { "ft10",18 + FP_REG_FIRST },\
+  { "ft11",19 + FP_REG_FIRST },\
+  { "ft12",20 + FP_REG_FIRST },\
+  { "ft13",21 + FP_REG_FIRST },\
+  { "ft14",22 + FP_REG_FIRST },\
+  { "ft15",23 + FP_REG_FIRST },\
+  { "fs0", 24 + FP_REG_FIRST },\
+  { "fs1", 25 + FP_REG_FIRST },\
+  { "fs2", 26 + FP_REG_FIRST },\
+  { "fs3", 27 + FP_REG_FIRST },\
+  { "fs4", 28 + FP_REG_FIRST },\
+  { "fs5", 29 + FP_REG_FIRST },\
+  { "fs6", 30 + FP_REG_FIRST },\
+  { "fs7", 31 + FP_REG_FIRST },\
   { "v0",   4 + GP_REG_FIRST },\
   { "v1",   5 + GP_REG_FIRST },\
   { "vr0",  0 + FP_REG_FIRST },\
diff --git a/gcc/testsuite/gcc.target/loongarch/regname-float-abi.c 
b/gcc/testsuite/gcc.target/loongarch/regname-float-abi.c
new file mode 100644
index ..2224304fcca6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/regname-float-abi.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wno-pedantic -std=gnu90 -mfpu=64" } */
+
+register double fs0 asm("fs0"); /* { dg-note "conflicts with 'fs0'" } */
+register double f24 asm("$f24"); /* { dg-warning "register of 'f24' used for 
multiple global register variables" } */
+
+void
+test (void)
+{
+  asm("" ::: "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", "fa6", "fa7",
+"ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7",
+"ft8", "ft9", "ft10", "ft11", "ft12", "ft13", "ft14", "ft15",
+"fs0", "fs1", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7");
+}


[gcc r15-8249] libiberty: add ldirname function

2025-03-18 Thread Jose E. Marchesi via Gcc-cvs
https://gcc.gnu.org/g:31dd621796f9ff30b3df129a0e47c8d2348fa8c3

commit r15-8249-g31dd621796f9ff30b3df129a0e47c8d2348fa8c3
Author: Jose E. Marchesi 
Date:   Mon Mar 17 12:47:40 2025 +0100

libiberty: add ldirname function

This patch adds a function ldirname to libiberty.  It is implemented
in terms of lbasename.  Basically, given a given pathname, the dirname
part is what is not the basename minus the last directory separator
separating the dirname with the basename.

include/ChangeLog

* libiberty.h (ldirname): New function declaration.
(dos_ldirname): Likewise.
(unix_ldirname): Likewise.

libiberty/ChangeLog

* ldirname.c: New file.
* Makefile.in (CFILES): Add ldirname.c.
(REQUIRED_OFILES): Add ldirname.$(objext).
(./ldirname.$(objext)): New rule.
* makefile.vms (OBJS): Add ldirname.obj.
* configure.com (FILES): Add ldirname.

Diff:
---
 include/libiberty.h | 12 +++
 libiberty/Makefile.in   | 14 +++-
 libiberty/configure.com |  2 +-
 libiberty/ldirname.c| 94 +
 libiberty/makefile.vms  |  2 +-
 5 files changed, 121 insertions(+), 3 deletions(-)

diff --git a/include/libiberty.h b/include/libiberty.h
index 9cd1de4684cd..f2e763a306a1 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -133,6 +133,18 @@ extern const char *dos_lbasename (const char *) 
ATTRIBUTE_RETURNS_NONNULL ATTRIB
 
 extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL 
ATTRIBUTE_NONNULL(1);
 
+/* A dirname () that is always compiled in.  */
+
+extern char *ldirname (const char *) ATTRIBUTE_NONNULL(1);
+
+/* Same, but assumes DOS semantics regardless of host.  */
+
+extern char *dos_ldirname (const char *) ATTRIBUTE_NONNULL(1);
+
+/* Same, but assumes Unix semantics regardless of host.  */
+
+extern char *unix_ldirname (const char *) ATTRIBUTE_NONNULL(1);
+
 /* A well-defined realpath () that is always compiled in.  */
 
 extern char *lrealpath (const char *);
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 0db124338af1..4870fa95f2f3 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -136,6 +136,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c
\
hashtab.c hex.c \
index.c insque.c\
lbasename.c \
+   ldirname.c  \
lrealpath.c \
make-relative-prefix.c  \
make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmem.c  \
@@ -179,7 +180,7 @@ REQUIRED_OFILES =   
\
./fnmatch.$(objext) ./fopen_unlocked.$(objext)  \
./getopt.$(objext) ./getopt1.$(objext) ./getpwd.$(objext)   \
./getruntime.$(objext) ./hashtab.$(objext) ./hex.$(objext)  \
-   ./lbasename.$(objext) ./lrealpath.$(objext) \
+   ./lbasename.$(objext) ./ldirname.$(objext) ./lrealpath.$(objext)\
./make-relative-prefix.$(objext) ./make-temp-file.$(objext) \
./objalloc.$(objext)\
./obstack.$(objext) \
@@ -965,6 +966,17 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
else true; fi
$(COMPILE.c) $(srcdir)/lbasename.c $(OUTPUT_OPTION)
 
+./ldirname.$(objext): $(srcdir)/ldirname.c config.h $(INCDIR)/ansidecl.h \
+   $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \
+   $(INCDIR)/safe-ctype.h
+   if [ x"$(PICFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(srcdir)/ldirname.c -o pic/$@; \
+   else true; fi
+   if [ x"$(NOASANFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/ldirname.c -o 
noasan/$@; \
+   else true; fi
+   $(COMPILE.c) $(srcdir)/ldirname.c $(OUTPUT_OPTION)
+
 ./lrealpath.$(objext): $(srcdir)/lrealpath.c config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/libiberty.h
if [ x"$(PICFLAG)" != x ]; then \
diff --git a/libiberty/configure.com b/libiberty/configure.com
index 030182914f74..55aee2f78f98 100644
--- a/libiberty/configure.com
+++ b/libiberty/configure.com
@@ -17,7 +17,7 @@ $DECK
 $ FILES="getopt,obstack,xexit,xmalloc,hex,getopt1,cplus-dem,cp-demangle,"+-
 "cp-demint,asprintf,vasprintf,mkstemps,concat,getruntime,getpagesize,"+-
 "getpwd,xstrerror,xmemdup,xstrdup,xatexit,choose-temp,fnmatch,objalloc,"+-
-"safe-ctype,hashtab,lbasename,argv,lrealpath,make-temp-file,"+-
+"safe-ctype,hashtab,lbasename,ldirname,argv,lrealpath,make-temp-file,"+-
 "stpcpy,unlink-if-ordinar