[gcc r15-9077] gccrs: ast: Add optional diverging else to AST::LetStmt

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:79c54a83aa7cdb82be820ecc76d0e379c4bfa1d1

commit r15-9077-g79c54a83aa7cdb82be820ecc76d0e379c4bfa1d1
Author: Arthur Cohen 
Date:   Wed Mar 5 15:31:56 2025 +

gccrs: ast: Add optional diverging else to AST::LetStmt

gcc/rust/ChangeLog:

* ast/rust-stmt.h (class LetStmt): Add optional expression for 
diverging else.
* ast/rust-ast-builder.cc (Builder::let): Use new API.

Diff:
---
 gcc/rust/ast/rust-ast-builder.cc |  3 ++-
 gcc/rust/ast/rust-stmt.h | 29 -
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc
index 86290e199c6b..cdc6eec254bc 100644
--- a/gcc/rust/ast/rust-ast-builder.cc
+++ b/gcc/rust/ast/rust-ast-builder.cc
@@ -17,6 +17,7 @@
 // .
 
 #include "rust-ast-builder.h"
+#include "optional.h"
 #include "rust-ast-builder-type.h"
 #include "rust-ast.h"
 #include "rust-common.h"
@@ -352,7 +353,7 @@ Builder::let (std::unique_ptr &&pattern, 
std::unique_ptr &&type,
 {
   return std::unique_ptr (new LetStmt (std::move (pattern),
 std::move (init), std::move (type),
-{}, loc));
+tl::nullopt, {}, loc));
 }
 
 std::unique_ptr
diff --git a/gcc/rust/ast/rust-stmt.h b/gcc/rust/ast/rust-stmt.h
index 6cbecaffd033..f843a79b3f99 100644
--- a/gcc/rust/ast/rust-stmt.h
+++ b/gcc/rust/ast/rust-stmt.h
@@ -19,6 +19,7 @@
 #ifndef RUST_AST_STATEMENT_H
 #define RUST_AST_STATEMENT_H
 
+#include "optional.h"
 #include "rust-ast.h"
 #include "rust-path.h"
 #include "rust-expr.h"
@@ -72,6 +73,8 @@ class LetStmt : public Stmt
   // bool has_init_expr;
   std::unique_ptr init_expr;
 
+  tl::optional> else_expr;
+
   location_t locus;
 
 public:
@@ -85,15 +88,18 @@ public:
 
   // Returns whether let statement has an initialisation expression.
   bool has_init_expr () const { return init_expr != nullptr; }
+  bool has_else_expr () const { return else_expr.has_value (); }
 
   std::string as_string () const override;
 
   LetStmt (std::unique_ptr variables_pattern,
   std::unique_ptr init_expr, std::unique_ptr type,
+  tl::optional> else_expr,
   std::vector outer_attrs, location_t locus)
 : outer_attrs (std::move (outer_attrs)),
   variables_pattern (std::move (variables_pattern)),
-  type (std::move (type)), init_expr (std::move (init_expr)), locus (locus)
+  type (std::move (type)), init_expr (std::move (init_expr)),
+  else_expr (std::move (else_expr)), locus (locus)
   {}
 
   // Copy constructor with clone
@@ -107,6 +113,9 @@ public:
 // guard to prevent null dereference (always required)
 if (other.init_expr != nullptr)
   init_expr = other.init_expr->clone_expr ();
+if (other.else_expr.has_value ())
+  else_expr = other.else_expr.value ()->clone_expr ();
+
 if (other.type != nullptr)
   type = other.type->clone_type ();
   }
@@ -128,6 +137,12 @@ public:
   init_expr = other.init_expr->clone_expr ();
 else
   init_expr = nullptr;
+
+if (other.else_expr != nullptr)
+  else_expr = other.else_expr.value ()->clone_expr ();
+else
+  else_expr = tl::nullopt;
+
 if (other.type != nullptr)
   type = other.type->clone_type ();
 else
@@ -162,12 +177,24 @@ public:
 return *init_expr;
   }
 
+  Expr &get_else_expr ()
+  {
+rust_assert (has_else_expr ());
+return *else_expr.value ();
+  }
+
   std::unique_ptr &get_init_expr_ptr ()
   {
 rust_assert (has_init_expr ());
 return init_expr;
   }
 
+  std::unique_ptr &get_else_expr_ptr ()
+  {
+rust_assert (has_else_expr ());
+return else_expr.value ();
+  }
+
   Pattern &get_pattern ()
   {
 rust_assert (variables_pattern != nullptr);


[gcc r15-9075] gccrs: Fix testcase module path

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9faba024ef18b9c4d67f22bd3b020b5e445fad0a

commit r15-9075-g9faba024ef18b9c4d67f22bd3b020b5e445fad0a
Author: Pierre-Emmanuel Patry 
Date:   Thu Mar 20 15:10:07 2025 +0100

gccrs: Fix testcase module path

Those tests are coming from libcore and module inlining was wrong, in
libcore there was a use declaration to import those modules which was
missing here.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2330.rs: Use complete path from crate root.
* rust/compile/issue-1901.rs: Likewise.
* rust/compile/issue-1981.rs: Likewise.
* rust/compile/iterators1.rs: Likewise.
* rust/compile/sizeof-stray-infer-var-bug.rs: Likewise.
* rust/compile/for-loop1.rs: Likewise.
* rust/compile/for-loop2.rs: Likewise.
* rust/compile/torture/builtin_abort.rs: Likewise.
* rust/compile/torture/uninit-intrinsic-1.rs: Likewise.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/for-loop1.rs| 60 ++--
 gcc/testsuite/rust/compile/for-loop2.rs| 66 +++---
 gcc/testsuite/rust/compile/issue-1901.rs   |  4 +-
 gcc/testsuite/rust/compile/issue-1981.rs   | 40 ++---
 gcc/testsuite/rust/compile/issue-2330.rs   | 38 ++---
 gcc/testsuite/rust/compile/iterators1.rs   | 58 +--
 .../rust/compile/sizeof-stray-infer-var-bug.rs |  2 +-
 .../rust/compile/torture/builtin_abort.rs  |  4 +-
 .../rust/compile/torture/uninit-intrinsic-1.rs |  4 +-
 9 files changed, 139 insertions(+), 137 deletions(-)

diff --git a/gcc/testsuite/rust/compile/for-loop1.rs 
b/gcc/testsuite/rust/compile/for-loop1.rs
index 1023ecde1c35..21e0399161b5 100644
--- a/gcc/testsuite/rust/compile/for-loop1.rs
+++ b/gcc/testsuite/rust/compile/for-loop1.rs
@@ -102,30 +102,30 @@ mod ptr {
 #[lang = "const_ptr"]
 impl *const T {
 pub unsafe fn offset(self, count: isize) -> *const T {
-intrinsics::offset(self, count)
+crate::intrinsics::offset(self, count)
 }
 }
 
 #[lang = "mut_ptr"]
 impl *mut T {
 pub unsafe fn offset(self, count: isize) -> *mut T {
-intrinsics::offset(self, count) as *mut T
+crate::intrinsics::offset(self, count) as *mut T
 }
 }
 
 pub unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) {
 let x = x as *mut u8;
 let y = y as *mut u8;
-let len = mem::size_of::() * count;
+let len = crate::mem::size_of::() * count;
 swap_nonoverlapping_bytes(x, y, len)
 }
 
 pub unsafe fn swap_nonoverlapping_one(x: *mut T, y: *mut T) {
 // For types smaller than the block optimization below,
 // just swap directly to avoid pessimizing codegen.
-if mem::size_of::() < 32 {
+if crate::mem::size_of::() < 32 {
 let z = read(x);
-intrinsics::copy_nonoverlapping(y, x, 1);
+crate::intrinsics::copy_nonoverlapping(y, x, 1);
 write(y, z);
 } else {
 swap_nonoverlapping(x, y, 1);
@@ -133,12 +133,12 @@ mod ptr {
 }
 
 pub unsafe fn write(dst: *mut T, src: T) {
-intrinsics::move_val_init(&mut *dst, src)
+crate::intrinsics::move_val_init(&mut *dst, src)
 }
 
 pub unsafe fn read(src: *const T) -> T {
-let mut tmp: T = mem::uninitialized();
-intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+let mut tmp: T = crate::mem::uninitialized();
+crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
 tmp
 }
 
@@ -146,7 +146,7 @@ mod ptr {
 struct Block(u64, u64, u64, u64);
 struct UnalignedBlock(u64, u64, u64, u64);
 
-let block_size = mem::size_of::();
+let block_size = crate::mem::size_of::();
 
 // Loop through x & y, copying them `Block` at a time
 // The optimizer should unroll the loop fully for most types
@@ -155,31 +155,31 @@ mod ptr {
 while i + block_size <= len {
 // Create some uninitialized memory as scratch space
 // Declaring `t` here avoids aligning the stack when this loop is 
unused
-let mut t: Block = mem::uninitialized();
+let mut t: Block = crate::mem::uninitialized();
 let t = &mut t as *mut _ as *mut u8;
 let x = x.offset(i as isize);
 let y = y.offset(i as isize);
 
 // Swap a block of bytes of x & y, using t as a temporary buffer
 // This should be optimized into efficient SIMD operations where 
available
-intrinsics::copy_nonoverlapping(x, t, block_size);
-intrinsics::copy_nonoverlapping(y, x, block_size);
-intrinsics::copy_nonoverlapping(t, y, block_size);
+crate::intrinsics::copy_nonoverlapping(x, t, block_size)

[gcc r15-9076] gccrs: Remove now passing test from exclusion list

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:86699237eee63ae712a68c27edc59294ee68bc4e

commit r15-9076-g86699237eee63ae712a68c27edc59294ee68bc4e
Author: Pierre-Emmanuel Patry 
Date:   Thu Mar 20 17:13:36 2025 +0100

gccrs: Remove now passing test from exclusion list

Those tests were malformed and failed with the new name resolution
because of it.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/nr2/exclude | 5 -
 1 file changed, 5 deletions(-)

diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index 1582d5a2d969..45e90a4df933 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -2,8 +2,6 @@ canonical_paths1.rs
 cfg1.rs
 const_generics_3.rs
 generics9.rs
-issue-1901.rs
-issue-1981.rs
 issue-2043.rs
 issue-2330.rs
 issue-2812.rs
@@ -21,7 +19,6 @@ privacy8.rs
 pub_restricted_1.rs
 pub_restricted_2.rs
 pub_restricted_3.rs
-sizeof-stray-infer-var-bug.rs
 undeclared_label.rs
 use_1.rs
 while_break_expr.rs
@@ -37,9 +34,7 @@ issue-3403.rs
 derive-eq-invalid.rs
 derive-hash1.rs
 torture/alt_patterns1.rs
-torture/builtin_abort.rs
 torture/loop4.rs
 torture/loop8.rs
 torture/name_resolve1.rs
-torture/uninit-intrinsic-1.rs
 # please don't delete the trailing newline


[gcc r15-9080] gccrs: name-resolution: Handle let-else properly

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:02afa004778d49b86fb8c7320efaee4cff4e3a9d

commit r15-9080-g02afa004778d49b86fb8c7320efaee4cff4e3a9d
Author: Arthur Cohen 
Date:   Wed Mar 5 15:34:25 2025 +

gccrs: name-resolution: Handle let-else properly

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-stmt.h: Add handling for diverging else.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.

Diff:
---
 gcc/rust/resolve/rust-ast-resolve-stmt.h| 7 ---
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h 
b/gcc/rust/resolve/rust-ast-resolve-stmt.h
index d3ff14f755e7..6c99d6a6f6c0 100644
--- a/gcc/rust/resolve/rust-ast-resolve-stmt.h
+++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h
@@ -73,9 +73,10 @@ public:
   void visit (AST::LetStmt &stmt) override
   {
 if (stmt.has_init_expr ())
-  {
-   ResolveExpr::go (stmt.get_init_expr (), prefix, canonical_prefix);
-  }
+  ResolveExpr::go (stmt.get_init_expr (), prefix, canonical_prefix);
+
+if (stmt.has_else_expr ())
+  ResolveExpr::go (stmt.get_else_expr (), prefix, canonical_prefix);
 
 PatternDeclaration::go (stmt.get_pattern (), Rib::ItemType::Var);
 if (stmt.has_type ())
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index cf7b7dcd03fb..95df7272c757 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -140,6 +140,9 @@ Late::visit (AST::LetStmt &let)
 visit (let.get_init_expr ());
   visit (let.get_pattern ());
 
+  if (let.has_else_expr ())
+visit (let.get_init_expr ());
+
   // how do we deal with the fact that `let a = blipbloup` should look for a
   // label and cannot go through function ribs, but `let a = blipbloup()` can?


[gcc r15-9074] gccrs: Fix function name to printf

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:4427d53a3b952b7e0ba207daf862ca8552f5ac58

commit r15-9074-g4427d53a3b952b7e0ba207daf862ca8552f5ac58
Author: Pierre-Emmanuel Patry 
Date:   Thu Mar 20 17:26:55 2025 +0100

gccrs: Fix function name to printf

Function could not be found and triggered an error message.

gcc/testsuite/ChangeLog:

* rust/compile/feature_rust_attri0.rs: Add extern
function declaration and change name to printf.
* rust/compile/nr2/exclude: Remove now passing test from exclusion
list.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/feature_rust_attri0.rs | 6 +-
 gcc/testsuite/rust/compile/nr2/exclude| 1 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/rust/compile/feature_rust_attri0.rs 
b/gcc/testsuite/rust/compile/feature_rust_attri0.rs
index 9c11f561b5b6..1937acf3fe5f 100644
--- a/gcc/testsuite/rust/compile/feature_rust_attri0.rs
+++ b/gcc/testsuite/rust/compile/feature_rust_attri0.rs
@@ -1,3 +1,7 @@
+extern "C" {
+fn printf(s: *const i8, ...);
+}
+
 #[rustc_builtin_macro] //{ dg-error "internal implementation detail. " "" { 
target *-*-* }  }
 macro_rules! line {
 () => {{}};
@@ -5,7 +9,7 @@ macro_rules! line {
 
 fn main() -> i32 {
 let a = line!();
-print(a);
+printf("%d\0" as *const str as *const i8, a);
 
 0
 }
diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index fed7bde63070..1582d5a2d969 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -1,7 +1,6 @@
 canonical_paths1.rs
 cfg1.rs
 const_generics_3.rs
-feature_rust_attri0.rs
 generics9.rs
 issue-1901.rs
 issue-1981.rs


[gcc r15-9078] gccrs: parser: Parse let-else statements

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:010890e3f99e8cd771b7f3f126d2a5be63a2ba46

commit r15-9078-g010890e3f99e8cd771b7f3f126d2a5be63a2ba46
Author: Arthur Cohen 
Date:   Wed Mar 5 15:30:04 2025 +

gccrs: parser: Parse let-else statements

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_let_stmt): Add new parsing 
in case of `else` token.

Diff:
---
 gcc/rust/parse/rust-parse-impl.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index dd6086896f83..71d72504cfc3 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -6163,6 +6163,10 @@ Parser::parse_let_stmt (AST::AttrVec 
outer_attrs,
}
 }
 
+  tl::optional> else_expr = tl::nullopt;
+  if (maybe_skip_token (ELSE))
+else_expr = parse_block_expr ();
+
   if (restrictions.consume_semi)
 {
   // `stmt` macro variables are parsed without a semicolon, but should be
@@ -6177,7 +6181,7 @@ Parser::parse_let_stmt (AST::AttrVec 
outer_attrs,
 
   return std::unique_ptr (
 new AST::LetStmt (std::move (pattern), std::move (expr), std::move (type),
- std::move (outer_attrs), locus));
+ std::move (else_expr), std::move (outer_attrs), locus));
 }
 
 // Parses a type path.


[gcc r15-9083] rust: Lower minimum supported Rust version to 1.49

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

commit r15-9083-gd560f3f95943394ed630d9baf0c5268b4be4b9aa
Author: Arthur Cohen 
Date:   Mon Mar 24 15:32:51 2025 +0100

rust: Lower minimum supported Rust version to 1.49

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/Cargo.lock: Regenerate.
* checks/errors/borrowck/ffi-polonius/Cargo.toml: Update to use 
source patching instead of
vendoring, lower edition to 2018.
* checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml: Change 
edition to 2018.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs: Remove 
uses of unstable
feature.
* checks/errors/borrowck/ffi-polonius/.cargo/config.toml: Removed.

libgrust/ChangeLog:

* libformat_parser/Makefile.am: Avoid using --config as it is 
unsupported by cargo 1.49.
* libformat_parser/Makefile.in: Regenerate.
* libformat_parser/generic_format_parser/src/lib.rs: Use extension 
trait for missing
features.
* libformat_parser/src/lib.rs: Likewise.
* libformat_parser/.cargo/config: Moved to...
* libformat_parser/.cargo/config.toml: ...here.

Diff:
---
 .../checks/errors/borrowck/ffi-polonius/Cargo.lock |  10 --
 .../checks/errors/borrowck/ffi-polonius/Cargo.toml |  10 +-
 .../borrowck/ffi-polonius/vendor/log/Cargo.toml|   2 +-
 .../borrowck/ffi-polonius/vendor/log/src/lib.rs| 138 -
 libgrust/libformat_parser/.cargo/config|   5 -
 .../libformat_parser}/.cargo/config.toml   |   0
 libgrust/libformat_parser/Makefile.am  |  11 +-
 libgrust/libformat_parser/Makefile.in  |  10 +-
 .../generic_format_parser/src/lib.rs   |  14 +++
 libgrust/libformat_parser/src/lib.rs   |  11 ++
 10 files changed, 41 insertions(+), 170 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
index f7cbd414caf5..1b223b655560 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.lock
@@ -1,12 +1,8 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-version = 3
-
 [[package]]
 name = "datafrog"
 version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
 
 [[package]]
 name = "ffi-polonius"
@@ -18,14 +14,10 @@ dependencies = [
 [[package]]
 name = "log"
 version = "0.4.22"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
 
 [[package]]
 name = "polonius-engine"
 version = "0.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f"
 dependencies = [
  "datafrog",
  "log",
@@ -35,5 +27,3 @@ dependencies = [
 [[package]]
 name = "rustc-hash"
 version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
index 71315c3b635e..3bc8e3f873e7 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml
@@ -1,11 +1,17 @@
 [package]
 name = "ffi-polonius"
 version = "0.1.0"
-edition = "2021"
+edition = "2018"
 license = "GPL-3"
 
 [lib]
 crate-type = ["staticlib"]
 
 [dependencies]
-polonius-engine = "0.13.0"
\ No newline at end of file
+polonius-engine = "0.13.0"
+
+[patch.crates-io]
+log = { path = "vendor/log" }
+datafrog = { path = "vendor/datafrog" }
+polonius-engine = { path = "vendor/polonius-engine" }
+rustc-hash = { path = "vendor/rustc-hash" }
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
index 313a0051ae5f..a199e3170101 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml
@@ -10,7 +10,7 @@
 # See Cargo.toml.orig for the original contents.
 
 [package]
-edition = "2021"
+edition = "2018"
 rust-version = "1.60.0"
 name = "log"
 version = "0.4.22"
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
index 6b43a9ae16d8..603bbacb18c7 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs
@@ -397,20 +397,13 @@ mod serde;
 #[cfg(feature = "kv")]
 pub mod kv;

[gcc r15-9089] gccrs: Fix ICE when array elements are not a value

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

commit r15-9089-ge60632a2797cb40d301a7421011d2d974a3612df
Author: Philip Herron 
Date:   Wed Mar 26 17:11:36 2025 +

gccrs: Fix ICE when array elements are not a value

We need to check for error_mark_node when doing adjustments from coercion
sites otherwise we hit assetions as part of the coercion. That fixes the
ICE but the reason for the error_mark_node is because the array element
value.

Fixes Rust-GCC#3567

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::array_value_expr): add 
value chk for array expr

gcc/testsuite/ChangeLog:

* rust/compile/issue-3567.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/backend/rust-compile-expr.cc| 11 +++
 gcc/testsuite/rust/compile/issue-3567.rs |  4 
 2 files changed, 15 insertions(+)

diff --git a/gcc/rust/backend/rust-compile-expr.cc 
b/gcc/rust/backend/rust-compile-expr.cc
index 21f4ca1ba180..e4ab9f010b8e 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1902,6 +1902,14 @@ CompileExpr::array_value_expr (location_t expr_locus,
   for (auto &elem : elems.get_values ())
 {
   tree translated_expr = CompileExpr::Compile (*elem, ctx);
+  if (translated_expr == error_mark_node)
+   {
+ rich_location r (line_table, expr_locus);
+ r.add_fixit_replace (elem->get_locus (), "not a value");
+ rust_error_at (r, ErrorCode::E0423, "expected value");
+ return error_mark_node;
+   }
+
   constructor.push_back (translated_expr);
   indexes.push_back (i++);
 }
@@ -2003,6 +2011,9 @@ HIRCompileBase::resolve_adjustements (
   tree e = expression;
   for (auto &adjustment : adjustments)
 {
+  if (e == error_mark_node)
+   return error_mark_node;
+
   switch (adjustment.get_type ())
{
case Resolver::Adjustment::AdjustmentType::ERROR:
diff --git a/gcc/testsuite/rust/compile/issue-3567.rs 
b/gcc/testsuite/rust/compile/issue-3567.rs
new file mode 100644
index ..021d9c27838e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3567.rs
@@ -0,0 +1,4 @@
+fn main() {
+let _: &[i8] = &[i8];
+// { dg-error "expected value .E0423." "" { target *-*-* } .-1 }
+}


[gcc r15-9082] gccrs: nr2.0: Fix test const_generics_3.rs

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:17057c4e09aa76c7c3e9c2a14662b96d8963344b

commit r15-9082-g17057c4e09aa76c7c3e9c2a14662b96d8963344b
Author: Owen Avery 
Date:   Thu Mar 20 12:17:20 2025 -0400

gccrs: nr2.0: Fix test const_generics_3.rs

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_3.rs: Modify test to run with name
resolution 2.0 only and to handle the absence of a bogus
resolution error.
* rust/compile/nr2/exclude: Remove const_generics_3.rs.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/testsuite/rust/compile/const_generics_3.rs | 8 +---
 gcc/testsuite/rust/compile/nr2/exclude | 1 -
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/rust/compile/const_generics_3.rs 
b/gcc/testsuite/rust/compile/const_generics_3.rs
index e4e9008c4a69..524d48d5bcf5 100644
--- a/gcc/testsuite/rust/compile/const_generics_3.rs
+++ b/gcc/testsuite/rust/compile/const_generics_3.rs
@@ -1,10 +1,12 @@
-// { dg-additional-options "-w" }
+// { dg-additional-options "-w -frust-name-resolution-2.0" }
+
+#[lang = "sized"]
+trait Sized {}
 
 const M: usize = 4;
 
 struct Foo {
-// FIXME: This error is bogus. But having it means parsing is valid!
-value: [i32; N], // { dg-error "cannot find value .N. in this scope" }
+value: [T; N],
 }
 
 fn main() {
diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index 45e90a4df933..71c2b682bf02 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -1,6 +1,5 @@
 canonical_paths1.rs
 cfg1.rs
-const_generics_3.rs
 generics9.rs
 issue-2043.rs
 issue-2330.rs


[gcc r15-9084] gccrs: Lower raw string literals

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:284120406a9f916a538af36b34127a0bfa33bb06

commit r15-9084-g284120406a9f916a538af36b34127a0bfa33bb06
Author: Owen Avery 
Date:   Tue Mar 25 18:50:56 2025 -0400

gccrs: Lower raw string literals

gcc/rust/ChangeLog:

* hir/rust-ast-lower-base.cc
(ASTLoweringBase::lower_literal): Lower raw string literals into
normal string literals.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3549.rs: New test.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/hir/rust-ast-lower-base.cc  | 4 ++--
 gcc/testsuite/rust/compile/issue-3549.rs | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/hir/rust-ast-lower-base.cc 
b/gcc/rust/hir/rust-ast-lower-base.cc
index c1fef3d7a207..b0d347e65188 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -933,8 +933,8 @@ ASTLoweringBase::lower_literal (const AST::Literal &literal)
 case AST::Literal::LitType::BYTE_STRING:
   type = HIR::Literal::LitType::BYTE_STRING;
   break;
-case AST::Literal::LitType::RAW_STRING: // TODO: Lower raw string literals.
-  rust_unreachable ();
+case AST::Literal::LitType::RAW_STRING:
+  type = HIR::Literal::LitType::STRING;
   break;
 case AST::Literal::LitType::INT:
   type = HIR::Literal::LitType::INT;
diff --git a/gcc/testsuite/rust/compile/issue-3549.rs 
b/gcc/testsuite/rust/compile/issue-3549.rs
new file mode 100644
index ..cedbb5a02b55
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3549.rs
@@ -0,0 +1,3 @@
+fn main() {
+r#""#;
+}


[gcc r15-9097] gccrs: Add new test to highlight namespace for self import

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:405a294780dd12f242bb96540b1251091f13b051

commit r15-9097-g405a294780dd12f242bb96540b1251091f13b051
Author: Pierre-Emmanuel Patry 
Date:   Tue Mar 25 19:03:00 2025 +0100

gccrs: Add new test to highlight namespace for self import

gcc/testsuite/ChangeLog:

* rust/compile/self_import_namespace.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/self_import_namespace.rs | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/rust/compile/self_import_namespace.rs 
b/gcc/testsuite/rust/compile/self_import_namespace.rs
new file mode 100644
index ..2d9b2ed8e0fc
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_import_namespace.rs
@@ -0,0 +1,14 @@
+// { dg-additional-options "-frust-name-resolution-2.0" }
+
+mod bar {
+pub mod foo {}
+pub fn foo() {}
+}
+
+// This only imports the module `foo`. The function `foo` lives in
+// the value namespace and is not imported.
+use bar::foo::{self};
+
+fn main() {
+foo(); // { dg-error "expected value" }
+}


[gcc r15-9095] gccrs: Resolve module final self segment in use decls

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:45bd8bef02cb144f92119256f9f13d739e259b73

commit r15-9095-g45bd8bef02cb144f92119256f9f13d739e259b73
Author: Pierre-Emmanuel Patry 
Date:   Mon Mar 24 18:31:12 2025 +0100

gccrs: Resolve module final self segment in use decls

Lowercase self suffix with path was not resolved properly, this should
point to the module right before.

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.hxx: Add a new specialized function
to retrieve the last "real" segment depending on the namespace.
* resolve/rust-forever-stack.h: Add new function prototype.
* resolve/rust-early-name-resolver-2.0.cc 
(Early::finalize_rebind_import):
Set declared name according to the selected segment, if there is a 
self
suffix in the use declaration then select the previous segment.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 17 ++
 gcc/rust/resolve/rust-forever-stack.h|  4 
 gcc/rust/resolve/rust-forever-stack.hxx  | 29 
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 492a665f43e9..afaca1f71f03 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -417,10 +417,19 @@ Early::finalize_rebind_import (const Early::ImportPair 
&mapping)
   declared_name = rebind.get_identifier ().as_string ();
   locus = rebind.get_identifier ().get_locus ();
   break;
-case AST::UseTreeRebind::NewBindType::NONE:
-  declared_name = path.get_final_segment ().as_string ();
-  locus = path.get_final_segment ().get_locus ();
-  break;
+  case AST::UseTreeRebind::NewBindType::NONE: {
+   const auto &segments = path.get_segments ();
+   // We don't want to insert `self` with `use module::self`
+   if (path.get_final_segment ().is_lower_self_seg ())
+ {
+   rust_assert (segments.size () > 1);
+   declared_name = segments[segments.size () - 2].as_string ();
+ }
+   else
+ declared_name = path.get_final_segment ().as_string ();
+   locus = path.get_final_segment ().get_locus ();
+   break;
+  }
 case AST::UseTreeRebind::NewBindType::WILDCARD:
   rust_unreachable ();
   break;
diff --git a/gcc/rust/resolve/rust-forever-stack.h 
b/gcc/rust/resolve/rust-forever-stack.h
index 2a4c7348728b..d86212073b8d 100644
--- a/gcc/rust/resolve/rust-forever-stack.h
+++ b/gcc/rust/resolve/rust-forever-stack.h
@@ -795,6 +795,10 @@ private:
 SegIterator iterator,
 std::function insert_segment_resolution);
 
+  tl::optional resolve_final_segment (Node &final_node,
+  std::string &seg_name,
+  bool is_lower_self);
+
   /* Helper functions for forward resolution (to_canonical_path, to_rib...) */
   struct DfsResult
   {
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx 
b/gcc/rust/resolve/rust-forever-stack.hxx
index a6e0b30a57b1..fbe537d3b41d 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -594,6 +594,26 @@ ForeverStack::resolve_segments (
   return *current_node;
 }
 
+template <>
+inline tl::optional
+ForeverStack::resolve_final_segment (Node &final_node,
+  std::string &seg_name,
+  bool is_lower_self)
+{
+  if (is_lower_self)
+return Rib::Definition::NonShadowable (final_node.id);
+  else
+return final_node.rib.get (seg_name);
+}
+
+template 
+tl::optional
+ForeverStack::resolve_final_segment (Node &final_node, std::string 
&seg_name,
+   bool is_lower_self)
+{
+  return final_node.rib.get (seg_name);
+}
+
 template 
 template 
 tl::optional
@@ -643,12 +663,13 @@ ForeverStack::resolve_path (
   if (final_node.rib.kind == Rib::Kind::TraitOrImpl)
return tl::nullopt;
 
-  std::string seg_name
-   = unwrap_type_segment (segments.back ()).as_string ();
+  auto &seg = unwrap_type_segment (segments.back ());
+  std::string seg_name = seg.as_string ();
 
   // assuming this can't be a lang item segment
-  tl::optional res = final_node.rib.get (seg_name);
-
+  tl::optional res
+   = resolve_final_segment (final_node, seg_name,
+seg.is_lower_self_seg ());
   // Ok we didn't find it in the rib, Lets try the prelude...
   if (!res)
res = get_prelude (seg_name);


[gcc r15-9093] gccrs: Fix ICE when doing method resolution on trait predicates

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:5ea9b77d2790177fc3e224140b1b671363f689f2

commit r15-9093-g5ea9b77d2790177fc3e224140b1b671363f689f2
Author: Philip Herron 
Date:   Thu Mar 27 14:22:48 2025 +

gccrs: Fix ICE when doing method resolution on trait predicates

We need to ensure we are adding methods to the possible candidates.

Fixes Rust-GCC#3554

gcc/rust/ChangeLog:

* typecheck/rust-hir-dot-operator.cc:

gcc/testsuite/ChangeLog:

* rust/compile/issue-3554-1.rs: New test.
* rust/compile/issue-3554-2.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/typecheck/rust-hir-dot-operator.cc |  7 +--
 gcc/testsuite/rust/compile/issue-3554-1.rs  |  8 
 gcc/testsuite/rust/compile/issue-3554-2.rs  | 18 ++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-dot-operator.cc 
b/gcc/rust/typecheck/rust-hir-dot-operator.cc
index 38bd5b75fb70..c1165e9e5b17 100644
--- a/gcc/rust/typecheck/rust-hir-dot-operator.cc
+++ b/gcc/rust/typecheck/rust-hir-dot-operator.cc
@@ -472,8 +472,11 @@ MethodResolver::get_predicate_items (
   if (ty->get_kind () == TyTy::TypeKind::FNDEF)
{
  TyTy::FnType *fnty = static_cast (ty);
- predicate_candidate candidate{lookup, fnty};
- predicate_items.push_back (candidate);
+ if (fnty->is_method ())
+   {
+ predicate_candidate candidate{lookup, fnty};
+ predicate_items.push_back (candidate);
+   }
}
 }
 
diff --git a/gcc/testsuite/rust/compile/issue-3554-1.rs 
b/gcc/testsuite/rust/compile/issue-3554-1.rs
new file mode 100644
index ..a66be35d3638
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3554-1.rs
@@ -0,0 +1,8 @@
+trait Tr {
+fn foo();
+
+fn bar(&self) {
+self.foo()
+// { dg-error "no method named .foo. found in the current scope 
.E0599." "" { target *-*-* } .-1 }
+}
+}
diff --git a/gcc/testsuite/rust/compile/issue-3554-2.rs 
b/gcc/testsuite/rust/compile/issue-3554-2.rs
new file mode 100644
index ..e455a8b2cec0
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3554-2.rs
@@ -0,0 +1,18 @@
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "fn_once"]
+pub trait FnOnce {
+#[lang = "fn_once_output"]
+type Output;
+
+extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+trait Tr {
+fn foo();
+
+fn bar(&self) {
+(|| self.foo())()
+// { dg-error "no method named .foo. found in the current scope 
.E0599." "" { target *-*-* } .-1 }
+}
+}


[gcc r15-9104] gccrs: FIX ICE when working with HIR::BareFunctionType

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:3729b279fbef2404d91f08009102e5dd497f5cb6

commit r15-9104-g3729b279fbef2404d91f08009102e5dd497f5cb6
Author: Philip Herron 
Date:   Fri Mar 28 17:42:07 2025 +

gccrs: FIX ICE when working with HIR::BareFunctionType

Fixes Rust-GCC#3615

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): check has type
* hir/tree/rust-hir-type.cc (BareFunctionType::BareFunctionType): 
likewise

gcc/testsuite/ChangeLog:

* rust/compile/issue-3615.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/hir/rust-hir-dump.cc| 4 +++-
 gcc/rust/hir/tree/rust-hir-type.cc   | 3 ++-
 gcc/testsuite/rust/compile/issue-3615.rs | 7 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 0a9d617a9193..89fcc3dd1f97 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -2440,7 +2440,9 @@ Dump::visit (BareFunctionType &e)
   end_field ("params");
 }
 
-  visit_field ("return_type", e.get_return_type ());
+  if (e.has_return_type ())
+visit_field ("return_type", e.get_return_type ());
+
   put_field ("is_variadic", std::to_string (e.get_is_variadic ()));
   end ("BareFunctionType");
 }
diff --git a/gcc/rust/hir/tree/rust-hir-type.cc 
b/gcc/rust/hir/tree/rust-hir-type.cc
index 689d86b7372b..6a6c319fc98e 100644
--- a/gcc/rust/hir/tree/rust-hir-type.cc
+++ b/gcc/rust/hir/tree/rust-hir-type.cc
@@ -268,7 +268,8 @@ BareFunctionType::BareFunctionType (BareFunctionType const 
&other)
 for_lifetimes (other.for_lifetimes),
 function_qualifiers (other.function_qualifiers), params (other.params),
 is_variadic (other.is_variadic),
-return_type (other.return_type->clone_type ())
+return_type (other.has_return_type () ? other.return_type->clone_type ()
+ : nullptr)
 {}
 
 BareFunctionType &
diff --git a/gcc/testsuite/rust/compile/issue-3615.rs 
b/gcc/testsuite/rust/compile/issue-3615.rs
new file mode 100644
index ..e5c50725ea2b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3615.rs
@@ -0,0 +1,7 @@
+pub trait Trait {
+pub fn nrvo(init: fn()) -> [u8; 4096] {
+let mut buf = [0; 4096];
+
+buf
+}
+}


[gcc r15-9105] gccrs: FIX ICE for malformed repr attribute

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:5d6467f637273418535316b051491e0ad594a194

commit r15-9105-g5d6467f637273418535316b051491e0ad594a194
Author: Philip Herron 
Date:   Fri Mar 28 17:52:51 2025 +

gccrs: FIX ICE for malformed repr attribute

Fixes Rust-GCC#3614

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc 
(TypeCheckBase::parse_repr_options): check for input

gcc/testsuite/ChangeLog:

* rust/compile/issue-3614.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-base.cc | 6 ++
 gcc/testsuite/rust/compile/issue-3614.rs   | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc 
b/gcc/rust/typecheck/rust-hir-type-check-base.cc
index 8f2471d54d55..7fc6467e8aee 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc
@@ -305,6 +305,12 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec 
&attrs, location_t locus)
   for (const auto &attr : attrs)
 {
   bool is_repr = attr.get_path ().as_string () == Values::Attributes::REPR;
+  if (is_repr && !attr.has_attr_input ())
+   {
+ rust_error_at (attr.get_locus (), "malformed %qs attribute", "repr");
+ continue;
+   }
+
   if (is_repr)
{
  const AST::AttrInput &input = attr.get_attr_input ();
diff --git a/gcc/testsuite/rust/compile/issue-3614.rs 
b/gcc/testsuite/rust/compile/issue-3614.rs
new file mode 100644
index ..350a7e43ba8e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3614.rs
@@ -0,0 +1,3 @@
+#[repr] // { dg-error "malformed .repr. attribute" }
+
+struct _B {}


[gcc r15-9106] gccrs: fix ice when setting up regions

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

commit r15-9106-ge0df215ca50c2bd2a0ccc103484b629d2fbd43ec
Author: Philip Herron 
Date:   Fri Mar 28 18:24:57 2025 +

gccrs: fix ice when setting up regions

num regions is based on the used arguments of regions which can be
less than the substutions requirements. So lets check for that and allow
anon regions to be created for them.

Fixes Rust-GCC#3605

gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.h: check for min range

gcc/testsuite/ChangeLog:

* rust/compile/issue-3605.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/typecheck/rust-tyty-subst.h | 2 +-
 gcc/testsuite/rust/compile/issue-3605.rs | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/typecheck/rust-tyty-subst.h 
b/gcc/rust/typecheck/rust-tyty-subst.h
index b8e928d60f03..3f0b912fa7b0 100644
--- a/gcc/rust/typecheck/rust-tyty-subst.h
+++ b/gcc/rust/typecheck/rust-tyty-subst.h
@@ -125,7 +125,7 @@ public:
 std::vector subst)
   {
 RegionParamList list (num_regions);
-for (size_t i = 0; i < subst.size (); i++)
+for (size_t i = 0; i < MIN (num_regions, subst.size ()); i++)
   list.regions.at (i) = subst.at (i);
 for (size_t i = subst.size (); i < num_regions; i++)
   {
diff --git a/gcc/testsuite/rust/compile/issue-3605.rs 
b/gcc/testsuite/rust/compile/issue-3605.rs
new file mode 100644
index ..05e6e48e66e3
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3605.rs
@@ -0,0 +1,5 @@
+enum Foo<'a> {}
+
+enum Bar<'a> {
+in_band_def_explicit_impl(Foo<'a>),
+}


[gcc r15-9086] gccrs: Fix validation of constant items

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

commit r15-9086-gf100bd794c26126c37ef7e3e9cb023a06735f429
Author: Owen Avery 
Date:   Tue Mar 25 18:18:21 2025 -0400

gccrs: Fix validation of constant items

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc
(ASTValidation::visit): Allow constant items lacking expressions
if and only if they're associated with a trait definition, not a
trait implementation.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3541-1.rs: New test.
* rust/compile/issue-3541-2.rs: Likewise.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/checks/errors/rust-ast-validation.cc | 2 +-
 gcc/testsuite/rust/compile/issue-3541-1.rs| 5 +
 gcc/testsuite/rust/compile/issue-3541-2.rs| 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc 
b/gcc/rust/checks/errors/rust-ast-validation.cc
index 59b28057bab5..0f4bdeb6935f 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -56,7 +56,7 @@ ASTValidation::visit (AST::LoopLabel &label)
 void
 ASTValidation::visit (AST::ConstantItem &const_item)
 {
-  if (!const_item.has_expr () && ctx.peek () != Kind::TRAIT_IMPL)
+  if (!const_item.has_expr () && ctx.peek () != Kind::TRAIT)
 {
   rust_error_at (const_item.get_locus (),
 "associated constant in % without body");
diff --git a/gcc/testsuite/rust/compile/issue-3541-1.rs 
b/gcc/testsuite/rust/compile/issue-3541-1.rs
new file mode 100644
index ..6b47b7e11a52
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3541-1.rs
@@ -0,0 +1,5 @@
+impl B for u32 {
+const BAR: i32; // { dg-error "associated constant in .impl." }
+}
+
+trait B {}
diff --git a/gcc/testsuite/rust/compile/issue-3541-2.rs 
b/gcc/testsuite/rust/compile/issue-3541-2.rs
new file mode 100644
index ..9f17eedab54c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3541-2.rs
@@ -0,0 +1,3 @@
+trait B {
+const BAR: i32;
+}


[gcc r15-9102] gccrs: Add ending newline to rust-macro-builtins-log-debug.cc

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:453616bd98429e78ebb9db55cc4d89b45bf9a3b0

commit r15-9102-g453616bd98429e78ebb9db55cc4d89b45bf9a3b0
Author: Owen Avery 
Date:   Thu Mar 27 20:39:00 2025 -0400

gccrs: Add ending newline to rust-macro-builtins-log-debug.cc

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-log-debug.cc:
Add newline to end of file.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/expand/rust-macro-builtins-log-debug.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/expand/rust-macro-builtins-log-debug.cc 
b/gcc/rust/expand/rust-macro-builtins-log-debug.cc
index 49670d2b986a..3d7b54f7b0c7 100644
--- a/gcc/rust/expand/rust-macro-builtins-log-debug.cc
+++ b/gcc/rust/expand/rust-macro-builtins-log-debug.cc
@@ -30,4 +30,4 @@ MacroBuiltin::assert_handler (location_t invoc_locus,
 
   return AST::Fragment::create_error ();
 }
-} // namespace Rust
\ No newline at end of file
+} // namespace Rust


[gcc r15-9100] gccrs: nr2.0: Fix test macros/mbe/macro43.rs

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

commit r15-9100-ga69ba47dfeb26adafe1d0f011cd134fadcab7cea
Author: Owen Avery 
Date:   Sun Mar 23 21:04:32 2025 -0400

gccrs: nr2.0: Fix test macros/mbe/macro43.rs

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro43.rs: Adjust test to pass with
name resolution 2.0.
* rust/compile/nr2/exclude: Remove macros/mbe/macro43.rs.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/testsuite/rust/compile/macros/mbe/macro43.rs | 15 +++
 gcc/testsuite/rust/compile/nr2/exclude   |  1 -
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro43.rs 
b/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
index fbc36a9d6e55..0a7f038ef369 100644
--- a/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
+++ b/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
@@ -1,3 +1,10 @@
+use Option::{None, Some};
+
+enum Option {
+None,
+Some(T)
+}
+
 macro_rules! nonzero_integers {
 ( $( $Ty: ident($Int: ty); )+ ) => {
 $(
@@ -14,7 +21,7 @@ macro_rules! nonzero_integers {
 // not all derive macros are implemented yet, and this test does 
not test these anyways
 // #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
 #[repr(transparent)]
-pub struct $Ty(NonZero<$Int>);
+pub struct $Ty($Int);
 
 impl $Ty {
 /// Create a non-zero without checking the value.
@@ -25,7 +32,7 @@ macro_rules! nonzero_integers {
 #[stable(feature = "nonzero", since = "1.28.0")]
 #[inline]
 pub const unsafe fn new_unchecked(n: $Int) -> Self {
-$Ty(NonZero(n))
+$Ty(n)
 }
 
 /// Create a non-zero if the given value is not zero.
@@ -33,7 +40,7 @@ macro_rules! nonzero_integers {
 #[inline]
 pub fn new(n: $Int) -> Option {
 if n != 0 {
-Some($Ty(NonZero(n)))
+Some($Ty(n))
 } else {
 None
 }
@@ -43,7 +50,7 @@ macro_rules! nonzero_integers {
 #[stable(feature = "nonzero", since = "1.28.0")]
 #[inline]
 pub fn get(self) -> $Int {
-self.0 .0
+self.0
 }
 
 }
diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index 75a0ae0ea0ed..19bf6f8f6091 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -5,7 +5,6 @@ issue-2043.rs
 issue-2812.rs
 issue-3315-2.rs
 lookup_err1.rs
-macros/mbe/macro43.rs
 macros/mbe/macro6.rs
 multiple_bindings1.rs
 multiple_bindings2.rs


[gcc r15-9090] gccrs: Add check for super traits being implemented by Self

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:0b522745670e83ee4b5af0782982743b3f715c30

commit r15-9090-g0b522745670e83ee4b5af0782982743b3f715c30
Author: Philip Herron 
Date:   Wed Mar 26 19:00:41 2025 +

gccrs: Add check for super traits being implemented by Self

We need to recursively check the super traits of the predicate the Self
type is trying to implement. Otherwise its cannot implement it.

Fixes Rust-GCC#3553

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc 
(TypeCheckItem::resolve_impl_block_substitutions):
Track the polarity
* typecheck/rust-tyty-bounds.cc 
(TypeBoundPredicate::validate_type_implements_this):
new validator
* typecheck/rust-tyty.h: new prototypes

gcc/testsuite/ChangeLog:

* rust/compile/issue-3553.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-item.cc | 13 --
 gcc/rust/typecheck/rust-tyty-bounds.cc | 59 ++
 gcc/rust/typecheck/rust-tyty.h |  8 
 gcc/testsuite/rust/compile/issue-3553.rs   | 18 
 4 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc 
b/gcc/rust/typecheck/rust-hir-type-check-item.cc
index a003848cce0e..977492143517 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc
@@ -725,11 +725,11 @@ TypeCheckItem::resolve_impl_block_substitutions 
(HIR::ImplBlock &impl_block,
 
   // we don't error out here see: gcc/testsuite/rust/compile/traits2.rs
   // for example
-  specified_bound = get_predicate_from_bound (ref, impl_block.get_type ());
+  specified_bound = get_predicate_from_bound (ref, impl_block.get_type (),
+ impl_block.get_polarity ());
 }
 
   TyTy::BaseType *self = TypeCheckType::Resolve (impl_block.get_type ());
-
   if (self->is ())
 {
   // we cannot check for unconstrained type arguments when the Self type is
@@ -771,7 +771,14 @@ TypeCheckItem::validate_trait_impl_block (
 
   // we don't error out here see: gcc/testsuite/rust/compile/traits2.rs
   // for example
-  specified_bound = get_predicate_from_bound (ref, impl_block.get_type ());
+  specified_bound = get_predicate_from_bound (ref, impl_block.get_type (),
+ impl_block.get_polarity ());
+
+  // need to check that if this specified bound has super traits does this
+  // Self
+  // implement them?
+  specified_bound.validate_type_implements_super_traits (
+   *self, impl_block.get_type (), impl_block.get_trait_ref ());
 }
 
   bool is_trait_impl_block = !trait_reference->is_error ();
diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc 
b/gcc/rust/typecheck/rust-tyty-bounds.cc
index 65f24c0aa2ac..e028a0af80bb 100644
--- a/gcc/rust/typecheck/rust-tyty-bounds.cc
+++ b/gcc/rust/typecheck/rust-tyty-bounds.cc
@@ -828,6 +828,65 @@ TypeBoundPredicate::is_equal (const TypeBoundPredicate 
&other) const
   return true;
 }
 
+bool
+TypeBoundPredicate::validate_type_implements_super_traits (
+  TyTy::BaseType &self, HIR::Type &impl_type, HIR::Type &trait) const
+{
+  if (get_polarity () != BoundPolarity::RegularBound)
+return true;
+
+  auto &ptref = *get ();
+  for (auto &super : super_traits)
+{
+  if (super.get_polarity () != BoundPolarity::RegularBound)
+   continue;
+
+  if (!super.validate_type_implements_this (self, impl_type, trait))
+   {
+ auto &sptref = *super.get ();
+
+ // emit error
+ std::string fixit1
+   = "required by this bound in: " + ptref.get_name ();
+ std::string fixit2 = "the trait " + sptref.get_name ()
+  + " is not implemented for "
+  + impl_type.as_string ();
+
+ rich_location r (line_table, trait.get_locus ());
+ r.add_fixit_insert_after (super.get_locus (), fixit1.c_str ());
+ r.add_fixit_insert_after (trait.get_locus (), fixit2.c_str ());
+ rust_error_at (r, ErrorCode::E0277,
+"the trait bound %<%s: %s%> is not satisfied",
+impl_type.as_string ().c_str (),
+sptref.get_name ().c_str ());
+
+ return false;
+   }
+
+  if (!super.validate_type_implements_super_traits (self, impl_type, 
trait))
+   return false;
+}
+
+  return true;
+}
+
+bool
+TypeBoundPredicate::validate_type_implements_this (TyTy::BaseType &self,
+  HIR::Type &impl_type,
+  HIR::Type &trait) const
+{
+  const auto &ptref = *get ();
+  auto probed_bounds = Resolver::TypeBoundsProbe::Probe (&self);
+  for (auto &elem : probed_bounds)
+{
+  auto &tref = *(elem.first);

[gcc r15-9111] libstdc++: Fix -Wstringop-overread warning in std::vector [PR114758]

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:1f6c19f307c8de9830130a0ba071c24e3835beb3

commit r15-9111-g1f6c19f307c8de9830130a0ba071c24e3835beb3
Author: Jonathan Wakely 
Date:   Fri Mar 28 15:41:41 2025 +

libstdc++: Fix -Wstringop-overread warning in std::vector [PR114758]

As in r13-4393-gcca06f0d6d76b0 and a few other commits, we can avoid
bogus warnings in std::vector by hoisting some loads to before the
allocation that calls operator new. This means that the compiler has
enough info to remove the dead branches that trigger bogus warnings.

On trunk this is only needed with -fno-assume-sane-operators-new-delete
but it will help on the branches where that option doesn't exist.

libstdc++-v3/ChangeLog:

PR libstdc++/114758
* include/bits/vector.tcc (vector::_M_fill_insert):
Hoist loads of begin() and end() before allocation.
* testsuite/23_containers/vector/bool/capacity/114758.cc: New
test.

Reviewed-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/include/bits/vector.tcc |  5 +++--
 .../testsuite/23_containers/vector/bool/capacity/114758.cc   | 12 
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/vector.tcc 
b/libstdc++-v3/include/bits/vector.tcc
index f197278d52e0..29aa63e47428 100644
--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -1134,11 +1134,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
  const size_type __len = 
_M_check_len(__n, "vector::_M_fill_insert");
+ iterator __begin = begin(), __end = end();
  _Bit_pointer __q = this->_M_allocate(__len);
  iterator __start(std::__addressof(*__q), 0);
- iterator __i = _M_copy_aligned(begin(), __position, __start);
+ iterator __i = _M_copy_aligned(__begin, __position, __start);
  std::fill(__i, __i + difference_type(__n), __x);
- iterator __finish = std::copy(__position, end(),
+ iterator __finish = std::copy(__position, __end,
__i + difference_type(__n));
  this->_M_deallocate();
  this->_M_impl._M_end_of_storage = __q + _S_nword(__len);
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc 
b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc
new file mode 100644
index ..c56d50afddb1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/114758.cc
@@ -0,0 +1,12 @@
+// { dg-options "-O3 -Werror=stringop-overread 
-fno-assume-sane-operators-new-delete" }
+// { dg-do compile }
+
+// Bug libstdc++/114758 The layout of a std::vector reports a warning
+
+#include 
+
+void pr114758(std::vector& v)
+{
+  v.resize(3);
+  v = std::vector(3, false);
+}


[gcc r15-9112] libstdc++: Fix -Warray-bounds warning in std::vector [PR110498]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:aa3aaf2bfb8fcc17076993df4297597b68bc5f60

commit r15-9112-gaa3aaf2bfb8fcc17076993df4297597b68bc5f60
Author: Jonathan Wakely 
Date:   Fri Mar 28 15:41:41 2025 +

libstdc++: Fix -Warray-bounds warning in std::vector [PR110498]

In this case, we need to tell the compiler that the current size is not
larger than the new size so that all the existing elements can be copied
to the new storage. This avoids bogus warnings about overflowing the new
storage when the compiler can't tell that that cannot happen.

We might as well also hoist the loads of begin() and end() before the
allocation too. All callers will have loaded at least begin() before
calling _M_reallocate.

libstdc++-v3/ChangeLog:

PR libstdc++/110498
* include/bits/vector.tcc (vector::_M_reallocate):
Hoist loads of begin() and end() before allocation and use them
to state an unreachable condition.
* testsuite/23_containers/vector/bool/capacity/110498.cc: New
test.

Reviewed-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/include/bits/vector.tcc   |  5 -
 .../23_containers/vector/bool/capacity/110498.cc   | 18 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/vector.tcc 
b/libstdc++-v3/include/bits/vector.tcc
index 29aa63e47428..7a92f34ec644 100644
--- a/libstdc++-v3/include/bits/vector.tcc
+++ b/libstdc++-v3/include/bits/vector.tcc
@@ -1106,9 +1106,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 vector::
 _M_reallocate(size_type __n)
 {
+  const iterator __begin = begin(), __end = end();
+  if (size_type(__end - __begin) > __n)
+   __builtin_unreachable();
   _Bit_pointer __q = this->_M_allocate(__n);
   iterator __start(std::__addressof(*__q), 0);
-  iterator __finish(_M_copy_aligned(begin(), end(), __start));
+  iterator __finish(_M_copy_aligned(__begin, __end, __start));
   this->_M_deallocate();
   this->_M_impl._M_start = __start;
   this->_M_impl._M_finish = __finish;
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc 
b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc
new file mode 100644
index ..f848edcb25e1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/capacity/110498.cc
@@ -0,0 +1,18 @@
+// { dg-options "-O3 -Werror=array-bounds 
-fno-assume-sane-operators-new-delete" }
+// { dg-do compile }
+
+// Bug libstdc++/110498
+// Spurious warnings stringop-overflow and array-bounds copying data as bytes
+// into vector::reserve
+
+#include 
+
+void f(std::vector& v)
+{
+  // Warning emitted when set to any number in the range [1,64].
+  const std::size_t reserve_size = 30;
+
+  v.reserve(reserve_size);
+  v.push_back(0);
+}
+


[gcc r15-9107] gccrs: fix crash in parse repr options and missing delete call

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:2d8f37c9a59ca5dd98dc77fc13fb83328adcf317

commit r15-9107-g2d8f37c9a59ca5dd98dc77fc13fb83328adcf317
Author: Philip Herron 
Date:   Fri Mar 28 18:06:14 2025 +

gccrs: fix crash in parse repr options and missing delete call

Fixes Rust-GCC#3606

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc 
(TypeCheckBase::parse_repr_options):
check for null and empty and add missing delete call

gcc/testsuite/ChangeLog:

* rust/compile/issue-3606.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-base.cc | 20 ++--
 gcc/testsuite/rust/compile/issue-3606.rs   |  6 ++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc 
b/gcc/rust/typecheck/rust-hir-type-check-base.cc
index 7fc6467e8aee..34a726cc6650 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc
@@ -321,8 +321,22 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec 
&attrs, location_t locus)
  AST::AttrInputMetaItemContainer *meta_items
= option.parse_to_meta_item ();
 
- const std::string inline_option
-   = meta_items->get_items ().at (0)->as_string ();
+ if (meta_items == nullptr)
+   {
+ rust_error_at (attr.get_locus (), "malformed %qs attribute",
+"repr");
+ continue;
+   }
+
+ auto &items = meta_items->get_items ();
+ if (items.size () == 0)
+   {
+ // nothing to do with this its empty
+ delete meta_items;
+ continue;
+   }
+
+ const std::string inline_option = items.at (0)->as_string ();
 
  // TODO: it would probably be better to make the MetaItems more aware
  // of constructs with nesting like #[repr(packed(2))] rather than
@@ -359,6 +373,8 @@ TypeCheckBase::parse_repr_options (const AST::AttrVec 
&attrs, location_t locus)
  else if (is_align)
repr.align = value;
 
+ delete meta_items;
+
  // Multiple repr options must be specified with e.g. #[repr(C,
  // packed(2))].
  break;
diff --git a/gcc/testsuite/rust/compile/issue-3606.rs 
b/gcc/testsuite/rust/compile/issue-3606.rs
new file mode 100644
index ..73b0bd6743bc
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3606.rs
@@ -0,0 +1,6 @@
+// { dg-options "-w" }
+#[repr()]
+pub struct Coord {
+x: u32,
+y: u32,
+}


[gcc r15-9101] gccrs: nr2.0: Rename prelude to lang_prelude

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:503bdbba04f4a62797375a15613724cfa522b0b8

commit r15-9101-g503bdbba04f4a62797375a15613724cfa522b0b8
Author: Owen Avery 
Date:   Thu Mar 27 15:30:23 2025 -0400

gccrs: nr2.0: Rename prelude to lang_prelude

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h
(ForeverStack::get_prelude): Rename to...
(ForeverStack::get_lang_prelude): ...here.
(ForeverStack::prelude): Rename to...
(ForeverStack::lang_prelude): ...here.
(ForeverStack::ForeverStack): Handle renames.
* resolve/rust-forever-stack.hxx
(ForeverStack::push_inner): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
(ForeverStack::get_prelude): Rename to...
(ForeverStack::get_lang_prelude): ...here and handle renames.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle renames.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/resolve/rust-forever-stack.h   |  8 
 gcc/rust/resolve/rust-forever-stack.hxx | 17 +
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc |  2 +-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/gcc/rust/resolve/rust-forever-stack.h 
b/gcc/rust/resolve/rust-forever-stack.h
index d86212073b8d..f390e3889df8 100644
--- a/gcc/rust/resolve/rust-forever-stack.h
+++ b/gcc/rust/resolve/rust-forever-stack.h
@@ -548,7 +548,7 @@ template  class ForeverStack
 public:
   ForeverStack ()
 : root (Node (Rib (Rib::Kind::Normal), UNKNOWN_NODEID)),
-  prelude (Node (Rib (Rib::Kind::Prelude), UNKNOWN_NODEID, root)),
+  lang_prelude (Node (Rib (Rib::Kind::Prelude), UNKNOWN_NODEID, root)),
   cursor_reference (root)
   {
 rust_assert (root.is_root ());
@@ -658,8 +658,8 @@ public:
* the current map, an empty one otherwise.
*/
   tl::optional get (const Identifier &name);
-  tl::optional get_prelude (const Identifier &name);
-  tl::optional get_prelude (const std::string &name);
+  tl::optional get_lang_prelude (const Identifier &name);
+  tl::optional get_lang_prelude (const std::string &name);
 
   /**
* Resolve a path to its definition in the current `ForeverStack`
@@ -767,7 +767,7 @@ private:
* It has the root node as a parent, and acts as a "special case" for name
* resolution
*/
-  Node prelude;
+  Node lang_prelude;
 
   std::reference_wrapper cursor_reference;
 
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx 
b/gcc/rust/resolve/rust-forever-stack.hxx
index fbe537d3b41d..885f28206840 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -77,7 +77,7 @@ ForeverStack::push_inner (Rib rib, Link link)
   rust_assert (&cursor_reference.get () == &root);
   // Prelude doesn't have an access path
   rust_assert (!link.path);
-  update_cursor (this->prelude);
+  update_cursor (this->lang_prelude);
   return;
 }
   // If the link does not exist, we create it and emplace a new `Node` with the
@@ -319,16 +319,16 @@ ForeverStack::get (const Identifier &name)
 
 template 
 tl::optional
-ForeverStack::get_prelude (const Identifier &name)
+ForeverStack::get_lang_prelude (const Identifier &name)
 {
-  return prelude.rib.get (name.as_string ());
+  return lang_prelude.rib.get (name.as_string ());
 }
 
 template 
 tl::optional
-ForeverStack::get_prelude (const std::string &name)
+ForeverStack::get_lang_prelude (const std::string &name)
 {
-  return prelude.rib.get (name);
+  return lang_prelude.rib.get (name);
 }
 
 template <>
@@ -571,7 +571,7 @@ ForeverStack::resolve_segments (
  if (current_node->is_root () && !searched_prelude)
{
  searched_prelude = true;
- current_node = &prelude;
+ current_node = &lang_prelude;
  continue;
}
 
@@ -641,7 +641,8 @@ ForeverStack::resolve_path (
= get (unwrap_type_segment (segments.back ()).as_string ());
 
   if (!res)
-   res = get_prelude (unwrap_type_segment (segments.back ()).as_string ());
+   res = get_lang_prelude (
+ unwrap_type_segment (segments.back ()).as_string ());
 
   if (res && !res->is_ambiguous ())
insert_segment_resolution (segments.back (), res->get_node_id ());
@@ -672,7 +673,7 @@ ForeverStack::resolve_path (
 seg.is_lower_self_seg ());
   // Ok we didn't find it in the rib, Lets try the prelude...
   if (!res)
-   res = get_prelude (seg_name);
+   res = get_lang_prelude (seg_name);
 
   if (res && !res->is_ambiguous ())
insert_segment_resolution (segments.back (), res->get_node_id ());
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index 95df7272c757..7d323745edb7 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
++

[gcc r15-9096] gccrs: Update exclusion list

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:69736f3b611efcee9b24f6cdc1cf6f91cd3e9ac7

commit r15-9096-g69736f3b611efcee9b24f6cdc1cf6f91cd3e9ac7
Author: Pierre-Emmanuel Patry 
Date:   Tue Mar 25 18:47:04 2025 +0100

gccrs: Update exclusion list

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove now passing tests from exclusion
list.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/nr2/exclude | 6 --
 1 file changed, 6 deletions(-)

diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index 9273bd1489e1..75a0ae0ea0ed 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -2,12 +2,8 @@ canonical_paths1.rs
 cfg1.rs
 generics9.rs
 issue-2043.rs
-issue-2330.rs
 issue-2812.rs
-issue-850.rs
-issue-855.rs
 issue-3315-2.rs
-iterators1.rs
 lookup_err1.rs
 macros/mbe/macro43.rs
 macros/mbe/macro6.rs
@@ -27,8 +23,6 @@ derive_clone_enum3.rs
 derive-debug1.rs
 derive-default1.rs
 issue-3402-1.rs
-for-loop1.rs
-for-loop2.rs
 issue-3403.rs
 derive-eq-invalid.rs
 derive-hash1.rs


[gcc r15-9099] gccrs: Fix ICE during const expr eval on array expressions

2025-03-31 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:732c9d0cd5d1ebfee57aa1f4ee5d1487765d5ca7

commit r15-9099-g732c9d0cd5d1ebfee57aa1f4ee5d1487765d5ca7
Author: Philip Herron 
Date:   Thu Mar 27 17:27:56 2025 +

gccrs: Fix ICE during const expr eval on array expressions

Array expressions are still getting turned into VIEW_CONVERT_EXPR's becuase
TYPE_MAIN_VARIANT is not set so then we might as well reuse the type-hasher
to sort this out.

Fixes Rust-GCC#3588

gcc/rust/ChangeLog:

* backend/rust-compile-context.h: only push named types
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): run the 
type hasher

gcc/testsuite/ChangeLog:

* rust/compile/issue-3588.rs: New test.

Signed-off-by: Philip Herron 

Diff:
---
 gcc/rust/backend/rust-compile-context.h  | 5 -
 gcc/rust/backend/rust-compile-type.cc| 2 ++
 gcc/testsuite/rust/compile/issue-3588.rs | 5 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/backend/rust-compile-context.h 
b/gcc/rust/backend/rust-compile-context.h
index a44638817dbc..ce81a1d0db2c 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -72,7 +72,10 @@ public:
   return it->second;
 
 compiled_type_map.insert ({h, type});
-push_type (type);
+
+if (TYPE_NAME (type) != NULL)
+  push_type (type);
+
 return type;
   }
 
diff --git a/gcc/rust/backend/rust-compile-type.cc 
b/gcc/rust/backend/rust-compile-type.cc
index 813e11c47cfe..83e5756429f5 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -481,6 +481,8 @@ TyTyResolveCompile::visit (const TyTy::ArrayType &type)
   tree folded_capacity_expr = fold_expr (capacity_expr);
 
   translated = Backend::array_type (element_type, folded_capacity_expr);
+  if (translated != error_mark_node)
+translated = ctx->insert_compiled_type (translated);
 }
 
 void
diff --git a/gcc/testsuite/rust/compile/issue-3588.rs 
b/gcc/testsuite/rust/compile/issue-3588.rs
new file mode 100644
index ..744d9671c42a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3588.rs
@@ -0,0 +1,5 @@
+const FOO: i32 = if true { [1, 2, 3] } else { [2, 3, 4] }[0];
+
+pub fn test() -> i32 {
+FOO
+}


[gcc r15-9118] RISC-V: testsuite: Fix broken testsuite error of zicbop

2025-03-31 Thread Kito Cheng via Gcc-cvs
https://gcc.gnu.org/g:954708cf02adc01d3af9d7d4a860377e985cc9af

commit r15-9118-g954708cf02adc01d3af9d7d4a860377e985cc9af
Author: Liao Shihua 
Date:   Mon Mar 31 16:53:27 2025 +0800

RISC-V: testsuite: Fix broken testsuite error of zicbop

Fix broken testsuite like
"ERROR: gcc.target/riscv/cmo-zicbop-2.c   -Os : 1: too many arguments for " 
dg-do 1 compile target { { rv32-*-*}} "

gcc/testsuite/ChangeLog:

* gcc.target/riscv/cmo-zicbop-1.c: Fix missing { before target .
* gcc.target/riscv/cmo-zicbop-2.c: Likewise.
* gcc.target/riscv/prefetch-zicbop.c:Likewise.
* gcc.target/riscv/prefetch-zihintntl.c:Likewise.

Diff:
---
 gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c   | 2 +-
 gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c   | 2 +-
 gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c| 2 +-
 gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c 
b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
index e40874fc3df9..581b5dbbfbf8 100644
--- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
+++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}} } */
+/* { dg-do compile { target rv64-*-* } } */
 /* { dg-options "-march=rv64gc_zicbop -mabi=lp64" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c 
b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
index dd6e1eafd44a..3f7c1a455ad7 100644
--- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
+++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv32-*-*}} } */
+/* { dg-do compile { target rv64-*-* } } */
 /* { dg-options "-march=rv32gc_zicbop -mabi=ilp32" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c 
b/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
index 250f9ec6b0a8..44da4b2e5786 100644
--- a/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
+++ b/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}} } */
+/* { dg-do compile { target rv64-*-* } } */
 /* { dg-options "-march=rv64gc_zicbop -mabi=lp64" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c 
b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
index 54e809f43535..43439d7aee68 100644
--- a/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
+++ b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}} } */
+/* { dg-do compile { target rv64-*-* } } */
 /* { dg-options "-march=rv64gc_zicbop_zihintntl -mabi=lp64" } */
 
 void foo (char *p)


[gcc r15-9116] RISC-V: Fix wrong LMUL when only implict zve32f.

2025-03-31 Thread Kito Cheng via Gcc-cvs
https://gcc.gnu.org/g:28751389a68e131e21fcaf8e3f661d76a2b4d0cc

commit r15-9116-g28751389a68e131e21fcaf8e3f661d76a2b4d0cc
Author: Monk Chiang 
Date:   Tue Feb 4 15:29:17 2025 +0800

RISC-V: Fix wrong LMUL when only implict zve32f.

According to Section 3.4.2, Vector Register Grouping, in the RISC-V
Vector Specification, the rule for LMUL is LMUL >= SEW/ELEN

Changes since V2:
- Add check on vector-iterators.md
- Add one more testcase to check the VLS use correct mode.

gcc/ChangeLog:

* config/riscv/riscv-v.cc: Add restrict for insert LMUL.
* config/riscv/riscv-vector-builtins-types.def:
Use RVV_REQUIRE_ELEN_64 to check LMUL number.
* config/riscv/riscv-vector-switch.def: Likewise.
* config/riscv/vector-iterators.md: Check TARGET_VECTOR_ELEN_64
rather than "TARGET_MIN_VLEN > 32" for all iterator.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr111391-2.c: Update test.
* gcc.target/riscv/rvv/base/abi-14.c: Update test.
* gcc.target/riscv/rvv/base/abi-16.c: Update test.
* gcc.target/riscv/rvv/base/abi-18.c: Update test.
* gcc.target/riscv/rvv/base/vsetvl_zve32-1.c: New test.
* gcc.target/riscv/rvv/base/vsetvl_zve32-2.c: New test.

Co-authored-by: Kito Cheng 

Diff:
---
 gcc/config/riscv/riscv-v.cc|   8 +-
 gcc/config/riscv/riscv-vector-builtins-types.def   | 322 ++---
 gcc/config/riscv/riscv-vector-switch.def   |  84 +++---
 gcc/config/riscv/vector-iterators.md   | 256 
 .../gcc.target/riscv/rvv/autovec/pr111391-2.c  |   2 +-
 gcc/testsuite/gcc.target/riscv/rvv/base/abi-14.c   |  84 +++---
 gcc/testsuite/gcc.target/riscv/rvv/base/abi-16.c   |  98 +++
 gcc/testsuite/gcc.target/riscv/rvv/base/abi-18.c   | 112 +++
 .../gcc.target/riscv/rvv/base/vsetvl_zve32-1.c |  73 +
 .../gcc.target/riscv/rvv/base/vsetvl_zve32-2.c |  25 ++
 10 files changed, 582 insertions(+), 482 deletions(-)

diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index 287eb3e54cf7..aae2d274336e 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -1782,13 +1782,15 @@ get_vlmul (machine_mode mode)
   int inner_size = GET_MODE_BITSIZE (GET_MODE_INNER (mode));
   if (size < TARGET_MIN_VLEN)
{
+ /* Follow rule LMUL >= SEW / ELEN.  */
+ int elen = TARGET_VECTOR_ELEN_64 ? 1 : 2;
  int factor = TARGET_MIN_VLEN / size;
  if (inner_size == 8)
-   factor = MIN (factor, 8);
+   factor = MIN (factor, 8 / elen);
  else if (inner_size == 16)
-   factor = MIN (factor, 4);
+   factor = MIN (factor, 4 / elen);
  else if (inner_size == 32)
-   factor = MIN (factor, 2);
+   factor = MIN (factor, 2 / elen);
  else if (inner_size == 64)
factor = MIN (factor, 1);
  else
diff --git a/gcc/config/riscv/riscv-vector-builtins-types.def 
b/gcc/config/riscv/riscv-vector-builtins-types.def
index 6b98b93dfb60..857b63758a05 100644
--- a/gcc/config/riscv/riscv-vector-builtins-types.def
+++ b/gcc/config/riscv/riscv-vector-builtins-types.def
@@ -369,20 +369,20 @@ along with GCC; see the file COPYING3. If not see
 #define DEF_RVV_XFQF_OPS(TYPE, REQUIRE)
 #endif
 
-DEF_RVV_I_OPS (vint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_I_OPS (vint8mf8_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_I_OPS (vint8mf4_t, 0)
 DEF_RVV_I_OPS (vint8mf2_t, 0)
 DEF_RVV_I_OPS (vint8m1_t, 0)
 DEF_RVV_I_OPS (vint8m2_t, 0)
 DEF_RVV_I_OPS (vint8m4_t, 0)
 DEF_RVV_I_OPS (vint8m8_t, 0)
-DEF_RVV_I_OPS (vint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_I_OPS (vint16mf4_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_I_OPS (vint16mf2_t, 0)
 DEF_RVV_I_OPS (vint16m1_t, 0)
 DEF_RVV_I_OPS (vint16m2_t, 0)
 DEF_RVV_I_OPS (vint16m4_t, 0)
 DEF_RVV_I_OPS (vint16m8_t, 0)
-DEF_RVV_I_OPS (vint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_I_OPS (vint32mf2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_I_OPS (vint32m1_t, 0)
 DEF_RVV_I_OPS (vint32m2_t, 0)
 DEF_RVV_I_OPS (vint32m4_t, 0)
@@ -392,20 +392,20 @@ DEF_RVV_I_OPS (vint64m2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_I_OPS (vint64m4_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_I_OPS (vint64m8_t, RVV_REQUIRE_ELEN_64)
 
-DEF_RVV_U_OPS (vuint8mf8_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_U_OPS (vuint8mf8_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_U_OPS (vuint8mf4_t, 0)
 DEF_RVV_U_OPS (vuint8mf2_t, 0)
 DEF_RVV_U_OPS (vuint8m1_t, 0)
 DEF_RVV_U_OPS (vuint8m2_t, 0)
 DEF_RVV_U_OPS (vuint8m4_t, 0)
 DEF_RVV_U_OPS (vuint8m8_t, 0)
-DEF_RVV_U_OPS (vuint16mf4_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_U_OPS (vuint16mf4_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_U_OPS (vuint16mf2_t, 0)
 DEF_RVV_U_OPS (vuint16m1_t, 0)
 DEF_RVV_U_OPS (vuint16m2_t, 0)
 DEF_RVV_U_OPS (vuint16m4_t, 0)
 DEF_RVV_U_OPS (vuint16m8_t, 0)
-DEF_RVV_U_OPS (vuint32mf2_t, RVV_REQUIRE_MIN_VLEN_64)
+DEF_RVV_U_OPS (vuint32mf

[gcc r15-9110] Libstdc++: Fix bootstrap failure for cross without tm.tm_zone [PR119550]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:97cbe3cd5f36470884e940bda4469dc9b5b93cfd

commit r15-9110-g97cbe3cd5f36470884e940bda4469dc9b5b93cfd
Author: Jonathan Wakely 
Date:   Mon Mar 31 15:07:12 2025 +0100

Libstdc++: Fix bootstrap failure for cross without tm.tm_zone [PR119550]

In r15-8491-g778c28c70f8573 I added a use of the Autoconf macro
AC_STRUCT_TIMEZONE, but that requires a link-test for the global tzname
object if tm.tm_zone isn't supported. That link-test isn't allowed for
cross-compilation, so bootstrap fails if tm.tm_zone isn't supported.

Since libstdc++ only cares about tm.tm_zone and won't use tzname anyway,
we don't need the link-test. Replace AC_STRUCT_TIMEZONE with a custom
macro that only checks for tm.tm_zone. We can improve on the Autoconf
macro by checking it's a suitable type, which isn't actually checked by
AC_STRUCT_TIMEZONE.

libstdc++-v3/ChangeLog:

PR libstdc++/119550
* acinclude.m4 (GLIBCXX_STRUCT_TM_TM_ZONE): New macro.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_STRUCT_TM_TM_ZONE.
* include/bits/chrono_io.h (__formatter_chrono::_M_c): Check
_GLIBCXX_USE_STRUCT_TM_TM_ZONE instead of
_GLIBCXX_HAVE_STRUCT_TM_TM_ZONE.

Diff:
---
 libstdc++-v3/acinclude.m4 |  35 +
 libstdc++-v3/config.h.in  |  21 +--
 libstdc++-v3/configure| 238 ++
 libstdc++-v3/configure.ac |   5 +-
 libstdc++-v3/include/bits/chrono_io.h |   2 +-
 5 files changed, 109 insertions(+), 192 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e668d2dba274..02fd349e11df 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -5744,6 +5744,41 @@ AC_DEFUN([GLIBCXX_ZONEINFO_DIR], [
   fi
 ])
 
+dnl
+dnl Check for a tm_zone member in struct tm.
+dnl
+dnl This member is defined as const char* in Glibc, newlib, POSIX.1-2024,
+dnl and as char* in BSD (including macOS).
+dnl
+dnl Defines:
+dnl  _GLIBCXX_USE_STRUCT_TM_TM_ZONE if struct tm has a tm_zone member.
+dnl
+AC_DEFUN([GLIBCXX_STRUCT_TM_TM_ZONE], [
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=c++20"
+
+  AC_CACHE_CHECK([for tm_zone member of struct tm], glibcxx_cv_tm_zone, [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include 
+   ],
+   [struct tm t{}; t.tm_zone = (char*)0;]
+   )],
+   [glibcxx_cv_tm_zone=yes],
+   [glibcxx_cv_tm_zone=no]
+  )
+])
+
+  if test $glibcxx_cv_tm_zone = yes; then
+AC_DEFINE(_GLIBCXX_USE_STRUCT_TM_TM_ZONE, 1,
+ [Define if struct tm has a tm_zone member.])
+  fi
+
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+])
+
 dnl
 dnl Check whether lock tables can be aligned to avoid false sharing.
 dnl
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index be151f43dd68..77bbaf1beaa5 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -74,10 +74,6 @@
don't. */
 #undef HAVE_DECL_STRNLEN
 
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
-   */
-#undef HAVE_DECL_TZNAME
-
 /* Define to 1 if you have the  header file. */
 #undef HAVE_DIRENT_H
 
@@ -412,9 +408,6 @@
 /* Define to 1 if `d_type' is a member of `struct dirent'. */
 #undef HAVE_STRUCT_DIRENT_D_TYPE
 
-/* Define to 1 if `tm_zone' is a member of `struct tm'. */
-#undef HAVE_STRUCT_TM_TM_ZONE
-
 /* Define if strxfrm_l is available in . */
 #undef HAVE_STRXFRM_L
 
@@ -506,17 +499,9 @@
 /* Define to 1 if the target supports thread-local storage. */
 #undef HAVE_TLS
 
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
-   `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#undef HAVE_TM_ZONE
-
 /* Define if truncate is available in . */
 #undef HAVE_TRUNCATE
 
-/* Define to 1 if you don't have `tm_zone' but do have the external array
-   `tzname'. */
-#undef HAVE_TZNAME
-
 /* Define to 1 if you have the  header file. */
 #undef HAVE_UCHAR_H
 
@@ -605,9 +590,6 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
-/* Define to 1 if your  declares `struct tm'. */
-#undef TM_IN_SYS_TIME
-
 /* Version number of package */
 #undef VERSION
 
@@ -906,6 +888,9 @@
 /* Define to restrict std::__basic_file<> to stdio APIs. */
 #undef _GLIBCXX_USE_STDIO_PURE
 
+/* Define if struct tm has a tm_zone member. */
+#undef _GLIBCXX_USE_STRUCT_TM_TM_ZONE
+
 /* Define if struct stat has timespec members. */
 #undef _GLIBCXX_USE_ST_MTIM
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 67d2b8c7b72c..56d0bcb297ea 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -2731,63 +2731,6 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_decl
-
-# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
-# --

[gcc r14-11482] libstdc++: Update tzdata to 2025b

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:a93c02154f536acbadecb78f72223ec7bf95b46f

commit r14-11482-ga93c02154f536acbadecb78f72223ec7bf95b46f
Author: Jonathan Wakely 
Date:   Fri Jan 12 16:57:41 2024 +

libstdc++: Update tzdata to 2025b

Import the new 2025b tzdata.zi file.

libstdc++-v3/ChangeLog:

* src/c++20/tzdata.zi: Import new file from 2025b release.

(cherry picked from commit fd3bb314052f04f9357b4dce89fcb61ecfd3a83b)

Diff:
---
 libstdc++-v3/src/c++20/tzdata.zi | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++20/tzdata.zi b/libstdc++-v3/src/c++20/tzdata.zi
index db6ba4af2b01..a7fb52f1968f 100644
--- a/libstdc++-v3/src/c++20/tzdata.zi
+++ b/libstdc++-v3/src/c++20/tzdata.zi
@@ -1,4 +1,4 @@
-# version 2025a
+# version 2025b
 # This zic input file is in the public domain.
 R d 1916 o - Jun 14 23s 1 S
 R d 1916 1919 - O Su>=1 23s 0 -
@@ -2432,6 +2432,20 @@ Z America/Ciudad_Juarez -7:5:56 - LMT 1922 Ja 1 7u
 Z America/Costa_Rica -5:36:13 - LMT 1890
 -5:36:13 - SJMT 1921 Ja 15
 -6 CR C%sT
+Z America/Coyhaique -4:48:16 - LMT 1890
+-4:42:45 - SMT 1910 Ja 10
+-5 - %z 1916 Jul
+-4:42:45 - SMT 1918 S 10
+-4 - %z 1919 Jul
+-4:42:45 - SMT 1927 S
+-5 x %z 1932 S
+-4 - %z 1942 Jun
+-5 - %z 1942 Au
+-4 - %z 1946 Au 28 24
+-5 1 %z 1947 Mar 31 24
+-5 - %z 1947 May 21 23
+-4 x %z 2025 Mar 20
+-3 - %z
 Z America/Cuiaba -3:44:20 - LMT 1914
 -4 B %z 2003 S 24
 -4 - %z 2004 O
@@ -3420,7 +3434,7 @@ Z Asia/Tbilisi 2:59:11 - LMT 1880
 Z Asia/Tehran 3:25:44 - LMT 1916
 3:25:44 - TMT 1935 Jun 13
 3:30 i %z 1977 O 20 24
-4 i %z 1979
+4 i %z 1978 N 10 24
 3:30 i %z
 Z Asia/Thimphu 5:58:36 - LMT 1947 Au 15
 5:30 - %z 1987 O


[gcc r15-9065] tree-optimization/119532 - ICE with fixed-point tail recursion

2025-03-31 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:95c25cb09f58810bc520c3db469945c6a751aa32

commit r15-9065-g95c25cb09f58810bc520c3db469945c6a751aa32
Author: Richard Biener 
Date:   Mon Mar 31 10:02:27 2025 +0200

tree-optimization/119532 - ICE with fixed-point tail recursion

The following disables tail recursion optimization when fixed-point
types are involved as we cannot generate -1 for all fixed-point
types.

PR tree-optimization/119532
* tree-tailcall.cc (process_assignment): FAIL for fixed-point
typed functions.

* gcc.dg/torture/pr119532.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr119532.c | 14 ++
 gcc/tree-tailcall.cc|  4 
 2 files changed, 18 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr119532.c 
b/gcc/testsuite/gcc.dg/torture/pr119532.c
new file mode 100644
index ..bba2e451d2b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr119532.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target fixed_point } */
+
+extern _Fract sinuhk_deg (unsigned short _Accum);
+
+_Fract cosuhk_deg (unsigned short _Accum deg)
+{
+  unsigned short _Accum _90_deg = 90uhk;
+  __asm ("" : "+r" (_90_deg));
+
+  return deg <= _90_deg
+? sinuhk_deg (_90_deg - deg)
+: -sinuhk_deg (deg - _90_deg);
+}
diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index 8ba675221915..8ea1c8b5f99f 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -361,6 +361,10 @@ process_assignment (gassign *stmt,
 if (FLOAT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl
   return FAIL;
 
+  /* We at least cannot build -1 for all fixed point types.  */
+  if (FIXED_POINT_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl
+return FAIL;
+
   if (rhs_class == GIMPLE_UNARY_RHS
   && op0 == *ass_var)
 ;


[gcc/mikael/heads/refactor_descriptor_v04] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' was updated to point to:

 4666a53f3701... Replace span with elem_len

It previously pointed to:

 89ee81befb32... Replace span with elem_len

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  89ee81b... Replace span with elem_len


Summary of changes (added commits):
---

  4666a53... Replace span with elem_len


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:4666a53f37016475a5d08429b142c4b0ba5d2888

commit 4666a53f37016475a5d08429b142c4b0ba5d2888
Author: Mikael Morin 
Date:   Mon Mar 31 12:05:26 2025 +0200

Replace span with elem_len

Correction ISO_Fortran_binding_3.f90

Correction régression ISO_Fortran_binding_4.f90

Diff:
---
 gcc/fortran/trans-array.cc|   4 +-
 gcc/fortran/trans-descriptor.cc   | 112 +++---
 gcc/fortran/trans-descriptor.h|   1 -
 gcc/fortran/trans-intrinsic.cc|   6 +-
 gcc/fortran/trans-openmp.cc   |   6 +-
 gcc/fortran/trans-types.cc|  17 ++---
 gcc/fortran/trans.cc  |  27 ---
 libgfortran/caf/single.c  |   2 +-
 libgfortran/intrinsics/associated.c   |   2 -
 libgfortran/libgfortran.h |   3 -
 libgfortran/runtime/ISO_Fortran_binding.c |   9 +--
 11 files changed, 57 insertions(+), 132 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 595ba97aa8ca..a48d0f4b8a4a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -450,7 +450,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = build_fold_indirect_ref_loc (input_location, desc);
 
   /* This will have the span field set.  */
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (expr->ts.type == BT_ASSUMED)
 {
@@ -458,7 +458,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = GFC_DECL_SAVED_DESCRIPTOR (desc);
   if (POINTER_TYPE_P (TREE_TYPE (desc)))
desc = build_fold_indirect_ref_loc (input_location, desc);
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (TREE_CODE (desc) == COMPONENT_REF
   && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 7e709609435c..2bc47f646bbb 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -164,9 +164,8 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #define DATA_FIELD 0
 #define OFFSET_FIELD 1
 #define DTYPE_FIELD 2
-#define SPAN_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
+#define DIMENSION_FIELD 3
+#define CAF_TOKEN_FIELD 4
 
 #define STRIDE_SUBFIELD 0
 #define LBOUND_SUBFIELD 1
@@ -282,27 +281,6 @@ conv_dtype_set (stmtblock_t *block, tree desc, tree val)
   gfc_add_modify (block, t, val);
 }
 
-tree
-get_span (tree desc)
-{
-  tree field = get_component (desc, SPAN_FIELD);
-  gcc_assert (TREE_TYPE (field) == gfc_array_index_type);
-  return field;
-}
-
-tree
-conv_span_get (tree desc)
-{
-  return non_lvalue_loc (input_location, get_span (desc));
-}
-
-void
-conv_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  tree t = get_span (desc);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
-}
-
 tree
 get_rank (tree desc)
 {
@@ -715,18 +693,6 @@ gfc_conv_descriptor_dtype_set (stmtblock_t *block, tree 
desc, tree val)
   gfc_descriptor::conv_dtype_set (block, desc, val);
 }
 
-tree
-gfc_conv_descriptor_span_get (tree desc)
-{
-  return gfc_descriptor::conv_span_get (desc);
-}
-
-static void
-gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  return gfc_descriptor::conv_span_set (block, desc, value);
-}
-
 tree
 gfc_conv_descriptor_dimension_get (tree desc, tree dim)
 {
@@ -932,10 +898,11 @@ tree
 gfc_conv_descriptor_sm_get (tree desc, tree dim)
 {
   tree stride = gfc_conv_descriptor_stride_get (desc, dim);
-  tree span = gfc_conv_descriptor_span_get (desc);
+  tree elem_len = gfc_conv_descriptor_elem_len_get (desc);
+  elem_len = fold_convert (gfc_array_index_type, elem_len);
 
   return fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- stride, span);
+ stride, elem_len);
 }
 
 
@@ -,31 +1078,6 @@ get_descr_data_value (const descr_change_info &info)
 }
 
 
-static tree
-get_descr_span (const descr_change_info &info)
-{
-  switch (info.type)
-{
-case UNKNOWN_CHANGE:
-case EXPLICIT_NULLIFICATION:
-case INITIALISATION:
-case DEFAULT_INITIALISATION:
-case NULL_INITIALISATION:
-  return NULL_TREE;
-
-case SCALAR_VALUE:
-  {
-   tree fields = TYPE_FIELDS (info.descriptor_type);
-   tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-   return build_zero_cst (TREE_TYPE (span_field));
-  }
-
-default:
-  gcc_unreachable ();
-}
-}
-
-
 static tree
 get_descr_caf_token (const descr_change_info &info)
 {
@@ -1357,14 +1299,6 @@ get_descriptor_init (tree type, gfc_typespec *ts, int 
rank,
   CONSTRUCTOR_APPEND_ELT (v, dtype_field, dtype_value);
 }
 
-  tree span_value = get_descr_span (change);
-  if (span_value != NULL_TREE)
-{
-  tree span_field = gfc_advance_chain (fields, SPAN_FIEL

[gcc r15-9066] c++: lambda in function template signature [PR119401]

2025-03-31 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:1949beb7dbe66687542f4a19d316914dd73fe84d

commit r15-9066-g1949beb7dbe66687542f4a19d316914dd73fe84d
Author: Jason Merrill 
Date:   Sat Mar 29 14:00:55 2025 -0400

c++: lambda in function template signature [PR119401]

Here we instantiate the lambda three times in producing A<0>::f:
1) in tsubst_function_type, substituting the type of A<>::f
2) in tsubst_function_decl, substituting the parameters of A<>::f
3) in regenerate_decl_from_template when instantiating A<>::f

The first one gets thrown away by maybe_rebuild_function_decl_type.  Before
r15-7202, we happily built all of them and mangled the result wrongly as
lambda #3.  After r15-7202, we try to mangle #3 as #1, which breaks because
 #1 is already mangled as #1.

This patch avoids building #3 by suppressing regenerate_decl_from_template
if the template signature includes a lambda, fixing the ICE.

We now mangle the lambda as #2, which is still wrong.  Addressing that
should involve not calling tsubst_function_type from tsubst_function_decl,
and building the type from the parms types in the first place rather than
fixing it up in maybe_rebuild_function_decl_type.

PR c++/119401

gcc/cp/ChangeLog:

* pt.cc (regenerate_decl_from_template): Don't regenerate if the
signature involves a lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-targ11.C: New test.

Diff:
---
 gcc/cp/pt.cc   | 13 +
 gcc/testsuite/g++.dg/cpp2a/lambda-targ11.C | 13 +
 gcc/testsuite/g++.dg/cpp2a/lambda-targ12.C | 13 +
 3 files changed, 39 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 417d107d6993..f7c56a107945 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -27238,6 +27238,19 @@ regenerate_decl_from_template (tree decl, tree tmpl, 
tree args)
   if (DECL_UNIQUE_FRIEND_P (decl))
goto done;
 
+  /* A template with a lambda in the signature also changes type if
+regenerated (PR119401).  */
+  walk_tree_fn find_lambda
+   = [](tree *tp, int *, void *)
+   {
+ if (TREE_CODE (*tp) == LAMBDA_EXPR)
+   return *tp;
+ return NULL_TREE;
+   };
+  if (cp_walk_tree_without_duplicates
+ (&TREE_TYPE (tmpl), find_lambda, nullptr))
+   goto done;
+
   /* Use the source location of the definition.  */
   DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (tmpl);
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-targ11.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-targ11.C
new file mode 100644
index ..9f2f743b7eb4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-targ11.C
@@ -0,0 +1,13 @@
+// PR c++/119401
+// { dg-do compile { target c++20 } }
+
+template 
+struct B {};
+template 
+struct A {
+  void f(B<[]{}>) {}
+};
+auto t = &A<0>::f;
+
+// A<0>::f(B::{lambda()#1}{}>)
+// { dg-final { scan-assembler "_ZN1AILi0EE1fE1BIXtlNS0_UlvE_" { xfail 
*-*-* } } }
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-targ12.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-targ12.C
new file mode 100644
index ..bb3f701967f6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-targ12.C
@@ -0,0 +1,13 @@
+// PR c++/119401
+// { dg-do compile { target c++20 } }
+
+template 
+struct B {};
+template 
+struct A {
+  void f(B) {}
+};
+auto t = &A<0>::f;
+
+// A<0>::f(B::{lambda()#1}>)
+// { dg-final { scan-assembler "_ZN1AILi0EE1fE1BINS0_UlvE_EE" { xfail *-*-* } 
} }


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

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:4655e9c9eef67fde3e7e0b95a218a13ff5b33c1d

commit r13-9466-g4655e9c9eef67fde3e7e0b95a218a13ff5b33c1d
Author: Jonathan Wakely 
Date:   Mon Dec 16 17:42:24 2024 +

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

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

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

libstdc++-v3/ChangeLog:

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

(cherry picked from commit b273e25e11c842a5729d0e03c85088cf5ba8e06c)

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

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


[gcc r13-9467] libstdc++: Fix std::deque::emplace calling wrong _M_insert_aux [PR90389]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:86700d114498ef6ed1f14b54732ba62c9f9504d4

commit r13-9467-g86700d114498ef6ed1f14b54732ba62c9f9504d4
Author: Jonathan Wakely 
Date:   Tue Dec 17 17:38:43 2024 +

libstdc++: Fix std::deque::emplace calling wrong _M_insert_aux [PR90389]

We have several overloads of std::deque::_M_insert_aux, one of which is
variadic and called by std::deque::emplace. With a suitable set of
arguments to emplace, it's possible for one of the non-variadic
_M_insert_aux overloads to be selected by overload resolution, making
emplace ill-formed.

Rename the variadic _M_insert_aux to _M_emplace_aux so that calls to
emplace never select an _M_insert_aux overload. Also add an inline
_M_insert_aux for the const lvalue overload that is called from
insert(const_iterator, const value_type&).

libstdc++-v3/ChangeLog:

PR libstdc++/90389
* include/bits/deque.tcc (_M_insert_aux): Rename variadic
overload to _M_emplace_aux.
* include/bits/stl_deque.h (_M_insert_aux): Define inline.
(_M_emplace_aux): Declare.
* testsuite/23_containers/deque/modifiers/emplace/90389.cc: New
test.

(cherry picked from commit 5f44b1776e748a7528020557036740905a11b1df)

Diff:
---
 libstdc++-v3/include/bits/deque.tcc|  6 +--
 libstdc++-v3/include/bits/stl_deque.h  |  6 ++-
 .../23_containers/deque/modifiers/emplace/90389.cc | 43 ++
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/deque.tcc 
b/libstdc++-v3/include/bits/deque.tcc
index 45a6feebe991..4bc4587be19e 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -200,8 +200,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
  }
else
- return _M_insert_aux(__position._M_const_cast(),
-  std::forward<_Args>(__args)...);
+ return _M_emplace_aux(__position._M_const_cast(),
+   std::forward<_Args>(__args)...);
   }
 #endif
 
@@ -646,7 +646,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 template
   typename deque<_Tp, _Alloc>::iterator
   deque<_Tp, _Alloc>::
-  _M_insert_aux(iterator __pos, _Args&&... __args)
+  _M_emplace_aux(iterator __pos, _Args&&... __args)
   {
value_type __x_copy(std::forward<_Args>(__args)...); // XXX copy
 #else
diff --git a/libstdc++-v3/include/bits/stl_deque.h 
b/libstdc++-v3/include/bits/stl_deque.h
index 685ce43992a6..b1e485b1db57 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -2054,9 +2054,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   iterator
   _M_insert_aux(iterator __pos, const value_type& __x);
 #else
+  iterator
+  _M_insert_aux(iterator __pos, const value_type& __x)
+  { return _M_emplace_aux(__pos, __x); }
+
   template
iterator
-   _M_insert_aux(iterator __pos, _Args&&... __args);
+   _M_emplace_aux(iterator __pos, _Args&&... __args);
 #endif
 
   // called by insert(p,n,x) via fill_insert
diff --git 
a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/90389.cc 
b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/90389.cc
new file mode 100644
index ..b4932498700b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/90389.cc
@@ -0,0 +1,43 @@
+// { dg-do run { target c++11 } }
+
+// Bug 90389 - std::deque::emplace tries to call wrong overload internally
+
+#include 
+#include 
+
+struct X
+{
+  X() = default;
+  X(void*, void*, std::size_t) { }
+};
+
+void
+test_pr90389()
+{
+  const int n = 3;
+  std::deque d(n);
+  d.emplace(d.begin(), nullptr, nullptr, d.size());
+  VERIFY( d.size() == n+1 );
+}
+
+struct Y
+{
+  Y() = default;
+  Y(std::size_t, const Y&) { }
+};
+
+void
+test_pr118079()
+{
+  const int n = 3;
+  std::deque d(n);
+  const Y y{};
+  d.emplace(d.begin(), d.size(), y);
+  VERIFY( d.size() == n+1 );
+}
+
+int main()
+{
+  test_pr90389();
+  test_pr118079();
+}


[gcc r13-9464] libstdc++: Add testcases for resolved bug [PR101527]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:b19afd649fcc0b747c4834d43d969f4233aeaee2

commit r13-9464-gb19afd649fcc0b747c4834d43d969f4233aeaee2
Author: Jonathan Wakely 
Date:   Mon Mar 24 21:36:16 2025 +

libstdc++: Add testcases for resolved bug [PR101527]

These tests were fixed by a front-end change r13-465-g4df735e01e3199 so
this just adds them to the testsuite to be sure we don't regress.

libstdc++-v3/ChangeLog:

PR libstdc++/101527
* testsuite/24_iterators/common_iterator/101527.cc: New test.
* testsuite/24_iterators/counted_iterator/101527.cc: New test.

(cherry picked from commit f7c0b0fc4fdeaf034dc38356830625f7280d325d)

Diff:
---
 .../testsuite/24_iterators/common_iterator/101527.cc   | 14 ++
 .../testsuite/24_iterators/counted_iterator/101527.cc  | 14 ++
 2 files changed, 28 insertions(+)

diff --git a/libstdc++-v3/testsuite/24_iterators/common_iterator/101527.cc 
b/libstdc++-v3/testsuite/24_iterators/common_iterator/101527.cc
new file mode 100644
index ..0a2a5e8dfcca
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/common_iterator/101527.cc
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++20 } }
+
+// PR libstdc++/101527
+// implementation of std::common_iterator and std::counted_iterator's
+// operator== seems to be wrong
+
+#include 
+
+bool test_pr101527()
+{
+  std::common_iterator it1;
+  std::common_iterator it2;
+  return it1 == it2;
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/counted_iterator/101527.cc 
b/libstdc++-v3/testsuite/24_iterators/counted_iterator/101527.cc
new file mode 100644
index ..51c6e99cd77c
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/counted_iterator/101527.cc
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++20 } }
+
+// PR libstdc++/101527
+// implementation of std::common_iterator and std::counted_iterator's
+// operator== seems to be wrong
+
+#include 
+
+bool test_pr101527()
+{
+  std::counted_iterator it1;
+  std::counted_iterator it2;
+  return it1 == it2;
+}


[gcc r13-9469] libstdc++: Skip redundant assertions in std::array equality [PR106212]

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:083224c28524217b1a4b14f55b0447d520020451

commit r13-9469-g083224c28524217b1a4b14f55b0447d520020451
Author: Jonathan Wakely 
Date:   Mon Dec 9 17:35:24 2024 +

libstdc++: Skip redundant assertions in std::array equality [PR106212]

As PR c++/106212 shows, the Debug Mode checks cause a compilation error
for equality comparisons involving std::array prvalues in constant
expressions. Those Debug Mode checks are redundant when
comparing two std::array objects, because we already know we have a
valid range. We can also avoid the unnecessary step of using
std::__niter_base to do __normal_iterator unwrapping, which isn't needed
because our std::array iterators are just pointers. Using
std::__equal_aux1 instead of std::equal avoids the redundant checks in
std::equal and std::__equal_aux.

libstdc++-v3/ChangeLog:

PR libstdc++/106212
* include/std/array (operator==): Use std::__equal_aux1 instead
of std::equal.
* testsuite/23_containers/array/comparison_operators/106212.cc:
New test.

(cherry picked from commit 3aeb2edee2f9fc39ab77c7e020f09d7204b167ac)

Diff:
---
 libstdc++-v3/include/std/array|  2 +-
 .../23_containers/array/comparison_operators/106212.cc| 15 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index dd9b4a0ab038..5dc1c9b4bb81 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -295,7 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX20_CONSTEXPR
 inline bool
 operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
-{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
+{ return std::__equal_aux1(__one.begin(), __one.end(), __two.begin()); }
 
 #if __cpp_lib_three_way_comparison && __cpp_lib_concepts
   template
diff --git 
a/libstdc++-v3/testsuite/23_containers/array/comparison_operators/106212.cc 
b/libstdc++-v3/testsuite/23_containers/array/comparison_operators/106212.cc
new file mode 100644
index ..f7b12bd04efd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/comparison_operators/106212.cc
@@ -0,0 +1,15 @@
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile { target c++20 } }
+
+// Bug libstdc++/106212 - Code becomes non-constexpr with _GLIBCXX_DEBUG
+
+#include 
+
+struct A
+{
+  constexpr A(int i) : e{i} {}
+  constexpr bool operator==(const A& a) const = default;
+  std::array e;
+};
+
+static_assert(A{1} != A{2}, "");


[gcc r13-9468] libstdc++: Skip redundant assertions in std::span construction [PR117966]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:c55e69d87caf8ec7c4a008b571f2232570255855

commit r13-9468-gc55e69d87caf8ec7c4a008b571f2232570255855
Author: Jonathan Wakely 
Date:   Mon Dec 9 17:35:24 2024 +

libstdc++: Skip redundant assertions in std::span construction [PR117966]

As PR c++/117966 shows, the Debug Mode checks cause a compilation error
for a global constexpr std::span. Those debug checks are redundant when
constructing from an array or a range, because we already know we have a
valid range and we know its size. Instead of delegating to the
std::span(contiguous_iterator, contiguous_iterator) constructor, just
initialize the data members directly.

libstdc++-v3/ChangeLog:

PR libstdc++/117966
* include/std/span (span(T (&)[N])): Do not delegate to
constructor that performs redundant checks.
(span(array&), span(const array&)): Likewise.
(span(Range&&), span(const span&)): Likewise.
* testsuite/23_containers/span/117966.cc: New test.

(cherry picked from commit e95bda027e0b81922c1bf44770674190bdf787e8)

Diff:
---
 libstdc++-v3/include/std/span   | 10 +-
 libstdc++-v3/testsuite/23_containers/span/117966.cc | 13 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index b70893779d84..d9a4b40e9459 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -187,21 +187,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
requires (_Extent == dynamic_extent || _ArrayExtent == _Extent)
constexpr
span(type_identity_t (&__arr)[_ArrayExtent]) noexcept
-   : span(static_cast(__arr), _ArrayExtent)
+   : _M_ptr(__arr), _M_extent(_ArrayExtent)
{ }
 
   template
requires __is_compatible_array<_Tp, _ArrayExtent>::value
constexpr
span(array<_Tp, _ArrayExtent>& __arr) noexcept
-   : span(static_cast(__arr.data()), _ArrayExtent)
+   : _M_ptr(__arr.data()), _M_extent(_ArrayExtent)
{ }
 
   template
requires __is_compatible_array::value
constexpr
span(const array<_Tp, _ArrayExtent>& __arr) noexcept
-   : span(static_cast(__arr.data()), _ArrayExtent)
+   : _M_ptr(__arr.data()), _M_extent(_ArrayExtent)
{ }
 
   template
@@ -215,7 +215,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
span(_Range&& __range)
noexcept(noexcept(ranges::data(__range))
  && noexcept(ranges::size(__range)))
-   : span(ranges::data(__range), ranges::size(__range))
+   : _M_ptr(ranges::data(__range)), _M_extent(ranges::size(__range))
{
  if constexpr (extent != dynamic_extent)
{
@@ -233,7 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr
explicit(extent != dynamic_extent && _OExtent == dynamic_extent)
span(const span<_OType, _OExtent>& __s) noexcept
-   : _M_extent(__s.size()), _M_ptr(__s.data())
+   : _M_ptr(__s.data()), _M_extent(__s.size())
{
  if constexpr (extent != dynamic_extent)
{
diff --git a/libstdc++-v3/testsuite/23_containers/span/117966.cc 
b/libstdc++-v3/testsuite/23_containers/span/117966.cc
new file mode 100644
index ..8bbb5ca1e079
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/span/117966.cc
@@ -0,0 +1,13 @@
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile { target c++20 } }
+
+// Bug 117966
+// constexpr std::span construction fails to compile with D_GLIBCXX_DEBUG
+
+#include 
+#include 
+
+struct A {
+  constexpr A(std::span) {}
+};
+constexpr A val{std::array{0x11, 0x22}};


[gcc r13-9472] libstdc++: Fix std::basic_stracktrace to not assume allocators throw std::bad_alloc

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:2b44ca5a76dffcedacbec2ccf0917f8039e192b1

commit r13-9472-g2b44ca5a76dffcedacbec2ccf0917f8039e192b1
Author: Jonathan Wakely 
Date:   Tue Sep 24 12:44:09 2024 +0100

libstdc++: Fix std::basic_stracktrace to not assume allocators throw 
std::bad_alloc

The standard allows allocators to throw any kind of exception, not only
something that can be caught as std::bad_alloc. std::basic_stracktrace
was assuming std::bad_alloc.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::_Impl::_M_allocate):
Do not assume allocators only throw std::bad_alloc.

(cherry picked from commit c45844eb7dadcd48e3ce8a45c270382f7ad1)

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

diff --git a/libstdc++-v3/include/std/stacktrace 
b/libstdc++-v3/include/std/stacktrace
index 79bd092c479c..9d4b3a5a8c06 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -618,7 +618,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  if constexpr (is_same_v>)
{
  // For std::allocator we use nothrow-new directly so we
- // don't need to handle bad_alloc exceptions.
+ // don't need to handle exceptions from __alloc.allocate(n).
  size_t __nb = __n * sizeof(value_type);
  void* const __p = _GLIBCXX_OPERATOR_NEW (__nb, nothrow_t{});
  if (__p == nullptr) [[unlikely]]
@@ -631,7 +631,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
  _M_frames = __alloc.allocate(__n);
}
- __catch (const std::bad_alloc&)
+ __catch (...)
{
  return nullptr;
}


[gcc r13-9471] libstdc++: Fix parallel std::exclusive_scan [PR108236]

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:081989e519b2fa80a36d852af43cdda63b2e1a16

commit r13-9471-g081989e519b2fa80a36d852af43cdda63b2e1a16
Author: Jonathan Wakely 
Date:   Tue Dec 3 16:36:05 2024 +

libstdc++: Fix parallel std::exclusive_scan [PR108236]

The standard says that std::exclusive_scan can be used to work in
place, i.e. where the output range is the same as the input range. This
means that the first sum cannot be written to the output until after
reading the first input value, otherwise we'll already have overwritten
the first input value.

While writing a new testcase I also realised that the serial version of
std::exclusive_scan uses copy construction for the accumulator variable,
but the standard only requires Cpp17MoveConstructible. We also require
move assignable, which is missing from the standard's requirements, but
we should at least use move construction not copy construction.

A similar problem exists for some other new C++17 numeric algos, but
I'll fix the others in a subsequent commit.

libstdc++-v3/ChangeLog:

PR libstdc++/108236
* include/pstl/glue_numeric_impl.h (exclusive_scan): Pass __init
as rvalue.
* include/pstl/numeric_impl.h (__brick_transform_scan): Do not
write through __result until after reading through __first. Move
__init into return value.
(__pattern_transform_scan): Pass __init as rvalue.
* include/std/numeric (exclusive_scan): Move construct instead
of copy constructing.
* testsuite/26_numerics/exclusive_scan/2.cc: New test.
* testsuite/26_numerics/pstl/numeric_ops/108236.cc: New test.

(cherry picked from commit cd107a6343c96c4ef26096e250d43a4a4211eced)

Diff:
---
 libstdc++-v3/include/pstl/glue_numeric_impl.h  |  2 +-
 libstdc++-v3/include/pstl/numeric_impl.h   |  9 ++--
 libstdc++-v3/include/std/numeric   |  4 +-
 .../testsuite/26_numerics/exclusive_scan/2.cc  | 46 
 .../26_numerics/pstl/numeric_ops/108236.cc | 50 ++
 5 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/pstl/glue_numeric_impl.h 
b/libstdc++-v3/include/pstl/glue_numeric_impl.h
index 9db64b513a47..49226bd14c5c 100644
--- a/libstdc++-v3/include/pstl/glue_numeric_impl.h
+++ b/libstdc++-v3/include/pstl/glue_numeric_impl.h
@@ -111,7 +111,7 @@ exclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 
__first, _ForwardIte
 {
 using namespace __pstl;
 return __internal::__pattern_transform_scan(
-std::forward<_ExecutionPolicy>(__exec), __first, __last, __result, 
__pstl::__internal::__no_op(), __init,
+std::forward<_ExecutionPolicy>(__exec), __first, __last, __result, 
__pstl::__internal::__no_op(), std::move(__init),
 __binary_op, /*inclusive=*/std::false_type(),
 __internal::__is_vectorization_preferred<_ExecutionPolicy, 
_ForwardIterator1, _ForwardIterator2>(__exec),
 __internal::__is_parallelization_preferred<_ExecutionPolicy, 
_ForwardIterator1, _ForwardIterator2>(__exec));
diff --git a/libstdc++-v3/include/pstl/numeric_impl.h 
b/libstdc++-v3/include/pstl/numeric_impl.h
index 0b02bcf07891..1c9194dd3d6f 100644
--- a/libstdc++-v3/include/pstl/numeric_impl.h
+++ b/libstdc++-v3/include/pstl/numeric_impl.h
@@ -149,11 +149,12 @@ __brick_transform_scan(_ForwardIterator __first, 
_ForwardIterator __last, _Outpu
 {
 for (; __first != __last; ++__first, ++__result)
 {
-*__result = __init;
+   _Tp __v = std::move(__init);
 _PSTL_PRAGMA_FORCEINLINE
-__init = __binary_op(__init, __unary_op(*__first));
+__init = __binary_op(__v, __unary_op(*__first));
+*__result = std::move(__v);
 }
-return std::make_pair(__result, __init);
+return std::make_pair(__result, std::move(__init));
 }
 
 // Inclusive form
@@ -214,7 +215,7 @@ __pattern_transform_scan(_ExecutionPolicy&&, 
_ForwardIterator __first, _ForwardI
  _OutputIterator __result, _UnaryOperation __unary_op, 
_Tp __init, _BinaryOperation __binary_op,
  _Inclusive, _IsVector __is_vector, 
/*is_parallel=*/std::false_type) noexcept
 {
-return __internal::__brick_transform_scan(__first, __last, __result, 
__unary_op, __init, __binary_op, _Inclusive(),
+  return __internal::__brick_transform_scan(__first, __last, __result, 
__unary_op, std::move(__init), __binary_op, _Inclusive(),
   __is_vector)
 .first;
 }
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index 514db9366231..dfbaf8499cbd 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -485,8 +485,8 @@ namespace __detail
 {
   while (__first != __last)
{
- auto __v = __init;
- __init = __binary_

[gcc r13-9474] libstdc++: Fix "IEE" typo in comment in std::time_put::do_put

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:08e7f31dd2c209caf85cc624c0d75f3e09d5c59e

commit r13-9474-g08e7f31dd2c209caf85cc624c0d75f3e09d5c59e
Author: Jonathan Wakely 
Date:   Wed Mar 19 23:26:10 2025 +

libstdc++: Fix "IEE" typo in comment in std::time_put::do_put

libstdc++-v3/ChangeLog:

* include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix
typo in comment.

(cherry picked from commit b8e39b4c33ce74c243e467391f6cc0144d4a9477)

Diff:
---
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc 
b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index b19f44253001..23ba676af1b3 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -1648,7 +1648,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
   const size_t __maxlen = 128;
   char_type __res[__maxlen];
 
-  // NB: In IEE 1003.1-200x, and perhaps other locale models, it
+  // NB: In IEEE 1003.1-200x, and perhaps other locale models, it
   // is possible that the format character will be longer than one
   // character. Possibilities include 'E' or 'O' followed by a
   // format character: if __mod is not the default argument, assume


[gcc r13-9473] libstdc++: Use constexpr instead of _GLIBCXX20_CONSTEXPR in

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:9d2a7a749e5d418f11c504c3081ce383444af84e

commit r13-9473-g9d2a7a749e5d418f11c504c3081ce383444af84e
Author: Jonathan Wakely 
Date:   Wed Sep 18 16:17:28 2024 +0100

libstdc++: Use constexpr instead of _GLIBCXX20_CONSTEXPR in 

For the operator<=> overload we can use the 'constexpr' keyword
directly, because we know the language dialect is at least C++20.

libstdc++-v3/ChangeLog:

* include/bits/stl_vector.h (operator<=>): Use constexpr
instead of _GLIBCXX20_CONSTEXPR macro.

(cherry picked from commit b6463161c3cd0b1f764697290d9569c7153b8a5b)

Diff:
---
 libstdc++-v3/include/bits/stl_vector.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_vector.h 
b/libstdc++-v3/include/bits/stl_vector.h
index 798e66d91ac8..ac63b218fa9b 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -2041,7 +2041,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 { return (__x.size() == __y.size()
  && std::equal(__x.begin(), __x.end(), __y.begin())); }
 
-#if __cpp_lib_three_way_comparison
+#if __cpp_lib_three_way_comparison // >= C++20
   /**
*  @brief  Vector ordering relation.
*  @param  __x  A `vector`.
@@ -2054,8 +2054,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  `<` and `>=` etc.
   */
   template
-_GLIBCXX20_CONSTEXPR
-inline __detail::__synth3way_t<_Tp>
+constexpr __detail::__synth3way_t<_Tp>
 operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
 {
   return std::lexicographical_compare_three_way(__x.begin(), __x.end(),


[gcc r13-9477] libstdc++: Update tzdata to 2025b

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:0d80c4122049446b49f54220b8b3dffdf695e77a

commit r13-9477-g0d80c4122049446b49f54220b8b3dffdf695e77a
Author: Jonathan Wakely 
Date:   Fri Jan 12 16:57:41 2024 +

libstdc++: Update tzdata to 2025b

Import the new 2025b tzdata.zi file.

libstdc++-v3/ChangeLog:

* src/c++20/tzdata.zi: Import new file from 2025b release.

(cherry picked from commit fd3bb314052f04f9357b4dce89fcb61ecfd3a83b)

Diff:
---
 libstdc++-v3/src/c++20/tzdata.zi | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++20/tzdata.zi b/libstdc++-v3/src/c++20/tzdata.zi
index db6ba4af2b01..a7fb52f1968f 100644
--- a/libstdc++-v3/src/c++20/tzdata.zi
+++ b/libstdc++-v3/src/c++20/tzdata.zi
@@ -1,4 +1,4 @@
-# version 2025a
+# version 2025b
 # This zic input file is in the public domain.
 R d 1916 o - Jun 14 23s 1 S
 R d 1916 1919 - O Su>=1 23s 0 -
@@ -2432,6 +2432,20 @@ Z America/Ciudad_Juarez -7:5:56 - LMT 1922 Ja 1 7u
 Z America/Costa_Rica -5:36:13 - LMT 1890
 -5:36:13 - SJMT 1921 Ja 15
 -6 CR C%sT
+Z America/Coyhaique -4:48:16 - LMT 1890
+-4:42:45 - SMT 1910 Ja 10
+-5 - %z 1916 Jul
+-4:42:45 - SMT 1918 S 10
+-4 - %z 1919 Jul
+-4:42:45 - SMT 1927 S
+-5 x %z 1932 S
+-4 - %z 1942 Jun
+-5 - %z 1942 Au
+-4 - %z 1946 Au 28 24
+-5 1 %z 1947 Mar 31 24
+-5 - %z 1947 May 21 23
+-4 x %z 2025 Mar 20
+-3 - %z
 Z America/Cuiaba -3:44:20 - LMT 1914
 -4 B %z 2003 S 24
 -4 - %z 2004 O
@@ -3420,7 +3434,7 @@ Z Asia/Tbilisi 2:59:11 - LMT 1880
 Z Asia/Tehran 3:25:44 - LMT 1916
 3:25:44 - TMT 1935 Jun 13
 3:30 i %z 1977 O 20 24
-4 i %z 1979
+4 i %z 1978 N 10 24
 3:30 i %z
 Z Asia/Thimphu 5:58:36 - LMT 1947 Au 15
 5:30 - %z 1987 O


[gcc r13-9476] libstdc++: Update tzdata to 2025a

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0ad74de398a8785ea285d7071697c5a0f9321846

commit r13-9476-g0ad74de398a8785ea285d7071697c5a0f9321846
Author: Jonathan Wakely 
Date:   Fri Jan 12 16:57:41 2024 +

libstdc++: Update tzdata to 2025a

Import the new 2025a tzdata.zi file. The leapseconds file was also
updated to have a new expiry (no new leap seconds were added).

libstdc++-v3/ChangeLog:

* include/std/chrono (__detail::__get_leap_second_info): Update
expiry date for leap seconds list.
* src/c++20/tzdata.zi: Import new file from 2025a release.
* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds)
Update expiry date for leap seconds list.

(cherry picked from commit 0ce4c1c48564e465a331c100e757e2258b4c632a)

Diff:
---
 libstdc++-v3/include/std/chrono  |2 +-
 libstdc++-v3/src/c++20/tzdata.zi | 1682 +++---
 libstdc++-v3/src/c++20/tzdb.cc   |4 +-
 3 files changed, 840 insertions(+), 848 deletions(-)

diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index 1f3f897d932a..913d49a0722f 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -3253,7 +3253,7 @@ namespace __detail
   };
   // The list above is known to be valid until (at least) this date
   // and only contains positive leap seconds.
-  const sys_seconds __expires(1735344000s); // 2024-12-28 00:00:00 UTC
+  const sys_seconds __expires(176688s); // 2025-12-28 00:00:00 UTC
 
 #if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   if (__ss > __expires)
diff --git a/libstdc++-v3/src/c++20/tzdata.zi b/libstdc++-v3/src/c++20/tzdata.zi
index be1c40859202..db6ba4af2b01 100644
--- a/libstdc++-v3/src/c++20/tzdata.zi
+++ b/libstdc++-v3/src/c++20/tzdata.zi
@@ -1,4 +1,4 @@
-# version 2024a
+# version 2025a
 # This zic input file is in the public domain.
 R d 1916 o - Jun 14 23s 1 S
 R d 1916 1919 - O Su>=1 23s 0 -
@@ -721,12 +721,16 @@ R P 2085 o - Ap 21 2 0 -
 R P 2085 o - Jun 9 2 1 S
 R P 2086 o - Ap 13 2 0 -
 R P 2086 o - May 25 2 1 S
-R PH 1936 o - N 1 0 1 D
-R PH 1937 o - F 1 0 0 S
-R PH 1954 o - Ap 12 0 1 D
-R PH 1954 o - Jul 1 0 0 S
-R PH 1978 o - Mar 22 0 1 D
-R PH 1978 o - S 21 0 0 S
+R PH 1936 o - O 31 24 1 D
+R PH 1937 o - Ja 15 24 0 S
+R PH 1941 o - D 15 24 1 D
+R PH 1945 o - N 30 24 0 S
+R PH 1954 o - Ap 11 24 1 D
+R PH 1954 o - Jun 4 24 0 S
+R PH 1977 o - Mar 27 24 1 D
+R PH 1977 o - S 21 24 0 S
+R PH 1990 o - May 21 0 1 D
+R PH 1990 o - Jul 28 24 0 S
 R S 1920 1923 - Ap Su>=15 2 1 S
 R S 1920 1923 - O Su>=1 2 0 -
 R S 1962 o - Ap 29 2 1 S
@@ -1324,14 +1328,10 @@ R O 1961 1964 - May lastSu 1s 1 S
 R O 1962 1964 - S lastSu 1s 0 -
 R p 1916 o - Jun 17 23 1 S
 R p 1916 o - N 1 1 0 -
-R p 1917 o - F 28 23s 1 S
-R p 1917 1921 - O 14 23s 0 -
-R p 1918 o - Mar 1 23s 1 S
-R p 1919 o - F 28 23s 1 S
-R p 1920 o - F 29 23s 1 S
-R p 1921 o - F 28 23s 1 S
+R p 1917 1921 - Mar 1 0 1 S
+R p 1917 1921 - O 14 24 0 -
 R p 1924 o - Ap 16 23s 1 S
-R p 1924 o - O 14 23s 0 -
+R p 1924 o - O 4 23s 0 -
 R p 1926 o - Ap 17 23s 1 S
 R p 1926 1929 - O Sa>=1 23s 0 -
 R p 1927 o - Ap 9 23s 1 S
@@ -1349,8 +1349,9 @@ R p 1938 o - Mar 26 23s 1 S
 R p 1939 o - Ap 15 23s 1 S
 R p 1939 o - N 18 23s 0 -
 R p 1940 o - F 24 23s 1 S
-R p 1940 1941 - O 5 23s 0 -
+R p 1940 o - O 7 23s 0 -
 R p 1941 o - Ap 5 23s 1 S
+R p 1941 o - O 5 23s 0 -
 R p 1942 1945 - Mar Sa>=8 23s 1 S
 R p 1942 o - Ap 25 22s 2 M
 R p 1942 o - Au 15 22s 1 S
@@ -1360,16 +1361,16 @@ R p 1943 1945 - Au Sa>=25 22s 1 S
 R p 1944 1945 - Ap Sa>=21 22s 2 M
 R p 1946 o - Ap Sa>=1 23s 1 S
 R p 1946 o - O Sa>=1 23s 0 -
-R p 1947 1965 - Ap Su>=1 2s 1 S
+R p 1947 1966 - Ap Su>=1 2s 1 S
 R p 1947 1965 - O Su>=1 2s 0 -
-R p 1977 o - Mar 27 0s 1 S
-R p 1977 o - S 25 0s 0 -
-R p 1978 1979 - Ap Su>=1 0s 1 S
-R p 1978 o - O 1 0s 0 -
-R p 1979 1982 - S lastSu 1s 0 -
-R p 1980 o - Mar lastSu 0s 1 S
-R p 1981 1982 - Mar lastSu 1s 1 S
-R p 1983 o - Mar lastSu 2s 1 S
+R p 1976 o - S lastSu 1 0 -
+R p 1977 o - Mar lastSu 0s 1 S
+R p 1977 o - S lastSu 0s 0 -
+R p 1978 1980 - Ap Su>=1 1s 1 S
+R p 1978 o - O 1 1s 0 -
+R p 1979 1980 - S lastSu 1s 0 -
+R p 1981 1986 - Mar lastSu 0s 1 S
+R p 1981 1985 - S lastSu 0s 0 -
 R z 1932 o - May 21 0s 1 S
 R z 1932 1939 - O Su>=1 0s 0 -
 R z 1933 1939 - Ap Su>=2 0s 1 S
@@ -1728,7 +1729,7 @@ R Y 1972 2006 - O lastSu 2 0 S
 R Y 1987 2006 - Ap Su>=1 2 1 D
 R Yu 1965 o - Ap lastSu 0 2 DD
 R Yu 1965 o - O lastSu 2 0 S
-R m 1931 o - May 1 23 1 D
+R m 1931 o - Ap 30 0 1 D
 R m 1931 o - O 1 0 0 S
 R m 1939 o - F 5 0 1 D
 R m 1939 o - Jun 25 0 0 S
@@ -2022,9 +2023,9 @@ R y 2002 2004 - Ap Su>=1 0 0 -
 R y 2002 2003 - S Su>=1 0 1 -
 R y 2004 2009 - O Su>=15 0 1 -
 R y 2005 2009 - Mar Su>=8 0 0 -
-R y 2010 ma - O Su>=1 0 1 -
+R y 2010 2024 - O Su>=1 0 1 -
 R y 2010 2012 - Ap Su>=8 0 0 -
-R y 2013 ma - Mar Su>=22 0 0 -
+R y 2013 2024 - Mar Su>=22 0 0 -
 R PE 1938 o - Ja 1 0 1 -
 R PE 1938 o - Ap 1 0 0 -
 

[gcc r13-9478] libstdc++: Cast -1 to size_t in [PR119429]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:1662a95371061018415ef26c2e787451c420aa56

commit r13-9478-g1662a95371061018415ef26c2e787451c420aa56
Author: Jonathan Wakely 
Date:   Mon Mar 24 21:25:20 2025 +

libstdc++: Cast -1 to size_t in  [PR119429]

This avoids a runtime error from Clang's annoying -fsanitize=integer
(even though it's not undefined and behaves correctly).

libstdc++-v3/ChangeLog:

PR libstdc++/119429
* include/std/format (__format::_Scanner::_Scanner): Cast
default argument to size_t.

(cherry picked from commit 039cc50867000e6427924ca490dc810eaa44cf08)

Diff:
---
 libstdc++-v3/include/std/format | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 3c9b5a088a3f..26e87c427afd 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -3513,7 +3513,7 @@ namespace __format
   basic_format_parse_context<_CharT> _M_pc;
 
   constexpr explicit
-  _Scanner(basic_string_view<_CharT> __str, size_t __nargs = -1)
+  _Scanner(basic_string_view<_CharT> __str, size_t __nargs = (size_t)-1)
   : _M_pc(__str, __nargs)
   { }


[gcc r13-9479] libstdc++: Make std::erase for linked lists convert to bool

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:8debc3440846a9840330835e61b5179616beaf63

commit r13-9479-g8debc3440846a9840330835e61b5179616beaf63
Author: Jonathan Wakely 
Date:   Thu Mar 6 21:18:21 2025 +

libstdc++: Make std::erase for linked lists convert to bool

LWG 4135 (approved in Wrocław, November 2024) fixes the lambda
expressions used by std::erase for std::list and std::forward_list.
Previously they attempted to copy something that isn't required to be
copyable. Instead they should convert it to bool right away.

The issue resolution also changes the lambda's parameter to be const, so
that it can't modify the elements while comparing them.

libstdc++-v3/ChangeLog:

* include/std/forward_list (erase): Change lambda to have
explicit return type and const parameter type.
* include/std/list (erase): Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Check lambda
is correct.
* testsuite/23_containers/list/erasure.cc: Likewise.

Reviewed-by: Patrick Palka 
(cherry picked from commit e6e7b477bbdbfb3fee6b44087a59f94fd1e2c7a3)

Diff:
---
 libstdc++-v3/include/std/forward_list  |  5 +++--
 libstdc++-v3/include/std/list  |  5 +++--
 .../23_containers/forward_list/erasure.cc  | 22 ++
 .../testsuite/23_containers/list/erasure.cc| 22 ++
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/std/forward_list 
b/libstdc++-v3/include/std/forward_list
index 1c110df971b7..2e9379d388ea 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -75,8 +75,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 inline typename forward_list<_Tp, _Alloc>::size_type
 erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
-  using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
-  return std::erase_if(__cont, [&](__elem_type& __elem) {
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4135. helper lambda of std::erase for list should specify return type
+  return std::erase_if(__cont, [&](const auto& __elem) -> bool {
  return __elem == __value;
   });
 }
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index 48861b9a3400..9eff5e9b0b04 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -99,8 +99,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 inline typename list<_Tp, _Alloc>::size_type
 erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
-  using __elem_type = typename list<_Tp, _Alloc>::value_type;
-  return std::erase_if(__cont, [&](__elem_type& __elem) {
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4135. helper lambda of std::erase for list should specify return type
+  return std::erase_if(__cont, [&](const auto& __elem) -> bool {
  return __elem == __value;
   });
 }
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
index 1454e8319774..ace04d4737f3 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
@@ -52,6 +52,28 @@ test02()
   VERIFY( num == 0 );
 }
 
+// LWG 4135.
+// The helper lambda of std::erase for list should specify return type as bool
+void
+test_lwg4135()
+{
+  struct Bool {
+Bool() = default;
+Bool(const Bool&) = delete;
+operator bool() const { return false; }
+  };
+
+  static Bool b;
+
+  struct Int {
+Bool& operator==(Int) const { return b; }
+void operator==(Int) = delete;
+  };
+
+  std::forward_list l;
+  std::erase(l, Int{});
+}
+
 int
 main()
 {
diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
index de036dcd5bb4..3828df101ddf 100644
--- a/libstdc++-v3/testsuite/23_containers/list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
@@ -51,6 +51,28 @@ test02()
   VERIFY( num == 0 );
 }
 
+// LWG 4135.
+// The helper lambda of std::erase for list should specify return type as bool
+void
+test_lwg4135()
+{
+  struct Bool {
+Bool() = default;
+Bool(const Bool&) = delete;
+operator bool() const { return false; }
+  };
+
+  static Bool b;
+
+  struct Int {
+Bool& operator==(Int) const { return b; }
+void operator==(Int) = delete;
+  };
+
+  std::list l;
+  std::erase(l, Int{});
+}
+
 int
 main()
 {


[gcc/devel/omp/gcc-14] OpenMP: modify_call_for_omp_dispatch - fix invalid memory access after 'error' [PR119541]

2025-03-31 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:fa13241d67e21088305a6fc54c76b9f9a3d9d4c4

commit fa13241d67e21088305a6fc54c76b9f9a3d9d4c4
Author: Tobias Burnus 
Date:   Mon Mar 31 11:44:26 2025 +0200

OpenMP: modify_call_for_omp_dispatch - fix invalid memory access after 
'error' [PR119541]

OpenMP requires that the number of dispatch 'interop' clauses (ninterop)
is less or equal to the number of declare variant 'append_args' interop
objects (nappend).

While 'nappend < ninterop' was diagnosed as error, the processing continues,
which lead to an invalid out-of-bounds memory access. Solution: only
process the first nappend 'interop' clauses.

gcc/ChangeLog:

PR middle-end/119541
* gimplify.cc (modify_call_for_omp_dispatch): Limit interop claues
processing by the number of append_args arguments.

(cherry picked from commit f3899e0fd3f9aa6b579a21e87b50c61ea5c448df)

Diff:
---
 gcc/ChangeLog.omp   | 9 +
 gcc/gimplify.cc | 3 ++-
 gcc/testsuite/ChangeLog.omp | 8 
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 3e349ac21873..5287d5333895 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,12 @@
+2025-03-31  Tobias Burnus  
+
+   Backported from master:
+   2025-03-31  Tobias Burnus  
+
+   PR middle-end/119541
+   * gimplify.cc (modify_call_for_omp_dispatch): Limit interop claues
+   processing by the number of append_args arguments.
+
 2025-03-27  Tobias Burnus  
 
Backported from master:
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 49ff5ace9bcf..f85a722e2d5c 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3969,6 +3969,7 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
  : DECL_SOURCE_LOCATION (fndecl),
  "% candidate %qD declared here",
  fndecl);
+ ninterop = nappend;
}
 }
   if (dispatch_interop && !dispatch_device_num)
@@ -3991,7 +3992,7 @@ modify_call_for_omp_dispatch (tree expr, tree 
dispatch_clauses,
  buffer[i] = CALL_EXPR_ARG (expr, i);
}
   int j = ninterop;
-  for (tree t = dispatch_interop; t; t = TREE_CHAIN (t))
+  for (tree t = dispatch_interop; t && j > 0; t = TREE_CHAIN (t))
if (OMP_CLAUSE_CODE (t) == OMP_CLAUSE_INTEROP)
  buffer[i + --j] = OMP_CLAUSE_DECL (t);
   gcc_checking_assert (j == 0);
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 675f1ba3792d..0c39103e3b33 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,11 @@
+2025-03-30  Tobias Burnus  
+
+   Backported from master:
+   2025-03-30  Tobias Burnus  
+
+   * g++.dg/gomp/append-args-8.C: Remove bogus '3' after \.\[0-9\]+
+   pattern.
+
 2025-03-27  Tobias Burnus  
 
Backported from master:


[gcc r15-9067] aarch64: Remove +sme -> +sve2 feature flag dependency

2025-03-31 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:432f0dd62c3b29efbc0b8a1650c05c370477c0b6

commit r15-9067-g432f0dd62c3b29efbc0b8a1650c05c370477c0b6
Author: Andre Simoes Dias Vieira 
Date:   Mon Mar 31 11:12:21 2025 +0100

aarch64: Remove +sme -> +sve2 feature flag dependency

As per the AArch64 ISA FEAT_SME does not require FEAT_SVE2. However, we 
don't
support SME without SVE2 and bail out with a 'sorry' if this configuration 
is
encountered.  We may choose to support this in the future.

gcc/ChangeLog:

* config/aarch64/aarch64-option-extensions.def (SME): Remove SVE2 as
prerequisite and add in FCMA and F16FML.
* config/aarch64/aarch64.cc (aarch64_override_options_internal):
Diagnose use of SME without SVE2 and implicitly enable SVE2 when
enabling SME after streaming mode diagnosis.
* doc/invoke.texi (sme): Document that this can only be used with 
the
sve2 extension.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no-sve-with-sme-1.c: New.
* gcc.target/aarch64/no-sve-with-sme-2.c: New.
* gcc.target/aarch64/no-sve-with-sme-3.c: New.
* gcc.target/aarch64/no-sve-with-sme-4.c: New.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Pass +sve2 to existing
+sme pragma.
* gcc.target/aarch64/sve/acle/general-c/binary_int_opt_single_n_2.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binary_opt_single_n_2.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binary_single_1.c: Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/binary_za_slice_int_opt_single_1.c:
* gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_2.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_3.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_4.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_1.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_2.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_3.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/binary_za_slice_uint_opt_single_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/binaryxn_2.c: Likewise.
* gcc.target/aarch64/sve/acle/general-c/clamp_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general-c/compare_scalar_count_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/dot_za_slice_int_lane_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/dot_za_slice_lane_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/dot_za_slice_lane_2.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/dot_za_slice_uint_lane_1.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/shift_right_imm_narrowxn_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/storexn_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general-c/ternary_mfloat8_lane_1.c:
Likewise.
* 
gcc.target/aarch64/sve/acle/general-c/ternary_mfloat8_lane_group_selection_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/ternary_qq_or_011_lane_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/unary_convertxn_1.c: 
Likewise.
* gcc.target/aarch64/sve/acle/general-c/unary_convertxn_narrow_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/unary_convertxn_narrowt_1.c:
Likewise.
* gcc.target/aarch64/sve/acle/general-c/unary_za_slice_1.c: 
Likewise.
* gcc.target/aarch64/sve/acle/general-c/unaryxn_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general-c/write_za_1.c: Likewise.
* gcc.target/aarch64/sve/acle/general-c/write_za_slice_1.c: 
Likewise.

Diff:
---
 gcc/config/aarch64/aarch64-option-extensions.def |  2 +-
 gcc/config/aarch64/aarch64.cc| 11 ++-
 gcc/doc/invoke.texi  |  3 ++-
 gcc/testsuite/gcc.target/aarch64/no-sve-with-sme-1.c |  8 
 gcc/testsuite/gcc.target/aarch64/no-sve-with-sme-2.c |  9 +
 gcc/testsuite/gcc.target/aarch64/no-sve-with-sme-3.c |  8 
 gcc/testsuite/gcc.target/aarch64/no-sve-with-sme-4.c | 11 +++
 gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_4.c  | 16 
 .../sve/acle/general-c/binary_int_opt_single_n_2.c   |  2 +-
 .../aarch64/sve/acle/general-c/b

[gcc r15-9068] c++: fix reporting routines re-entered [PR119303]

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

commit r15-9068-gc7eec82942496520d6b0604aa945a89f279e2562
Author: Marek Polacek 
Date:   Thu Mar 27 15:03:18 2025 -0400

c++: fix reporting routines re-entered [PR119303]

We crash while we call warning_at ("inline function used but never defined")
since it invokes dump_template_bindings -> tsubst -> ... -> convert_like ->
... -> c_common_truthvalue_conversion -> warning_at ("enum constant in 
boolean
 context")

cp_truthvalue_conversion correctly gets complain=0 but it calls
c_common_truthvalue_conversion from c-family which doesn't have
a similar parameter.

We can fix this by tweaking diagnostic_context::report_diagnostic to
check for recursion after checking if the diagnostic was enabled.

PR c++/116960
PR c++/119303

gcc/ChangeLog:

* diagnostic.cc (diagnostic_context::report_diagnostic): Check for
non-zero m_lock later, after checking diagnostic_enabled.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval26.C: New test.
* g++.dg/warn/undefined2.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/diagnostic.cc| 24 
 gcc/testsuite/g++.dg/cpp2a/lambda-uneval26.C | 10 ++
 gcc/testsuite/g++.dg/warn/undefined2.C   | 14 ++
 3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 82d7f946818b..07c76b6c6526 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -1398,18 +1398,6 @@ diagnostic_context::report_diagnostic (diagnostic_info 
*diagnostic)
   if (diagnostic->kind == DK_NOTE && m_inhibit_notes_p)
 return false;
 
-  if (m_lock > 0)
-{
-  /* If we're reporting an ICE in the middle of some other error,
-try to flush out the previous error, then let this one
-through.  Don't do this more than once.  */
-  if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
- && m_lock == 1)
-   pp_newline_and_flush (m_reference_printer);
-  else
-   error_recursion ();
-}
-
   /* If the user requested that warnings be treated as errors, so be
  it.  Note that we do this before the next block so that
  individual warnings can be overridden back to warnings with
@@ -1437,6 +1425,18 @@ diagnostic_context::report_diagnostic (diagnostic_info 
*diagnostic)
   if (diagnostic->kind != DK_NOTE && diagnostic->kind != DK_ICE)
 check_max_errors (false);
 
+  if (m_lock > 0)
+{
+  /* If we're reporting an ICE in the middle of some other error,
+try to flush out the previous error, then let this one
+through.  Don't do this more than once.  */
+  if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
+ && m_lock == 1)
+   pp_newline_and_flush (m_reference_printer);
+  else
+   error_recursion ();
+}
+
   m_lock++;
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval26.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval26.C
new file mode 100644
index ..3e3097bedcbf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval26.C
@@ -0,0 +1,10 @@
+// PR c++/116960
+// { dg-do compile { target c++20 } }
+
+template
+using Foo = decltype([](auto) { return 0; }(0));
+
+template
+Foo<[] {}> foo() {}   // { dg-warning "no return statement" }
+
+auto t = foo();
diff --git a/gcc/testsuite/g++.dg/warn/undefined2.C 
b/gcc/testsuite/g++.dg/warn/undefined2.C
new file mode 100644
index ..1b2ec353adb9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/undefined2.C
@@ -0,0 +1,14 @@
+// PR c++/119303
+
+template  struct c {
+  enum { d = 4 };
+};
+template  struct e {
+  typedef void g;
+};
+template 
+inline typename e::d>::g bar(_Tp); // { dg-warning "used but never 
defined" }
+
+int x;
+
+void foo() { bar(x); }


[gcc r15-9060] gcc_release: Generate srcdir extras/infos/man pages from all FEs [PR119510]

2025-03-31 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:7d126e2bbb378d1344f871011406c08aa88a85cd

commit r15-9060-g7d126e2bbb378d1344f871011406c08aa88a85cd
Author: Jakub Jelinek 
Date:   Mon Mar 31 10:13:42 2025 +0200

gcc_release: Generate srcdir extras/infos/man pages from all FEs [PR119510]

Enabling cobol explicitly (at least unconditionally) in gcc_release has the
disadvantage that the script no longer works for GCC <= 14, I think it would
be better to keep it working for all still supported release branches.

And as mentioned in the PR, we still don't generate the
--enable-generated-files-in-srcdir extras/infos/man pages for languages
not actually enabled.
Using --enable-languages=all would mean gcc_release takes far longer and
more importantly, various FEs have extra dependencies, Ada requires a
working Ada compiler (furthermore not newer than the gcc release, so if
I run this on a system with say GCC 15 installed, even when I have Ada
installed, I won't be able to gcc_release GCC 14 or 13 etc.), D working D
compiler, Go takes a long time to build libgo.

So, the following patch instead takes similar approach to what
make regenerate-opt-urls
takes, it generates stuff even for non-enabled languages.
For most languages it works just fine and is a matter of say for cobol
make cobol.srcextra cobol.srcinfo cobol.srcman
The only problem is Modula 2, which has some messed up dependencies and
when the FE is not enabled, this will try to build the whole FE as well and
fail.  I think it would be useful to fix that but at least before that is
fixed on the trunk and all release branches, the following patch just
conditionally (so that it works even for GCC 12 which doesn't have Modula 2)
enables also m2.

And lastly, libffi seems to be only enabled for Go (and maybe D), I'd prefer
not to enable those languages for the reasons stated above, so if we really
need libffi.info in release tarballs (despite libffi being used only as
implementation detail and not installed), the patch just generates it by
hand.

2025-03-29  Jakub Jelinek  

PR other/119510
* gcc_release: Use --enable-languages=c,c++,lto and if m2 is 
available,
with,m2 appended to that.  Check for all possible languages and run
make $lang.srcextra $lang.srcinfo $lang.srcman for those.  Add
libffi/doc/libffi.info.

Diff:
---
 maintainer-scripts/gcc_release | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/maintainer-scripts/gcc_release b/maintainer-scripts/gcc_release
index 471a10cc39e4..2ead4a754647 100755
--- a/maintainer-scripts/gcc_release
+++ b/maintainer-scripts/gcc_release
@@ -266,10 +266,28 @@ EOF
'' | 0* | *[!0-9]*) num_cpus=1;;
   esac
 fi
+enable_langs=c,c++,lto
+if [ -f ${SOURCE_DIRECTORY}/gcc/m2/Make-lang.in ]; then
+  enable_langs=$enable_langs,m2
+fi
 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
-  -c "--enable-languages=default,cobol --enable-generated-files-in-srcdir 
--disable-multilib" \
+  -c "--enable-languages=$enable_langs --enable-generated-files-in-srcdir 
--disable-multilib" \
   -m "-j$num_cpus" build || \
   error "Could not rebuild GCC"
+cd ${OBJECT_DIRECTORY}/gcc
+all_languages=`sed -n -e '/"all_languages"/s/^.*=//p' config.status \
+  | sed -e 's/"//g'`
+for lang in $all_languages; do
+  make $lang.srcextra $lang.srcinfo $lang.srcman || \
+   error "Could not build GCC $lang source extras"
+done
+if [ -d ${SOURCE_DIRECTORY}/libffi/doc ]; then
+  makeinfo --split-size=500  -I ${SOURCE_DIRECTORY}/gcc/doc/include \
+   -I ${SOURCE_DIRECTORY}/libffi/doc/ -o 
${SOURCE_DIRECTORY}/libffi/doc/libffi.info \
+   ${SOURCE_DIRECTORY}/libffi/doc/libffi.texi || \
+   error "Could not build libffi.info"
+fi
+cd ${SOURCE_DIRECTORY}
   fi
 
   # Move message catalogs to source directory.


[gcc/devel/omp/gcc-14] gcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree

2025-03-31 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:f8bde63c202b4dd6b7b26021ed62ceb5df6e5c81

commit f8bde63c202b4dd6b7b26021ed62ceb5df6e5c81
Author: Tobias Burnus 
Date:   Sun Mar 30 09:55:29 2025 +0200

gcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree

gcc/testsuite/ChangeLog:

* g++.dg/gomp/append-args-8.C: Remove bogus '3' after \.\[0-9\]+
pattern.

(cherry picked from commit e0886d8ad4c51919c349d0b31f2bec3acbc79e14)

Diff:
---
 gcc/testsuite/g++.dg/gomp/append-args-8.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/gomp/append-args-8.C 
b/gcc/testsuite/g++.dg/gomp/append-args-8.C
index 7fbbfa88b886..786a2b3dc57c 100644
--- a/gcc/testsuite/g++.dg/gomp/append-args-8.C
+++ b/gcc/testsuite/g++.dg/gomp/append-args-8.C
@@ -89,5 +89,5 @@ test (int *a, int *b)
 
 
 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_interop \\(-5, 0, 0B, 0B, 
0B, 0, 0B, 3, interopobjs\.\[0-9\]+, 0, 0B\\);" 1 "gimple" } }  */
-/* { dg-final { scan-tree-dump-times "repl3 \\(a, 
interop\.\[0-9\]+3, interop\.\[0-9\]+2, interop\.\[0-9\]+, 1, 2, \"abc\"\\);" 1 
"gimple" } }  */
+/* { dg-final { scan-tree-dump-times "repl3 \\(a, 
interop\.\[0-9\]+, interop\.\[0-9\]+, interop\.\[0-9\]+, 1, 2, \"abc\"\\);" 1 
"gimple" } }  */
 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_interop \\(-5, 3, 
interopobjs\.\[0-9\]+, tgt_tgtsync\.\[0-9\]+, pref_type\.\[0-9\]+, 0, 0B, 0, 
0B, 0, 0B\\);" 1 "gimple" } }  */


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: format code

2025-03-31 Thread Ondrej Machota via Gcc-cvs
https://gcc.gnu.org/g:7cbb0ce1fbec2adad90bd7c14342243ea9505ff9

commit 7cbb0ce1fbec2adad90bd7c14342243ea9505ff9
Author: Ondřej Machota 
Date:   Mon Mar 31 11:19:18 2025 +0200

rtl-ssa-dce: format code

Diff:
---
 gcc/dce.cc | 306 +++--
 1 file changed, 94 insertions(+), 212 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index a90a8d9ccf53..d16cec35eb16 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -1325,8 +1325,10 @@ struct offset_bitmap {
 sbitmap m_bitmap;
   
   public:
-offset_bitmap(size_t size, int offset) : m_offset{offset}, 
m_bitmap{sbitmap_alloc(size)} {}
-offset_bitmap(int min_index, int max_index) : 
offset_bitmap(size_t(max_index - min_index), min_index) {}
+offset_bitmap(size_t size, int offset) : m_offset{offset},
+  m_bitmap{sbitmap_alloc(size)} {}
+offset_bitmap(int min_index, int max_index) : 
+  offset_bitmap(size_t(max_index - min_index), min_index) {}
 
 void clear_bit(int index) {
   bitmap_clear_bit(m_bitmap, index + m_offset);
@@ -1345,75 +1347,7 @@ struct offset_bitmap {
 }
 };
 
-bool side_effects_with_mem (const_rtx x)
-{
-  const RTX_CODE code = GET_CODE (x);
-  switch (code)
-{
-case LABEL_REF:
-case SYMBOL_REF:
-case CONST:
-CASE_CONST_ANY:
-case PC:
-case REG:
-case SCRATCH:
-case ADDR_VEC:
-case ADDR_DIFF_VEC:
-case VAR_LOCATION:
-  return false;
-
-case CLOBBER:
-  /* Reject CLOBBER with a non-VOID mode.  These are made by combine.cc
-when some combination can't be done.  If we see one, don't think
-that we can simplify the expression.  */
-  return (GET_MODE (x) != VOIDmode);
-
-case PRE_INC:
-case PRE_DEC:
-case POST_INC:
-case POST_DEC:
-case PRE_MODIFY:
-case POST_MODIFY:
-case CALL:
-case UNSPEC_VOLATILE:
-  return true;
-
-case MEM: // We might want tu return true iff volatile or mem is a 
destination
-  // write or possible null read
-case ASM_INPUT:
-case ASM_OPERANDS:
-   return true;
-
-default:
-  break;
-}
-
-  /* Recursively scan the operands of this expression.  */
-
-  {
-const char *fmt = GET_RTX_FORMAT (code);
-int i;
-
-for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
-  {
-   if (fmt[i] == 'e')
- {
-   if (side_effects_with_mem (XEXP (x, i)))
- return true;
- }
-   else if (fmt[i] == 'E')
- {
-   int j;
-   for (j = 0; j < XVECLEN (x, i); j++)
- if (side_effects_with_mem (XVECEXP (x, i, j)))
-   return true;
- }
-  }
-  }
-  return false;
-}
-
-bool is_ssa_prelive(const_rtx insn) {
+bool is_rtx_prelive(const_rtx insn) {
   switch (GET_CODE(insn)) {
 case PREFETCH:
 case UNSPEC:
@@ -1429,15 +1363,12 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   gcc_assert(insn != nullptr);
 
   if (!NONJUMP_INSN_P (insn))
-  {
-// This handles jumps, debug_insns, call_insn, ...
+/* This handles jumps, debug_insns, call_insn, ... */
 return true;
-  }
 
-  // TODO : handle calls correctly
   if (CALL_P (insn)
   /* We cannot delete pure or const sibling calls because it is
-hard to see the result.  */
+  hard to see the result.  */
   && (!SIBLING_CALL_P (insn))
   /* We can delete dead const or pure calls as long as they do not
  infinite loop.  */
@@ -1447,111 +1378,74 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
 return true;
 // return !find_call_stack_args (as_a  (insn), false, 
fast, arg_stores);
 
-  // Only rtx_insn should be handled here
+  /* Only rtx_insn should be handled here */
   gcc_assert(GET_CODE(insn) == INSN);
 
   /* Don't delete insns that may throw if we cannot do so.  */
-  if (!(cfun->can_delete_dead_exceptions && can_alter_cfg) && !insn_nothrow_p 
(insn))
+  if (!(cfun->can_delete_dead_exceptions && can_alter_cfg)
+  && !insn_nothrow_p (insn))
 return true;
  
   /* Callee-save restores are needed.  */
-  if (RTX_FRAME_RELATED_P (insn) && crtl->shrink_wrapped_separate && 
find_reg_note (insn, REG_CFA_RESTORE, NULL))
+  if (RTX_FRAME_RELATED_P (insn) && crtl->shrink_wrapped_separate 
+  && find_reg_note (insn, REG_CFA_RESTORE, NULL))
 return true;
 
-  // TODO : asm_noperands???
-
   rtx body = PATTERN(insn);
   switch (GET_CODE(body)) {
 case CLOBBER: // gcc/gcc/testsuite/gcc.c-torture/compile/2605-1.c
 case USE:
 case VAR_LOCATION:
-case PREFETCH: // This and following case might be removed since they are 
part of deletable_insn_p_1
-case TRAP_IF:
+/* Following cases might be removed since they are part of is_rtx_prelive 
*/
+case PREFETCH:
+case TRAP_IF: /* testsuite/gcc.c-torture/execute/20020418-1.c */
 case UNSPEC:
   return true;
 
 case PARALLEL:
   for (int i = XVECLEN (body, 0) - 1; i >= 0; i--)
-if (is_ssa_prelive (XVECEXP (body, 

[gcc r15-9062] PR middle-end/119442: expr.cc: Fix vec_duplicate into vector boolean modes

2025-03-31 Thread Kyrylo Tkachov via Gcc-cvs
https://gcc.gnu.org/g:70391e3958db791edea4e877636592de47a785e7

commit r15-9062-g70391e3958db791edea4e877636592de47a785e7
Author: Kyrylo Tkachov 
Date:   Mon Mar 24 01:53:06 2025 -0700

PR middle-end/119442: expr.cc: Fix vec_duplicate into vector boolean modes

In this testcase GCC tries to expand a VNx4BI vector:
  vector(4)  _40;
  _39 = () _24;
  _40 = {_39, _39, _39, _39};

This ends up in a scalarised sequence of bitfield insert operations.
This is despite the fact that AArch64 provides a vec_duplicate pattern
specifically for vec_duplicate into VNx4BI.

The store_constructor code is overly conservative when trying vec_duplicate
as it sees a requested VNx4BImode and an element mode of QImode, which I 
guess
is the storage mode of BImode objects.

The vec_duplicate expander in aarch64-sve.md explicitly allows QImode 
element
modes so it should be safe to use it.  This patch extends that mode check
to allow such expanders.

The testcase is heavily auto-reduced from a real application but in itself 
is
nonsensical, but it does demonstrate the current problematic codegen.

This the testcase goes from:
pfalse  p15.b
str p15, [sp, #6, mul vl]
mov w0, 0
ldr w2, [sp, 12]
bfi w2, w0, 0, 4
uxtwx2, w2
bfi w2, w0, 4, 4
uxtwx2, w2
bfi w2, w0, 8, 4
uxtwx2, w2
bfi w2, w0, 12, 4
str w2, [sp, 12]
ldr p15, [sp, #6, mul vl]

into:
whilelo p15.s, wzr, wzr

The whilelo could be optimised away into a pfalse of course, but the 
important
part is that the bfis are gones.

Bootstrapped and tested on aarch64-none-linux-gnu.

Signed-off-by: Kyrylo Tkachov 

gcc/

PR middle-end/119442
* expr.cc (store_constructor): Also allow element modes explicitly
accepted by target vec_duplicate pattern.

gcc/testsuite/

PR middle-end/119442
* gcc.target/aarch64/vls_sve_vec_dup_1.c: New test.

Diff:
---
 gcc/expr.cc  | 11 ---
 gcc/testsuite/gcc.target/aarch64/vls_sve_vec_dup_1.c | 15 +++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 9f4382d7986b..2147eedad7be 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -7920,11 +7920,16 @@ store_constructor (tree exp, rtx target, int cleared, 
poly_int64 size,
gcc_assert (eltmode != BLKmode);
 
/* Try using vec_duplicate_optab for uniform vectors.  */
+   icode = optab_handler (vec_duplicate_optab, mode);
if (!TREE_SIDE_EFFECTS (exp)
&& VECTOR_MODE_P (mode)
-   && eltmode == GET_MODE_INNER (mode)
-   && ((icode = optab_handler (vec_duplicate_optab, mode))
-   != CODE_FOR_nothing)
+   && icode != CODE_FOR_nothing
+   /* If the vec_duplicate target pattern does not specify an element
+  mode check that eltmode is the normal inner mode of the
+  requested vector mode.  But if the target allows eltmode
+  explicitly go ahead and use it.  */
+   && (eltmode == GET_MODE_INNER (mode)
+   || insn_data[icode].operand[1].mode == eltmode)
&& (elt = uniform_vector_p (exp))
&& !VECTOR_TYPE_P (TREE_TYPE (elt)))
  {
diff --git a/gcc/testsuite/gcc.target/aarch64/vls_sve_vec_dup_1.c 
b/gcc/testsuite/gcc.target/aarch64/vls_sve_vec_dup_1.c
new file mode 100644
index ..ada0d4fc0a43
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/vls_sve_vec_dup_1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=armv8.2-a+sve -msve-vector-bits=128" } */
+
+float fasten_main_etot_0;
+void fasten_main() {
+  for (int l = 0; l < 2;) {
+int phphb_nz;
+for (; l < 32; l++) {
+  float dslv_e = l && phphb_nz;
+  fasten_main_etot_0 += dslv_e;
+}
+  }
+}
+
+/* { dg-final { scan-assembler-not {bfi\tw\[0-9\]+} } } */


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: fix calls that should not be prelive

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

commit a5ce39df8ae350e2239f7b3bd5aded8a94f5fb54
Author: Ondřej Machota 
Date:   Mon Mar 31 19:27:28 2025 +0200

rtl-ssa-dce: fix calls that should not be prelive

Diff:
---
 gcc/dce.cc | 30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index d16cec35eb16..b4ea199c6d76 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -1362,21 +1362,21 @@ bool is_rtx_prelive(const_rtx insn) {
 bool is_rtx_insn_prelive(rtx_insn *insn) {
   gcc_assert(insn != nullptr);
 
-  if (!NONJUMP_INSN_P (insn))
-/* This handles jumps, debug_insns, call_insn, ... */
-return true;
-
   if (CALL_P (insn)
-  /* We cannot delete pure or const sibling calls because it is
-  hard to see the result.  */
-  && (!SIBLING_CALL_P (insn))
-  /* We can delete dead const or pure calls as long as they do not
- infinite loop.  */
-  && (RTL_CONST_OR_PURE_CALL_P (insn) && !RTL_LOOPING_CONST_OR_PURE_CALL_P 
(insn))
-  /* Don't delete calls that may throw if we cannot do so.  */
-  && can_delete_call (insn))
+/* We cannot delete pure or const sibling calls because it is
+  hard to see the result.  */
+&& (!SIBLING_CALL_P (insn))
+/* We can delete dead const or pure calls as long as they do not
+  infinite loop.  */
+&& (RTL_CONST_OR_PURE_CALL_P (insn) && !RTL_LOOPING_CONST_OR_PURE_CALL_P 
(insn))
+/* Don't delete calls that may throw if we cannot do so.  */
+&& can_delete_call (insn))
+  return false;
+  // return !find_call_stack_args (as_a  (insn), false, fast, 
arg_stores);
+
+  if (!NONJUMP_INSN_P (insn))
+/* This handles jumps, notes, call_insns, debug_insns, ... */
 return true;
-// return !find_call_stack_args (as_a  (insn), false, 
fast, arg_stores);
 
   /* Only rtx_insn should be handled here */
   gcc_assert(GET_CODE(insn) == INSN);
@@ -1571,7 +1571,9 @@ rtl_ssa_dce_sweep(std::unordered_set marked)
  of changes with appropriate size */
   auto_vec to_delete;
   for (insn_info * insn : crtl->ssa->all_insns()) {
-/* artificial and marked insns cannot be deleted */
+/* Artificial and marked insns cannot be deleted.
+   There is a slight problem with phis, because we might want to delete
+   some phi nodes from phi insn. */
 if (insn->is_artificial() || marked.count(insn) > 0)
   continue;


[gcc r15-9072] Only write gcov when file output is on [PR119553]

2025-03-31 Thread Jorgen Kvalsvik via Gcc-cvs
https://gcc.gnu.org/g:de742091f4df997f426d99bcfed3c44914788033

commit r15-9072-gde742091f4df997f426d99bcfed3c44914788033
Author: Jørgen Kvalsvik 
Date:   Mon Mar 31 19:03:37 2025 +0200

Only write gcov when file output is on [PR119553]

gcov_write_* functions must be guarded so they only are called when
output_to_file is true, like for -fcondition-coverage, otherwise it
triggers an invalid read as detected by valgrind. The gcno file is
mostly written to from profile.cc, so it doesn't make too much sense
to hide it in path-coverage.cc. The find_paths name was a bit
imprecise, and is renamed to instrument_prime_paths.

PR gcov-profile/119553

gcc/ChangeLog:

* path-coverage.cc (find_paths): Return path count, don't
write to gcno, and rename to ...
(instrument_prime_paths): ... this.
* profile.cc (branch_prob): Write path counts to gcno.

Diff:
---
 gcc/path-coverage.cc | 15 ++-
 gcc/profile.cc   | 12 ++--
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/gcc/path-coverage.cc b/gcc/path-coverage.cc
index 55b392986035..55058fd04ff2 100644
--- a/gcc/path-coverage.cc
+++ b/gcc/path-coverage.cc
@@ -504,8 +504,8 @@ flush_on_gsi (gimple_stmt_iterator *gsi, size_t bucket, 
tree local, tree mask,
bit N%64 in bucket N/64.  For large functions, an individual basic block
will only be part of a small subset of paths, and by extension buckets and
local counters.  Only the necessary counters are read and written.  */
-void
-find_paths (struct function *fn)
+unsigned
+instrument_prime_paths (struct function *fn)
 {
   mark_dfs_back_edges (fn);
   vec> paths = find_prime_paths (fn);
@@ -515,7 +515,7 @@ find_paths (struct function *fn)
   warning_at (fn->function_start_locus, OPT_Wcoverage_too_many_paths,
  "paths exceeding limit, giving up path coverage");
   release_vec_vec (paths);
-  return;
+  return 0;
 }
 
   tree gcov_type_node = get_gcov_type ();
@@ -526,14 +526,9 @@ find_paths (struct function *fn)
   if (!coverage_counter_alloc (GCOV_COUNTER_PATHS, nbuckets))
 {
   release_vec_vec (paths);
-  return;
+  return 0;
 }
 
-  gcov_position_t offset {};
-  offset = gcov_write_tag (GCOV_TAG_PATHS);
-  gcov_write_unsigned (paths.length ());
-  gcov_write_length (offset);
-
   hash_map  ands;
   hash_map  iors;
   hash_map  flushes;
@@ -771,6 +766,8 @@ find_paths (struct function *fn)
}
 }
 
+  const unsigned npaths = paths.length ();
   blocks.release ();
   release_vec_vec (paths);
+  return npaths;
 }
diff --git a/gcc/profile.cc b/gcc/profile.cc
index 0b222cf38640..c0f5097726bd 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -1611,9 +1611,17 @@ branch_prob (bool thunk)
instrument_values (values);
 }
 
-  void find_paths (struct function*);
+  unsigned instrument_prime_paths (struct function*);
   if (path_coverage_flag)
-find_paths (cfun);
+{
+  const unsigned npaths = instrument_prime_paths (cfun);
+  if (output_to_file)
+   {
+ gcov_position_t offset = gcov_write_tag (GCOV_TAG_PATHS);
+ gcov_write_unsigned (npaths);
+ gcov_write_length (offset);
+   }
+}
 
   free_aux_for_edges ();


[gcc r15-9073] d: Bump front-end language version to v2.111.0

2025-03-31 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:2d270bdc31414178ed73caee94e14e78b2212217

commit r15-9073-g2d270bdc31414178ed73caee94e14e78b2212217
Author: Iain Buclaw 
Date:   Mon Mar 31 19:37:38 2025 +0200

d: Bump front-end language version to v2.111.0

Merges the front-end language implementation and runtime library with
upstream dmd c6863be720, and the standard library with phobos 60034b56e.

Synchronizing with the upstream release of v2.111.0.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd c6863be720.
* dmd/VERSION: Bump version to v2.111.0.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime c6863be720.
* src/MERGE: Merge upstream phobos 60034b56e.

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

[gcc r14-11481] libstdc++: Update tzdata to 2025a

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:ea45b49d3a8719c3450081ac6c4437e060fc4010

commit r14-11481-gea45b49d3a8719c3450081ac6c4437e060fc4010
Author: Jonathan Wakely 
Date:   Fri Jan 12 16:57:41 2024 +

libstdc++: Update tzdata to 2025a

Import the new 2025a tzdata.zi file. The leapseconds file was also
updated to have a new expiry (no new leap seconds were added).

libstdc++-v3/ChangeLog:

* include/std/chrono (__detail::__get_leap_second_info): Update
expiry date for leap seconds list.
* src/c++20/tzdata.zi: Import new file from 2025a release.
* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds)
Update expiry date for leap seconds list.

(cherry picked from commit 0ce4c1c48564e465a331c100e757e2258b4c632a)

Diff:
---
 libstdc++-v3/include/std/chrono  |2 +-
 libstdc++-v3/src/c++20/tzdata.zi | 1682 +++---
 libstdc++-v3/src/c++20/tzdb.cc   |4 +-
 3 files changed, 840 insertions(+), 848 deletions(-)

diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index b0aadf83b03f..7e6d6f81339a 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -3243,7 +3243,7 @@ namespace __detail
   };
   // The list above is known to be valid until (at least) this date
   // and only contains positive leap seconds.
-  const sys_seconds __expires(1735344000s); // 2024-12-28 00:00:00 UTC
+  const sys_seconds __expires(176688s); // 2025-12-28 00:00:00 UTC
 
 #if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
   if (__ss > __expires)
diff --git a/libstdc++-v3/src/c++20/tzdata.zi b/libstdc++-v3/src/c++20/tzdata.zi
index be1c40859202..db6ba4af2b01 100644
--- a/libstdc++-v3/src/c++20/tzdata.zi
+++ b/libstdc++-v3/src/c++20/tzdata.zi
@@ -1,4 +1,4 @@
-# version 2024a
+# version 2025a
 # This zic input file is in the public domain.
 R d 1916 o - Jun 14 23s 1 S
 R d 1916 1919 - O Su>=1 23s 0 -
@@ -721,12 +721,16 @@ R P 2085 o - Ap 21 2 0 -
 R P 2085 o - Jun 9 2 1 S
 R P 2086 o - Ap 13 2 0 -
 R P 2086 o - May 25 2 1 S
-R PH 1936 o - N 1 0 1 D
-R PH 1937 o - F 1 0 0 S
-R PH 1954 o - Ap 12 0 1 D
-R PH 1954 o - Jul 1 0 0 S
-R PH 1978 o - Mar 22 0 1 D
-R PH 1978 o - S 21 0 0 S
+R PH 1936 o - O 31 24 1 D
+R PH 1937 o - Ja 15 24 0 S
+R PH 1941 o - D 15 24 1 D
+R PH 1945 o - N 30 24 0 S
+R PH 1954 o - Ap 11 24 1 D
+R PH 1954 o - Jun 4 24 0 S
+R PH 1977 o - Mar 27 24 1 D
+R PH 1977 o - S 21 24 0 S
+R PH 1990 o - May 21 0 1 D
+R PH 1990 o - Jul 28 24 0 S
 R S 1920 1923 - Ap Su>=15 2 1 S
 R S 1920 1923 - O Su>=1 2 0 -
 R S 1962 o - Ap 29 2 1 S
@@ -1324,14 +1328,10 @@ R O 1961 1964 - May lastSu 1s 1 S
 R O 1962 1964 - S lastSu 1s 0 -
 R p 1916 o - Jun 17 23 1 S
 R p 1916 o - N 1 1 0 -
-R p 1917 o - F 28 23s 1 S
-R p 1917 1921 - O 14 23s 0 -
-R p 1918 o - Mar 1 23s 1 S
-R p 1919 o - F 28 23s 1 S
-R p 1920 o - F 29 23s 1 S
-R p 1921 o - F 28 23s 1 S
+R p 1917 1921 - Mar 1 0 1 S
+R p 1917 1921 - O 14 24 0 -
 R p 1924 o - Ap 16 23s 1 S
-R p 1924 o - O 14 23s 0 -
+R p 1924 o - O 4 23s 0 -
 R p 1926 o - Ap 17 23s 1 S
 R p 1926 1929 - O Sa>=1 23s 0 -
 R p 1927 o - Ap 9 23s 1 S
@@ -1349,8 +1349,9 @@ R p 1938 o - Mar 26 23s 1 S
 R p 1939 o - Ap 15 23s 1 S
 R p 1939 o - N 18 23s 0 -
 R p 1940 o - F 24 23s 1 S
-R p 1940 1941 - O 5 23s 0 -
+R p 1940 o - O 7 23s 0 -
 R p 1941 o - Ap 5 23s 1 S
+R p 1941 o - O 5 23s 0 -
 R p 1942 1945 - Mar Sa>=8 23s 1 S
 R p 1942 o - Ap 25 22s 2 M
 R p 1942 o - Au 15 22s 1 S
@@ -1360,16 +1361,16 @@ R p 1943 1945 - Au Sa>=25 22s 1 S
 R p 1944 1945 - Ap Sa>=21 22s 2 M
 R p 1946 o - Ap Sa>=1 23s 1 S
 R p 1946 o - O Sa>=1 23s 0 -
-R p 1947 1965 - Ap Su>=1 2s 1 S
+R p 1947 1966 - Ap Su>=1 2s 1 S
 R p 1947 1965 - O Su>=1 2s 0 -
-R p 1977 o - Mar 27 0s 1 S
-R p 1977 o - S 25 0s 0 -
-R p 1978 1979 - Ap Su>=1 0s 1 S
-R p 1978 o - O 1 0s 0 -
-R p 1979 1982 - S lastSu 1s 0 -
-R p 1980 o - Mar lastSu 0s 1 S
-R p 1981 1982 - Mar lastSu 1s 1 S
-R p 1983 o - Mar lastSu 2s 1 S
+R p 1976 o - S lastSu 1 0 -
+R p 1977 o - Mar lastSu 0s 1 S
+R p 1977 o - S lastSu 0s 0 -
+R p 1978 1980 - Ap Su>=1 1s 1 S
+R p 1978 o - O 1 1s 0 -
+R p 1979 1980 - S lastSu 1s 0 -
+R p 1981 1986 - Mar lastSu 0s 1 S
+R p 1981 1985 - S lastSu 0s 0 -
 R z 1932 o - May 21 0s 1 S
 R z 1932 1939 - O Su>=1 0s 0 -
 R z 1933 1939 - Ap Su>=2 0s 1 S
@@ -1728,7 +1729,7 @@ R Y 1972 2006 - O lastSu 2 0 S
 R Y 1987 2006 - Ap Su>=1 2 1 D
 R Yu 1965 o - Ap lastSu 0 2 DD
 R Yu 1965 o - O lastSu 2 0 S
-R m 1931 o - May 1 23 1 D
+R m 1931 o - Ap 30 0 1 D
 R m 1931 o - O 1 0 0 S
 R m 1939 o - F 5 0 1 D
 R m 1939 o - Jun 25 0 0 S
@@ -2022,9 +2023,9 @@ R y 2002 2004 - Ap Su>=1 0 0 -
 R y 2002 2003 - S Su>=1 0 1 -
 R y 2004 2009 - O Su>=15 0 1 -
 R y 2005 2009 - Mar Su>=8 0 0 -
-R y 2010 ma - O Su>=1 0 1 -
+R y 2010 2024 - O Su>=1 0 1 -
 R y 2010 2012 - Ap Su>=8 0 0 -
-R y 2013 ma - Mar Su>=22 0 0 -
+R y 2013 2024 - Mar Su>=22 0 0 -
 R PE 1938 o - Ja 1 0 1 -
 R PE 1938 o - Ap 1 0 0 -

[gcc r14-11483] libstdc++: Optimize std::vector construction from input iterators [PR108487]

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:5a830c6cd54d376ee23043381c6ed761559e1e08

commit r14-11483-g5a830c6cd54d376ee23043381c6ed761559e1e08
Author: Jonathan Wakely 
Date:   Tue Mar 25 13:24:08 2025 +

libstdc++: Optimize std::vector construction from input iterators [PR108487]

LWG 3291 make std::ranges::iota_view's iterator have input_iterator_tag
as its iterator_category, even though it satisfies the C++20
std::forward_iterator concept. This means that the traditional
std::vector::vector(InputIterator, InputIterator) constructor treats
iota_view iterators as input iterators, because it only understands the
C++17 iterator requirements, not the C++20 iterator concepts. This
results in a loop that calls emplace_back for each individual element of
the iota_view, requiring the vector to reallocate repeatedly as the
values are inserted. This makes it unnecessarily slow to construct a
vector from an iota_view.

This change adds a new _M_range_initialize_n function for initializing a
vector from a range (which doesn't have to be common) and a size. This
new function can be used by vector(InputIterator, InputIterator) when
std::ranges::distance can be used to get the size. It can also be used
by the _M_range_initialize overload that gets the size for a
Cpp17ForwardIterator pair using std::distance, and by the
vector(initializer_list) constructor.

With this new function constructing a std::vector from iota_view does
a single allocation of the correct size and so doesn't need to
reallocate in a loop.

libstdc++-v3/ChangeLog:

PR libstdc++/108487
* include/bits/stl_vector.h (vector(initializer_list)): Call
_M_range_initialize_n instead of _M_range_initialize.
(vector(InputIterator, InputIterator)): Use _M_range_initialize_n
for C++20 sized sentinels and forward iterators.
(vector::_M_range_initialize(FwIt, FwIt, forward_iterator_tag)):
Use _M_range_initialize_n.
(vector::_M_range_initialize_n): New function.
* testsuite/23_containers/vector/cons/108487.cc: New test.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/initlist-opt1.C: Match _M_range_initialize_n
instead of _M_range_initialize.
* g++.dg/tree-ssa/initlist-opt2.C: Likewise.

Reviewed-by: Tomasz Kamiński 

(cherry picked from commit e200f53a5556516ec831e6b7a34aaa0f10a4ab0a)

Diff:
---
 gcc/testsuite/g++.dg/tree-ssa/initlist-opt1.C  |  2 +-
 gcc/testsuite/g++.dg/tree-ssa/initlist-opt2.C  |  2 +-
 libstdc++-v3/include/bits/stl_vector.h | 41 --
 .../testsuite/23_containers/vector/cons/108487.cc  | 24 +
 4 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/initlist-opt1.C 
b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt1.C
index b1d2d25faf4c..f4f09117e65e 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/initlist-opt1.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt1.C
@@ -3,7 +3,7 @@
 // { dg-do compile { target c++11 } }
 
 // Test that we do range-initialization from const char *.
-// { dg-final { scan-tree-dump {_M_range_initialize} 
"gimple" } }
+// { dg-final { scan-tree-dump {_M_range_initialize_n} 
"gimple" } }
 // { dg-final { scan-tree-dump {static const char.*72} "gimple" } }
 
 #include 
diff --git a/gcc/testsuite/g++.dg/tree-ssa/initlist-opt2.C 
b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt2.C
index 1e9ac739b2d7..63f1feb30381 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/initlist-opt2.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/initlist-opt2.C
@@ -3,7 +3,7 @@
 // { dg-do compile { target c++11 } }
 
 // Test that we do range-initialization from const char *.
-// { dg-final { scan-tree-dump {_M_range_initialize} 
"gimple" } }
+// { dg-final { scan-tree-dump {_M_range_initialize_n= 202002L
 # include 
 #endif
+#if __glibcxx_concepts // C++ >= C++20
+# include   // ranges::distance
+#endif
 
 #include 
 
@@ -679,8 +682,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 const allocator_type& __a = allocator_type())
   : _Base(__a)
   {
-   _M_range_initialize(__l.begin(), __l.end(),
-   random_access_iterator_tag());
+   _M_range_initialize_n(__l.begin(), __l.end(), __l.size());
   }
 #endif
 
@@ -708,6 +710,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   const allocator_type& __a = allocator_type())
: _Base(__a)
{
+#if __glibcxx_concepts // C++ >= C++20
+ if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>
+ || forward_iterator<_InputIterator>)
+   {
+ const auto __n
+   = static_cast(ranges::distance(__first, __last));
+ _M_range_initialize_n(__first, __last, __n);
+ return;
+   }
+ else
+#endif
  _M_range_initialize(

[gcc r14-11486] libstdc++: Make std::erase for linked lists convert to bool

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d22bd12554d5c4214da7072aff4d0babaf82b412

commit r14-11486-gd22bd12554d5c4214da7072aff4d0babaf82b412
Author: Jonathan Wakely 
Date:   Thu Mar 6 21:18:21 2025 +

libstdc++: Make std::erase for linked lists convert to bool

LWG 4135 (approved in Wrocław, November 2024) fixes the lambda
expressions used by std::erase for std::list and std::forward_list.
Previously they attempted to copy something that isn't required to be
copyable. Instead they should convert it to bool right away.

The issue resolution also changes the lambda's parameter to be const, so
that it can't modify the elements while comparing them.

libstdc++-v3/ChangeLog:

* include/std/forward_list (erase): Change lambda to have
explicit return type and const parameter type.
* include/std/list (erase): Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Check lambda
is correct.
* testsuite/23_containers/list/erasure.cc: Likewise.

Reviewed-by: Patrick Palka 
(cherry picked from commit e6e7b477bbdbfb3fee6b44087a59f94fd1e2c7a3)

Diff:
---
 libstdc++-v3/include/std/forward_list  |  5 +++--
 libstdc++-v3/include/std/list  |  5 +++--
 .../23_containers/forward_list/erasure.cc  | 22 ++
 .../testsuite/23_containers/list/erasure.cc| 22 ++
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/std/forward_list 
b/libstdc++-v3/include/std/forward_list
index dfd7d48d1219..91dd6745bec4 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -79,8 +79,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 inline typename forward_list<_Tp, _Alloc>::size_type
 erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
-  using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
-  return std::erase_if(__cont, [&](__elem_type& __elem) {
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4135. helper lambda of std::erase for list should specify return type
+  return std::erase_if(__cont, [&](const auto& __elem) -> bool {
  return __elem == __value;
   });
 }
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index ff632fc1ab2f..d6126e493fa2 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -103,8 +103,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 inline typename list<_Tp, _Alloc>::size_type
 erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
 {
-  using __elem_type = typename list<_Tp, _Alloc>::value_type;
-  return std::erase_if(__cont, [&](__elem_type& __elem) {
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4135. helper lambda of std::erase for list should specify return type
+  return std::erase_if(__cont, [&](const auto& __elem) -> bool {
  return __elem == __value;
   });
 }
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
index 271cb3a577e8..c5a7013f6b6b 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
@@ -53,6 +53,28 @@ test02()
   VERIFY( num == 0 );
 }
 
+// LWG 4135.
+// The helper lambda of std::erase for list should specify return type as bool
+void
+test_lwg4135()
+{
+  struct Bool {
+Bool() = default;
+Bool(const Bool&) = delete;
+operator bool() const { return false; }
+  };
+
+  static Bool b;
+
+  struct Int {
+Bool& operator==(Int) const { return b; }
+void operator==(Int) = delete;
+  };
+
+  std::forward_list l;
+  std::erase(l, Int{});
+}
+
 int
 main()
 {
diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc 
b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
index c5d041526dca..0df3a8772bdf 100644
--- a/libstdc++-v3/testsuite/23_containers/list/erasure.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc
@@ -52,6 +52,28 @@ test02()
   VERIFY( num == 0 );
 }
 
+// LWG 4135.
+// The helper lambda of std::erase for list should specify return type as bool
+void
+test_lwg4135()
+{
+  struct Bool {
+Bool() = default;
+Bool(const Bool&) = delete;
+operator bool() const { return false; }
+  };
+
+  static Bool b;
+
+  struct Int {
+Bool& operator==(Int) const { return b; }
+void operator==(Int) = delete;
+  };
+
+  std::list l;
+  std::erase(l, Int{});
+}
+
 int
 main()
 {


[gcc r15-9064] arm: testsuite: fix vect-fmaxmin.c test

2025-03-31 Thread Richard Earnshaw via Gcc-cvs
https://gcc.gnu.org/g:f30e180194bfbcd7594566ef050534388be31e8d

commit r15-9064-gf30e180194bfbcd7594566ef050534388be31e8d
Author: Richard Earnshaw 
Date:   Mon Mar 31 10:37:11 2025 +0100

arm: testsuite: fix vect-fmaxmin.c test

This is another case of a test that was both an executable test
requiring specific hardware and an assembler scan test.  The
requirement for the hardware was masking some useful testing that
could be done (by scanning the assembly output) on almost all test
runs.  Fixed in a similar manner to fmaxmin{,-2}.c by splitting the
test into two, one that scans the assembler output and one that
executes the compiled code if suitable hardware is available.

The masked issue was that this test was expecting vectorization to
occur that was incorrect given the options passed.  For correct
vectorization we need -funsafe-math-optimizations as the vector
version of the single-precision operation will apply a truncation of
denormal values.

gcc/testsuite/ChangeLog:

* gcc.target/arm/vect-fmaxmin-2.c: New compile test.  Split from ...
* gcc.target/arm/vect-fmaxmin.c: ... here.  Remove scan-assembler
subtests.  For both, add -funsafe-math-optimizations.

Diff:
---
 gcc/testsuite/gcc.target/arm/vect-fmaxmin-2.c | 14 ++
 gcc/testsuite/gcc.target/arm/vect-fmaxmin.c   | 10 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/vect-fmaxmin-2.c 
b/gcc/testsuite/gcc.target/arm/vect-fmaxmin-2.c
new file mode 100644
index ..57b0a3ad8019
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/vect-fmaxmin-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v8a_hard_ok } */
+/* { dg-options "-O2 -ftree-vectorize -funsafe-math-optimizations -fno-inline 
-save-temps" } */
+/* { dg-add-options arm_arch_v8a_hard } */
+
+#include "fmaxmin.x"
+
+/* { dg-final { scan-assembler-times "vmaxnm.f32\tq\[0-9\]+, q\[0-9\]+, 
q\[0-9\]+" 1 } } */
+/* { dg-final { scan-assembler-times "vminnm.f32\tq\[0-9\]+, q\[0-9\]+, 
q\[0-9\]+" 1 } } */
+
+/* NOTE: There are no double precision vector versions of vmaxnm/vminnm.  */
+/* { dg-final { scan-assembler-times "vmaxnm.f64\td\[0-9\]+, d\[0-9\]+, 
d\[0-9\]+" 1 } } */
+/* { dg-final { scan-assembler-times "vminnm.f64\td\[0-9\]+, d\[0-9\]+, 
d\[0-9\]+" 1 } } */
+
diff --git a/gcc/testsuite/gcc.target/arm/vect-fmaxmin.c 
b/gcc/testsuite/gcc.target/arm/vect-fmaxmin.c
index ba45c4d379e7..89dc14bd594e 100644
--- a/gcc/testsuite/gcc.target/arm/vect-fmaxmin.c
+++ b/gcc/testsuite/gcc.target/arm/vect-fmaxmin.c
@@ -1,14 +1,6 @@
 /* { dg-do run } */
 /* { dg-require-effective-target arm_v8_neon_hw } */
-/* { dg-options "-O2 -ftree-vectorize -fno-inline -march=armv8-a -save-temps" 
} */
+/* { dg-options "-O2 -ftree-vectorize -fno-inline -funsafe-math-optimizations" 
} */
 /* { dg-add-options arm_v8_neon } */
 
 #include "fmaxmin.x"
-
-/* { dg-final { scan-assembler-times "vmaxnm.f32\tq\[0-9\]+, q\[0-9\]+, 
q\[0-9\]+" 1 } } */
-/* { dg-final { scan-assembler-times "vminnm.f32\tq\[0-9\]+, q\[0-9\]+, 
q\[0-9\]+" 1 } } */
-
-/* NOTE: There are no double precision vector versions of vmaxnm/vminnm.  */
-/* { dg-final { scan-assembler-times "vmaxnm.f64\td\[0-9\]+, d\[0-9\]+, 
d\[0-9\]+" 1 } } */
-/* { dg-final { scan-assembler-times "vminnm.f64\td\[0-9\]+, d\[0-9\]+, 
d\[0-9\]+" 1 } } */
-


[gcc r13-9458] doc: Fix minor grammar nit in -ftrivial-auto-var-init docs

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:1b1614aab0a49946558a4112126c2d1e6e003cab

commit r13-9458-g1b1614aab0a49946558a4112126c2d1e6e003cab
Author: Jonathan Wakely 
Date:   Mon Mar 10 13:48:15 2025 +

doc: Fix minor grammar nit in -ftrivial-auto-var-init docs

gcc/ChangeLog:

* doc/extend.texi (Common Variable Attributes): Fix grammar in
final sentence of -ftrivial-auto-var-init description.

(cherry picked from commit f695d0392ffc82298d55474cd3025aec26db04ec)

Diff:
---
 gcc/doc/extend.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 5c6ce67b7d18..2a2fc3900026 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7789,7 +7789,7 @@ to be excluded from such automatical initialization in 
order to reduce runtime
 overhead.
 
 This attribute has no effect when the option @code{-ftrivial-auto-var-init}
-does not present.
+is not present.
 
 @cindex @code{vector_size} variable attribute
 @item vector_size (@var{bytes})


[gcc/mikael/heads/refactor_descriptor_v04] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' was updated to point to:

 89ee81befb32... Replace span with elem_len

It previously pointed to:

 b21b635e1146... Replace span with elem_len

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  b21b635... Replace span with elem_len


Summary of changes (added commits):
---

  89ee81b... Replace span with elem_len


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:89ee81befb324ed105ba40de81348c2128d81f68

commit 89ee81befb324ed105ba40de81348c2128d81f68
Author: Mikael Morin 
Date:   Mon Mar 31 12:05:26 2025 +0200

Replace span with elem_len

Correction ISO_Fortran_binding_3.f90

Diff:
---
 gcc/fortran/trans-array.cc|   4 +-
 gcc/fortran/trans-descriptor.cc   | 112 +++---
 gcc/fortran/trans-descriptor.h|   1 -
 gcc/fortran/trans-intrinsic.cc|   6 +-
 gcc/fortran/trans-openmp.cc   |   6 +-
 gcc/fortran/trans-types.cc|  17 ++---
 gcc/fortran/trans.cc  |   8 +--
 libgfortran/caf/single.c  |   2 +-
 libgfortran/intrinsics/associated.c   |   2 -
 libgfortran/libgfortran.h |   3 -
 libgfortran/runtime/ISO_Fortran_binding.c |   9 +--
 11 files changed, 45 insertions(+), 125 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 595ba97aa8ca..a48d0f4b8a4a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -450,7 +450,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = build_fold_indirect_ref_loc (input_location, desc);
 
   /* This will have the span field set.  */
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (expr->ts.type == BT_ASSUMED)
 {
@@ -458,7 +458,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = GFC_DECL_SAVED_DESCRIPTOR (desc);
   if (POINTER_TYPE_P (TREE_TYPE (desc)))
desc = build_fold_indirect_ref_loc (input_location, desc);
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (TREE_CODE (desc) == COMPONENT_REF
   && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 7e709609435c..2bc47f646bbb 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -164,9 +164,8 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #define DATA_FIELD 0
 #define OFFSET_FIELD 1
 #define DTYPE_FIELD 2
-#define SPAN_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
+#define DIMENSION_FIELD 3
+#define CAF_TOKEN_FIELD 4
 
 #define STRIDE_SUBFIELD 0
 #define LBOUND_SUBFIELD 1
@@ -282,27 +281,6 @@ conv_dtype_set (stmtblock_t *block, tree desc, tree val)
   gfc_add_modify (block, t, val);
 }
 
-tree
-get_span (tree desc)
-{
-  tree field = get_component (desc, SPAN_FIELD);
-  gcc_assert (TREE_TYPE (field) == gfc_array_index_type);
-  return field;
-}
-
-tree
-conv_span_get (tree desc)
-{
-  return non_lvalue_loc (input_location, get_span (desc));
-}
-
-void
-conv_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  tree t = get_span (desc);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
-}
-
 tree
 get_rank (tree desc)
 {
@@ -715,18 +693,6 @@ gfc_conv_descriptor_dtype_set (stmtblock_t *block, tree 
desc, tree val)
   gfc_descriptor::conv_dtype_set (block, desc, val);
 }
 
-tree
-gfc_conv_descriptor_span_get (tree desc)
-{
-  return gfc_descriptor::conv_span_get (desc);
-}
-
-static void
-gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  return gfc_descriptor::conv_span_set (block, desc, value);
-}
-
 tree
 gfc_conv_descriptor_dimension_get (tree desc, tree dim)
 {
@@ -932,10 +898,11 @@ tree
 gfc_conv_descriptor_sm_get (tree desc, tree dim)
 {
   tree stride = gfc_conv_descriptor_stride_get (desc, dim);
-  tree span = gfc_conv_descriptor_span_get (desc);
+  tree elem_len = gfc_conv_descriptor_elem_len_get (desc);
+  elem_len = fold_convert (gfc_array_index_type, elem_len);
 
   return fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- stride, span);
+ stride, elem_len);
 }
 
 
@@ -,31 +1078,6 @@ get_descr_data_value (const descr_change_info &info)
 }
 
 
-static tree
-get_descr_span (const descr_change_info &info)
-{
-  switch (info.type)
-{
-case UNKNOWN_CHANGE:
-case EXPLICIT_NULLIFICATION:
-case INITIALISATION:
-case DEFAULT_INITIALISATION:
-case NULL_INITIALISATION:
-  return NULL_TREE;
-
-case SCALAR_VALUE:
-  {
-   tree fields = TYPE_FIELDS (info.descriptor_type);
-   tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-   return build_zero_cst (TREE_TYPE (span_field));
-  }
-
-default:
-  gcc_unreachable ();
-}
-}
-
-
 static tree
 get_descr_caf_token (const descr_change_info &info)
 {
@@ -1357,14 +1299,6 @@ get_descriptor_init (tree type, gfc_typespec *ts, int 
rank,
   CONSTRUCTOR_APPEND_ELT (v, dtype_field, dtype_value);
 }
 
-  tree span_value = get_descr_span (change);
-  if (span_value != NULL_TREE)
-{
-  tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-  tree span_value = build_zero_cst (TREE_TYPE (span_

[gcc r13-9460] libstdc++: Remove stray comma in testing docs

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:4dfce5c5c01a08a5e413d800dca57294f97c6df1

commit r13-9460-g4dfce5c5c01a08a5e413d800dca57294f97c6df1
Author: Jonathan Wakely 
Date:   Tue Mar 4 11:13:23 2025 +

libstdc++: Remove stray comma in testing docs

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Remove stray comma.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit ac16d6d74fcb4ca10c939b00782b4dfada666273)

Diff:
---
 libstdc++-v3/doc/html/manual/test.html | 2 +-
 libstdc++-v3/doc/xml/manual/test.xml   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/test.html 
b/libstdc++-v3/doc/html/manual/test.html
index dafbd18a0f47..190df2b2f7db 100644
--- a/libstdc++-v3/doc/html/manual/test.html
+++ b/libstdc++-v3/doc/html/manual/test.html
@@ -232,7 +232,7 @@ cat 27_io/objects/char/3_xin.in | a.out
 
   The testsuite will create a number of files in the directory in
-  which you run this command,.  Some of those files might use the
+  which you run this command.  Some of those files might use the
   same name as files created by other testsuites (like the ones
   for GCC and G++), so you should not try to run all the
   testsuites in parallel from the same directory.
diff --git a/libstdc++-v3/doc/xml/manual/test.xml 
b/libstdc++-v3/doc/xml/manual/test.xml
index 3ae2d076feaf..d8d4ae92790f 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -383,7 +383,7 @@ cat 27_io/objects/char/3_xin.in | a.out
 
 
   The testsuite will create a number of files in the directory in
-  which you run this command,.  Some of those files might use the
+  which you run this command.  Some of those files might use the
   same name as files created by other testsuites (like the ones
   for GCC and G++), so you should not try to run all the
   testsuites in parallel from the same directory.


[gcc r13-9461] libstdc++: Update references to gcc.gnu.org/onlinedocs

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:7cdc7efa117380bc6f08b419ae00be15c7dfa2b0

commit r13-9461-g7cdc7efa117380bc6f08b419ae00be15c7dfa2b0
Author: Gerald Pfeifer 
Date:   Sat Aug 17 15:21:21 2024 +0200

libstdc++: Update references to gcc.gnu.org/onlinedocs

libstdc++-v3:
* doc/xml/manual/abi.xml: Update reference to
gcc.gnu.org/onlinedocs.
* doc/xml/manual/concurrency_extensions.xml (interface): Ditto.
* doc/xml/manual/extensions.xml: Ditto.
* doc/xml/manual/parallel_mode.xml: Ditto.
* doc/xml/manual/shared_ptr.xml: Ditto.
* doc/xml/manual/using_exceptions.xml: Ditto. And change GNU GCC
to GCC.
* doc/html/*: Regenerate.

(cherry picked from commit e68ab0f16072af97f0898fa0a14e72fcda442775)

Diff:
---
 libstdc++-v3/doc/html/manual/abi.html  | 2 +-
 libstdc++-v3/doc/html/manual/ext_concurrency_impl.html | 4 ++--
 libstdc++-v3/doc/html/manual/ext_demangling.html   | 2 +-
 libstdc++-v3/doc/html/manual/memory.html   | 2 +-
 libstdc++-v3/doc/html/manual/parallel_mode_design.html | 2 +-
 libstdc++-v3/doc/html/manual/parallel_mode_using.html  | 2 +-
 libstdc++-v3/doc/html/manual/using_exceptions.html | 4 ++--
 libstdc++-v3/doc/xml/manual/abi.xml| 2 +-
 libstdc++-v3/doc/xml/manual/concurrency_extensions.xml | 4 ++--
 libstdc++-v3/doc/xml/manual/extensions.xml | 2 +-
 libstdc++-v3/doc/xml/manual/parallel_mode.xml  | 4 ++--
 libstdc++-v3/doc/xml/manual/shared_ptr.xml | 2 +-
 libstdc++-v3/doc/xml/manual/using_exceptions.xml   | 4 ++--
 13 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/abi.html 
b/libstdc++-v3/doc/html/manual/abi.html
index 33eec5707dcc..b8c1c5a9812b 100644
--- a/libstdc++-v3/doc/html/manual/abi.html
+++ b/libstdc++-v3/doc/html/manual/abi.html
@@ -28,7 +28,7 @@
   g++ command line options may change the ABI as a side-effect of
   use. Such flags include -fpack-struct and
   -fno-exceptions, but include others: see the 
complete
-  list in the GCC manual under the heading http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code%20Gen%20Options";
 target="_top">Options
+  list in the GCC manual under the heading https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code%20Gen%20Options";
 target="_top">Options
   for Code Generation Conventions.
 
   The configure options used when building a specific libstdc++
diff --git a/libstdc++-v3/doc/html/manual/ext_concurrency_impl.html 
b/libstdc++-v3/doc/html/manual/ext_concurrency_impl.html
index 23b90f34572b..669c07cf2917 100644
--- a/libstdc++-v3/doc/html/manual/ext_concurrency_impl.html
+++ b/libstdc++-v3/doc/html/manual/ext_concurrency_impl.html
@@ -34,7 +34,7 @@ non-ancient x86 hardware, -march=native usually does t
 trick. For hosts without compiler intrinsics, but with capable
 hardware, hand-crafted assembly is selected. This is the case for the 
following hosts:
 crishppai386i486m48kmipssparcAnd for the rest, a simulated 
atomic lock via pthreads.
- Detailed information about compiler intrinsics for atomic operations 
can be found in the GCC http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html"; 
target="_top"> documentation.
+Detailed information about compiler intrinsics for atomic operations 
can be found in the GCC https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html"; 
target="_top"> documentation.
  More details on the library fallbacks from the porting section.
 Thread 
AbstractionA thin layer above IEEE 1003.1 (i.e. 
pthreads) is used to abstract
 the thread interface for GCC. This layer is called "gthread," and is
@@ -44,7 +44,7 @@ a POSIX-like interface.
 the current host. In libstdc++ implementation files,
  is used to select the proper gthreads file.
 Within libstdc++ sources, all calls to underlying thread functionality
-use this layer. More detail as to the specific interface can be found in the 
source http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html"; 
target="_top">documentation.
+use this layer. More detail as to the specific interface can be found in the 
source https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html"; 
target="_top">documentation.
 By design, the gthread layer is interoperable with the types,
 functions, and usage found in the usual  file,
 including pthread_t, pthread_once_t, pthread_create,
diff --git a/libstdc++-v3/doc/html/manual/ext_demangling.html 
b/libstdc++-v3/doc/html/manual/ext_demangling.html
index 028ec71d8c81..fb409e214fa7 100644
--- a/libstdc++-v3/doc/html/manual/ext_demangling.html
+++ b/libstdc++-v3/doc/html/manual/ext_demangling.html
@@ -7,7 +7,7 @@
 original C++ source identifiers is called
 “demangling.”
   
-If you have read the http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html"; 
target="_top">source
+If you have read the https://g

[gcc r13-9462] libstdc++: Fix some typos and grammatical errors in docs

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:cbd41cd2915cc9b980952cc17b6979deb3696fbb

commit r13-9462-gcbd41cd2915cc9b980952cc17b6979deb3696fbb
Author: Jonathan Wakely 
Date:   Wed Oct 30 21:10:58 2024 +

libstdc++: Fix some typos and grammatical errors in docs

Also remove some redundant 'void' parameters from code examples.

libstdc++-v3/ChangeLog:

* doc/xml/manual/using_exceptions.xml: Fix typos and grammatical
errors.
* doc/html/manual/using_exceptions.html: Regenerate.

(cherry picked from commit 96566cc46d633c2026976e585b5743e880a8f99b)

Diff:
---
 libstdc++-v3/doc/html/manual/using_exceptions.html | 10 +-
 libstdc++-v3/doc/xml/manual/using_exceptions.xml   | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/using_exceptions.html 
b/libstdc++-v3/doc/html/manual/using_exceptions.html
index cf9e7026b3fa..eb4501b1f6ba 100644
--- a/libstdc++-v3/doc/html/manual/using_exceptions.html
+++ b/libstdc++-v3/doc/html/manual/using_exceptions.html
@@ -158,7 +158,7 @@ exception neutrality and exception safety.
   Doing without
 C++ is a language that strives to be as efficient as is possible
 in delivering features. As such, considerable care is used by both
-language implementer and designers to make sure unused features
+language implementer and designers to make sure unused features do
 not impose hidden or unexpected costs. The GNU system tries to be
 as flexible and as configurable as possible. So, it should come as
 no surprise that GNU C++ provides an optional language extension,
@@ -179,7 +179,7 @@ exception neutrality and exception safety.
 uses try or catch, you
 shouldn't use -fno-exceptions.
   
-And what it to be gained, tinkering in the back alleys with a
+And what is to be gained, tinkering in the back alleys with a
 language like this? Exception handling overhead can be measured
 in the size of the executable binary, and varies with the
 capabilities of the underlying operating system and specific
@@ -216,15 +216,15 @@ exception neutrality and exception safety.
 # define __throw_exception_again
 #endif
 
-  In addition, for every object derived from
+  In addition, for most of the classes derived from
   class exception, there exists a corresponding
   function with C language linkage. An example:
 
 #if __cpp_exceptions
-  void __throw_bad_exception(void)
+  void __throw_bad_exception()
   { throw bad_exception(); }
 #else
-  void __throw_bad_exception(void)
+  void __throw_bad_exception()
   { abort(); }
 #endif
 
diff --git a/libstdc++-v3/doc/xml/manual/using_exceptions.xml 
b/libstdc++-v3/doc/xml/manual/using_exceptions.xml
index 9b884ab0817b..ac2ba9dffd45 100644
--- a/libstdc++-v3/doc/xml/manual/using_exceptions.xml
+++ b/libstdc++-v3/doc/xml/manual/using_exceptions.xml
@@ -274,7 +274,7 @@ exception neutrality and exception safety.
   
 C++ is a language that strives to be as efficient as is possible
 in delivering features. As such, considerable care is used by both
-language implementer and designers to make sure unused features
+language implementer and designers to make sure unused features do
 not impose hidden or unexpected costs. The GNU system tries to be
 as flexible and as configurable as possible. So, it should come as
 no surprise that GNU C++ provides an optional language extension,
@@ -299,7 +299,7 @@ exception neutrality and exception safety.
   
 
   
-And what it to be gained, tinkering in the back alleys with a
+And what is to be gained, tinkering in the back alleys with a
 language like this? Exception handling overhead can be measured
 in the size of the executable binary, and varies with the
 capabilities of the underlying operating system and specific
@@ -344,17 +344,17 @@ exception neutrality and exception safety.
 
 
 
-  In addition, for every object derived from
+  In addition, for most of the classes derived from
   class exception, there exists a corresponding
   function with C language linkage. An example:
 
 
 
 #if __cpp_exceptions
-  void __throw_bad_exception(void)
+  void __throw_bad_exception()
   { throw bad_exception(); }
 #else
-  void __throw_bad_exception(void)
+  void __throw_bad_exception()
   { abort(); }
 #endif
 


[gcc r13-9459] libstdc++: Correct statement about default -std option

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:9445b773f9a4fad52425dd8ffcecbaae4e7a2b30

commit r13-9459-g9445b773f9a4fad52425dd8ffcecbaae4e7a2b30
Author: Jonathan Wakely 
Date:   Wed Mar 19 23:27:24 2025 +

libstdc++: Correct statement about default -std option

The default is -std=gnu++17 now, not -std=gnu++14.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Fix default for -std option.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit b93e60e7901526d7df2d8c0f5e0e46c57e8e3771)

Diff:
---
 libstdc++-v3/doc/html/manual/test.html | 4 ++--
 libstdc++-v3/doc/xml/manual/test.xml   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/test.html 
b/libstdc++-v3/doc/html/manual/test.html
index a308ecf5996f..dafbd18a0f47 100644
--- a/libstdc++-v3/doc/html/manual/test.html
+++ b/libstdc++-v3/doc/html/manual/test.html
@@ -345,11 +345,11 @@ cat 27_io/objects/char/3_xin.in | 
a.out-O3 but 
with
   different -std options:
-make check 
'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++14}\"'
+make check 
'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++17}\"'
   N.B. that set of variations could also be written as
   unix/-O3\"{-std=gnu++98,-std=gnu++11,}\" so 
that
   the third variation would use the default for -std
-  (which is -std=gnu++14 as of GCC 6).
+  (which is -std=gnu++17 as of GCC 11).
 
   To run the libstdc++ test suite under the
   debug mode, use
diff --git a/libstdc++-v3/doc/xml/manual/test.xml 
b/libstdc++-v3/doc/xml/manual/test.xml
index 9853a2848148..3ae2d076feaf 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -591,11 +591,11 @@ cat 27_io/objects/char/3_xin.in | a.out
   tests multiple times in different variations. For example, to run the
   entire testsuite three times using -O3 but with
   different -std options:
-make check 
'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++14}\"'
+make check 
'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++17}\"'
   N.B. that set of variations could also be written as
   unix/-O3\"{-std=gnu++98,-std=gnu++11,}\" so that
   the third variation would use the default for -std
-  (which is -std=gnu++14 as of GCC 6).
+  (which is -std=gnu++17 as of GCC 11).
 
 
 


[gcc r13-9463] libstdc++: Fix some broken links in the manual

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:4ad6a2503d19e92b0749d5891aafb16d7d93fff7

commit r13-9463-g4ad6a2503d19e92b0749d5891aafb16d7d93fff7
Author: Jonathan Wakely 
Date:   Mon Mar 24 21:28:47 2025 +

libstdc++: Fix some broken links in the manual

libstdc++-v3/ChangeLog:

* doc/xml/manual/policy_data_structures_biblio.xml: Fix two
broken links.
* doc/html/manual/policy_data_structures.html: Regenerate.

(cherry picked from commit 1e4d81aab2542f529d23329fcc5e642eedd617d9)

Diff:
---
 libstdc++-v3/doc/html/manual/policy_data_structures.html  | 4 ++--
 libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/policy_data_structures.html 
b/libstdc++-v3/doc/html/manual/policy_data_structures.html
index 45e07814184d..ba140809bbe0 100644
--- a/libstdc++-v3/doc/html/manual/policy_data_structures.html
+++ b/libstdc++-v3/doc/html/manual/policy_data_structures.html
@@ -1037,7 +1037,7 @@
  . 
  Addison-Wesley Publishing Company
. [biblio.kt99fat_heaps] 
-   https://www.cs.princeton.edu/research/techreps/TR-597-99"; target="_top">
+   https://www.cs.princeton.edu/research/techreps/293"; target="_top">
  New Heap Data Structures

   . 
@@ -1185,7 +1185,7 @@
. 
  Addison-Wesley Publishing Company
. [biblio.nelson96stlpq] 
-   https://marknelson.us/posts/1996/01/01/priority-queues.html"; 
target="_top">Priority Queues and the STL
+   https://web.archive.org/web/20240806213010/https://marknelson.us/posts/1996/01/01/priority-queues.html";
 target="_top">Priority Queues and the STL

   . 
January 1996
diff --git a/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml 
b/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
index 1450b8fc000e..928598d33c6b 100644
--- a/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
+++ b/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
@@ -737,7 +737,7 @@
 
   
http://www.w3.org/1999/xlink";
- 
xlink:href="https://www.cs.princeton.edu/research/techreps/TR-597-99";>
+ xlink:href="https://www.cs.princeton.edu/research/techreps/293";>
  New Heap Data Structures

   
@@ -1138,7 +1138,7 @@
 
   
http://www.w3.org/1999/xlink";
- 
xlink:href="https://marknelson.us/posts/1996/01/01/priority-queues.html";>Priority
 Queues and the STL
+ 
xlink:href="https://web.archive.org/web/20240806213010/https://marknelson.us/posts/1996/01/01/priority-queues.html";>Priority
 Queues and the STL

   
   


[gcc r14-11485] libstdc++: Fix some broken links in the manual

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:cf01493b1f5aec3056596b17192662f44fa13a64

commit r14-11485-gcf01493b1f5aec3056596b17192662f44fa13a64
Author: Jonathan Wakely 
Date:   Mon Mar 24 21:28:47 2025 +

libstdc++: Fix some broken links in the manual

libstdc++-v3/ChangeLog:

* doc/xml/manual/policy_data_structures_biblio.xml: Fix two
broken links.
* doc/html/manual/policy_data_structures.html: Regenerate.

(cherry picked from commit 1e4d81aab2542f529d23329fcc5e642eedd617d9)

Diff:
---
 libstdc++-v3/doc/html/manual/policy_data_structures.html  | 4 ++--
 libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/policy_data_structures.html 
b/libstdc++-v3/doc/html/manual/policy_data_structures.html
index 45e07814184d..ba140809bbe0 100644
--- a/libstdc++-v3/doc/html/manual/policy_data_structures.html
+++ b/libstdc++-v3/doc/html/manual/policy_data_structures.html
@@ -1037,7 +1037,7 @@
  . 
  Addison-Wesley Publishing Company
. [biblio.kt99fat_heaps] 
-   https://www.cs.princeton.edu/research/techreps/TR-597-99"; target="_top">
+   https://www.cs.princeton.edu/research/techreps/293"; target="_top">
  New Heap Data Structures

   . 
@@ -1185,7 +1185,7 @@
. 
  Addison-Wesley Publishing Company
. [biblio.nelson96stlpq] 
-   https://marknelson.us/posts/1996/01/01/priority-queues.html"; 
target="_top">Priority Queues and the STL
+   https://web.archive.org/web/20240806213010/https://marknelson.us/posts/1996/01/01/priority-queues.html";
 target="_top">Priority Queues and the STL

   . 
January 1996
diff --git a/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml 
b/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
index 1450b8fc000e..928598d33c6b 100644
--- a/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
+++ b/libstdc++-v3/doc/xml/manual/policy_data_structures_biblio.xml
@@ -737,7 +737,7 @@
 
   
http://www.w3.org/1999/xlink";
- 
xlink:href="https://www.cs.princeton.edu/research/techreps/TR-597-99";>
+ xlink:href="https://www.cs.princeton.edu/research/techreps/293";>
  New Heap Data Structures

   
@@ -1138,7 +1138,7 @@
 
   
http://www.w3.org/1999/xlink";
- 
xlink:href="https://marknelson.us/posts/1996/01/01/priority-queues.html";>Priority
 Queues and the STL
+ 
xlink:href="https://web.archive.org/web/20240806213010/https://marknelson.us/posts/1996/01/01/priority-queues.html";>Priority
 Queues and the STL

   
   


[gcc r14-11487] libstdc++: Remove stray comma in testing docs

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:0b49d8bc67d26384d41f369137636bb7851150d2

commit r14-11487-g0b49d8bc67d26384d41f369137636bb7851150d2
Author: Jonathan Wakely 
Date:   Tue Mar 4 11:13:23 2025 +

libstdc++: Remove stray comma in testing docs

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Remove stray comma.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit ac16d6d74fcb4ca10c939b00782b4dfada666273)

Diff:
---
 libstdc++-v3/doc/html/manual/test.html | 2 +-
 libstdc++-v3/doc/xml/manual/test.xml   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/test.html 
b/libstdc++-v3/doc/html/manual/test.html
index b8a3b9545a7b..3eab28206314 100644
--- a/libstdc++-v3/doc/html/manual/test.html
+++ b/libstdc++-v3/doc/html/manual/test.html
@@ -230,7 +230,7 @@ cat 27_io/objects/char/3_xin.in | a.out
 
   The testsuite will create a number of files in the directory in
-  which you run this command,.  Some of those files might use the
+  which you run this command.  Some of those files might use the
   same name as files created by other testsuites (like the ones
   for GCC and G++), so you should not try to run all the
   testsuites in parallel from the same directory.
diff --git a/libstdc++-v3/doc/xml/manual/test.xml 
b/libstdc++-v3/doc/xml/manual/test.xml
index eb340277def5..826658725e9a 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -381,7 +381,7 @@ cat 27_io/objects/char/3_xin.in | a.out
 
 
   The testsuite will create a number of files in the directory in
-  which you run this command,.  Some of those files might use the
+  which you run this command.  Some of those files might use the
   same name as files created by other testsuites (like the ones
   for GCC and G++), so you should not try to run all the
   testsuites in parallel from the same directory.


[gcc r14-11484] doc: Fix minor grammar nit in -ftrivial-auto-var-init docs

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d276541a82c1fd3d5d272b09f2b7da0e42e4cf4c

commit r14-11484-gd276541a82c1fd3d5d272b09f2b7da0e42e4cf4c
Author: Jonathan Wakely 
Date:   Mon Mar 10 13:48:15 2025 +

doc: Fix minor grammar nit in -ftrivial-auto-var-init docs

gcc/ChangeLog:

* doc/extend.texi (Common Variable Attributes): Fix grammar in
final sentence of -ftrivial-auto-var-init description.

(cherry picked from commit f695d0392ffc82298d55474cd3025aec26db04ec)

Diff:
---
 gcc/doc/extend.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 27fefb30041e..22a2877bd663 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -8158,7 +8158,7 @@ to be excluded from such automatical initialization in 
order to reduce runtime
 overhead.
 
 This attribute has no effect when the option @code{-ftrivial-auto-var-init}
-does not present.
+is not present.
 
 @cindex @code{vector_size} variable attribute
 @item vector_size (@var{bytes})


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0f759df50875205daa64930f100c9bdec009e691

commit 0f759df50875205daa64930f100c9bdec009e691
Author: Mikael Morin 
Date:   Mon Mar 31 12:05:26 2025 +0200

Replace span with elem_len

Correction ISO_Fortran_binding_3.f90

Correction régression ISO_Fortran_binding_4.f90

Correction régression associate_60.f90

Diff:
---
 gcc/fortran/trans-array.cc|   4 +-
 gcc/fortran/trans-descriptor.cc   | 126 --
 gcc/fortran/trans-descriptor.h|   1 -
 gcc/fortran/trans-intrinsic.cc|   6 +-
 gcc/fortran/trans-openmp.cc   |   6 +-
 gcc/fortran/trans-types.cc|  17 ++--
 gcc/fortran/trans.cc  |  27 ---
 libgfortran/caf/single.c  |   2 +-
 libgfortran/intrinsics/associated.c   |   2 -
 libgfortran/libgfortran.h |   3 -
 libgfortran/runtime/ISO_Fortran_binding.c |   9 +--
 11 files changed, 64 insertions(+), 139 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 595ba97aa8ca..a48d0f4b8a4a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -450,7 +450,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = build_fold_indirect_ref_loc (input_location, desc);
 
   /* This will have the span field set.  */
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (expr->ts.type == BT_ASSUMED)
 {
@@ -458,7 +458,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
desc = GFC_DECL_SAVED_DESCRIPTOR (desc);
   if (POINTER_TYPE_P (TREE_TYPE (desc)))
desc = build_fold_indirect_ref_loc (input_location, desc);
-  tmp = gfc_conv_descriptor_span_get (desc);
+  tmp = gfc_conv_descriptor_elem_len_get (desc);
 }
   else if (TREE_CODE (desc) == COMPONENT_REF
   && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 7e709609435c..b217ccaea03c 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -164,9 +164,8 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #define DATA_FIELD 0
 #define OFFSET_FIELD 1
 #define DTYPE_FIELD 2
-#define SPAN_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
+#define DIMENSION_FIELD 3
+#define CAF_TOKEN_FIELD 4
 
 #define STRIDE_SUBFIELD 0
 #define LBOUND_SUBFIELD 1
@@ -282,27 +281,6 @@ conv_dtype_set (stmtblock_t *block, tree desc, tree val)
   gfc_add_modify (block, t, val);
 }
 
-tree
-get_span (tree desc)
-{
-  tree field = get_component (desc, SPAN_FIELD);
-  gcc_assert (TREE_TYPE (field) == gfc_array_index_type);
-  return field;
-}
-
-tree
-conv_span_get (tree desc)
-{
-  return non_lvalue_loc (input_location, get_span (desc));
-}
-
-void
-conv_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  tree t = get_span (desc);
-  gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
-}
-
 tree
 get_rank (tree desc)
 {
@@ -715,18 +693,6 @@ gfc_conv_descriptor_dtype_set (stmtblock_t *block, tree 
desc, tree val)
   gfc_descriptor::conv_dtype_set (block, desc, val);
 }
 
-tree
-gfc_conv_descriptor_span_get (tree desc)
-{
-  return gfc_descriptor::conv_span_get (desc);
-}
-
-static void
-gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
-{
-  return gfc_descriptor::conv_span_set (block, desc, value);
-}
-
 tree
 gfc_conv_descriptor_dimension_get (tree desc, tree dim)
 {
@@ -932,10 +898,11 @@ tree
 gfc_conv_descriptor_sm_get (tree desc, tree dim)
 {
   tree stride = gfc_conv_descriptor_stride_get (desc, dim);
-  tree span = gfc_conv_descriptor_span_get (desc);
+  tree elem_len = gfc_conv_descriptor_elem_len_get (desc);
+  elem_len = fold_convert (gfc_array_index_type, elem_len);
 
   return fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- stride, span);
+ stride, elem_len);
 }
 
 
@@ -,31 +1078,6 @@ get_descr_data_value (const descr_change_info &info)
 }
 
 
-static tree
-get_descr_span (const descr_change_info &info)
-{
-  switch (info.type)
-{
-case UNKNOWN_CHANGE:
-case EXPLICIT_NULLIFICATION:
-case INITIALISATION:
-case DEFAULT_INITIALISATION:
-case NULL_INITIALISATION:
-  return NULL_TREE;
-
-case SCALAR_VALUE:
-  {
-   tree fields = TYPE_FIELDS (info.descriptor_type);
-   tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-   return build_zero_cst (TREE_TYPE (span_field));
-  }
-
-default:
-  gcc_unreachable ();
-}
-}
-
-
 static tree
 get_descr_caf_token (const descr_change_info &info)
 {
@@ -1357,14 +1299,6 @@ get_descriptor_init (tree type, gfc_typespec *ts, int 
rank,
   CONSTRUCTOR_APPEND_ELT (v, dtype_field, dtype_value);
 }
 
-  tree span_value = get_descr_span (change);
-  if (span_value != NULL_TREE)
-{
-  tree sp

[gcc/mikael/heads/refactor_descriptor_v04] Replace span with elem_len

2025-03-31 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' was updated to point to:

 0f759df50875... Replace span with elem_len

It previously pointed to:

 4666a53f3701... Replace span with elem_len

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  4666a53... Replace span with elem_len


Summary of changes (added commits):
---

  0f759df... Replace span with elem_len


[gcc r13-9465] libstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e346a33381df08988f2b1c1f09f1ba573bb1f80b

commit r13-9465-ge346a33381df08988f2b1c1f09f1ba573bb1f80b
Author: Jonathan Wakely 
Date:   Mon Dec 30 13:08:41 2024 +

libstdc++: Implement LWG 2937 for std::filesystem::equivalent [PR118158]

Do not report an error for (is_other(s1) && is_other(s2)) as the
standard originally said, nor for (is_other(s1) || is_other(s2)) as
libstdc++ was doing. We can compare inode numbers for special files and
so give sensible answers.

libstdc++-v3/ChangeLog:

PR libstdc++/118158
* src/c++17/fs_ops.cc (fs::equivalent): Remove error reporting
for is_other(s1) && is_other(s2) case, as per LWG 2937.
* testsuite/27_io/filesystem/operations/pr118158.cc: New test.

(cherry picked from commit 301a961ffd0567eece55ece42e80a7ba9e855ba0)

Diff:
---
 libstdc++-v3/src/c++17/fs_ops.cc   | 22 +++-
 .../27_io/filesystem/operations/pr118158.cc| 62 ++
 2 files changed, 69 insertions(+), 15 deletions(-)

diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc
index 668b8c8951c4..5d50dc507fc1 100644
--- a/libstdc++-v3/src/c++17/fs_ops.cc
+++ b/libstdc++-v3/src/c++17/fs_ops.cc
@@ -915,24 +915,16 @@ fs::equivalent(const path& p1, const path& p2, 
error_code& ec) noexcept
   else
 err = errno;
 
-  if (exists(s1) && exists(s2))
-{
-  if (is_other(s1) && is_other(s2))
-   {
- ec = std::__unsupported();
- return false;
-   }
-  ec.clear();
-  if (is_other(s1) || is_other(s2))
-   return false;
-  return fs::equiv_files(p1.c_str(), st1, p2.c_str(), st2, ec);
-}
+  if (err)
+ec.assign(err, std::generic_category());
   else if (!exists(s1) || !exists(s2))
 ec = std::make_error_code(std::errc::no_such_file_or_directory);
-  else if (err)
-ec.assign(err, std::generic_category());
   else
-ec.clear();
+{
+  ec.clear();
+  if (s1.type() == s2.type())
+   return fs::equiv_files(p1.c_str(), st1, p2.c_str(), st2, ec);
+}
   return false;
 #else
   ec = std::make_error_code(std::errc::function_not_supported);
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/pr118158.cc 
b/libstdc++-v3/testsuite/27_io/filesystem/operations/pr118158.cc
new file mode 100644
index ..b57a2d184f41
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/pr118158.cc
@@ -0,0 +1,62 @@
+// { dg-do run { target c++17 } }
+// { dg-require-filesystem-ts "" }
+
+#include 
+#include 
+#include 
+
+#if defined(_GLIBCXX_HAVE_SYS_STAT_H) && defined(_GLIBCXX_HAVE_SYS_TYPES_H)
+# include 
+# include   // mkfifo
+#endif
+
+namespace fs = std::filesystem;
+
+void
+test_pr118158()
+{
+#if defined(_GLIBCXX_HAVE_SYS_STAT_H) && defined(_GLIBCXX_HAVE_SYS_TYPES_H) \
+  && defined(S_IWUSR) && defined(S_IRUSR)
+  auto p1 = __gnu_test::nonexistent_path();
+  auto p2 = __gnu_test::nonexistent_path();
+  auto p3 = __gnu_test::nonexistent_path();
+  const std::error_code bad_ec = make_error_code(std::errc::invalid_argument);
+  std::error_code ec;
+  bool result;
+
+  VERIFY( ! ::mkfifo(p1.c_str(), S_IWUSR | S_IRUSR) );
+  __gnu_test::scoped_file f1(p1, __gnu_test::scoped_file::adopt_file);
+
+  // Special file is equivalent to itself.
+  VERIFY( equivalent(p1, p1) );
+  VERIFY( equivalent(p1, p1, ec) );
+  VERIFY( ! ec );
+
+  VERIFY( ! ::mkfifo(p2.c_str(), S_IWUSR | S_IRUSR) );
+  __gnu_test::scoped_file f2(p2, __gnu_test::scoped_file::adopt_file);
+
+  ec = bad_ec;
+  // Distinct special files are not equivalent.
+  VERIFY( ! equivalent(p1, p2, ec) );
+  VERIFY( ! ec );
+
+  // Non-existent paths are always an error.
+  VERIFY( ! equivalent(p1, p3, ec) );
+  VERIFY( ec == std::errc::no_such_file_or_directory );
+  ec = bad_ec;
+  VERIFY( ! equivalent(p3, p2, ec) );
+  VERIFY( ec == std::errc::no_such_file_or_directory );
+
+  // Special file is not equivalent to regular file.
+  __gnu_test::scoped_file f3(p3);
+  ec = bad_ec;
+  VERIFY( ! equivalent(p1, p3, ec) );
+  VERIFY( ! ec );
+#endif
+}
+
+int
+main()
+{
+  test_pr118158();
+}


[gcc r15-9057] target/119010 - reservations for Zen4/Zen5 movhlps to memory

2025-03-31 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a46430c85611ac7faec9507472b8736b89643659

commit r15-9057-ga46430c85611ac7faec9507472b8736b89643659
Author: Richard Biener 
Date:   Thu Mar 27 13:45:45 2025 +0100

target/119010 - reservations for Zen4/Zen5 movhlps to memory

The following adds missing reservations for the store variant of
sselog reservations covering

;; 112--> b  0: i1499 [dx-0x10]=vec_select(xmm10,parallel):nothing

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_log_evex_store,
znver5_sse_log_evex_store): New reservations.

Diff:
---
 gcc/config/i386/zn4zn5.md | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index 6720fda17056..1ac1d07c04b8 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -1367,6 +1367,20 @@
(eq_attr "memory" "load"
 
"znver4-direct,znver5-load,znver4-fpu0|znver4-fpu1|znver4-fpu2|znver4-fpu3")
 
+(define_insn_reservation "znver4_sse_log_evex_store" 1
+(and (eq_attr "cpu" "znver4")
+ (and (eq_attr "type" "sselog")
+  (and (eq_attr "mode" "V16SF,V8DF,XI")
+   (eq_attr "memory" "store"
+
"znver4-direct,znver4-store,znver4-fpu0*2|znver4-fpu1*2|znver4-fpu2*2|znver4-fpu3*2")
+
+(define_insn_reservation "znver5_sse_log_evex_store" 1
+(and (eq_attr "cpu" "znver5")
+ (and (eq_attr "type" "sselog")
+  (and (eq_attr "mode" "V16SF,V8DF,XI")
+   (eq_attr "memory" "store"
+
"znver4-direct,znver5-store,znver4-fpu0|znver4-fpu1|znver4-fpu2|znver4-fpu3")
+
 (define_insn_reservation "znver4_sse_log1_evex" 1
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "sselog1")


[gcc r13-9475] libstdc++: Fix comment typo

2025-03-31 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:8160e7649c99a6acf519d84a8c5b7a67af3b7b1a

commit r13-9475-g8160e7649c99a6acf519d84a8c5b7a67af3b7b1a
Author: Jakub Jelinek 
Date:   Thu Mar 20 10:36:29 2025 +0100

libstdc++: Fix comment typo

Another IEE typo.

2025-03-20  Jakub Jelinek  

* testsuite/18_support/numeric_limits/traps.cc (main): Fix comment
typo.

(cherry picked from commit d458020e19b686e0d46320e7d26fa876c19965a0)

Diff:
---
 libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc 
b/libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc
index 30e4beb641a5..33a7063cdf89 100644
--- a/libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc
+++ b/libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc
@@ -48,7 +48,7 @@ int main()
 For floating points, trapping is a different, more complicated
 story.  If is_iecxxx is true, then division by zero would not trap
 (infinity).  If is_iecxxx is false, we don't know (VAX may trap for
-0/0 -- I have to check).  For most cases (i.e. IEE-754), trapping
+0/0 -- I have to check).  For most cases (i.e. IEEE-754), trapping
 for floating points have to do with whether there is a support for
 signaling NaN.
 - Gaby.


[gcc r14-11489] d: Fix error with -Warray-bounds and -O2 [PR117002]

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

commit r14-11489-ga6a2da499ab8b6b9e52cec5bc32bbd48371bb6ba
Author: Iain Buclaw 
Date:   Sat Mar 29 23:16:25 2025 +0100

d: Fix error with -Warray-bounds and -O2 [PR117002]

The record layout of class types in D don't get any tail padding, so it
is possible for the `classInstanceSize' to not be a multiple of the
`classInstanceAlignment'.

Rather than setting the instance alignment on the underlying
RECORD_TYPE, instead give the type an alignment of 1, which will mark it
as TYPE_PACKED.  The value of `classInstanceAlignment' is instead
applied to the DECL_ALIGN of both the static `init' symbol, and the
stack allocated variable used when generating `new' for a `scope' class.

PR d/117002

gcc/d/ChangeLog:

* decl.cc (aggregate_initializer_decl): Set explicit decl alignment 
of
class instance.
* expr.cc (ExprVisitor::visit (NewExp *)): Likewise.
* types.cc (TypeVisitor::visit (TypeClass *)): Mark the record type 
of
classes as packed.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr117002.d: New test.

(cherry picked from commit 9fadadbbbc2b5352e5e70e0e1a9be9b447176913)

Diff:
---
 gcc/d/decl.cc   |  6 ++
 gcc/d/expr.cc   |  2 ++
 gcc/d/types.cc  |  3 ++-
 gcc/testsuite/gdc.dg/torture/pr117002.d | 28 
 4 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 7cc203ac8429..a29fd230ca77 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -2394,6 +2394,12 @@ aggregate_initializer_decl (AggregateDeclaration *decl)
   SET_DECL_ALIGN (sinit, sd->alignment.get () * BITS_PER_UNIT);
   DECL_USER_ALIGN (sinit) = true;
 }
+  else if (sd == NULL)
+{
+  /* Alignment of class is determined its biggest field alignment.  */
+  SET_DECL_ALIGN (sinit, decl->alignsize * BITS_PER_UNIT);
+  DECL_USER_ALIGN (sinit) = true;
+}
 
   decl->sinit = sinit;
   return sinit;
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 733302f8e2ee..cc76b09751fb 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2241,6 +2241,8 @@ public:
   storage class, then the instance is allocated on the stack
   rather than the heap or using the class specific allocator.  */
tree var = build_local_temp (TREE_TYPE (type));
+   SET_DECL_ALIGN (var, cd->alignsize * BITS_PER_UNIT);
+   DECL_USER_ALIGN (var) = 1;
new_call = build_nop (type, build_address (var));
setup_exp = modify_expr (var, aggregate_initializer_decl (cd));
  }
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 02f69af166d6..6b045bde0a44 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -1278,7 +1278,8 @@ public:
 build_type_decl (basetype, t->sym);
 set_visibility_for_decl (basetype, t->sym);
 apply_user_attributes (t->sym, basetype);
-finish_aggregate_type (t->sym->structsize, t->sym->alignsize, basetype);
+/* The underlying record type of classes are packed.  */
+finish_aggregate_type (t->sym->structsize, 1, basetype);
 
 /* Classes only live in memory, so always set the TREE_ADDRESSABLE bit.  */
 for (tree tv = basetype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
diff --git a/gcc/testsuite/gdc.dg/torture/pr117002.d 
b/gcc/testsuite/gdc.dg/torture/pr117002.d
new file mode 100644
index ..5b8c19e5b12f
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/torture/pr117002.d
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-additional-options "-Warray-bounds" }
+extern(C++) class C117002
+{
+ubyte[4] not_multiple_of_8;
+}
+
+int pr117002a(void *p)
+{
+auto init = __traits(initSymbol, C117002);
+if (init.ptr + init.length <= p)
+return 1;
+return 0;
+}
+
+void pr117002b(void *p)
+{
+auto init = __traits(initSymbol, C117002);
+p[0 .. init.length] = init[];
+}
+
+void pr117002c()
+{
+scope var = new C117002;
+void *p = cast(void*)var;
+auto init = __traits(initSymbol, C117002);
+p[0 .. __traits(classInstanceSize, C117002)] = init[];
+}


[gcc r15-9071] libstdc++: Tweak linker script to avoid conflict on Solaris

2025-03-31 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:44289d258a970e39059afa33d2a44d16ba41d3f2

commit r15-9071-g44289d258a970e39059afa33d2a44d16ba41d3f2
Author: Jonathan Wakely 
Date:   Mon Mar 31 17:07:55 2025 +0100

libstdc++: Tweak linker script to avoid conflict on Solaris

The new symbols for the _M_construct function template match an
existing pattern in the GLIBCXX_3.4.21 version, as well as the intended
pattern in the GLIBCXX_3.4.34 version. That causes a linker error on
Solaris.

libstdc++-v3/ChangeLog:

* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Make
std::basic_string::_M_construct patterns more precise.

Diff:
---
 libstdc++-v3/config/abi/pre/gnu.ver | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver 
b/libstdc++-v3/config/abi/pre/gnu.ver
index 10bf9975d450..29bc7d86256e 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1767,7 +1767,8 @@ GLIBCXX_3.4.21 {
 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE10_S_compareE[jmy][jmy];
 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE11_M_capacityE[jmy];
 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_Alloc_hiderC[12]EP[cw]RKS3_;
-_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M*;
+
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructE[jmy][cw];
+
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructI[NP]*;
 _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE13*;
 
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE14_M_replace_aux*;
 _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE1[68-9]*;