[gcc r14-9513] testsuite: Define _POSIX_C_SOURCE for test

2024-03-18 Thread Torbjorn Svensson via Gcc-cvs
https://gcc.gnu.org/g:58753dba800de14144785199fd710e9b00544155

commit r14-9513-g58753dba800de14144785199fd710e9b00544155
Author: Torbjörn SVENSSON 
Date:   Sun Mar 10 18:18:51 2024 +0100

testsuite: Define _POSIX_C_SOURCE for test

As the tests assume that strndup() is visible (only part of
POSIX.1-2008) define the guard to ensure that it's visible.  Currently,
glibc appears to always have this defined in C++, newlib does not.

Without this patch, fails like this can be seen:

Testing analyzer/strndup-1.c,  -std=c++98
.../strndup-1.c: In function 'void test_1(const char*)':
.../strndup-1.c:11:13: error: 'strndup' was not declared in this scope; did 
you mean 'strncmp'?
.../strndup-1.c: In function 'void test_2(const char*)':
.../strndup-1.c:16:13: error: 'strndup' was not declared in this scope; did 
you mean 'strncmp'?
.../strndup-1.c: In function 'void test_3(const char*)':
.../strndup-1.c:21:13: error: 'strndup' was not declared in this scope; did 
you mean 'strncmp'?

Patch has been verified on Linux.

gcc/testsuite/ChangeLog:

* c-c++-common/analyzer/strndup-1.c: Define _POSIX_C_SOURCE.

Signed-off-by: Torbjörn SVENSSON 

Diff:
---
 gcc/testsuite/c-c++-common/analyzer/strndup-1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c 
b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
index 85ccae85d83..577ece0cfba 100644
--- a/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
+++ b/gcc/testsuite/c-c++-common/analyzer/strndup-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* 
hppa*-*-hpux* *-*-mingw* *-*-vxworks* } } */
+/* { dg-additional-options "-D_POSIX_C_SOURCE=200809L" } */
 
 #include 
 #include 


[gcc r13-8462] riscv: xtheadmempair: Fix CFA reg notes

2024-03-18 Thread Christoph Mテシllner via Gcc-cvs
https://gcc.gnu.org/g:d9d51e0552693bf1bcf6f23d53d058d60d72416e

commit r13-8462-gd9d51e0552693bf1bcf6f23d53d058d60d72416e
Author: Christoph Müllner 
Date:   Mon Apr 24 23:09:06 2023 +0200

riscv: xtheadmempair: Fix CFA reg notes

The current implementation triggers an assertion in
dwarf2out_frame_debug_cfa_offset() under certain circumstances.
The standard code uses REG_FRAME_RELATED_EXPR notes instead
of REG_CFA_OFFSET notes when saving registers on the stack.
So let's do this as well.

gcc/ChangeLog:

PR target/114160
* config/riscv/thead.cc (th_mempair_save_regs):
Emit REG_FRAME_RELATED_EXPR notes in prologue.

(cherry picked from commit 93973e4c5d3bcde1f84cad3b42a8c36e23900d19)

Signed-off-by: Christoph Müllner 

Diff:
---
 gcc/config/riscv/thead.cc | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/thead.cc b/gcc/config/riscv/thead.cc
index 75203805310..d7e3cf80d9b 100644
--- a/gcc/config/riscv/thead.cc
+++ b/gcc/config/riscv/thead.cc
@@ -368,8 +368,12 @@ th_mempair_save_regs (rtx operands[4])
   rtx set2 = gen_rtx_SET (operands[2], operands[3]);
   rtx insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set1, 
set2)));
   RTX_FRAME_RELATED_P (insn) = 1;
-  add_reg_note (insn, REG_CFA_OFFSET, copy_rtx (set1));
-  add_reg_note (insn, REG_CFA_OFFSET, copy_rtx (set2));
+
+  REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+ copy_rtx (set1), REG_NOTES (insn));
+
+  REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+ copy_rtx (set2), REG_NOTES (insn));
 }
 
 /* Similar like riscv_restore_reg, but restores two registers from memory


[gcc r14-9514] avr.md - Tweak xor insn constraints.

2024-03-18 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:9361f19e081294b04e16ac2f6056b3b910f27ff4

commit r14-9514-g9361f19e081294b04e16ac2f6056b3b910f27ff4
Author: Georg-Johann Lay 
Date:   Mon Mar 18 08:50:02 2024 +0100

avr.md - Tweak xor insn constraints.

xor insn can handle some more values without the requirement of a
scratch register.  This patch adds a new constraint alternative for
such values.  The output function avr_out_bitop already handles
these cases, so no change is needed there.

gcc/
* config/avr/constraints.md (CX2, CX3, CX4): New constraints.
* config/avr/avr-protos.h (avr_xor_noclobber_dconst): New proto.
* config/avr/avr.cc (avr_xor_noclobber_dconst): New function.
* config/avr/avr.md (xorhi3, *xorhi3): Add "d,0,CX2,X" alternative.
(xorpsi3, *xorpsi3): Add "d,0,CX3,X" alternative.
(xorsi3, *xorsi3): Add "d,0,CX4,X" alternative.

Diff:
---
 gcc/config/avr/avr-protos.h   |  1 +
 gcc/config/avr/avr.cc | 25 ++
 gcc/config/avr/avr.md | 60 +--
 gcc/config/avr/constraints.md | 17 +++-
 4 files changed, 72 insertions(+), 31 deletions(-)

diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index bb680312117..dc23cfbf461 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -101,6 +101,7 @@ extern const char* avr_out_xload (rtx_insn *, rtx*, int*);
 extern const char* avr_out_cpymem (rtx_insn *, rtx*, int*);
 extern const char* avr_out_insert_bits (rtx*, int*);
 extern bool avr_popcount_each_byte (rtx, int, int);
+extern bool avr_xor_noclobber_dconst (rtx, int);
 extern bool avr_has_nibble_0xf (rtx);
 
 extern int extra_constraint_Q (rtx x);
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 00fce8da15f..12c59668b4c 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -281,6 +281,31 @@ avr_popcount_each_byte (rtx xval, int n_bytes, int 
pop_mask)
 }
 
 
+/* Constraint helper function.  XVAL is a CONST_INT.  Return true if we
+   can perform XOR without a clobber reg, provided the operation is on
+   a d-register.  This means each byte is in { 0, 0xff, 0x80 }.  */
+
+bool
+avr_xor_noclobber_dconst (rtx xval, int n_bytes)
+{
+  machine_mode mode = GET_MODE (xval);
+
+  if (VOIDmode == mode)
+mode = SImode;
+
+  for (int i = 0; i < n_bytes; ++i)
+{
+  rtx xval8 = simplify_gen_subreg (QImode, xval, mode, i);
+  unsigned int val8 = UINTVAL (xval8) & GET_MODE_MASK (QImode);
+
+  if (val8 != 0 && val8 != 0xff && val8 != 0x80)
+   return false;
+}
+
+  return true;
+}
+
+
 /* Access some RTX as INT_MODE.  If X is a CONST_FIXED we can get
the bit representation of X by "casting" it to CONST_INT.  */
 
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index bc408633eb5..97f42be7729 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -4741,10 +4741,10 @@
   [(set_attr "length" "1")])
 
 (define_insn_and_split "xorhi3"
-  [(set (match_operand:HI 0 "register_operand"   "=??r,r  ,r")
-(xor:HI (match_operand:HI 1 "register_operand" "%0,0  ,0")
-(match_operand:HI 2 "nonmemory_operand" "r,Cx2,n")))
-   (clobber (match_scratch:QI 3"=X,X  ,&d"))]
+  [(set (match_operand:HI 0 "register_operand"   "=??r,r  ,d  ,r")
+(xor:HI (match_operand:HI 1 "register_operand" "%0,0  ,0  ,0")
+(match_operand:HI 2 "nonmemory_operand" "r,Cx2,CX2,n")))
+   (clobber (match_scratch:QI 3"=X,X  ,X  ,&d"))]
   ""
   "#"
   "&& reload_completed"
@@ -4755,10 +4755,10 @@
   (clobber (reg:CC REG_CC))])])
 
 (define_insn "*xorhi3"
-  [(set (match_operand:HI 0 "register_operand"   "=??r,r  ,r")
-(xor:HI (match_operand:HI 1 "register_operand" "%0,0  ,0")
-(match_operand:HI 2 "nonmemory_operand" "r,Cx2,n")))
-   (clobber (match_scratch:QI 3"=X,X  ,&d"))
+  [(set (match_operand:HI 0 "register_operand"   "=??r,r  ,d  ,r")
+(xor:HI (match_operand:HI 1 "register_operand" "%0,0  ,0  ,0")
+(match_operand:HI 2 "nonmemory_operand" "r,Cx2,CX2,n")))
+   (clobber (match_scratch:QI 3"=X,X  ,X  ,&d"))
(clobber (reg:CC REG_CC))]
   "reload_completed"
   {
@@ -4767,14 +4767,14 @@
 
 return avr_out_bitop (insn, operands, NULL);
   }
-  [(set_attr "length" "2,2,4")
-   (set_attr "adjust_len" "*,out_bitop,out_bitop")])
+  [(set_attr "length" "2,2,4,4")
+   (set_attr "adjust_len" "*,out_bitop,out_bitop,out_bitop")])
 
 (define_insn_and_split "xorpsi3"
-  [(set (match_operand:PSI 0 "register_operand""=??r,r  ,r")
-(xor:PSI (match_operand:PSI 1 "register_operand" "%0,0  ,0")
- (match_operand:PSI 2 "nonmemory_operand" "r,Cx3,n")))
-   (clobber (match_scratch:QI 3  "=X,X  ,&d"))]
+  [(set (match_operand:PSI 0 "register_

[gcc r14-9515] Add AMD znver5 processor enablement with scheduler model

2024-03-18 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:d0aa0af9a9b7dd709a8c7ff6604ed6b7da0fc23a

commit r14-9515-gd0aa0af9a9b7dd709a8c7ff6604ed6b7da0fc23a
Author: Jan Hubicka 
Date:   Mon Mar 18 10:22:44 2024 +0100

Add AMD znver5 processor enablement with scheduler model

2024-02-14  Jan Hubicka  
Karthiban Anbazhagan  

gcc/ChangeLog:
* common/config/i386/cpuinfo.h (get_amd_cpu): Recognize znver5.
* common/config/i386/i386-common.cc (processor_names): Add znver5.
(processor_alias_table): Likewise.
* common/config/i386/i386-cpuinfo.h (processor_types): Add new zen
family.
(processor_subtypes): Add znver5.
* config.gcc (x86_64-*-* |...): Likewise.
* config/i386/driver-i386.cc (host_detect_local_cpu): Let
march=native detect znver5 cpu's.
* config/i386/i386-c.cc (ix86_target_macros_internal): Add
znver5.
* config/i386/i386-options.cc (m_ZNVER5): New definition
(processor_cost_table): Add znver5.
* config/i386/i386.cc (ix86_reassociation_width): Likewise.
* config/i386/i386.h (processor_type): Add PROCESSOR_ZNVER5
(PTA_ZNVER5): New definition.
* config/i386/i386.md (define_attr "cpu"): Add znver5.
(Scheduling descriptions) Add znver5.md.
* config/i386/x86-tune-costs.h (znver5_cost): New definition.
* config/i386/x86-tune-sched.cc (ix86_issue_rate): Add znver5.
(ix86_adjust_cost): Likewise.
* config/i386/x86-tune.def (avx512_move_by_pieces): Add m_ZNVER5.
(avx512_store_by_pieces): Add m_ZNVER5.
* doc/extend.texi: Add znver5.
* doc/invoke.texi: Likewise.
* config/i386/znver4.md: Rename to zn4zn5.md; combine znver4 and 
znver5 Scheduler.

gcc/testsuite/ChangeLog:
* g++.target/i386/mv29.C: Handle znver5 arch.
* gcc.target/i386/funcspec-56.inc:Likewise.

Diff:
---
 gcc/common/config/i386/cpuinfo.h  |   16 +
 gcc/common/config/i386/i386-common.cc |6 +-
 gcc/common/config/i386/i386-cpuinfo.h |2 +
 gcc/config.gcc|   14 +-
 gcc/config/i386/driver-i386.cc|5 +
 gcc/config/i386/i386-c.cc |7 +
 gcc/config/i386/i386-options.cc   |6 +-
 gcc/config/i386/i386.cc   |3 +-
 gcc/config/i386/i386.h|4 +-
 gcc/config/i386/i386.md   |5 +-
 gcc/config/i386/x86-tune-costs.h  |  136 
 gcc/config/i386/x86-tune-sched.cc |2 +
 gcc/config/i386/x86-tune.def  |4 +-
 gcc/config/i386/znver4.md | 1068 -
 gcc/doc/extend.texi   |3 +
 gcc/doc/invoke.texi   |   10 +
 gcc/testsuite/g++.target/i386/mv29.C  |6 +
 gcc/testsuite/gcc.target/i386/funcspec-56.inc |2 +
 18 files changed, 219 insertions(+), 1080 deletions(-)

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index a595ee537a8..017a952a5db 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -310,6 +310,22 @@ get_amd_cpu (struct __processor_model *cpu_model,
  cpu_model->__cpu_subtype = AMDFAM19H_ZNVER3;
}
   break;
+case 0x1a:
+  cpu_model->__cpu_type = AMDFAM1AH;
+  if (model <= 0x77)
+   {
+ cpu = "znver5";
+ CHECK___builtin_cpu_is ("znver5");
+ cpu_model->__cpu_subtype = AMDFAM1AH_ZNVER5;
+   }
+  else if (has_cpu_feature (cpu_model, cpu_features2,
+   FEATURE_AVX512VP2INTERSECT))
+   {
+ cpu = "znver5";
+ CHECK___builtin_cpu_is ("znver5");
+ cpu_model->__cpu_subtype = AMDFAM1AH_ZNVER5;
+   }
+  break;
 default:
   break;
 }
diff --git a/gcc/common/config/i386/i386-common.cc 
b/gcc/common/config/i386/i386-common.cc
index c35191e6925..f814df8385b 100644
--- a/gcc/common/config/i386/i386-common.cc
+++ b/gcc/common/config/i386/i386-common.cc
@@ -2166,7 +2166,8 @@ const char *const processor_names[] =
   "znver1",
   "znver2",
   "znver3",
-  "znver4"
+  "znver4",
+  "znver5"
 };
 
 /* Guarantee that the array is aligned with enum processor_type.  */
@@ -2435,6 +2436,9 @@ const pta processor_alias_table[] =
   {"znver4", PROCESSOR_ZNVER4, CPU_ZNVER4,
 PTA_ZNVER4,
 M_CPU_SUBTYPE (AMDFAM19H_ZNVER4), P_PROC_AVX512F},
+  {"znver5", PROCESSOR_ZNVER5, CPU_ZNVER5,
+PTA_ZNVER5,
+M_CPU_SUBTYPE (AMDFAM1AH_ZNVER5), P_PROC_AVX512F},
   {"btver1", PROCESSOR_BTVER1, CPU_GENERIC,
 PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
   | PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_PRFCHW
diff --git a/gcc/common/config/i386/i386-cpuinfo.h 
b/gcc/common/config/i386/i386-cpui

[gcc r13-8463] libstdc++: Move test error_category to global scope

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e4ac0519ec85fd422ee2987cc8308dced96c68be

commit r13-8463-ge4ac0519ec85fd422ee2987cc8308dced96c68be
Author: Jonathan Wakely 
Date:   Wed Mar 13 10:02:12 2024 +

libstdc++: Move test error_category to global scope

A recent GDB change causes this test to fail due to missing RTTI for the
custom_cast type. This is presumably because the custom_cat type was
defined as a local class, so has no linkage. Moving it to local scope
seems to fix the test regressions, and probably makes the test more
realistic as a local class with no linkage isn't practical to use as an
error category that almost certainly needs to be referred to in other
scopes.

libstdc++-v3/ChangeLog:

* testsuite/libstdc++-prettyprinters/cxx11.cc: Move custom_cat
to namespace scope.

(cherry picked from commit a8c7c3a40953e34f57278d224a07dc3698c64a84)

Diff:
---
 libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc 
b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
index 0f1736a1550..973fa936d9e 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
@@ -63,6 +63,11 @@ struct datum
 
 std::unique_ptr global;
 
+struct custom_cat : std::error_category {
+  const char* name() const noexcept { return "miaow"; }
+  std::string message(int) const { return ""; }
+};
+
 int
 main()
 {
@@ -179,10 +184,7 @@ main()
   std::error_condition ecinval = 
std::make_error_condition(std::errc::invalid_argument);
   // { dg-final { note-test ecinval {std::error_condition = {"generic": 
EINVAL}} } }
 
-  struct custom_cat : std::error_category {
-const char* name() const noexcept { return "miaow"; }
-std::string message(int) const { return ""; }
-  } cat;
+  custom_cat cat;
   std::error_code emiaow(42, cat);
   // { dg-final { note-test emiaow {std::error_code = {custom_cat: 42}} } }
   std::error_condition ecmiaow(42, cat);


[gcc r13-8464] libstdc++: Correct notes about std::call_once in manual [PR66146]

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:a2c960dd7ebe2db0e8153a7e691245a4928341c6

commit r13-8464-ga2c960dd7ebe2db0e8153a7e691245a4928341c6
Author: Jonathan Wakely 
Date:   Thu Mar 14 11:52:17 2024 +

libstdc++: Correct notes about std::call_once in manual [PR66146]

The bug with exceptions thrown during a std::call_once call affects all
targets, so fix the docs that say it only affects non-Linux targets.

libstdc++-v3/ChangeLog:

PR libstdc++/66146
* doc/xml/manual/status_cxx2011.xml: Remove mention of Linux in
note about std::call_once.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

(cherry picked from commit e6836bbbd7a01af0791c02087e568b4822418c0d)

Diff:
---
 libstdc++-v3/doc/html/manual/status.html   | 6 +++---
 libstdc++-v3/doc/xml/manual/status_cxx2011.xml | 2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2014.xml | 2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2017.xml | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/status.html 
b/libstdc++-v3/doc/html/manual/status.html
index 6f5c0238d8e..af94ead2b82 100644
--- a/libstdc++-v3/doc/html/manual/status.html
+++ b/libstdc++-v3/doc/html/manual/status.html
@@ -217,7 +217,7 @@ particular release.
30
   
Thread support
-  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.2Locks  
30.4.2.1Class template 
lock_guardY 30.4.2.2Class template unique_lockY 30.4.3Generic locking algorithmsY 30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceYException support is broken on non
 -Linux targets.
+  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.2Locks  
30.4.2.1Class template 
lock_guardY 30.4.2.2Class template unique_lockY 30.4.3Generic locking algorithmsY 30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceYException support is broken.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146"; target="_top">PR
66146.
   30.5Condition 
variablesY 30.5.1Class condition_variableY 30.5.2Class 
condition_variable_anyY 30.6Futures  
30.6.1Overview  30.6.2Error handlingY 30.6.3Class future_errorY 
30.6.4Shared stateY 
30.6.5Class template promiseY 
30.6.6Class template futureY 
30.6.7Class template shared_futureY 
30.6.8Function template 
asyncY 
30.6.9Class template packaged_taskY 

@@ -490,7 +490,7 @@ not in any particular release.
30
   
Thread support
-  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.1.4Shared timed mutex types 
 30.4.1.4.1Class shared_timed_mutexY 30.4.2Locks  30.4.2.1Class template lock_guardY 30.4.2.2Class template unique_lockY 
30.4.2.3Class template 
shared_lockY 30.4.3Generic locking algorithmsY <
 td align="left">30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceBrokenException support is broken on non-Linux targets.
+  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.1.4Shared timed mutex types 
 30.4.1.4.1Class shared_timed_mutexY 30.4.2Locks  30.4.2.1Class template lock_guardY 30.4.2.2Class template unique_lockY 
30.4.2.3Class template 
shared_lockY 30.4.3Generic locking algorithmsY <
 td align="left">30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceBrokenException support is broken.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146"; target="_top">PR
66146.
   30.5Condition 
variablesY 30.5.1Class condition_variableY 30.5.2Class 
condition_variable_anyY 30.6Futures  
30.6.1Overview  30.

[gcc r14-9516] Add missing config/i386/zn4zn5.md file

2024-03-18 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:dfc9d1cc8353bdd7fbc37bc10bb3fd40f49fa4af

commit r14-9516-gdfc9d1cc8353bdd7fbc37bc10bb3fd40f49fa4af
Author: Jan Hubicka 
Date:   Mon Mar 18 14:24:10 2024 +0100

Add missing config/i386/zn4zn5.md file

gcc/ChangeLog:

* config/i386/zn4zn5.md: Add file missed in the previous commit.

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

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
new file mode 100644
index 000..ba9cfbb5dfc
--- /dev/null
+++ b/gcc/config/i386/zn4zn5.md
@@ -0,0 +1,1785 @@
+;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; .
+;;
+
+
+(define_attr "znver4_decode" "direct,vector,double"
+  (const_string "direct"))
+
+;; AMD znver4 and znver5 Scheduling
+;; Modeling automatons for zen decoders, integer execution pipes,
+;; AGU pipes, branch, floating point execution and fp store units.
+(define_automaton "znver4, znver4_ieu, znver4_idiv, znver4_fdiv, znver4_agu, 
znver4_fpu, znver4_fp_store")
+
+;; Decoders unit has 4 decoders and all of them can decode fast path
+;; and vector type instructions.
+(define_cpu_unit "znver4-decode0" "znver4")
+(define_cpu_unit "znver4-decode1" "znver4")
+(define_cpu_unit "znver4-decode2" "znver4")
+(define_cpu_unit "znver4-decode3" "znver4")
+
+;; Currently blocking all decoders for vector path instructions as
+;; they are dispatched separetely as microcode sequence.
+(define_reservation "znver4-vector" 
"znver4-decode0+znver4-decode1+znver4-decode2+znver4-decode3")
+
+;; Direct instructions can be issued to any of the four decoders.
+(define_reservation "znver4-direct" 
"znver4-decode0|znver4-decode1|znver4-decode2|znver4-decode3")
+
+;; Fix me: Need to revisit this later to simulate fast path double behavior.
+(define_reservation "znver4-double" "znver4-direct")
+
+
+;; Integer unit 4 ALU pipes in znver4 6 ALU pipes in znver5.
+(define_cpu_unit "znver4-ieu0" "znver4_ieu")
+(define_cpu_unit "znver4-ieu1" "znver4_ieu")
+(define_cpu_unit "znver4-ieu2" "znver4_ieu")
+(define_cpu_unit "znver4-ieu3" "znver4_ieu")
+(define_cpu_unit "znver5-ieu4" "znver4_ieu")
+(define_cpu_unit "znver5-ieu5" "znver4_ieu")
+
+;; Znver4 has an additional branch unit.
+(define_cpu_unit "znver4-bru0" "znver4_ieu")
+
+(define_reservation "znver4-ieu" 
"znver4-ieu0|znver4-ieu1|znver4-ieu2|znver4-ieu3")
+(define_reservation "znver5-ieu" 
"znver4-ieu0|znver4-ieu1|znver4-ieu2|znver4-ieu3|znver5-ieu4|znver5-ieu5")
+
+;; 3 AGU pipes in znver4 and 4 AGU pipes in znver5
+(define_cpu_unit "znver4-agu0" "znver4_agu")
+(define_cpu_unit "znver4-agu1" "znver4_agu")
+(define_cpu_unit "znver4-agu2" "znver4_agu")
+(define_cpu_unit "znver5-agu3" "znver4_agu")
+
+(define_reservation "znver4-agu-reserve" "znver4-agu0|znver4-agu1|znver4-agu2")
+(define_reservation "znver5-agu-reserve" 
"znver4-agu0|znver4-agu1|znver4-agu2|znver5-agu3")
+
+;; Load is 4 cycles. We do not model reservation of load unit.
+(define_reservation "znver4-load" "znver4-agu-reserve")
+(define_reservation "znver4-store" "znver4-agu-reserve")
+(define_reservation "znver5-load" "znver5-agu-reserve")
+(define_reservation "znver5-store" "znver5-agu-reserve")
+
+;; vectorpath (microcoded) instructions are single issue instructions.
+;; So, they occupy all the integer units.
+;; This is used for both Znver4 and Znver5, since reserving extra units not 
used otherwise
+;; is harmless.
+(define_reservation "znver4-ivector" "znver4-ieu0+znver4-ieu1
+ 
+znver4-ieu2+znver4-ieu3+znver5-ieu4+znver5-ieu5+znver4-bru0
+ 
+znver4-agu0+znver4-agu1+znver4-agu2+znver5-agu3")
+
+;; Floating point unit 4 FP pipes in znver4 and znver5.
+(define_cpu_unit "znver4-fpu0" "znver4_fpu")
+(define_cpu_unit "znver4-fpu1" "znver4_fpu")
+(define_cpu_unit "znver4-fpu2" "znver4_fpu")
+(define_cpu_unit "znver4-fpu3" "znver4_fpu")
+
+(define_reservation "znver4-fpu" 
"znver4-fpu0|znver4-fpu1|znver4-fpu2|znver4-fpu3")
+
+;; DIV units
+(define_cpu_unit "znver4-idiv" "znver4_idiv")
+(define_cpu_unit "znver4-fdiv" "znver4_fdiv")
+
+;; Separate fp store and fp-to-int store. Although there are 2 store pipes, the
+;; throughput is limited to only one per cycle.
+(define_cpu_unit "znver4-fp-st

[gcc r14-9517] testsuite: Fix excess errors for new modules testcases on powerpc [PR114320]

2024-03-18 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:6cb5ef37c2fac240b68d8ee438aba4885956269f

commit r14-9517-g6cb5ef37c2fac240b68d8ee438aba4885956269f
Author: Nathaniel Shead 
Date:   Sat Mar 16 00:11:25 2024 +1100

testsuite: Fix excess errors for new modules testcases on powerpc [PR114320]

On some configurations, PowerPC emits -Wpsabi warnings when using IEEE
long doubles on a machine configured with IBM long double by default.
This patch suppresses these warnings for this testcase.

PR testsuite/114320

gcc/testsuite/ChangeLog:

* g++.dg/modules/target-powerpc-1_a.C: Suppress -Wpsabi.
* g++.dg/modules/target-powerpc-1_b.C: Likewise.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/testsuite/g++.dg/modules/target-powerpc-1_a.C | 2 +-
 gcc/testsuite/g++.dg/modules/target-powerpc-1_b.C | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/modules/target-powerpc-1_a.C 
b/gcc/testsuite/g++.dg/modules/target-powerpc-1_a.C
index 693ed101ed5..01709e0eac0 100644
--- a/gcc/testsuite/g++.dg/modules/target-powerpc-1_a.C
+++ b/gcc/testsuite/g++.dg/modules/target-powerpc-1_a.C
@@ -1,7 +1,7 @@
 // PR c++/98645
 // { dg-do compile { target powerpc*-*-* } }
 // { dg-require-effective-target ppc_float128_sw }
-// { dg-additional-options "-fmodules-ts -mfloat128 -mabi=ieeelongdouble" }
+// { dg-additional-options "-fmodules-ts -mfloat128 -mabi=ieeelongdouble 
-Wno-psabi" }
 
 export module M;
 export __ibm128 i = 0.0;
diff --git a/gcc/testsuite/g++.dg/modules/target-powerpc-1_b.C 
b/gcc/testsuite/g++.dg/modules/target-powerpc-1_b.C
index d6b684b556d..b4209bc1550 100644
--- a/gcc/testsuite/g++.dg/modules/target-powerpc-1_b.C
+++ b/gcc/testsuite/g++.dg/modules/target-powerpc-1_b.C
@@ -1,7 +1,7 @@
 // PR c++/98645
 // { dg-module-do compile { target powerpc*-*-* } }
 // { dg-require-effective-target ppc_float128_sw }
-// { dg-additional-options "-fmodules-ts -mfloat128 -mabi=ieeelongdouble" }
+// { dg-additional-options "-fmodules-ts -mfloat128 -mabi=ieeelongdouble 
-Wno-psabi" }
 
 import M;


[gcc r12-10221] libstdc++: Add missing std::tuple constructor [PR114147]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:fbdeeb1604d52a8ece8631f70ecd64d925d31741

commit r12-10221-gfbdeeb1604d52a8ece8631f70ecd64d925d31741
Author: Jonathan Wakely 
Date:   Fri Mar 1 11:16:58 2024 +

libstdc++: Add missing std::tuple constructor [PR114147]

I caused a regression with commit r10-908 by adding a constraint to the
non-explicit allocator-extended default constructor, but seemingly
forgot to add an explicit overload with the corresponding constraint.

libstdc++-v3/ChangeLog:

PR libstdc++/114147
* include/std/tuple (tuple::tuple(allocator_arg_t, const Alloc&)):
Add missing overload of allocator-extended default constructor.
(tuple::tuple(allocator_arg_t, const Alloc&)): Likewise.
* testsuite/20_util/tuple/cons/114147.cc: New test.

(cherry picked from commit 0a545ac7000501844670add0b3560ebdbcb123c6)

Diff:
---
 libstdc++-v3/include/std/tuple  | 14 ++
 libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc | 15 +++
 2 files changed, 29 insertions(+)

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 6d0060a191c..04b77113a84 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -801,6 +801,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
 
+  template::value> = false>
+   _GLIBCXX20_CONSTEXPR
+   explicit
+   tuple(allocator_arg_t __tag, const _Alloc& __a)
+   : _Inherited(__tag, __a) { }
+
   template= 1),
   _ImplicitCtor<_NotEmpty, const _Elements&...> = true>
_GLIBCXX20_CONSTEXPR
@@ -1155,6 +1162,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
 
+  template::value, _T1, _T2> = false>
+   _GLIBCXX20_CONSTEXPR
+   explicit
+   tuple(allocator_arg_t __tag, const _Alloc& __a)
+   : _Inherited(__tag, __a) { }
+
   template = true>
_GLIBCXX20_CONSTEXPR
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc 
b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
new file mode 100644
index 000..916e7204964
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+
+// PR libstdc++/114147
+// tuple allocator-extended ctor requires non-explicit default ctor
+
+#include 
+#include 
+
+struct X { explicit X(); };
+
+std::allocator a;
+std::tuple t0(std::allocator_arg, a);
+std::tuple t1(std::allocator_arg, a);
+std::tuple t2(std::allocator_arg, a);
+std::tuple t3(std::allocator_arg, a);


[gcc r12-10222] libstdc++: Simplify lifetime of eh_globals variable [PR107500]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d9076dafa12c93e96b349035fb59050151403866

commit r12-10222-gd9076dafa12c93e96b349035fb59050151403866
Author: Jonathan Wakely 
Date:   Thu Nov 3 11:48:57 2022 +

libstdc++: Simplify lifetime of eh_globals variable [PR107500]

Since this is a trivial type, we probably don't need to do anything to
ensure it's still accessible after other static dtors.

libstdc++-v3/ChangeLog:

PR libstdc++/107500
* libsupc++/eh_globals.cc (eh_globals): Remove immortalizing
wrapper.
(__cxxabiv1::__cxa_get_globals_fast): Adjust.
(__cxxabiv1::__cxa_get_globals): Adjust.

(cherry picked from commit 418999fe382c608facf57f96b53a9cb12d2fdd20)

Diff:
---
 libstdc++-v3/libsupc++/eh_globals.cc | 21 +
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/libsupc++/eh_globals.cc 
b/libstdc++-v3/libsupc++/eh_globals.cc
index 0aadb692a96..74e8a454ecc 100644
--- a/libstdc++-v3/libsupc++/eh_globals.cc
+++ b/libstdc++-v3/libsupc++/eh_globals.cc
@@ -70,19 +70,8 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 
 namespace
 {
-  struct constant_init
-  {
-union {
-  unsigned char unused;
-  __cxa_eh_globals obj;
-};
-constexpr constant_init() : obj() { }
-
-~constant_init() { /* do nothing, union member is not destroyed */ }
-  };
-
   // Single-threaded fallback buffer.
-  __constinit constant_init eh_globals;
+  __constinit __cxa_eh_globals eh_globals;
 }
 
 #if __GTHREADS
@@ -143,7 +132,7 @@ __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
   if (init._S_init)
 g = static_cast<__cxa_eh_globals*>(__gthread_getspecific(init._M_key));
   else
-g = &eh_globals.obj;
+g = &eh_globals;
   return g;
 }
 
@@ -168,7 +157,7 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
}
 }
   else
-g = &eh_globals.obj;
+g = &eh_globals;
   return g;
 }
 
@@ -176,11 +165,11 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
 
 extern "C" __cxa_eh_globals*
 __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW
-{ return &eh_globals.obj; }
+{ return &eh_globals; }
 
 extern "C" __cxa_eh_globals*
 __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW
-{ return &eh_globals.obj; }
+{ return &eh_globals; }
 
 #endif


[gcc r12-10223] libstdc++: Update outdated docs on contributing

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:57f4c935f915454879a0d13f0319ba09c9c01309

commit r12-10223-g57f4c935f915454879a0d13f0319ba09c9c01309
Author: Jonathan Wakely 
Date:   Wed Feb 28 11:24:47 2024 +

libstdc++: Update outdated docs on contributing

We don't want a separate ChangeLog submission now.

libstdc++-v3/ChangeLog:

* doc/xml/manual/appendix_contributing.xml: Replace outdated
info on ChangeLog entries.
* doc/html/manual/appendix_contributing.html: Regenerate.

(cherry picked from commit 7c7c937b5e71cf2b53f462cfa6a1df39b5538cee)

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

diff --git a/libstdc++-v3/doc/html/manual/appendix_contributing.html 
b/libstdc++-v3/doc/html/manual/appendix_contributing.html
index 8be678eb919..2d04cadd4e8 100644
--- a/libstdc++-v3/doc/html/manual/appendix_contributing.html
+++ b/libstdc++-v3/doc/html/manual/appendix_contributing.html
@@ -79,19 +79,19 @@
  bug. For new features a description of the feature and your
  implementation.

- A ChangeLog entry as plain text; see the various
- ChangeLog files for format and content. If you are
- using emacs as your editor, simply position the insertion
- point at the beginning of your change and hit CX-4a to bring
- up the appropriate ChangeLog entry. See--magic! Similar
- functionality also exists for vi.
+ A ChangeLog entry as part of the Git commit message. Check
+ some recent commits for format and content. The
+ contrib/mklog.py script can be used to
+ generate a ChangeLog template for commit messages. See
+ http://gcc.gnu.org/gitwrite.html"; 
target="_top">Read-write Git access
+ for scripts and aliases that are useful here.

  A testsuite submission or sample program that will
  easily and simply show the existing error or test new
  functionality.

  The patch itself. If you are using the Git repository use
- git diff or git format-patch
+ git show or git format-patch
  to produce a patch;
  otherwise, use diff -cp OLD 
NEW. If your
  version of diff does not support these options, then get the
@@ -102,6 +102,8 @@
  patches and related discussion should be sent to the
  libstdc++ mailing list. In common with the rest of GCC,
  patches should also be sent to the gcc-patches mailing list.
+ So you could send your email To:libstd...@gcc.gnu.org and
+ Cc:gcc-patc...@gcc.gnu.org for example.
Prev Up NextPart IV. 
   Appendices
  Home 
Directory Layout and Source Conventions
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml 
b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
index ceb21f4478a..074baf0fb4d 100644
--- a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
+++ b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
@@ -151,12 +151,12 @@
 
   

- A ChangeLog entry as plain text; see the various
- ChangeLog files for format and content. If you are
- using emacs as your editor, simply position the insertion
- point at the beginning of your change and hit CX-4a to bring
- up the appropriate ChangeLog entry. See--magic! Similar
- functionality also exists for vi.
+ A ChangeLog entry as part of the Git commit message. Check
+ some recent commits for format and content. The
+ contrib/mklog.py script can be used to
+ generate a ChangeLog template for commit messages. See
+ http://www.w3.org/1999/xlink"; 
xlink:href="http://gcc.gnu.org/gitwrite.html";>Read-write Git access
+ for scripts and aliases that are useful here.

   
 
@@ -171,7 +171,7 @@
   

  The patch itself. If you are using the Git repository use
- git diff or git format-patch
+ git show or git format-patch
  to produce a patch;
  otherwise, use diff -cp OLD NEW. If your
  version of diff does not support these options, then get the
@@ -186,6 +186,8 @@
  patches and related discussion should be sent to the
  libstdc++ mailing list. In common with the rest of GCC,
  patches should also be sent to the gcc-patches mailing list.
+ So you could send your email To:libstd...@gcc.gnu.org and
+ Cc:gcc-patc...@gcc.gnu.org for example.

   
 


[gcc r12-10224] libstdc++: Change some URLs in the manual to use https

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:7b9fa0982f4db0a64aacfe5018708a89f956245a

commit r12-10224-g7b9fa0982f4db0a64aacfe5018708a89f956245a
Author: Jonathan Wakely 
Date:   Wed Feb 28 14:36:28 2024 +

libstdc++: Change some URLs in the manual to use https

libstdc++-v3/ChangeLog:

* doc/xml/manual/appendix_contributing.xml: Change URLs to use
https.
* doc/html/manual/*: Regenerate.

(cherry picked from commit 06866bc368f828fa4f3dad25588d038414944c2e)

Diff:
---
 libstdc++-v3/doc/html/manual/appendix_contributing.html |  8 
 libstdc++-v3/doc/html/manual/source_code_style.html |  4 ++--
 libstdc++-v3/doc/xml/manual/appendix_contributing.xml   | 12 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/appendix_contributing.html 
b/libstdc++-v3/doc/html/manual/appendix_contributing.html
index 2d04cadd4e8..25d0944e187 100644
--- a/libstdc++-v3/doc/html/manual/appendix_contributing.html
+++ b/libstdc++-v3/doc/html/manual/appendix_contributing.html
@@ -10,7 +10,7 @@
 Table of 
ContentsContributor 
ChecklistReadingAssignmentGetting 
SourcesSubmitting 
PatchesDirectory Layout and Source 
ConventionsCoding StyleBad 
IdentifiersBy 
ExampleDesign Notes
   The GNU C++ Library is part of GCC and follows the same development model,
   so the general rules for
-  http://gcc.gnu.org/contribute.html"; 
target="_top">contributing
+  https://gcc.gnu.org/contribute.html"; 
target="_top">contributing
   to GCC apply. Active
   contributors are assigned maintainership responsibility, and given
   write access to the source repository. First-time contributors
@@ -34,7 +34,7 @@
  http://www.open-std.org/jtc1/sc22/wg21/"; 
target="_top">http://www.open-std.org/jtc1/sc22/wg21

  Peruse
- the http://www.gnu.org/prep/standards/"; 
target="_top">GNU
+ the https://www.gnu.org/prep/standards/"; 
target="_top">GNU
  Coding Standards, and chuckle when you hit the part
  about “Using Languages Other 
Than C”.

@@ -46,7 +46,7 @@
  library-specific information found in
   Porting and Maintenance.
   Assignment
-  See the http://gcc.gnu.org/contribute.html#legal"; 
target="_top">legal prerequisites for all GCC contributions.
+  See the https://gcc.gnu.org/contribute.html#legal"; 
target="_top">legal prerequisites for all GCC contributions.
 
   Historically, the libstdc++ assignment form added the following
   question:
@@ -83,7 +83,7 @@
  some recent commits for format and content. The
  contrib/mklog.py script can be used to
  generate a ChangeLog template for commit messages. See
- http://gcc.gnu.org/gitwrite.html"; 
target="_top">Read-write Git access
+ https://gcc.gnu.org/gitwrite.html"; 
target="_top">Read-write Git access
  for scripts and aliases that are useful here.

  A testsuite submission or sample program that will
diff --git a/libstdc++-v3/doc/html/manual/source_code_style.html 
b/libstdc++-v3/doc/html/manual/source_code_style.html
index 24e0d693127..1c0d00a5df8 100644
--- a/libstdc++-v3/doc/html/manual/source_code_style.html
+++ b/libstdc++-v3/doc/html/manual/source_code_style.html
@@ -197,13 +197,13 @@
   it is intended to precede the recommendations of the GNU Coding
   Standard, which can be referenced in full here:
 
-  http://www.gnu.org/prep/standards/standards.html#Formatting"; 
target="_top">http://www.gnu.org/prep/standards/standards.html#Formatting
+  https://www.gnu.org/prep/standards/standards.html#Formatting"; 
target="_top">https://www.gnu.org/prep/standards/standards.html#Formatting
 
   The rest of this is also interesting reading, but skip the "Design
   Advice" part.
 
   The GCC coding conventions are here, and are also useful:
-  http://gcc.gnu.org/codingconventions.html"; 
target="_top">http://gcc.gnu.org/codingconventions.html
+  https://gcc.gnu.org/codingconventions.html"; 
target="_top">https://gcc.gnu.org/codingconventions.html
 
   In addition, because it doesn't seem to be stated explicitly anywhere
   else, there is an 80 column source limit.
diff --git a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml 
b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
index 074baf0fb4d..2509330d807 100644
--- a/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
+++ b/libstdc++-v3/doc/xml/manual/appendix_contributing.xml
@@ -20,7 +20,7 @@
 
   The GNU C++ Library is part of GCC and follows the same development model,
   so the general rules for
-  http://www.w3.org/1999/xlink"; 
xlink:href="http://gcc.gnu.org/contribute.html";>contributing
+  http://www.w3.org/1999/xlink"; 
xlink:href="https://gcc.gnu.org/contribute.html";>contributing
   to GCC apply. Active
   contributors are assigned maintainership responsibility, and given
   write access to the source repository. First-time con

[gcc r12-10225] libstdc++: Move test error_category to global scope

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:a0bca5584725153ad560b97a33a07e3c56f6f953

commit r12-10225-ga0bca5584725153ad560b97a33a07e3c56f6f953
Author: Jonathan Wakely 
Date:   Wed Mar 13 10:02:12 2024 +

libstdc++: Move test error_category to global scope

A recent GDB change causes this test to fail due to missing RTTI for the
custom_cast type. This is presumably because the custom_cat type was
defined as a local class, so has no linkage. Moving it to local scope
seems to fix the test regressions, and probably makes the test more
realistic as a local class with no linkage isn't practical to use as an
error category that almost certainly needs to be referred to in other
scopes.

libstdc++-v3/ChangeLog:

* testsuite/libstdc++-prettyprinters/cxx11.cc: Move custom_cat
to namespace scope.

(cherry picked from commit a8c7c3a40953e34f57278d224a07dc3698c64a84)

Diff:
---
 libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc 
b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
index f97640a0189..c79f0fab602 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
@@ -63,6 +63,11 @@ struct datum
 
 std::unique_ptr global;
 
+struct custom_cat : std::error_category {
+  const char* name() const noexcept { return "miaow"; }
+  std::string message(int) const { return ""; }
+};
+
 int
 main()
 {
@@ -179,10 +184,7 @@ main()
   std::error_condition ecinval = 
std::make_error_condition(std::errc::invalid_argument);
   // { dg-final { note-test ecinval {std::error_condition = {"generic": 
EINVAL}} } }
 
-  struct custom_cat : std::error_category {
-const char* name() const noexcept { return "miaow"; }
-std::string message(int) const { return ""; }
-  } cat;
+  custom_cat cat;
   std::error_code emiaow(42, cat);
   // { dg-final { note-test emiaow {std::error_code = {custom_cat: 42}} } }
   std::error_condition ecmiaow(42, cat);


[gcc r12-10227] libstdc++: Fix access error in __gnu_test::uneq_allocator

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:80e88183d47ca4d7c8441355f736fc918d7d05dc

commit r12-10227-g80e88183d47ca4d7c8441355f736fc918d7d05dc
Author: Jonathan Wakely 
Date:   Thu Nov 23 14:34:59 2023 +

libstdc++: Fix access error in __gnu_test::uneq_allocator

The operator== function is only a friend of the LHS argument, so cannot
access the private member of the RHS argument. Use the public accessor
instead.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_allocator.h (uneq_allocator): Fix
equality operator for heterogeneous comparisons.

(cherry picked from commit 0585daf7de0673ade9feca1be66a68178786b48d)

Diff:
---
 libstdc++-v3/testsuite/util/testsuite_allocator.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h 
b/libstdc++-v3/testsuite/util/testsuite_allocator.h
index f33f602d2af..0c41181b4a5 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -418,7 +418,7 @@ namespace __gnu_test
operator==(const uneq_allocator& a,
   const uneq_allocator::other>& b)
-   { return a.personality == b.personality; }
+   { return a.personality == b.get_personality(); }
 
   template
friend inline bool


[gcc r12-10229] libstdc++: Fix std::tr2::dynamic_bitset support for alternate characters

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:22273b87425aa5bccf756ff8b1887dd6d4541588

commit r12-10229-g22273b87425aa5bccf756ff8b1887dd6d4541588
Author: Jonathan Wakely 
Date:   Sat Nov 18 21:09:53 2023 +

libstdc++: Fix std::tr2::dynamic_bitset support for alternate characters

libstdc++-v3/ChangeLog:

* include/tr2/dynamic_bitset (dynamic_bitset): Pass zero and one
characters to _M_copy_from_string.
* testsuite/tr2/dynamic_bitset/string.cc: New test.

(cherry picked from commit 49f7620a12e35f40bb1f6088d16bde9b061dc819)

Diff:
---
 libstdc++-v3/include/tr2/dynamic_bitset|  2 +-
 .../testsuite/tr2/dynamic_bitset/string.cc | 36 ++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/tr2/dynamic_bitset 
b/libstdc++-v3/include/tr2/dynamic_bitset
index 4023b3882cb..0d2160d611d 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset
+++ b/libstdc++-v3/include/tr2/dynamic_bitset
@@ -622,7 +622,7 @@ namespace tr2
  // Watch for npos.
  this->_M_Nb = (__n > __str.size() ? __str.size() - __pos : __n);
  this->resize(this->_M_Nb);
- this->_M_copy_from_string(__str, __pos, __n);
+ this->_M_copy_from_string(__str, __pos, __n, __zero, __one);
}
 
   /**
diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc 
b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc
new file mode 100644
index 000..c7d0efac35f
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/string.cc
@@ -0,0 +1,36 @@
+// { dg-do run { target c++11 } }
+
+#include 
+#include 
+#include 
+
+void
+test_string_ctor()
+{
+  std::tr2::dynamic_bitset<> b("101001");
+  VERIFY( b[0] == true );
+  VERIFY( b[1] == false );
+  VERIFY( b[2] == false );
+  VERIFY( b[3] == true );
+  VERIFY( b[4] == false );
+  VERIFY( b[5] == true );
+}
+
+void
+test_alt_chars()
+{
+  std::string str = "xOIOIOIOx";
+  std::tr2::dynamic_bitset<> b(str, 1, 6, 'I', 'O');
+  VERIFY( b[0] == false );
+  VERIFY( b[1] == true );
+  VERIFY( b[2] == false );
+  VERIFY( b[3] == true );
+  VERIFY( b[4] == false );
+  VERIFY( b[5] == true );
+}
+
+int main()
+{
+  test_string_ctor();
+  test_alt_chars();
+}


[gcc r12-10226] libstdc++: Correct notes about std::call_once in manual [PR66146]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:415457babf04d077929956ea97132448b0dc4b2c

commit r12-10226-g415457babf04d077929956ea97132448b0dc4b2c
Author: Jonathan Wakely 
Date:   Thu Mar 14 11:52:17 2024 +

libstdc++: Correct notes about std::call_once in manual [PR66146]

The bug with exceptions thrown during a std::call_once call affects all
targets, so fix the docs that say it only affects non-Linux targets.

libstdc++-v3/ChangeLog:

PR libstdc++/66146
* doc/xml/manual/status_cxx2011.xml: Remove mention of Linux in
note about std::call_once.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

(cherry picked from commit e6836bbbd7a01af0791c02087e568b4822418c0d)

Diff:
---
 libstdc++-v3/doc/html/manual/status.html   | 6 +++---
 libstdc++-v3/doc/xml/manual/status_cxx2011.xml | 2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2014.xml | 2 +-
 libstdc++-v3/doc/xml/manual/status_cxx2017.xml | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/status.html 
b/libstdc++-v3/doc/html/manual/status.html
index 76d7d58a831..a6494912c07 100644
--- a/libstdc++-v3/doc/html/manual/status.html
+++ b/libstdc++-v3/doc/html/manual/status.html
@@ -217,7 +217,7 @@ not in any particular release.
30
   
Thread support
-  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.2Locks  
30.4.2.1Class template 
lock_guardY 30.4.2.2Class template unique_lockY 30.4.3Generic locking algorithmsY 30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceYException support is broken on non
 -Linux targets.
+  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.2Locks  
30.4.2.1Class template 
lock_guardY 30.4.2.2Class template unique_lockY 30.4.3Generic locking algorithmsY 30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceYException support is broken.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146"; target="_top">PR
66146.
   30.5Condition 
variablesY 30.5.1Class condition_variableY 30.5.2Class 
condition_variable_anyY 30.6Futures  
30.6.1Overview  30.6.2Error handlingY 30.6.3Class future_errorY 
30.6.4Shared stateY 
30.6.5Class template promiseY 
30.6.6Class template futureY 
30.6.7Class template shared_futureY 
30.6.8Function template 
asyncY 
30.6.9Class template packaged_taskY 

@@ -490,7 +490,7 @@ not in any particular release.
30
   
Thread support
-  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.1.4Shared timed mutex types 
 30.4.1.4.1Class shared_timed_mutexY 30.4.2Locks  30.4.2.1Class template lock_guardY 30.4.2.2Class template unique_lockY 
30.4.2.3Class template 
shared_lockY 30.4.3Generic locking algorithmsY <
 td align="left">30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceBrokenException support is broken on non-Linux targets.
+  30.1GeneralY 30.2RequirementsY 30.3Threads  30.3.1Class threadPartialthread::id 
comparisons not well-defined30.3.2Namespace this_threadY 30.4Mutual exclusion 
 30.4.1Mutex requirements  
30.4.1.1In general 
 30.4.1.2Mutex types  
30.4.1.2.1Class mutexY 
30.4.1.2.2Class recursive_mutexY 30.4.1.3Timed mutex types  
30.4.1.3.1Class timed_mutexY 
30.4.1.3.2Class recursive_timed_mutexY 30.
 4.1.4Shared timed mutex types 
 30.4.1.4.1Class shared_timed_mutexY 30.4.2Locks  30.4.2.1Class template lock_guardY 30.4.2.2Class template unique_lockY 
30.4.2.3Class template 
shared_lockY 30.4.3Generic locking algorithmsY <
 td align="left">30.4.4Call once 
 30.4.4.1Struct once_flagY 30.4.4.2Function call_onceBrokenException support is broken.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146"; target="_top">PR
66146.
   30.5Condition 
variablesY 30.5.1Class condition_variableY 30.5.2Class 
condition_variable_anyY 30.6Futures  
30.6.1O

[gcc r12-10230] libstdc++: Fix warning during configure

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:96e7603bf662010d282d739841c133e0723a2d39

commit r12-10230-g96e7603bf662010d282d739841c133e0723a2d39
Author: Jonathan Wakely 
Date:   Wed Nov 1 14:20:33 2023 +

libstdc++: Fix warning during configure

The checks for snprintf give a -Wformat warning due to a missing
argument.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_C99): Fix snprintf checks.
* configure: Regenerate.

(cherry picked from commit 8a4cde6319b40802a842a8fe71267524dd8af828)

Diff:
---
 libstdc++-v3/acinclude.m4 | 4 ++--
 libstdc++-v3/configure| 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 321065aff72..c25e8a70638 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -978,7 +978,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }], [],
 [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no])
 ])
@@ -1210,7 +1210,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }], [],
 [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
 ])
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index b371f422ff3..67cae65c533 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -17573,7 +17573,7 @@ else
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }
 int
 main ()
@@ -17604,7 +17604,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }
 int
 main ()
@@ -18249,7 +18249,7 @@ else
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }
 int
 main ()
@@ -18280,7 +18280,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
vscanf("%i", args);
vsnprintf(fmt, 0, "%i", args);
vsscanf(fmt, "%i", args);
-   snprintf(fmt, 0, "%i");
+   snprintf(fmt, 0, "%i", 1);
  }
 int
 main ()


[gcc r12-10231] libstdc++: Ensure active union member is correctly set

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:bfe05fbb30594b9f1fdfba32f3fc7b317e5158e0

commit r12-10231-gbfe05fbb30594b9f1fdfba32f3fc7b317e5158e0
Author: Nathaniel Shead 
Date:   Fri Sep 29 10:30:41 2023 +0100

libstdc++: Ensure active union member is correctly set

This patch ensures that the union members for std::string and
std::variant are always properly set when a change occurs.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: (basic_string(basic_string&&)):
Activate _M_local_buf when needed.
(basic_string(basic_string&&, const _Alloc&)): Likewise.
* include/bits/basic_string.tcc: (basic_string::swap): Likewise.
* include/std/variant: (__detail::__variant::__construct_n): New.
(__detail::__variant::__emplace): Use __construct_n.

Signed-off-by: Nathaniel Shead 
(cherry picked from commit 28adad7a32ed92a3c0906b38411c4ed686bbacc5)

Diff:
---
 libstdc++-v3/include/bits/basic_string.h   |  6 --
 libstdc++-v3/include/bits/basic_string.tcc |  4 
 libstdc++-v3/include/std/variant   | 32 --
 3 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index 9a6fe883b6c..3f38f20dd18 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -680,6 +680,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   {
if (__str._M_is_local())
  {
+   (void)_M_use_local_data();
traits_type::copy(_M_local_buf, __str._M_local_buf,
  __str.length() + 1);
  }
@@ -693,7 +694,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
// basic_stringbuf relies on writing into unallocated capacity so
// we mess up the contents if we put a '\0' in the string.
_M_length(__str.length());
-   __str._M_data(__str._M_local_data());
+   __str._M_data(__str._M_use_local_data());
__str._M_set_length(0);
   }
 
@@ -719,6 +720,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   {
if (__str._M_is_local())
  {
+   (void)_M_use_local_data();
traits_type::copy(_M_local_buf, __str._M_local_buf,
  __str.length() + 1);
_M_length(__str.length());
@@ -730,7 +732,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_data(__str._M_data());
_M_length(__str.length());
_M_capacity(__str._M_allocated_capacity);
-   __str._M_data(__str._M_local_buf);
+   __str._M_data(__str._M_use_local_data());
__str._M_set_length(0);
  }
else
diff --git a/libstdc++-v3/include/bits/basic_string.tcc 
b/libstdc++-v3/include/bits/basic_string.tcc
index 48fa28e6466..24465dab102 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -79,6 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  }
else if (__s.length())
  {
+   (void)_M_use_local_data();
traits_type::copy(_M_local_buf, __s._M_local_buf,
  __s.length() + 1);
_M_length(__s.length());
@@ -87,6 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  }
else if (length())
  {
+   (void)__s._M_use_local_data();
traits_type::copy(__s._M_local_buf, _M_local_buf,
  length() + 1);
__s._M_length(length());
@@ -97,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
else
  {
const size_type __tmp_capacity = __s._M_allocated_capacity;
+   (void)__s._M_use_local_data();
traits_type::copy(__s._M_local_buf, _M_local_buf,
  length() + 1);
_M_data(__s._M_data());
@@ -108,6 +111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  const size_type __tmp_capacity = _M_allocated_capacity;
  if (__s._M_is_local())
{
+ (void)_M_use_local_data();
  traits_type::copy(_M_local_buf, __s._M_local_buf,
__s.length() + 1);
  __s._M_data(_M_data());
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 2e784c744d3..64145da12bb 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -321,6 +321,33 @@ namespace __variant
 __get(_Variant&& __v) noexcept
 { return __variant::__get_n<_Np>(std::forward<_Variant>(__v)._M_u); }
 
+  // Gets the _Uninitialized to construct into for __u.
+  template
+constexpr decltype(auto)
+__construct_n(_Union& __u) noexcept
+{
+  if constexpr (_Np == 0)
+   return &__u._M_first;
+  else if constexpr (_Np == 1)
+   {
+ std::_Construct(&__u._M_rest);
+ return &__u._M_rest._M_first;
+   }
+  else if constexpr (_

[gcc r12-10232] libstdc++: Fix unconditional -Werror in libbacktrace directory

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:02a64d50d7780184428630e748fc301cb04ef96b

commit r12-10232-g02a64d50d7780184428630e748fc301cb04ef96b
Author: Alexey Lapshin 
Date:   Fri Sep 8 11:23:16 2023 +0100

libstdc++: Fix unconditional -Werror in libbacktrace directory

The -Werror flag should depend on the --enable-werror configure option.

libstdc++-v3/ChangeLog:

* src/libbacktrace/Makefile.am: Remove -Werror.
* src/libbacktrace/Makefile.in: Regenerate.

(cherry picked from commit 1a0c6decd2112267c88438466df2e1c46b20248e)

Diff:
---
 libstdc++-v3/src/libbacktrace/Makefile.am | 2 +-
 libstdc++-v3/src/libbacktrace/Makefile.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/libbacktrace/Makefile.am 
b/libstdc++-v3/src/libbacktrace/Makefile.am
index d8221c2c65a..94bbdb88b52 100644
--- a/libstdc++-v3/src/libbacktrace/Makefile.am
+++ b/libstdc++-v3/src/libbacktrace/Makefile.am
@@ -45,7 +45,7 @@ libstdc___libbacktrace_la_CPPFLAGS = \
$(BACKTRACE_CPPFLAGS)
 
 WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
--Wcast-qual -Werror
+-Wcast-qual
 C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes 
-Wold-style-definition -Wno-unused-but-set-variable
 CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter
 AM_CFLAGS = \
diff --git a/libstdc++-v3/src/libbacktrace/Makefile.in 
b/libstdc++-v3/src/libbacktrace/Makefile.in
index a7eb4d69cde..ad4fe7ae4a8 100644
--- a/libstdc++-v3/src/libbacktrace/Makefile.in
+++ b/libstdc++-v3/src/libbacktrace/Makefile.in
@@ -368,7 +368,7 @@ VTV_CXXFLAGS = @VTV_CXXFLAGS@
 VTV_CXXLINKFLAGS = @VTV_CXXLINKFLAGS@
 VTV_PCH_CXXFLAGS = @VTV_PCH_CXXFLAGS@
 WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
--Wcast-qual -Werror
+-Wcast-qual
 
 XMLCATALOG = @XMLCATALOG@
 XMLLINT = @XMLLINT@


[gcc r12-10233] libstdc++: Update outdated default -std in testing docs

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:8364faf223e54c0ddf7ab35eda158533e5195bb6

commit r12-10233-g8364faf223e54c0ddf7ab35eda158533e5195bb6
Author: Jonathan Wakely 
Date:   Fri Sep 8 16:28:06 2023 +0100

libstdc++: Update outdated default -std in testing docs

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Update reference to -std=gnu++14 as
the default.
* doc/html/manual/test.html: Regenerate.

(cherry picked from commit d8e351d8d656720f4037e0a86a4a6c73629e5307)

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

diff --git a/libstdc++-v3/doc/html/manual/test.html 
b/libstdc++-v3/doc/html/manual/test.html
index ef56a305687..168e247c52f 100644
--- a/libstdc++-v3/doc/html/manual/test.html
+++ b/libstdc++-v3/doc/html/manual/test.html
@@ -452,7 +452,7 @@ cat 27_io/objects/char/3_xin.in | a.outc++11_only. However, 
this means
 the test will be skipped by default (because the default mode is
-gnu++14), and so will only run when
+gnu++17), and so will only run when
 -std=gnu++11 or -std=c++11 is used
 explicitly. For tests that require a specific standard it is better to
 use a dg-options directive:
@@ -466,13 +466,13 @@ cat 27_io/objects/char/3_xin.in | 
a.outdg-options instead of (or in 
addition to)
 an effective target, so that they are not skipped by default.
-For example, tests for C++17 features should use
-// { dg-options "-std=gnu++17" }
+For example, tests for C++20 features should use
+// { dg-options "-std=gnu++20" }
 before any dg-do such as:
-// { dg-do run "c++17" }
+// { dg-do run { target c++20 } }
 The dg-options directive must come first, so 
that
 the -std flag has already been added to the 
options
-before checking the c++17 target.
+before checking the c++20 effective target.
   Examples of Test 
Directives
 Example 1: Testing compilation only:
 
diff --git a/libstdc++-v3/doc/xml/manual/test.xml 
b/libstdc++-v3/doc/xml/manual/test.xml
index ee00b06e385..17666114810 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -749,7 +749,7 @@ cat 27_io/objects/char/3_xin.in | a.out
 be run for a specific standard (and not later standards) using an
 effective target like c++11_only. However, this means
 the test will be skipped by default (because the default mode is
-gnu++14), and so will only run when
+gnu++17), and so will only run when
 -std=gnu++11 or -std=c++11 is used
 explicitly. For tests that require a specific standard it is better to
 use a dg-options directive:
@@ -765,13 +765,13 @@ cat 27_io/objects/char/3_xin.in | a.out
 Similarly, tests which depend on a newer standard than the default
 must use dg-options instead of (or in addition to)
 an effective target, so that they are not skipped by default.
-For example, tests for C++17 features should use
-// { dg-options "-std=gnu++17" }
+For example, tests for C++20 features should use
+// { dg-options "-std=gnu++20" }
 before any dg-do such as:
-// { dg-do run "c++17" }
+// { dg-do run { target c++20 } }
 The dg-options directive must come first, so that
 the -std flag has already been added to the options
-before checking the c++17 target.
+before checking the c++20 effective target.
   
 
 Examples of Test 
Directives


[gcc r12-10234] libstdc++: Fix some -Wmismatched-tags warnings

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:fe1c4d6cce6a35c0800f26d87c411a34cb9472bb

commit r12-10234-gfe1c4d6cce6a35c0800f26d87c411a34cb9472bb
Author: Jonathan Wakely 
Date:   Tue Aug 8 22:07:29 2023 +0100

libstdc++: Fix some -Wmismatched-tags warnings

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (atomic): Change class-head
to struct.
* include/bits/stl_tree.h (_Rb_tree_merge_helper): Change
class-head to struct in friend declaration.
* include/std/future (_Task_state_base, _Task_state): Likewise.
* include/std/scoped_allocator (__inner_type_impl): Likewise.
* include/std/valarray (_BinClos, _SClos, _GClos, _IClos)
(_ValFunClos, _RefFunClos): Change class-head to struct.

(cherry picked from commit 5b46eacc4949ec62ee718b172cf8eb056ff27654)

Diff:
---
 libstdc++-v3/include/bits/shared_ptr_atomic.h |  8 
 libstdc++-v3/include/bits/stl_tree.h  |  2 +-
 libstdc++-v3/include/std/future   |  4 ++--
 libstdc++-v3/include/std/scoped_allocator |  4 ++--
 libstdc++-v3/include/std/valarray | 12 ++--
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h 
b/libstdc++-v3/include/bits/shared_ptr_atomic.h
index 94570cd3ab3..e903fe89424 100644
--- a/libstdc++-v3/include/bits/shared_ptr_atomic.h
+++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h
@@ -356,7 +356,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #if __cplusplus >= 202002L
 # define __cpp_lib_atomic_shared_ptr 201711L
   template
-class atomic;
+struct atomic;
 
   template
 static constexpr bool __is_shared_ptr = false;
@@ -368,7 +368,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 {
   using value_type = _Tp;
 
-  friend class atomic<_Tp>;
+  friend struct atomic<_Tp>;
 
   // An atomic version of __shared_count<> and __weak_count<>.
   // Stores a _Sp_counted_base<>* but uses the LSB as a lock.
@@ -602,7 +602,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 };
 
   template
-class atomic>
+struct atomic>
 {
 public:
   using value_type = shared_ptr<_Tp>;
@@ -725,7 +725,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 };
 
   template
-class atomic>
+struct atomic>
 {
 public:
   using value_type = weak_ptr<_Tp>;
diff --git a/libstdc++-v3/include/bits/stl_tree.h 
b/libstdc++-v3/include/bits/stl_tree.h
index 7a352c17b22..6ced03252bc 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -1555,7 +1555,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>;
 
   template
-   friend class _Rb_tree_merge_helper;
+   friend struct _Rb_tree_merge_helper;
 
   /// Merge from a compatible container into one with unique keys.
   template
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index a1b2d7f1d3a..f1fa16c8649 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -623,10 +623,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   class _Async_state_impl;
 
 template
-  class _Task_state_base;
+  struct _Task_state_base;
 
 template
-  class _Task_state;
+  struct _Task_state;
 
 template
diff --git a/libstdc++-v3/include/std/scoped_allocator 
b/libstdc++-v3/include/std/scoped_allocator
index f2e3ed9f783..8ad4c90b694 100644
--- a/libstdc++-v3/include/std/scoped_allocator
+++ b/libstdc++-v3/include/std/scoped_allocator
@@ -165,7 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return _M_inner == __other._M_inner; }
 
 private:
-  template friend class __inner_type_impl;
+  template friend struct __inner_type_impl;
   template friend class scoped_allocator_adaptor;
 
   __type _M_inner;
@@ -187,7 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 friend class scoped_allocator_adaptor;
 
   template
-friend class __inner_type_impl;
+   friend struct __inner_type_impl;
 
   tuple
   _M_tie() const noexcept
diff --git a/libstdc++-v3/include/std/valarray 
b/libstdc++-v3/include/std/valarray
index 6f800d1b367..32e6e7e8a76 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -60,22 +60,22 @@ namespace __detail
 template class _Meta1,
 template class _Meta2,
 class _Dom1, class _Dom2>
-class _BinClos;
+struct _BinClos;
 
   template class _Meta, class _Dom>
-class _SClos;
+struct _SClos;
 
   template class _Meta, class _Dom>
-class _GClos;
+struct _GClos;
 
   template class _Meta, class _Dom>
-class _IClos;
+struct _IClos;
 
   template class _Meta, class _Dom>
-class _ValFunClos;
+struct _ValFunClos;
 
   template class _Meta, class _Dom>
-class _RefFunClos;
+struct _RefFunClos;
 } // namespace __detail
 
   using __detail::_UnClos;


[gcc r12-10228] libstdc++: Fix uses of signed types with functions

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:ac0cf0786bb3da60f412afe800fd385686b9517d

commit r12-10228-gac0cf0786bb3da60f412afe800fd385686b9517d
Author: Jonathan Wakely 
Date:   Tue Nov 14 10:56:57 2023 +

libstdc++: Fix  uses of signed types with  functions

In  we pass the int __base parameter to our internal versions
of  functions, __bit_width and __countr_zero. Those functions are
only defined for unsigned types, so we need to convert the base to
unsigned. The base must be in the range [2,36] so we can mask off the
low bits and then convert that to unsigned, so that we don't need to
care about negative values becoming large unsigned values.

libstdc++-v3/ChangeLog:

* include/std/charconv (__from_chars_pow2_base): Convert base to
unsigned for call to __countr_zero.
(__from_chars_alnum): Likewise for call to __bit_width.

(cherry picked from commit 1c15303375f7089ff985b085ab877b11ebfbc4b7)

Diff:
---
 libstdc++-v3/include/std/charconv | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/std/charconv 
b/libstdc++-v3/include/std/charconv
index b4d37435fa0..365a22dab58 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -458,7 +458,7 @@ namespace __detail
 
   // __glibcxx_assert((__base & (__base - 1)) == 0);
   // __glibcxx_assert(_DecOnly ? __base <= 8 : __base <= 32);
-  const int __log2_base = __countr_zero(__base);
+  const int __log2_base = __countr_zero(unsigned(__base & 0x3f));
 
   const ptrdiff_t __len = __last - __first;
   ptrdiff_t __i = 0;
@@ -510,9 +510,9 @@ namespace __detail
 __from_chars_alnum(const char*& __first, const char* __last, _Tp& __val,
   int __base)
 {
-  // __glibcxx_assert(!_DecOnly || __base <= 10);
+  // __glibcxx_assert(_DecOnly ? __base <= 10 : __base <= 36);
 
-  const int __bits_per_digit = __bit_width(__base);
+  const int __bits_per_digit = __bit_width(unsigned(__base & 0x3f));
   int __unused_bits_lower_bound = __gnu_cxx::__int_traits<_Tp>::__digits;
   for (; __first != __last; ++__first)
{


[gcc r12-10235] libstdc++: Use rvalues in std::string::resize_and_overwrite (LWG 3645)

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:d063387b783f49f0d7868259424e7e548ad1e3c2

commit r12-10235-gd063387b783f49f0d7868259424e7e548ad1e3c2
Author: Jonathan Wakely 
Date:   Wed Mar 22 11:54:31 2023 +

libstdc++: Use rvalues in std::string::resize_and_overwrite (LWG 3645)

Previously the C++23 draft required that the callback arguments were
lvalues, which was overvable by the callback. LWG 3645 removes that
overspecification, so we can pass rvalues and the user can't modify
our local variables. I've used auto(p) to produce rvalues, which is only
supported since Clang 15, but I think that's OK for a C++23 feature.

While making this change I noticed that we weren't correctly enforcing
the requirement that the callback returns an integer-like type. Add
better assertions for the type and value.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc 
(basic_string::resize_and_overwrite):
Pass rvalues to the callback, as now allowed by LWG 3645.
Enforce preconditions on the return value.
* 
testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
Adjust.

(cherry picked from commit ba4f5530c475eadd2a7edb46b6c1c9d5f9267501)

Diff:
---
 libstdc++-v3/include/bits/basic_string.tcc   | 9 ++---
 .../basic_string/capacity/char/resize_and_overwrite.cc   | 8 +---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.tcc 
b/libstdc++-v3/include/bits/basic_string.tcc
index 24465dab102..f3911611aea 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -594,9 +594,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_type _M_r;
   };
   _Terminator __term{this};
-  const size_type __n2 [[maybe_unused]] = __n;
-  __term._M_r = std::move(__op)(__p, __n);
-  _GLIBCXX_DEBUG_ASSERT(__term._M_r >= 0 && __term._M_r <= __n2);
+  auto __r = std::move(__op)(auto(__p), auto(__n));
+  static_assert(ranges::__detail::__is_integer_like);
+  _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n);
+  __term._M_r = size_type(__r);
+  if (__term._M_r > __n)
+   __builtin_unreachable();
 }
 #endif // C++23
 
diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
index a336b55f4a1..f716030dad7 100644
--- 
a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
@@ -84,9 +84,11 @@ test03()
   VERIFY( s == std::string(42, 'a') );
   VERIFY( s[42] == '\0' );
 
-  s.resize_and_overwrite(0, [](auto&& p, auto&& n) {
-static_assert( std::is_same_v );
-static_assert( std::is_same_v );
+  s.resize_and_overwrite(0, [](auto p, auto n) {
+// N.B. these requirements were relaxed by LWG 3645:
+// resize_and_overwrite is overspecified to call its callback with lvalues
+static_assert( std::is_same_v );
+static_assert( std::is_same_v );
 return 0;
   });
 }


[gcc r12-10236] libstdc++: Fix std::basic_string::resize_and_overwrite

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:b9d09c7cfcaeb777c5cbc2848a84142a329992c9

commit r12-10236-gb9d09c7cfcaeb777c5cbc2848a84142a329992c9
Author: Jonathan Wakely 
Date:   Tue Aug 15 13:48:23 2023 +0100

libstdc++: Fix std::basic_string::resize_and_overwrite

The callable used for resize_and_overwrite was being passed the string's
expanded capacity, which might be greater than the new size being
requested. This is not conforming, as the standard requires the same n
to be passed to the callable that the user passed to
resize_and_overwrite.

The existing tests didn't catch this because they all used a value which
was more than twice the existing capacity, so the _M_create call
allocated exactly what was requested, and the value passed to the
callable was correct. But when the requested size is greater than the
current capacity but smaller than twice the current capacity, _M_create
will allocate twice the current capacity and then that value was being
passed to the callable.

I noticed this because std::format(L"{}", 0.25) was producing L"0.25XX"
where the XX characters were whatever happened to be on the stack before
the call. When std::format used resize_and_overwrite to widen a string
it was copying too many characters into the destination and setting the
result's length too long.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.tcc (resize_and_overwrite): Invoke
the callable with the same size as resize_and_overwrite was
called with.
* 
testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
Check with small values for the new size.

(cherry picked from commit 4a2b262597e4a6bc5732d4564673c1e19381dcfa)

Diff:
---
 libstdc++-v3/include/bits/basic_string.tcc  |  7 ---
 .../capacity/char/resize_and_overwrite.cc   | 21 +
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.tcc 
b/libstdc++-v3/include/bits/basic_string.tcc
index f3911611aea..7d76cfde172 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -570,13 +570,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 constexpr void
 basic_string<_CharT, _Traits, _Alloc>::
-resize_and_overwrite(size_type __n, _Operation __op)
+resize_and_overwrite(const size_type __n, _Operation __op)
 {
   const size_type __capacity = capacity();
   _CharT* __p;
   if (__n > __capacity)
{
- __p = _M_create(__n, __capacity);
+ auto __new_capacity = __n; // Must not allow _M_create to modify __n.
+ __p = _M_create(__new_capacity, __capacity);
  this->_S_copy(__p, _M_data(), length()); // exclude trailing null
 #if __cpp_lib_is_constant_evaluated
  if (std::is_constant_evaluated())
@@ -584,7 +585,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
  _M_dispose();
  _M_data(__p);
- _M_capacity(__n);
+ _M_capacity(__new_capacity);
}
   else
__p = _M_data();
diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
index f716030dad7..0ea5e2b10ef 100644
--- 
a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc
@@ -120,6 +120,26 @@ test05()
   return true;
 }
 
+void
+test06()
+{
+  std::string s = "0123456789";
+  s.resize_and_overwrite(16, [](char* p, int n) {
+VERIFY( n == 16 );
+std::char_traits::copy(p + 10, "0123456798", 6);
+return n;
+  });
+  VERIFY( s.size() == 16 );
+  VERIFY( s == "0123456789012345" );
+
+  s.resize_and_overwrite(4, [](char* p, int n) {
+VERIFY( n == 4 );
+std::char_traits::copy(p, "abcd", 4);
+return n;
+  });
+  VERIFY( s.size() == 4 );
+}
+
 int main()
 {
   test01();
@@ -127,4 +147,5 @@ int main()
   test03();
   test04();
   static_assert( test05() );
+  test06();
 }


[gcc r12-10237] libstdc++: Remove unconditional use of atomics in Debug Mode

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:73d0816f570c26e856d94d56491e50332fd8b425

commit r12-10237-g73d0816f570c26e856d94d56491e50332fd8b425
Author: Jonathan Wakely 
Date:   Mon Sep 11 16:42:54 2023 +0100

libstdc++: Remove unconditional use of atomics in Debug Mode

The fix for PR 91910 (r10-3426-gf7a3a382279585) introduced unconditional
uses of atomics into src/c++11/debug.cc, which causes linker errors for
arm4t where GCC emits an unresolved reference to __sync_synchronize.

By making the uses of atomics depend on _GLIBCXX_HAS_GTHREADS we can
avoid those unconditional references to __sync_synchronize for targets
where the atomics are unnecessary. As a minor performance optimization
we can also check the __gnu_cxx::__is_single_threaded function to avoid
atomics for single-threaded programs even where they don't cause linker
errors.

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc (acquire_sequence_ptr_for_lock): New
function.
(reset_sequence_ptr): New function.
(_Safe_iterator_base::_M_detach)
(_Safe_local_iterator_base::_M_detach): Replace bare atomic_load
with acquire_sequence_ptr_for_lock.
(_Safe_iterator_base::_M_reset): Replace bare atomic_store with
reset_sequence_ptr.

(cherry picked from commit 4a2766ed00a47904dc8b85bf0538aa116d8e658b)

Diff:
---
 libstdc++-v3/src/c++11/debug.cc | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index 4706defedf1..1bfc6ccc581 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -24,6 +24,7 @@
 
 #include 
 #include 
+#include  // __is_single_threaded
 
 #include 
 #include 
@@ -173,6 +174,31 @@ namespace
__old->_M_reset();
   }
   }
+
+  void*
+  acquire_sequence_ptr_for_lock(__gnu_debug::_Safe_sequence_base*& seq)
+  {
+#ifdef __GTHREADS
+if (!__gnu_cxx::__is_single_threaded())
+  return __atomic_load_n(&seq, __ATOMIC_ACQUIRE);
+#endif
+return seq;
+  }
+
+  void
+  reset_sequence_ptr(__gnu_debug::_Safe_sequence_base*& seq)
+  {
+#ifdef __GTHREADS
+if (!__gnu_cxx::__is_single_threaded())
+  {
+   __atomic_store_n(&seq, (__gnu_debug::_Safe_sequence_base*)nullptr,
+__ATOMIC_RELEASE);
+   return;
+  }
+#endif
+seq = nullptr;
+  }
+
 } // anonymous namespace
 
 namespace __gnu_debug
@@ -403,7 +429,7 @@ namespace __gnu_debug
 // If the sequence destructor runs between loading the pointer and
 // locking the mutex, it will detach this iterator and set _M_sequence
 // to null, and then _M_detach_single() will do nothing.
-if (auto seq = __atomic_load_n(&_M_sequence, __ATOMIC_ACQUIRE))
+if (auto seq = acquire_sequence_ptr_for_lock(_M_sequence))
   {
__gnu_cxx::__scoped_lock sentry(get_safe_base_mutex(seq));
_M_detach_single();
@@ -425,7 +451,7 @@ namespace __gnu_debug
   _Safe_iterator_base::
   _M_reset() throw ()
   {
-__atomic_store_n(&_M_sequence, (_Safe_sequence_base*)0, __ATOMIC_RELEASE);
+reset_sequence_ptr(_M_sequence);
 _M_version = 0;
 _M_prior = 0;
 _M_next = 0;
@@ -485,7 +511,7 @@ namespace __gnu_debug
   _Safe_local_iterator_base::
   _M_detach()
   {
-if (auto seq = __atomic_load_n(&_M_sequence, __ATOMIC_ACQUIRE))
+if (auto seq = acquire_sequence_ptr_for_lock(_M_sequence))
   {
__gnu_cxx::__scoped_lock sentry(get_safe_base_mutex(seq));
_M_detach_single();


[gcc r12-10239] libstdc++: Qualify calls to std::_Destroy and _Destroy_aux

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:5c4cd53ffd70205b2b136661b3be175dec0ce8d7

commit r12-10239-g5c4cd53ffd70205b2b136661b3be175dec0ce8d7
Author: Jonathan Wakely 
Date:   Fri Jun 30 21:09:01 2023 +0100

libstdc++: Qualify calls to std::_Destroy and _Destroy_aux

These calls should be qualified to prevent ADL, which can cause errors
for incomplete types that are associated classes.

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h (_Destroy): Qualify call.
* include/bits/stl_construct.h (_Destroy, _Destroy_n): Likewise.
* testsuite/23_containers/vector/cons/destroy-adl.cc: New test.

(cherry picked from commit 33245d6b87a284495304c9952813b6b83d5df99f)

Diff:
---
 libstdc++-v3/include/bits/alloc_traits.h  |  2 +-
 libstdc++-v3/include/bits/stl_construct.h |  4 ++--
 .../testsuite/23_containers/vector/cons/destroy-adl.cc| 11 +++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/alloc_traits.h 
b/libstdc++-v3/include/bits/alloc_traits.h
index a4d06d3fc7a..5cc52babef8 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _Destroy(_ForwardIterator __first, _ForwardIterator __last,
 allocator<_Tp>&)
 {
-  _Destroy(__first, __last);
+  std::_Destroy(__first, __last);
 }
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/bits/stl_construct.h 
b/libstdc++-v3/include/bits/stl_construct.h
index 9531222809c..a081f26adc3 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #if __cplusplus >= 202002L
   if (std::__is_constant_evaluated())
-   return _Destroy_aux::__destroy(__first, __last);
+   return std::_Destroy_aux::__destroy(__first, __last);
 #endif
   std::_Destroy_aux<__has_trivial_destructor(_Value_type)>::
__destroy(__first, __last);
@@ -239,7 +239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #if __cplusplus >= 202002L
   if (std::__is_constant_evaluated())
-   return _Destroy_n_aux::__destroy_n(__first, __count);
+   return std::_Destroy_n_aux::__destroy_n(__first, __count);
 #endif
   return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>::
__destroy_n(__first, __count);
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc 
b/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc
new file mode 100644
index 000..5623842e9b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/destroy-adl.cc
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+#include 
+
+template struct Holder { T t; }; // { dg-bogus "incomplete type" }
+struct Incomplete;
+
+void destroy(std::vector*>* p)
+{
+  p->~vector();
+}


[gcc r12-10241] libstdc++: Fix PSTL test that fails in C++20

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:ceb82ba594a6c24f33351eda0ae3fbb6fd6d841a

commit r12-10241-gceb82ba594a6c24f33351eda0ae3fbb6fd6d841a
Author: Jonathan Wakely 
Date:   Thu Jun 1 16:49:53 2023 +0100

libstdc++: Fix PSTL test that fails in C++20

This test fails in C++20 and later due to a warning:

warning: C++20 says that these are ambiguous, even though the second is 
reversed:
note: candidate 1: 'bool MyClass::operator==(const MyClass&)'
note: candidate 2: 'bool MyClass::operator==(const MyClass&)' (reversed)
note: try making the operator a 'const' member function
FAIL: 26_numerics/pstl/numeric_ops/transform_reduce.cc (test for excess 
errors)

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc:
Add const to equality operator.

(cherry picked from commit f8403c43045cd56b5f775e1cf12a3f22feca4b58)

Diff:
---
 libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc 
b/libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc
index ec020b42bbb..bec1c141278 100644
--- a/libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc
+++ b/libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc
@@ -68,7 +68,7 @@ class MyClass
 }
 friend MyClass operator*(const MyClass& x, const MyClass& y) { return 
MyClass(x.my_field * y.my_field); }
 bool
-operator==(const MyClass& in)
+operator==(const MyClass& in) const
 {
 return my_field == in.my_field;
 }


[gcc r12-10242] libstdc++: Add missing noexcept to std::scoped_allocator_adaptor

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:65704fa293ca9d5f9186aa09037fc2869492973b

commit r12-10242-g65704fa293ca9d5f9186aa09037fc2869492973b
Author: Jonathan Wakely 
Date:   Fri May 26 21:33:58 2023 +0100

libstdc++: Add missing noexcept to std::scoped_allocator_adaptor

The standard requires these constructors and accessors to be noexcept.

libstdc++-v3/ChangeLog:

* include/std/scoped_allocator (scoped_allocator_adaptor): Add
noexcept to all constructors except the default constructor.
(scoped_allocator_adaptor::inner_allocator): Add noexcept.
(scoped_allocator_adaptor::outer_allocator): Likewise.
* testsuite/20_util/scoped_allocator/noexcept.cc: New test.

(cherry picked from commit b960c253e988c68ed3f3829125bc267bdf169356)

Diff:
---
 libstdc++-v3/include/std/scoped_allocator  | 45 -
 .../testsuite/20_util/scoped_allocator/noexcept.cc | 47 ++
 2 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/include/std/scoped_allocator 
b/libstdc++-v3/include/std/scoped_allocator
index 8ad4c90b694..dd00e8efdbb 100644
--- a/libstdc++-v3/include/std/scoped_allocator
+++ b/libstdc++-v3/include/std/scoped_allocator
@@ -66,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct __outermost_type
 {
   using type = _Alloc;
-  static type& _S_outermost(_Alloc& __a) { return __a; }
+  static type& _S_outermost(_Alloc& __a) noexcept { return __a; }
 };
 
   template
@@ -80,7 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   >;
 
   static typename __base::type&
-  _S_outermost(_Alloc& __a)
+  _S_outermost(_Alloc& __a) noexcept
   { return __base::_S_outermost(__a.outer_allocator()); }
 };
 
@@ -105,11 +105,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __inner_type_impl& operator=(__inner_type_impl&&) = default;
 
   template
-  __inner_type_impl(const __inner_type_impl<_Alloc>& __other)
+  __inner_type_impl(const __inner_type_impl<_Alloc>& __other) noexcept
   { }
 
   template
-  __inner_type_impl(__inner_type_impl<_Alloc>&& __other)
+  __inner_type_impl(__inner_type_impl<_Alloc>&& __other) noexcept
   { }
 
   __type&
@@ -138,16 +138,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __inner_type_impl& operator=(__inner_type_impl&&) = default;
 
   template
-  __inner_type_impl(const __inner_type_impl<_Allocs...>& __other)
+  __inner_type_impl(const __inner_type_impl<_Allocs...>& __other) noexcept
   : _M_inner(__other._M_inner) { }
 
   template
-  __inner_type_impl(__inner_type_impl<_Allocs...>&& __other)
+  __inner_type_impl(__inner_type_impl<_Allocs...>&& __other) noexcept
   : _M_inner(std::move(__other._M_inner)) { }
 
 template
   explicit
-  __inner_type_impl(_Args&&... __args)
+  __inner_type_impl(_Args&&... __args) noexcept
   : _M_inner(std::forward<_Args>(__args)...) { }
 
   __type&
@@ -308,31 +308,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template>
 scoped_allocator_adaptor(_Outer2&& __outer,
- const _InnerAllocs&... __inner)
+ const _InnerAllocs&... __inner) noexcept
 : _OuterAlloc(std::forward<_Outer2>(__outer)),
   _M_inner(__inner...)
 { }
 
-  scoped_allocator_adaptor(const scoped_allocator_adaptor& __other)
+  scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) 
noexcept
   : _OuterAlloc(__other.outer_allocator()),
_M_inner(__other._M_inner)
   { }
 
-  scoped_allocator_adaptor(scoped_allocator_adaptor&& __other)
+  scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) noexcept
   : _OuterAlloc(std::move(__other.outer_allocator())),
_M_inner(std::move(__other._M_inner))
   { }
 
   template>
 scoped_allocator_adaptor(
-const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other)
+ const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other
+   ) noexcept
 : _OuterAlloc(__other.outer_allocator()),
   _M_inner(__other._M_inner)
 { }
 
   template>
 scoped_allocator_adaptor(
-scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other)
+ scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) noexcept
 : _OuterAlloc(std::move(__other.outer_allocator())),
   _M_inner(std::move(__other._M_inner))
 { }
@@ -343,25 +344,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   scoped_allocator_adaptor&
   operator=(scoped_allocator_adaptor&&) = default;
 
-  inner_allocator_type& inner_allocator() noexcept
+  inner_allocator_type&
+  inner_allocator() noexcept
   { return _M_inner._M_get(this); }
 
-  const inner_allocator_type& inner_allocator() const noexcept
+  const inner_allocator_type&
+  inner_allocator() const noex

[gcc r12-10238] libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:ae8302e18f15f0befb372762b20a3a790a19a925

commit r12-10238-gae8302e18f15f0befb372762b20a3a790a19a925
Author: Jonathan Wakely 
Date:   Wed Jul 19 18:18:46 2023 +0100

libstdc++: Check for std::ratio in arithmetic and comparisons [PR110593]

The standard says that it should be ill-formed to use std::ratio_equal
etc. with types which are not specializations of std::ratio. This
implements that requirement.

We don't need to add assertions to every one of the class templates,
because many of them are implemented in terms of other ones. For
example, ratio_divide and ratio_subtract can rely on the assertions in
ratio_multiply and ratio_add respectively.

libstdc++-v3/ChangeLog:

PR libstdc++/110593
* include/bits/chrono.h (duration): Improve static assert
messages.
(__is_ratio): Move to ...
* include/std/ratio (__is_ratio): ... here.
(__is_ratio_v): New variable template and partial
specialization.
(__are_both_ratios): New function template.
(__ratio_multiply, ratio_equal, ratio_less, __ratio_add):
Add static assertion.
* testsuite/20_util/ratio/requirements/type_constraints.cc:
New test.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc:
Adjust expected error.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Likewise.

(cherry picked from commit 2d614822e9ea2a3d8800045d66e3220743753d09)

Diff:
---
 libstdc++-v3/include/bits/chrono.h | 19 ++--
 libstdc++-v3/include/std/ratio | 53 --
 .../20_util/duration/requirements/typedefs_neg1.cc |  2 +-
 .../20_util/duration/requirements/typedefs_neg2.cc |  2 +-
 .../20_util/ratio/requirements/type_constraints.cc | 34 ++
 5 files changed, 87 insertions(+), 23 deletions(-)

diff --git a/libstdc++-v3/include/bits/chrono.h 
b/libstdc++-v3/include/bits/chrono.h
index c585cac3d8a..d09f8563a59 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chrono.h
@@ -483,26 +483,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return numeric_limits<_Rep>::lowest(); }
   };
 
-/// @cond undocumented
-
-template
-  struct __is_ratio
-  : std::false_type
-  { };
-
-template
-  struct __is_ratio>
-  : std::true_type
-  { };
-
-/// @endcond
-
 template
   class duration
   {
-   static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration");
+   static_assert(!__is_duration<_Rep>::value,
+ "rep cannot be a std::chrono::duration");
static_assert(__is_ratio<_Period>::value,
- "period must be a specialization of ratio");
+ "period must be a specialization of std::ratio");
static_assert(_Period::num > 0, "period must be positive");
 
template
diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio
index 5a5643d2999..32a4da25a93 100644
--- a/libstdc++-v3/include/std/ratio
+++ b/libstdc++-v3/include/std/ratio
@@ -289,9 +289,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @cond undocumented
 
+  template
+struct __is_ratio
+: std::false_type
+{ };
+
+  template
+struct __is_ratio>
+: std::true_type
+{ };
+
+#if __cpp_variable_templates
+  template
+constexpr bool __is_ratio_v = false;
+  template
+constexpr bool __is_ratio_v> = true;
+#endif
+
+  template
+constexpr bool
+__are_both_ratios() noexcept
+{
+#if __cpp_variable_templates && __cpp_if_constexpr
+  if constexpr (__is_ratio_v<_R1>)
+   if constexpr (__is_ratio_v<_R2>)
+ return true;
+  return false;
+#else
+  return __and_<__is_ratio<_R1>, __is_ratio<_R2>>::value;
+#endif
+}
+
   template
 struct __ratio_multiply
 {
+  static_assert(std::__are_both_ratios<_R1, _R2>(),
+   "both template arguments must be a std::ratio");
+
 private:
   static const intmax_t __gcd1 =
 __static_gcd<_R1::num, _R2::den>::value;
@@ -356,7 +390,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 struct ratio_equal
 : integral_constant
-{ };
+{
+  static_assert(std::__are_both_ratios<_R1, _R2>(),
+   "both template arguments must be a std::ratio");
+};
 
   /// ratio_not_equal
   template
@@ -402,7 +439,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 struct ratio_less
 : __ratio_less_impl<_R1, _R2>::type
-{ };
+{
+  static_assert(std::__are_both_ratios<_R1, _R2>(),
+   "both template arguments must be a std::ratio");
+};
 
   /// ratio_less_equal
   template
@@ -430,13 +470,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template 
 inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value;
   template 
-

[gcc r12-10244] libstdc++: Fix std::abs(__float128) for -NaN and -0.0 [PR109758]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:9f381ebb7211c1359f5de87760148096fcba3357

commit r12-10244-g9f381ebb7211c1359f5de87760148096fcba3357
Author: Jonathan Wakely 
Date:   Wed May 10 12:20:58 2023 +0100

libstdc++: Fix std::abs(__float128) for -NaN and -0.0 [PR109758]

The current implementation of this non-standard overload of std::abs
incorrectly returns a negative value for negative NaNs and negative
zero, because x < 0 is false in both cases.

Use fabsl(long double) or fabsf128(_Float128) if those do the right
thing.  Otherwise, use __builtin_signbit(x) instead of x < 0 to detect
negative inputs. This assumes that __builtin_signbit handles __float128
correctly, but that seems to be true for all of GCC, clang and icc.

libstdc++-v3/ChangeLog:

PR libstdc++/109758
* include/bits/std_abs.h (abs(__float128)): Handle negative NaN
and negative zero correctly.
* testsuite/26_numerics/headers/cmath/109758.cc: New test.

(cherry picked from commit af595613acbd9863198ae69c7b1c9e856bca9e4f)

Diff:
---
 libstdc++-v3/include/bits/std_abs.h| 13 +-
 .../testsuite/26_numerics/headers/cmath/109758.cc  | 52 ++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/std_abs.h 
b/libstdc++-v3/include/bits/std_abs.h
index c8d589d2b0a..bd14addd159 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -101,11 +101,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __extension__ inline _GLIBCXX_CONSTEXPR
   __float128
   abs(__float128 __x)
-  { return __x < 0 ? -__x : __x; }
+  {
+#if defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
+return __builtin_fabsl(__x);
+#elif defined(_GLIBCXX_HAVE_FLOAT128_MATH)
+return __builtin_fabsf128(__x);
+#else
+// Assume that __builtin_signbit works for __float128.
+return __builtin_signbit(__x) ? -__x : __x;
+#endif
+  }
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
-} // extern "C"++"
+} // extern "C++"
 
 #endif // _GLIBCXX_BITS_STD_ABS_H
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/109758.cc 
b/libstdc++-v3/testsuite/26_numerics/headers/cmath/109758.cc
new file mode 100644
index 000..c9716d3d372
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/109758.cc
@@ -0,0 +1,52 @@
+// { dg-do run }
+// PR libstdc++/109758 std::abs(__float128) doesn't support NaN
+
+#include 
+#include 
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+void
+test_nan()
+{
+  __float128 nan = __builtin_nanl("");
+  VERIFY( !__builtin_signbit(std::abs(nan)) );
+  VERIFY( !__builtin_signbit(std::abs(-nan)) );
+}
+
+void
+test_zero()
+{
+  __float128 zero = 0.0;
+  VERIFY( !__builtin_signbit(std::abs(zero)) );
+  VERIFY( !__builtin_signbit(std::abs(zero * -2.0)) );
+}
+
+void
+test_neg()
+{
+  VERIFY( std::abs((__float128)-1.0) == -1.0 );
+  VERIFY( std::abs((__float128)-2e9) == -2e9 );
+  VERIFY( std::abs((__float128)-3e-4) == 3e-4 );
+}
+
+void
+test_inf()
+{
+  __float128 inf = __builtin_huge_vall();
+  VERIFY( std::abs(inf) == inf );
+  VERIFY( std::abs(-inf) == inf );
+}
+
+#if __cplusplus >= 201103L
+static_assert( std::abs((__float128)-1.0) == (__float128)1.0,
+  "std::abs(__float128) is usable in constant expressions" );
+#endif
+
+int main()
+{
+  test_nan();
+  test_zero();
+}
+#else
+int main() { }
+#endif


[gcc r12-10245] libstdc++: Add deprecated attribute to std::random_shuffle declarations

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:bfa7e7dfc19e07bff319636cf1bdfd57b6c68f41

commit r12-10245-gbfa7e7dfc19e07bff319636cf1bdfd57b6c68f41
Author: Jonathan Wakely 
Date:   Wed Jul 26 14:05:58 2023 +0100

libstdc++: Add deprecated attribute to std::random_shuffle declarations

We already have these attributes on the definitions in 
but they don't work due to PR c++/84542. Add the attributes to the
declarations in  as well, and add a test.

libstdc++-v3/ChangeLog:

* include/bits/algorithmfwd.h (random_shuffle): Add deprecated
attribute.
* include/bits/stl_algo.h (random_shuffle): Correct comments.
* testsuite/25_algorithms/random_shuffle/1.cc: Disable
deprecated warnings.
* testsuite/25_algorithms/random_shuffle/59603.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/deprecated.cc: New
test.

(cherry picked from commit c01b344e814001e07fd304ce98d013d811e90192)

Diff:
---
 libstdc++-v3/include/bits/algorithmfwd.h   |  2 ++
 libstdc++-v3/include/bits/stl_algo.h   |  4 ++--
 .../testsuite/25_algorithms/random_shuffle/1.cc|  1 +
 .../testsuite/25_algorithms/random_shuffle/59603.cc|  1 +
 .../25_algorithms/random_shuffle/deprecated.cc | 18 ++
 .../testsuite/25_algorithms/random_shuffle/moveable.cc |  1 +
 6 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/algorithmfwd.h 
b/libstdc++-v3/include/bits/algorithmfwd.h
index 5271a90b501..5b85b0bc60d 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -828,10 +828,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
 partition(_BIter, _BIter, _Predicate);
 
   template
+_GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
 void
 random_shuffle(_RAIter, _RAIter);
 
   template
+_GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
 void
 random_shuffle(_RAIter, _RAIter,
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/bits/stl_algo.h 
b/libstdc++-v3/include/bits/stl_algo.h
index 1f07b9e6589..41a8cf2f3e1 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -4532,7 +4532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
*  equally likely.
*
*  @deprecated
-   *  Since C++14 `std::random_shuffle` is not part of the C++ standard.
+   *  Since C++17, `std::random_shuffle` is not part of the C++ standard.
*  Use `std::shuffle` instead, which was introduced in C++11.
   */
   template
@@ -4572,7 +4572,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
*  range [0,N).
*
*  @deprecated
-   *  Since C++14 `std::random_shuffle` is not part of the C++ standard.
+   *  Since C++17, `std::random_shuffle` is not part of the C++ standard.
*  Use `std::shuffle` instead, which was introduced in C++11.
   */
   template
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc 
b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc
index fd1f5eb0717..37814f695c6 100644
--- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc
@@ -15,6 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
+// { dg-options "-Wno-deprecated-declarations" }
 // { dg-add-options using-deprecated }
 
 // 25.2.11 random_shuffle()
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc 
b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc
index d5ef0725036..3a31dd12da0 100644
--- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-do run { target c++11 } }
+// { dg-options "-Wno-deprecated-declarations" }
 // { dg-add-options using-deprecated }
 // { dg-require-debug-mode "" }
 
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc 
b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc
new file mode 100644
index 000..48fc5b029e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-add-options using-deprecated }
+
+// std::random_shuffle was deprecated in C++17 and removed in C++17.
+
+#include 
+
+std::ptrdiff_t rando(std::ptrdiff_t n);
+
+void
+test_depr(int* first, int* last)
+{
+  std::random_shuffle(first, last);
+  // { dg-warning "deprecated" "" { target c++14 } 13 }
+
+  std::random_shuffle(first, last, rando);
+  // { dg-warning "deprecated" "" { target c++14 } 16 }
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc 
b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc
index d72906828d0..18f6de40c69 100644
--- a/libstdc++-v3/testsuite/25

[gcc r12-10240] libstdc++: Improve tests for emplace member of sequence containers

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:1bb2bfb5d984456f59b42228f06d4ad4976358e7

commit r12-10240-g1bb2bfb5d984456f59b42228f06d4ad4976358e7
Author: Jonathan Wakely 
Date:   Thu Jun 8 12:19:26 2023 +0100

libstdc++: Improve tests for emplace member of sequence containers

Our existing tests for std::deque::emplace, std::list::emplace and
std::vector::emplace are poor. We only have compile tests for PR 52799
and the equivalent for a const_iterator as the insertion point. This
fails to check that the value is actually inserted correctly and the
right iterator is returned.

Add new tests that cover the existing 52799.cc and const_iterator.cc
compile-only tests, as well as verifying the effects are correct.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/deque/modifiers/emplace/52799.cc:
Removed.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
Removed.
* testsuite/23_containers/list/modifiers/emplace/52799.cc:
Removed.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Removed.
* testsuite/23_containers/vector/modifiers/emplace/52799.cc:
Removed.
* 
testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Removed.
* testsuite/23_containers/deque/modifiers/emplace/1.cc: New
test.
* testsuite/23_containers/list/modifiers/emplace/1.cc: New
test.
* testsuite/23_containers/vector/modifiers/emplace/1.cc: New
test.

(cherry picked from commit 3ec1d76a359542ed4c8370390efa9ee9e25e757f)

Diff:
---
 .../23_containers/deque/modifiers/emplace/1.cc | 70 +
 .../23_containers/deque/modifiers/emplace/52799.cc | 27 
 .../deque/modifiers/emplace/const_iterator.cc  | 26 
 .../23_containers/list/modifiers/emplace/1.cc  | 71 ++
 .../23_containers/list/modifiers/emplace/52799.cc  | 27 
 .../list/modifiers/emplace/const_iterator.cc   | 26 
 .../23_containers/vector/modifiers/emplace/1.cc| 70 +
 .../vector/modifiers/emplace/52799.cc  | 27 
 .../vector/modifiers/emplace/const_iterator.cc | 26 
 9 files changed, 211 insertions(+), 159 deletions(-)

diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/1.cc 
b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/1.cc
new file mode 100644
index 000..c6b0318e5ea
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/1.cc
@@ -0,0 +1,70 @@
+// { dg-do run { target c++11 } }
+
+#include 
+#include 
+
+void
+test01()
+{
+  std::deque c;
+  std::deque::iterator pos;
+
+  // libstdc++/52799
+  pos = c.emplace(c.begin());
+  VERIFY( c.size() == 1 );
+  VERIFY( c[0] == 0 );
+  VERIFY( pos == c.begin() );
+  pos = c.emplace(c.begin(), 2);
+  VERIFY( c.size() == 2 );
+  VERIFY( c[0] == 2 );
+  VERIFY( c[1] == 0 );
+  VERIFY( pos == c.begin() );
+  pos = c.emplace(c.end(), 3);
+  VERIFY( c.size() == 3 );
+  VERIFY( c[0] == 2 );
+  VERIFY( c[1] == 0 );
+  VERIFY( c[2] == 3 );
+  VERIFY( pos == --c.end() );
+
+  // const_iterator
+  pos = c.emplace(c.cbegin());
+  VERIFY( c.size() == 4 );
+  VERIFY( c[0] == 0 );
+  VERIFY( c[1] == 2 );
+  VERIFY( pos == c.cbegin() );
+  pos = c.emplace(c.cbegin() + 2, 22);
+  VERIFY( c.size() == 5 );
+  VERIFY( c[0] == 0 );
+  VERIFY( c[1] == 2 );
+  VERIFY( c[2] == 22 );
+  VERIFY( pos == c.cbegin() + 2 );
+}
+
+struct V
+{
+  explicit V(int a, int b = 0) : val(a+b) { }
+  int val;
+};
+
+void
+test02()
+{
+  std::deque c;
+  std::deque::iterator pos;
+
+  pos = c.emplace(c.end(), 1);
+  VERIFY( c.size() == 1 );
+  VERIFY( c[0].val == 1 );
+  VERIFY( pos == --c.end() );
+  pos = c.emplace(c.cend(), 2, 3);
+  VERIFY( c.size() == 2 );
+  VERIFY( c[0].val == 1 );
+  VERIFY( c[1].val == 5 );
+  VERIFY( pos == --c.cend() );
+}
+
+int main()
+{
+  test01();
+  test02();
+}
diff --git 
a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc 
b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc
deleted file mode 100644
index b236fca8db9..000
--- a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/52799.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// { dg-do compile { target c++11 } }
-
-// Copyright (C) 2012-2022 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

[gcc r12-10247] libstdc++: Add likely/unlikely attributes to implementation

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:ec9735922b6f28cf704c8a7850a34aed82675b91

commit r12-10247-gec9735922b6f28cf704c8a7850a34aed82675b91
Author: Jonathan Wakely 
Date:   Fri Feb 24 21:28:11 2023 +

libstdc++: Add likely/unlikely attributes to  implementation

For the common case of converting valid text this improves performance
significantly.

libstdc++-v3/ChangeLog:

* src/c++11/codecvt.cc: Add [[likely]] and [[unlikely]]
attributes.

(cherry picked from commit a41a56dee5c2d48337739d60c43cab5074bcc8e7)

Diff:
---
 libstdc++-v3/src/c++11/codecvt.cc | 92 +++
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/libstdc++-v3/src/c++11/codecvt.cc 
b/libstdc++-v3/src/c++11/codecvt.cc
index 03f0bfda972..5b0bcb0eaa4 100644
--- a/libstdc++-v3/src/c++11/codecvt.cc
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -256,19 +256,19 @@ namespace
   return incomplete_mb_character;
 char32_t c1 = (unsigned char) from[0];
 // https://en.wikipedia.org/wiki/UTF-8#Sample_code
-if (c1 < 0x80)
+if (c1 < 0x80) [[likely]]
 {
   ++from;
   return c1;
 }
-else if (c1 < 0xC2) // continuation or overlong 2-byte sequence
+else if (c1 < 0xC2) [[unlikely]] // continuation or overlong 2-byte 
sequence
   return invalid_mb_sequence;
 else if (c1 < 0xE0) // 2-byte sequence
 {
-  if (avail < 2)
+  if (avail < 2) [[unlikely]]
return incomplete_mb_character;
   char32_t c2 = (unsigned char) from[1];
-  if ((c2 & 0xC0) != 0x80)
+  if ((c2 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
   char32_t c = (c1 << 6) + c2 - 0x3080;
   if (c <= maxcode)
@@ -277,17 +277,17 @@ namespace
 }
 else if (c1 < 0xF0) // 3-byte sequence
 {
-  if (avail < 2)
+  if (avail < 2) [[unlikely]]
return incomplete_mb_character;
   char32_t c2 = (unsigned char) from[1];
-  if ((c2 & 0xC0) != 0x80)
+  if ((c2 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
-  if (c1 == 0xE0 && c2 < 0xA0) // overlong
+  if (c1 == 0xE0 && c2 < 0xA0) [[unlikely]] // overlong
return invalid_mb_sequence;
-  if (avail < 3)
+  if (avail < 3) [[unlikely]]
return incomplete_mb_character;
   char32_t c3 = (unsigned char) from[2];
-  if ((c3 & 0xC0) != 0x80)
+  if ((c3 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
   char32_t c = (c1 << 12) + (c2 << 6) + c3 - 0xE2080;
   if (c <= maxcode)
@@ -296,31 +296,31 @@ namespace
 }
 else if (c1 < 0xF5 && maxcode > 0x) // 4-byte sequence
 {
-  if (avail < 2)
+  if (avail < 2) [[unlikely]]
return incomplete_mb_character;
   char32_t c2 = (unsigned char) from[1];
-  if ((c2 & 0xC0) != 0x80)
+  if ((c2 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
-  if (c1 == 0xF0 && c2 < 0x90) // overlong
+  if (c1 == 0xF0 && c2 < 0x90) [[unlikely]] // overlong
return invalid_mb_sequence;
-  if (c1 == 0xF4 && c2 >= 0x90) // > U+10
+  if (c1 == 0xF4 && c2 >= 0x90) [[unlikely]] // > U+10
return invalid_mb_sequence;
-  if (avail < 3)
+  if (avail < 3) [[unlikely]]
return incomplete_mb_character;
   char32_t c3 = (unsigned char) from[2];
-  if ((c3 & 0xC0) != 0x80)
+  if ((c3 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
-  if (avail < 4)
+  if (avail < 4) [[unlikely]]
return incomplete_mb_character;
   char32_t c4 = (unsigned char) from[3];
-  if ((c4 & 0xC0) != 0x80)
+  if ((c4 & 0xC0) != 0x80) [[unlikely]]
return invalid_mb_sequence;
   char32_t c = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4 - 0x3C82080;
   if (c <= maxcode)
from += 4;
   return c;
 }
-else // > U+10
+else [[unlikely]] // > U+10
   return invalid_mb_sequence;
   }
 
@@ -330,20 +330,20 @@ namespace
   {
 if (code_point < 0x80)
   {
-   if (to.size() < 1)
+   if (to.size() < 1) [[unlikely]]
  return false;
to = code_point;
   }
 else if (code_point <= 0x7FF)
   {
-   if (to.size() < 2)
+   if (to.size() < 2) [[unlikely]]
  return false;
to = (code_point >> 6) + 0xC0;
to = (code_point & 0x3F) + 0x80;
   }
 else if (code_point <= 0x)
   {
-   if (to.size() < 3)
+   if (to.size() < 3) [[unlikely]]
  return false;
to = (code_point >> 12) + 0xE0;
to = ((code_point >> 6) & 0x3F) + 0x80;
@@ -351,14 +351,14 @@ namespace
   }
 else if (code_point <= 0x10)
   {
-   if (to.size() < 4)
+   if (to.size() < 4) [[unlikely]]
  return false;
to = (code_point >> 18) + 0xF0;
to = ((code_point >> 12) & 0x3F) + 0x80;
to = ((code_point >> 6) & 0x3F) + 0x80;
to = (code_point & 0x3F) + 0x80;
   

[gcc r12-10248] libstdc++: Add allocator-extended constructors to std::match_results (LWG 2195)

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:3d7dc8f0ae9ee812f142556a3e827cd5ea115748

commit r12-10248-g3d7dc8f0ae9ee812f142556a3e827cd5ea115748
Author: Jonathan Wakely 
Date:   Wed Mar 22 11:36:06 2023 +

libstdc++: Add allocator-extended constructors to std::match_results (LWG 
2195)

This was approved in Issaquah last month.

libstdc++-v3/ChangeLog:

* include/bits/regex.h (match_results): Add allocator-extended
copy and move constructors, as per LWG 2195.
* testsuite/28_regex/match_results/ctors/char/alloc.cc: New test.

(cherry picked from commit 9ae1108196ed65647846a7c06052317e8fa4852d)

Diff:
---
 libstdc++-v3/include/bits/regex.h  | 10 
 .../28_regex/match_results/ctors/char/alloc.cc | 56 ++
 2 files changed, 66 insertions(+)

diff --git a/libstdc++-v3/include/bits/regex.h 
b/libstdc++-v3/include/bits/regex.h
index 097ebf5a266..04dad2c663a 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1807,6 +1807,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*/
   ~match_results() = default;
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 2195. Missing constructors for match_results
+
+  match_results(const match_results& __m, const _Alloc& __a)
+  : _Base_type(__m, __a) { }
+
+  match_results(match_results&& __m, const _Alloc& __a)
+  noexcept(noexcept(_Base_type(std::move(__m), __a)))
+  : _Base_type(std::move(__m), __a) { }
+
   ///@}
 
   // 28.10.2, state:
diff --git a/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc 
b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc
new file mode 100644
index 000..bb5e7a91bd7
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc
@@ -0,0 +1,56 @@
+// { dg-do run { target c++11 } }
+
+#include 
+#include 
+#include 
+
+// LWG 2195. Missing constructors for match_results
+
+void
+test01()
+{
+  using Alloc = std::cmatch::allocator_type;
+  std::cmatch m1;
+  std::cmatch m2(m1, m1.get_allocator());
+  VERIFY( m2 == m1 );
+
+  static_assert( ! std::is_nothrow_constructible(),
+"Allocator-extended copy ctor is potentially-throwing" );
+
+  std::cmatch m3(std::move(m1), m2.get_allocator());
+  VERIFY( m3 == m2 );
+
+  // Libstdc++ extension:
+  static_assert( std::is_nothrow_constructible(),
+"Allocator-extended move ctor is non-throwing" );
+}
+
+void
+test02()
+{
+  using Alloc = __gnu_test::uneq_allocator;
+  using MR = std::match_results;
+
+  MR m1(Alloc(1));
+  MR m2(m1, Alloc(2));
+  VERIFY( m2 == m1 );
+
+  static_assert( ! std::is_nothrow_constructible(),
+"Allocator-extended copy ctor is potentially-throwing" );
+
+  MR m3(std::move(m1), Alloc(3));
+  VERIFY( m3 == m2 );
+
+  static_assert( ! std::is_nothrow_constructible(),
+"Allocator-extended move ctor is potentially-throwing" );
+}
+
+int main()
+{
+  test01();
+  test02();
+}


[gcc r12-10243] libstdc++: Fix -Wnonnull warnings during configure

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:93159e1af6e1d42e0e595bdc49da002fc830353c

commit r12-10243-g93159e1af6e1d42e0e595bdc49da002fc830353c
Author: Jonathan Wakely 
Date:   Fri May 12 12:17:08 2023 +0100

libstdc++: Fix -Wnonnull warnings during configure

We should not test for nan by passing it a null pointer, as this can
trigger -Wnonnull warnings.

Also fix an outdated comment about the default -std mode.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_C99_TR1): Use a non-null pointer
to check for nan, nanf, and nanl.
* configure: Regenerate.

(cherry picked from commit 6190a74ebee69415b501996821c92f60d892fb81)

Diff:
---
 libstdc++-v3/acinclude.m4 | 8 
 libstdc++-v3/configure| 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index c25e8a70638..3b657f04443 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1623,7 +1623,7 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
   AC_LANG_SAVE
   AC_LANG_CPLUSPLUS
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
+  # Use -std=c++98 because -std=gnu++98 leaves __STRICT_ANSI__
   # undefined and fake C99 facilities may be spuriously enabled.
   ac_save_CXXFLAGS="$CXXFLAGS"
   CXXFLAGS="$CXXFLAGS -std=c++98"
@@ -1888,9 +1888,9 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
  lround(0.0);
  lroundf(0.0f);
  lroundl(0.0l);
- nan(0);
- nanf(0);
- nanl(0);
+ nan("");
+ nanf("");
+ nanl("");
  nearbyint(0.0);
  nearbyintf(0.0f);
  nearbyintl(0.0l);
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 67cae65c533..926d91b076b 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -19695,7 +19695,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS 
$LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
-  # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
+  # Use -std=c++98 because -std=gnu++98 leaves __STRICT_ANSI__
   # undefined and fake C99 facilities may be spuriously enabled.
   ac_save_CXXFLAGS="$CXXFLAGS"
   CXXFLAGS="$CXXFLAGS -std=c++98"
@@ -20070,9 +20070,9 @@ typedef double_t  my_double_t;
  lround(0.0);
  lroundf(0.0f);
  lroundl(0.0l);
- nan(0);
- nanf(0);
- nanl(0);
+ nan("");
+ nanf("");
+ nanl("");
  nearbyint(0.0);
  nearbyintf(0.0f);
  nearbyintl(0.0l);


[gcc r12-10250] libstdc++: Do not use memmove for 1-element ranges [PR108846]

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:8ec265c1464dec74f98e6914cd164af5090a39ff

commit r12-10250-g8ec265c1464dec74f98e6914cd164af5090a39ff
Author: Jonathan Wakely 
Date:   Sat Feb 25 14:28:36 2023 +

libstdc++: Do not use memmove for 1-element ranges [PR108846]

This avoids overwriting tail padding when algorithms like std::copy are
used to write a single value through a pointer to a base subobject.

The pointer arithmetic on a Base* is valid for N==1, but the copy/move
operation needs to be done using assignment, not a memmove or memcpy of
sizeof(Base) bytes.

Instead of putting a check for N==1 in all of copy, copy_n, move etc.
this adds it to the __copy_move and __copy_move_backward partial
specializations used for trivially copyable types. When N==1 those
partial specializations dispatch to new static member functions of the
partial specializations for non-trivial types, so that a copy/move
assignment is done appropriately for the _IsMove constant.

libstdc++-v3/ChangeLog:

PR libstdc++/108846
* include/bits/stl_algobase.h (__copy_move)
Add __assign_one static member function.
(__copy_move): Likewise.
(__copy_move): Do not use memmove for a single
value.
(__copy_move_backward): Likewise.
* testsuite/25_algorithms/copy/108846.cc: New test.
* testsuite/25_algorithms/copy_backward/108846.cc: New test.
* testsuite/25_algorithms/copy_n/108846.cc: New test.
* testsuite/25_algorithms/move/108846.cc: New test.
* testsuite/25_algorithms/move_backward/108846.cc: New test.

(cherry picked from commit 822a11a1e642e0abe92a996e7033a5066905a447)

Diff:
---
 libstdc++-v3/include/bits/stl_algobase.h   | 46 +
 .../testsuite/25_algorithms/copy/108846.cc | 58 ++
 .../25_algorithms/copy_backward/108846.cc  | 58 ++
 .../testsuite/25_algorithms/copy_n/108846.cc   | 58 ++
 .../testsuite/25_algorithms/move/108846.cc | 58 ++
 .../25_algorithms/move_backward/108846.cc  | 58 ++
 6 files changed, 314 insertions(+), 22 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_algobase.h 
b/libstdc++-v3/include/bits/stl_algobase.h
index 84a1f9e98f6..7664301a208 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -388,6 +388,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
  return __result;
}
+
+  template
+   static void
+   __assign_one(_Tp* __to, _Up* __from)
+   { *__to = *__from; }
 };
 
 #if __cplusplus >= 201103L
@@ -408,27 +413,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
  return __result;
}
+
+  template
+   static void
+   __assign_one(_Tp* __to, _Up* __from)
+   { *__to = std::move(*__from); }
 };
 #endif
 
   template
 struct __copy_move<_IsMove, true, random_access_iterator_tag>
 {
-  template
+  template
_GLIBCXX20_CONSTEXPR
-   static _Tp*
-   __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
+   static _Up*
+   __copy_m(_Tp* __first, _Tp* __last, _Up* __result)
{
-#if __cplusplus >= 201103L
- using __assignable = __conditional_t<_IsMove,
-  is_move_assignable<_Tp>,
-  is_copy_assignable<_Tp>>;
- // trivial types can have deleted assignment
- static_assert( __assignable::value, "type must be assignable" );
-#endif
  const ptrdiff_t _Num = __last - __first;
- if (_Num)
+ if (__builtin_expect(_Num > 1, true))
__builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
+ else if (_Num == 1)
+   std::__copy_move<_IsMove, false, random_access_iterator_tag>::
+ __assign_one(__result, __first);
  return __result + _Num;
}
 };
@@ -725,21 +731,17 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
   template
 struct __copy_move_backward<_IsMove, true, random_access_iterator_tag>
 {
-  template
+  template
_GLIBCXX20_CONSTEXPR
-   static _Tp*
-   __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
+   static _Up*
+   __copy_move_b(_Tp* __first, _Tp* __last, _Up* __result)
{
-#if __cplusplus >= 201103L
- using __assignable = __conditional_t<_IsMove,
-  is_move_assignable<_Tp>,
-  is_copy_assignable<_Tp>>;
- // trivial types can have deleted assignment
- static_assert( __assignable::value, "type must be assignable" );
-#endif
  const ptrdiff_t _Num = __last - __first;
- if (_Num)
+ if (__builtin_expe

[gcc r12-10251] libstdc++: Fix conditions for using memcmp in std::lexicographical_compare_three_way [PR113960]

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:6f5dcea85a31845ec6f4b6886734b0f02e013718

commit r12-10251-g6f5dcea85a31845ec6f4b6886734b0f02e013718
Author: Jonathan Wakely 
Date:   Tue Feb 27 17:50:34 2024 +

libstdc++: Fix conditions for using memcmp in 
std::lexicographical_compare_three_way [PR113960]

The change in r11-2981-g2f983fa69005b6 meant that
std::lexicographical_compare_three_way started to use memcmp for
unsigned integers on big endian targets, but for that to be valid we
need the two value types to have the same size and we need to use that
size to compute the length passed to memcmp.

I already defined a __is_memcmp_ordered_with trait that does the right
checks, std::lexicographical_compare_three_way just needs to use it.

libstdc++-v3/ChangeLog:

PR libstdc++/113960
* include/bits/stl_algobase.h (__is_byte_iter): Replace with ...
(__memcmp_ordered_with): New concept.
(lexicographical_compare_three_way): Use __memcmp_ordered_with
instead of __is_byte_iter. Use correct length for memcmp.
* 
testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc:
New test.

(cherry picked from commit f5cdda8acb06c20335855ed353ab9a441c12128a)

Diff:
---
 libstdc++-v3/include/bits/stl_algobase.h   | 41 --
 .../lexicographical_compare_three_way/113960.cc| 15 
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_algobase.h 
b/libstdc++-v3/include/bits/stl_algobase.h
index 7664301a208..6e648e48ad0 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -1780,11 +1780,14 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
 }
 
 #if __cpp_lib_three_way_comparison
-  // Iter points to a contiguous range of unsigned narrow character type
-  // or std::byte, suitable for comparison by memcmp.
-  template
-concept __is_byte_iter = contiguous_iterator<_Iter>
-  && __is_memcmp_ordered>::__value;
+  // Both iterators refer to contiguous ranges of unsigned narrow characters,
+  // or std::byte, or big-endian unsigned integers, suitable for comparison
+  // using memcmp.
+  template
+concept __memcmp_ordered_with
+  = (__is_memcmp_ordered_with,
+ iter_value_t<_Iter2>>::__value)
+ && contiguous_iterator<_Iter1> && contiguous_iterator<_Iter2>;
 
   // Return a struct with two members, initialized to the smaller of x and y
   // (or x if they compare equal) and the result of the comparison x <=> y.
@@ -1834,20 +1837,20 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
   if (!std::__is_constant_evaluated())
if constexpr (same_as<_Comp, __detail::_Synth3way>
  || same_as<_Comp, compare_three_way>)
- if constexpr (__is_byte_iter<_InputIter1>)
-   if constexpr (__is_byte_iter<_InputIter2>)
- {
-   const auto [__len, __lencmp] = _GLIBCXX_STD_A::
- __min_cmp(__last1 - __first1, __last2 - __first2);
-   if (__len)
- {
-   const auto __c
- = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0;
-   if (__c != 0)
- return __c;
- }
-   return __lencmp;
- }
+ if constexpr (__memcmp_ordered_with<_InputIter1, _InputIter2>)
+   {
+ const auto [__len, __lencmp] = _GLIBCXX_STD_A::
+   __min_cmp(__last1 - __first1, __last2 - __first2);
+ if (__len)
+   {
+ const auto __blen = __len * sizeof(*__first1);
+ const auto __c
+   = __builtin_memcmp(&*__first1, &*__first2, __blen) <=> 0;
+ if (__c != 0)
+   return __c;
+   }
+ return __lencmp;
+   }
 
   while (__first1 != __last1)
{
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc
 
b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc
new file mode 100644
index 000..d51ae1a3d50
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/113960.cc
@@ -0,0 +1,15 @@
+// { dg-do run { target c++20 } }
+
+// PR libstdc++/113960
+// std::map with std::vector as input overwrites itself with c++20, on s390x
+
+#include 
+#include 
+
+int main()
+{
+  unsigned short a1[] { 1, 2, 3 };
+  unsigned short a2[] { 1, 2, 4 };
+  // Incorrect memcmp comparison for big endian targets.
+  VERIFY( std::lexicographical_compare_three_way(a1, a1+3, a2, a2+3) < 0 );
+}


[gcc r12-10252] libstdc++: Fix exception thrown by std::shared_lock::unlock() [PR112089]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:c285c1b9a940bde745f296e1bfc1a5cfddb63254

commit r12-10252-gc285c1b9a940bde745f296e1bfc1a5cfddb63254
Author: Jonathan Wakely 
Date:   Thu Oct 26 16:51:30 2023 +0100

libstdc++: Fix exception thrown by std::shared_lock::unlock() [PR112089]

The incorrect errc constant here looks like a copy&paste error.

libstdc++-v3/ChangeLog:

PR libstdc++/112089
* include/std/shared_mutex (shared_lock::unlock): Change errc
constant to operation_not_permitted.
* testsuite/30_threads/shared_lock/locking/112089.cc: New test.

(cherry picked from commit 0c305f3dec9a992dd775a3b9607b7b1e8c051859)

Diff:
---
 libstdc++-v3/include/std/shared_mutex  |  2 +-
 .../30_threads/shared_lock/locking/112089.cc   | 23 ++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/shared_mutex 
b/libstdc++-v3/include/std/shared_mutex
index 817a9587d87..0a61bedbe12 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -801,7 +801,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   unlock()
   {
if (!_M_owns)
- __throw_system_error(int(errc::resource_deadlock_would_occur));
+ __throw_system_error(int(errc::operation_not_permitted));
_M_pm->unlock_shared();
_M_owns = false;
   }
diff --git a/libstdc++-v3/testsuite/30_threads/shared_lock/locking/112089.cc 
b/libstdc++-v3/testsuite/30_threads/shared_lock/locking/112089.cc
new file mode 100644
index 000..432c17591a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_lock/locking/112089.cc
@@ -0,0 +1,23 @@
+// { dg-do run { target c++14 } }
+// { dg-require-gthreads "" }
+// { dg-additional-options "-pthread" { target pthread } }
+
+#include 
+#include 
+#include 
+
+// PR libstdc++/112089 shared_lock::unlock should throw operation_not_permitted
+
+int main()
+{
+  std::shared_lock l;
+  try
+  {
+l.unlock();
+VERIFY( false );
+  }
+  catch (const std::system_error& e)
+  {
+VERIFY( e.code() == std::errc::operation_not_permitted );
+  }
+}


[gcc r12-10246] libstdc++: Fix Unicode codecvt and add tests [PR86419]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:12c193e5723f08694c8784457200112bae117063

commit r12-10246-g12c193e5723f08694c8784457200112bae117063
Author: Dimitrij Mijoski 
Date:   Tue Jan 10 13:58:59 2023 +0100

libstdc++: Fix Unicode codecvt and add tests [PR86419]

Fixes the conversion from UTF-8 to UTF-16 to properly return partial
instead ok.
Fixes the conversion from UTF-16 to UTF-8 to properly return partial
instead ok.
Fixes the conversion from UTF-8 to UCS-2 to properly return partial
instead error.
Fixes the conversion from UTF-8 to UCS-2 to treat 4-byte UTF-8 sequences
as error just by seeing the leading byte.
Fixes UTF-8 decoding for all codecvts so they detect error at the end of
the input range when the last code point is also incomplete.

libstdc++-v3/ChangeLog:

PR libstdc++/86419
* src/c++11/codecvt.cc (read_utf8_code_point): Correctly detect
errors in incomplete multibyte sequences.
(utf16_in): Remove surrogates parameter. Fix conditions for
returning partial.
(utf16_out): Fix condition for returning partial.
(ucs2_in): Do not pass surrogates argument to utf16_in.
* testsuite/22_locale/codecvt/codecvt_unicode.cc: New test.
* testsuite/22_locale/codecvt/codecvt_unicode.h: New header for
tests.
* testsuite/22_locale/codecvt/codecvt_unicode_wchar_t.cc: New
test.

(cherry picked from commit 02dab998665dda0f6df31740e8897c42de3d740f)

Diff:
---
 libstdc++-v3/src/c++11/codecvt.cc  |   36 +-
 .../testsuite/22_locale/codecvt/codecvt_unicode.cc |   68 ++
 .../testsuite/22_locale/codecvt/codecvt_unicode.h  | 1269 
 .../22_locale/codecvt/codecvt_unicode_wchar_t.cc   |   59 +
 4 files changed, 1414 insertions(+), 18 deletions(-)

diff --git a/libstdc++-v3/src/c++11/codecvt.cc 
b/libstdc++-v3/src/c++11/codecvt.cc
index 9f8cb767732..03f0bfda972 100644
--- a/libstdc++-v3/src/c++11/codecvt.cc
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -277,13 +277,15 @@ namespace
 }
 else if (c1 < 0xF0) // 3-byte sequence
 {
-  if (avail < 3)
+  if (avail < 2)
return incomplete_mb_character;
   char32_t c2 = (unsigned char) from[1];
   if ((c2 & 0xC0) != 0x80)
return invalid_mb_sequence;
   if (c1 == 0xE0 && c2 < 0xA0) // overlong
return invalid_mb_sequence;
+  if (avail < 3)
+   return incomplete_mb_character;
   char32_t c3 = (unsigned char) from[2];
   if ((c3 & 0xC0) != 0x80)
return invalid_mb_sequence;
@@ -292,9 +294,9 @@ namespace
from += 3;
   return c;
 }
-else if (c1 < 0xF5) // 4-byte sequence
+else if (c1 < 0xF5 && maxcode > 0x) // 4-byte sequence
 {
-  if (avail < 4)
+  if (avail < 2)
return incomplete_mb_character;
   char32_t c2 = (unsigned char) from[1];
   if ((c2 & 0xC0) != 0x80)
@@ -302,10 +304,14 @@ namespace
   if (c1 == 0xF0 && c2 < 0x90) // overlong
return invalid_mb_sequence;
   if (c1 == 0xF4 && c2 >= 0x90) // > U+10
-  return invalid_mb_sequence;
+   return invalid_mb_sequence;
+  if (avail < 3)
+   return incomplete_mb_character;
   char32_t c3 = (unsigned char) from[2];
   if ((c3 & 0xC0) != 0x80)
return invalid_mb_sequence;
+  if (avail < 4)
+   return incomplete_mb_character;
   char32_t c4 = (unsigned char) from[3];
   if ((c4 & 0xC0) != 0x80)
return invalid_mb_sequence;
@@ -527,12 +533,11 @@ namespace
   // Flag indicating whether to process UTF-16 or UCS2
   enum class surrogates { allowed, disallowed };
 
-  // utf8 -> utf16 (or utf8 -> ucs2 if s == surrogates::disallowed)
-  template
+  // utf8 -> utf16 (or utf8 -> ucs2 if maxcode <= 0x)
+  template 
   codecvt_base::result
-  utf16_in(range& from, range& to,
-  unsigned long maxcode = max_code_point, codecvt_mode mode = {},
-  surrogates s = surrogates::allowed)
+  utf16_in(range &from, range &to,
+  unsigned long maxcode = max_code_point, codecvt_mode mode = {})
   {
 read_utf8_bom(from, mode);
 while (from.size() && to.size())
@@ -540,12 +545,7 @@ namespace
auto orig = from;
const char32_t codepoint = read_utf8_code_point(from, maxcode);
if (codepoint == incomplete_mb_character)
- {
-   if (s == surrogates::allowed)
- return codecvt_base::partial;
-   else
- return codecvt_base::error; // No surrogates in UCS2
- }
+ return codecvt_base::partial;
if (codepoint > maxcode)
  return codecvt_base::error;
if (!write_utf16_code_point(to, codepoint, mode))
@@ -554,7 +554,7 @@ namespace
return codecvt_base::partial;
  }
   }
-return codecvt_base::ok;
+return from.size() ? codecvt_base::partial : codecvt_base::ok;
   }
 
   // utf16 -> utf8 (

[gcc r12-10253] libstdc++: Remove non-void static assertions in variant's std::get [PR111172]

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:15c517049c0d8b6319990445939a69bb36fdc678

commit r12-10253-g15c517049c0d8b6319990445939a69bb36fdc678
Author: Jonathan Wakely 
Date:   Tue Sep 12 21:28:38 2023 +0100

libstdc++: Remove non-void static assertions in variant's std::get 
[PR72]

A void template argument would cause a substitution failure when trying
to form a reference for the return type, so the function body would
never be instantiated.

libstdc++-v3/ChangeLog:

PR libstdc++/72
* include/std/variant (get): Remove !is_void static
assertions.

(cherry picked from commit d19bdf8874059457fdfe50a9e14dad8f8b8cecbb)

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

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 64145da12bb..9abe7b9ed6d 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1150,7 +1150,6 @@ namespace __variant
 {
   static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T must occur exactly once in alternatives");
-  static_assert(!is_void_v<_Tp>, "_Tp must not be void");
   constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
   return std::get<__n>(__v);
 }
@@ -1161,7 +1160,6 @@ namespace __variant
 {
   static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T must occur exactly once in alternatives");
-  static_assert(!is_void_v<_Tp>, "_Tp must not be void");
   constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
   return std::get<__n>(std::move(__v));
 }
@@ -1172,7 +1170,6 @@ namespace __variant
 {
   static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T must occur exactly once in alternatives");
-  static_assert(!is_void_v<_Tp>, "_Tp must not be void");
   constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
   return std::get<__n>(__v);
 }
@@ -1183,7 +1180,6 @@ namespace __variant
 {
   static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T must occur exactly once in alternatives");
-  static_assert(!is_void_v<_Tp>, "_Tp must not be void");
   constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
   return std::get<__n>(std::move(__v));
 }


[gcc r12-10254] libstdc++: Add static_assert to std::integer_sequence [PR112473]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:dc0964f43dcee46dcd1843287a541668fd08a4a8

commit r12-10254-gdc0964f43dcee46dcd1843287a541668fd08a4a8
Author: Jonathan Wakely 
Date:   Fri Nov 10 12:21:52 2023 +

libstdc++: Add static_assert to std::integer_sequence [PR112473]

C++20 allows class types as non-type template parameters, but
std::integer_sequence explicitly disallows them. Enforce that.

libstdc++-v3/ChangeLog:

PR libstdc++/112473
* include/bits/utility.h (integer_sequence): Add static_assert.
* testsuite/20_util/integer_sequence/112473.cc: New test.

(cherry picked from commit 0953497a81f1e320989b9f2aaa7f56747eddd4a0)

Diff:
---
 libstdc++-v3/include/bits/utility.h   | 3 +++
 libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc | 8 
 2 files changed, 11 insertions(+)

diff --git a/libstdc++-v3/include/bits/utility.h 
b/libstdc++-v3/include/bits/utility.h
index 180866e3581..6483a8e537e 100644
--- a/libstdc++-v3/include/bits/utility.h
+++ b/libstdc++-v3/include/bits/utility.h
@@ -163,6 +163,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 struct integer_sequence
 {
+#if __cplusplus >= 202002L
+  static_assert(is_integral_v<_Tp>);
+#endif
   typedef _Tp value_type;
   static constexpr size_t size() noexcept { return sizeof...(_Idx); }
 };
diff --git a/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc 
b/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc
new file mode 100644
index 000..14abfbc8149
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/integer_sequence/112473.cc
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++20 } }
+
+// PR libstdc++/112473 - integer_sequence accepts non-integer types
+
+#include 
+
+std::integer_sequence, std::pair{0, 0}> ic;
+// { dg-error "static assertion failed" "" { target *-*-* } 0 }


[gcc r12-10255] libstdc++: Explicitly default some copy ctors and assignments

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:a389921f175c30e8ca0da38ccb79ed60cf744fd4

commit r12-10255-ga389921f175c30e8ca0da38ccb79ed60cf744fd4
Author: Jonathan Wakely 
Date:   Tue Aug 8 16:24:31 2023 +0100

libstdc++: Explicitly default some copy ctors and assignments

The standard says that the implicit copy assignment operator is
deprecated for classes that have a user-provided copy constructor, and
vice versa.

libstdc++-v3/ChangeLog:

* include/bits/new_allocator.h (__new_allocator): Define copy
assignment operator as defaulted.
* include/std/complex (complex, complex)
(complex): Define copy constructor as defaulted.

(cherry picked from commit 008e439f34d4b356825a6c9b70245143f00bd353)

Diff:
---
 libstdc++-v3/include/bits/new_allocator.h |  4 
 libstdc++-v3/include/std/complex  | 12 
 2 files changed, 16 insertions(+)

diff --git a/libstdc++-v3/include/bits/new_allocator.h 
b/libstdc++-v3/include/bits/new_allocator.h
index 99f7a2ee51e..d066d015a9d 100644
--- a/libstdc++-v3/include/bits/new_allocator.h
+++ b/libstdc++-v3/include/bits/new_allocator.h
@@ -86,6 +86,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX20_CONSTEXPR
__new_allocator(const __new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
 
+#if __cplusplus >= 201103L
+  __new_allocator& operator=(const __new_allocator&) = default;
+#endif
+
 #if __cplusplus <= 201703L
   ~__new_allocator() _GLIBCXX_USE_NOEXCEPT { }
 
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 8f9368fd7d0..bdc238e73b0 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -1098,6 +1098,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
+#if __cplusplus >= 201103L
+  _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
   explicit _GLIBCXX_CONSTEXPR complex(const complex&);
   explicit _GLIBCXX_CONSTEXPR complex(const complex&);
 
@@ -1244,6 +1248,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
+#if __cplusplus >= 201103L
+  _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
   _GLIBCXX_CONSTEXPR complex(const complex& __z)
   : _M_value(__z.__rep()) { }
 
@@ -1391,6 +1399,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 #endif
 
+#if __cplusplus >= 201103L
+  _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
   _GLIBCXX_CONSTEXPR complex(const complex& __z)
   : _M_value(__z.__rep()) { }


[gcc r12-10249] libstdc++: Make std::istream_iterator copy ctor constexpr (LWG 3600)

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:af1efe9ffeb4d21e2895081be1b88031166cdb93

commit r12-10249-gaf1efe9ffeb4d21e2895081be1b88031166cdb93
Author: Jonathan Wakely 
Date:   Wed Mar 22 11:10:38 2023 +

libstdc++: Make std::istream_iterator copy ctor constexpr (LWG 3600)

As explained in LWG 3600, we never implemented a C++0x change that made
the copy constructor of std::istream_iterator defined as defaulted. That
would be an ABI break, so the resolution of LWG 3600 is to not require
it to be trivial, but just constexpr and conditionally noexcept. This
applies that resolution.

libstdc++-v3/ChangeLog:

* include/bits/stream_iterator.h (istream_iterator): Add
constexpr to copy constructor, as per LWG 3600.
* testsuite/24_iterators/istream_iterator/cons/constexpr.cc:
Check copy construction.

(cherry picked from commit ad0b9cf1a076fb9a802d9ba7fa2223aa3166dca2)

Diff:
---
 libstdc++-v3/include/bits/stream_iterator.h  | 1 +
 .../testsuite/24_iterators/istream_iterator/cons/constexpr.cc| 5 +
 2 files changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/bits/stream_iterator.h 
b/libstdc++-v3/include/bits/stream_iterator.h
index 86c5845b835..019eaf840e7 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -77,6 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   : _M_stream(std::__addressof(__s)), _M_ok(true)
   { _M_read(); }
 
+  _GLIBCXX_CONSTEXPR
   istream_iterator(const istream_iterator& __obj)
   _GLIBCXX_NOEXCEPT_IF(is_nothrow_copy_constructible<_Tp>::value)
   : _M_stream(__obj._M_stream), _M_value(__obj._M_value),
diff --git 
a/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/constexpr.cc 
b/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/constexpr.cc
index 6b973c611a7..9570e7b9280 100644
--- a/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/constexpr.cc
+++ b/libstdc++-v3/testsuite/24_iterators/istream_iterator/cons/constexpr.cc
@@ -24,5 +24,10 @@ int main()
 {
   __gnu_test::constexpr_default_constructible test;
   test.operator()>();
+
+  // LWG 3600. Making istream_iterator copy constructor trivial is an ABI break
+  __gnu_test::constexpr_single_value_constructible test2;
+  test2.operator(), std::istream_iterator>();
+
   return 0;
 }


[gcc r12-10256] libstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0135f93383b72b24ac62a82593b3ce30d0c3b69f

commit r12-10256-g0135f93383b72b24ac62a82593b3ce30d0c3b69f
Author: Jonathan Wakely 
Date:   Thu Sep 7 17:03:40 2023 +0100

libstdc++: Add autoconf checks for mkdir, chmod, chdir, and getcwd

The filesystem code was using these functions without checking for their
existence, assuming that any UNIX-like libc with  would always
provide them. That's not true for some newlib targets like arm-eabi.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for mkdir,
chmod, chdir, and getcwd.
* config.h.in: Regenerate.
* configure: Regenerate.
* src/c++17/fs_ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.
* src/filesystem/ops-common.h [FILESYSTEM_IS_WINDOWS]
(chmod, mkdir, getcwd, chdir): Define new macros.
[FILESYSTEM_IS_WINDOWS] (chmod, mkdir, getcwd, chdir): Use
new macros.
* src/filesystem/ops.cc (create_dir): Use USE_MKDIR macro.
(fs::current_path): Use USE_GETCWD and USE_CHDIR macros.
(fs::permissions): Use USE_CHMOD macro.

(cherry picked from commit 5435449be0eb9ca41824eb16f774db3ccc2a593b)

Diff:
---
 libstdc++-v3/acinclude.m4|  60 
 libstdc++-v3/config.h.in |  12 ++
 libstdc++-v3/configure   | 252 +++
 libstdc++-v3/src/c++17/fs_ops.cc |  12 +-
 libstdc++-v3/src/filesystem/ops-common.h |  18 ++-
 libstdc++-v3/src/filesystem/ops.cc   |  10 +-
 6 files changed, 355 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 3b657f04443..cf6dbc3b165 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -4569,6 +4569,66 @@ dnl
   if test $glibcxx_cv_dirent_d_type = yes; then
 AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1, [Define to 1 if `d_type' is a 
member of `struct dirent'.])
   fi
+dnl
+  AC_CACHE_CHECK([for chmod], glibcxx_cv_chmod, [dnl
+GCC_TRY_COMPILE_OR_LINK(
+  [
+   #include 
+  ],
+  [
+   int i = chmod("", S_IRUSR);
+  ],
+  [glibcxx_cv_chmod=yes],
+  [glibcxx_cv_chmod=no])
+  ])
+  if test $glibcxx_cv_chmod = yes; then
+AC_DEFINE(_GLIBCXX_USE_CHMOD, 1, [Define if usable chmod is available in 
.])
+  fi
+dnl
+  AC_CACHE_CHECK([for mkdir], glibcxx_cv_mkdir, [dnl
+GCC_TRY_COMPILE_OR_LINK(
+  [
+   #include 
+  ],
+  [
+   int i = mkdir("", S_IRUSR);
+  ],
+  [glibcxx_cv_mkdir=yes],
+  [glibcxx_cv_mkdir=no])
+  ])
+  if test $glibcxx_cv_mkdir = yes; then
+AC_DEFINE(_GLIBCXX_USE_MKDIR, 1, [Define if usable mkdir is available in 
.])
+  fi
+dnl
+  AC_CACHE_CHECK([for chdir], glibcxx_cv_chdir, [dnl
+GCC_TRY_COMPILE_OR_LINK(
+  [
+   #include 
+  ],
+  [
+   int i = chdir("");
+  ],
+  [glibcxx_cv_chdir=yes],
+  [glibcxx_cv_chdir=no])
+  ])
+  if test $glibcxx_cv_chdir = yes; then
+AC_DEFINE(_GLIBCXX_USE_CHDIR, 1, [Define if usable chdir is available in 
.])
+  fi
+dnl
+  AC_CACHE_CHECK([for getcwd], glibcxx_cv_getcwd, [dnl
+GCC_TRY_COMPILE_OR_LINK(
+  [
+   #include 
+  ],
+  [
+   char* s = getcwd((char*)0, 1);
+  ],
+  [glibcxx_cv_getcwd=yes],
+  [glibcxx_cv_getcwd=no])
+  ])
+  if test $glibcxx_cv_getcwd = yes; then
+AC_DEFINE(_GLIBCXX_USE_GETCWD, 1, [Define if usable getcwd is available in 
.])
+  fi
 dnl
   AC_CACHE_CHECK([for realpath], glibcxx_cv_realpath, [dnl
 GCC_TRY_COMPILE_OR_LINK(
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 2a3972eef54..639000d797a 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -933,6 +933,12 @@
namespace std::tr1. */
 #undef _GLIBCXX_USE_C99_STDINT_TR1
 
+/* Define if usable chdir is available in . */
+#undef _GLIBCXX_USE_CHDIR
+
+/* Define if usable chmod is available in . */
+#undef _GLIBCXX_USE_CHMOD
+
 /* Defined if clock_gettime syscall has monotonic and realtime clock support.
*/
 #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
@@ -957,6 +963,9 @@
 /* Define if fchmodat is available in . */
 #undef _GLIBCXX_USE_FCHMODAT
 
+/* Define if usable getcwd is available in . */
+#undef _GLIBCXX_USE_GETCWD
+
 /* Defined if gettimeofday is available. */
 #undef _GLIBCXX_USE_GETTIMEOFDAY
 
@@ -972,6 +981,9 @@
 /* Define if lstat is available in . */
 #undef _GLIBCXX_USE_LSTAT
 
+/* Define if usable mkdir is available in . */
+#undef _GLIBCXX_USE_MKDIR
+
 /* Defined if nanosleep is available. */
 #undef _GLIBCXX_USE_NANOSLEEP
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 926d91b076b..bc92ce1303c 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -76336,6 +76336,258 @@ $as_echo "$glibcxx_cv_

[gcc r12-10257] libstdc++: Define std::basic_stringbuf::view() for old std::string ABI

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:e35b26c2442b61e7f45deb5ef3062d0ab6ec584b

commit r12-10257-ge35b26c2442b61e7f45deb5ef3062d0ab6ec584b
Author: Jonathan Wakely 
Date:   Tue Jan 31 22:32:15 2023 +

libstdc++: Define std::basic_stringbuf::view() for old std::string ABI

Unlike the new str()&& members in , there is no real difficulty
in supporting the new view() members for the old std::string ABI.
Enabling it fixes errors in  where std::ostringstream::view() is
used by ostream insertion operators for calendar types.

We just need to use [[gnu::always_inline]] on the view() members for the
old ABI, because the library doesn't contain instantiations of them for
the old ABI. Making them always inline avoids needing to add those
instantiations and export them.

libstdc++-v3/ChangeLog:

* include/std/sstream  (basic_stringbuf::view): Define for old
std::string ABI.
(basic_istringstream::view, basic_stringstream::view)
(basic_stringstream::view): Likewise.
* testsuite/27_io/basic_istringstream/view/char/1.cc: Remove
{ dg-require-effective-target cxx11_abi }.
* testsuite/27_io/basic_istringstream/view/wchar_t/1.cc:
Likewise.
* testsuite/27_io/basic_ostringstream/view/char/1.cc: Likewise.
* testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc:
Likewise.
* testsuite/27_io/basic_stringbuf/view/char/1.cc: Likewise.
* testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/char/1.cc: Likewise.
* testsuite/27_io/basic_stringstream/view/wchar_t/1.cc:
Likewise.

(cherry picked from commit 331b4f168a06cd85fe40fd03b48b128cc8af399c)

Diff:
---
 libstdc++-v3/include/std/sstream   | 32 +-
 .../27_io/basic_istringstream/view/char/1.cc   |  1 -
 .../27_io/basic_istringstream/view/wchar_t/1.cc|  1 -
 .../27_io/basic_ostringstream/view/char/1.cc   |  1 -
 .../27_io/basic_ostringstream/view/wchar_t/1.cc|  1 -
 .../testsuite/27_io/basic_stringbuf/view/char/1.cc |  1 -
 .../27_io/basic_stringbuf/view/wchar_t/1.cc|  1 -
 .../27_io/basic_stringstream/view/char/1.cc|  1 -
 .../27_io/basic_stringstream/view/wchar_t/1.cc |  1 -
 9 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index bc7d636e702..3a86888a76c 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -41,10 +41,15 @@
 
 #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
 # define _GLIBCXX_LVAL_REF_QUAL &
+# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
 #else
 # define _GLIBCXX_LVAL_REF_QUAL
+// For symbols that are not exported from libstdc++.so for the COW string ABI.
+# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
 #endif
 
+
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -249,7 +254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return __ret;
   }
 
-#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+#if __cplusplus > 201703L
+#if _GLIBCXX_USE_CXX11_ABI
 #if __cpp_concepts
   template<__allocator_like _SAlloc>
basic_string<_CharT, _Traits, _SAlloc>
@@ -273,7 +279,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_sync(_M_string.data(), 0, 0);
return __str;
   }
+#endif // cxx11 ABI
 
+  _GLIBCXX_SSTREAM_ALWAYS_INLINE
   basic_string_view
   view() const noexcept
   {
@@ -696,7 +704,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   str() const _GLIBCXX_LVAL_REF_QUAL
   { return _M_stringbuf.str(); }
 
-#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+#if __cplusplus > 201703L
+#if _GLIBCXX_USE_CXX11_ABI
 #if __cpp_concepts
   template<__allocator_like _SAlloc>
basic_string<_CharT, _Traits, _SAlloc>
@@ -707,11 +716,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   __string_type
   str() &&
   { return std::move(_M_stringbuf).str(); }
+#endif // cxx11 ABI
 
+  _GLIBCXX_SSTREAM_ALWAYS_INLINE
   basic_string_view
   view() const noexcept
   { return _M_stringbuf.view(); }
-#endif
+#endif // C++20
 
   /**
*  @brief  Setting a new buffer.
@@ -917,7 +928,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   str() const _GLIBCXX_LVAL_REF_QUAL
   { return _M_stringbuf.str(); }
 
-#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
+#if __cplusplus > 201703L
+#if _GLIBCXX_USE_CXX11_ABI
 #if __cpp_concepts
   template<__allocator_like _SAlloc>
basic_string<_CharT, _Traits, _SAlloc>
@@ -928,11 +940,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   __string_type
   str() &&
   { return std::move(_M_stringbuf).str(); }
+#endif // cxx11 ABI
 
+  _GLIBCXX_SSTREAM_ALWAYS_INLINE
   basic_string_view
   view() const noexcept
   { return _M_stringbuf.view(); }
-

[gcc r12-10258] libstdc++: Fix allocator propagation in regex algorithms [PR107376]

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:5c156f5be49007a5434452335f29844eb17868a6

commit r12-10258-g5c156f5be49007a5434452335f29844eb17868a6
Author: Jonathan Wakely 
Date:   Tue Oct 25 13:03:12 2022 +0100

libstdc++: Fix allocator propagation in regex algorithms [PR107376]

The PR points out that we assume the match_results allocator is default
constuctible, which might not be true. We also have a related issue with
unwanted propagation from an object that might have an unequal
allocator.

Ideally we use the same allocator type for _State_info::_M_match_queue
but that would be an ABI change now. We should investigate if that can
be done without breaking anything, which might be possible because the
_Executor object is short-lived and never leaks out of the regex_match,
regex_search, and regex_replace algorithms. If we change the mangled
name for _Executor then there would be no ODR violations when mixing old
and new definitions. This commit does not attempt that.

libstdc++-v3/ChangeLog:

PR libstdc++/107376
* include/bits/regex_executor.h (_Executor::_Executor): Use same
allocator for _M_cur_results and _M_results.
* include/bits/regex_executor.tcc (_Executor::_M_main_dispatch):
Prevent possibly incorrect allocator propagating to
_M_cur_results.
* testsuite/28_regex/algorithms/regex_match/107376.cc: New test.

(cherry picked from commit 988dd22ec6665117e8587389ac85389f1c321c45)

Diff:
---
 libstdc++-v3/include/bits/regex_executor.h | 17 ++---
 libstdc++-v3/include/bits/regex_executor.tcc   |  3 +-
 .../28_regex/algorithms/regex_match/107376.cc  | 76 ++
 3 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/include/bits/regex_executor.h 
b/libstdc++-v3/include/bits/regex_executor.h
index dc0878ce678..cdafcd5523d 100644
--- a/libstdc++-v3/include/bits/regex_executor.h
+++ b/libstdc++-v3/include/bits/regex_executor.h
@@ -71,14 +71,15 @@ namespace __detail
_ResultsVec&__results,
const _RegexT&  __re,
_FlagT  __flags)
-  : _M_begin(__begin),
-  _M_end(__end),
-  _M_re(__re),
-  _M_nfa(*__re._M_automaton),
-  _M_results(__results),
-  _M_rep_count(_M_nfa.size()),
-  _M_states(_M_nfa._M_start(), _M_nfa.size()),
-  _M_flags(__flags)
+  : _M_cur_results(__results.get_allocator()),
+   _M_begin(__begin),
+   _M_end(__end),
+   _M_re(__re),
+   _M_nfa(*__re._M_automaton),
+   _M_results(__results),
+   _M_rep_count(_M_nfa.size()),
+   _M_states(_M_nfa._M_start(), _M_nfa.size()),
+   _M_flags(__flags)
   {
using namespace regex_constants;
if (__flags & match_prev_avail) // ignore not_bol and not_bow
diff --git a/libstdc++-v3/include/bits/regex_executor.tcc 
b/libstdc++-v3/include/bits/regex_executor.tcc
index b93e958075e..a5885ed34ba 100644
--- a/libstdc++-v3/include/bits/regex_executor.tcc
+++ b/libstdc++-v3/include/bits/regex_executor.tcc
@@ -124,9 +124,10 @@ namespace __detail
break;
  std::fill_n(_M_states._M_visited_states, _M_nfa.size(), false);
  auto __old_queue = std::move(_M_states._M_match_queue);
+ auto __alloc = _M_cur_results.get_allocator();
  for (auto& __task : __old_queue)
{
- _M_cur_results = std::move(__task.second);
+ _M_cur_results = _ResultsVec(std::move(__task.second), __alloc);
  _M_dfs(__match_mode, __task.first);
}
  if (__match_mode == _Match_mode::_Prefix)
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/107376.cc 
b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/107376.cc
new file mode 100644
index 000..da4f7ad0a23
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/107376.cc
@@ -0,0 +1,76 @@
+// { dg-do run { target c++11 } }
+#include 
+#include 
+#include 
+
+template
+struct Alloc
+{
+  using value_type = T;
+  explicit Alloc(int) { }
+  template Alloc(const Alloc&) { }
+
+  T* allocate(std::size_t n)
+  { return std::allocator().allocate(n); }
+  void deallocate(T* ptr, std::size_t n)
+  { std::allocator().deallocate(ptr, n); }
+
+  bool operator==(const Alloc&) const { return true; }
+  bool operator!=(const Alloc&) const { return false; }
+};
+
+void
+test_non_default_constructible()
+{
+  using sub_match = std::sub_match;
+  using alloc_type = Alloc;
+  using match_results = std::match_results;
+  match_results res(alloc_type(1));
+
+  std::regex_match("x", res, std::regex(".")); // PR libstdc++/107376
+}
+
+template
+struct PropAlloc
+{
+  int id;
+
+  using value_type = T;
+  explicit PropAlloc(int id) : id(id) { }
+  template PropAlloc(const PropAlloc& a) : id(a.id) { }
+
+  using propagate_on_container_move_assignment = std::true_type;
+  using propagate_on_container

[gcc r12-10265] libstdc++: Add macros for the inline namespace std::_V2

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:f8ab9b7c08161739242b2760f881a3918373cd46

commit r12-10265-gf8ab9b7c08161739242b2760f881a3918373cd46
Author: Jonathan Wakely 
Date:   Wed May 11 16:35:45 2022 +0100

libstdc++: Add macros for the inline namespace std::_V2

Use macros to open and close the inline namespace _V2 that is used for
ABI versioning of individual components such as chrono::system_clock.

This allows the namespace to be hidden in the docs generated by Doxygen,
so that we document std::foo instead of std::_V2::foo.

This also makes it easy to remove that namespace entirely for the
gnu-versioned-namespace build, where everything is already versioned as
std::__8 and there are no backwards compatibility guarantees.

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Expand new macros to
nothing.
* include/bits/c++config (_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE)
(_GLIBCXX_END_INLINE_ABI_NAMESPACE): Define new macros.
* include/bits/algorithmfwd.h (_V2::__rotate): Use new macros
for the namespace.
* include/bits/chrono.h (chrono::_V2::system_clock): Likewise.
* include/bits/stl_algo.h (_V2::__rotate): Likewise.
* include/std/condition_variable (_V2::condition_variable_any):
Likewise.
* include/std/system_error (_V2::error_category): Likewise.

(cherry picked from commit e4905f11852d722cd711b53a5626245528ace1d2)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in|  2 ++
 libstdc++-v3/include/bits/algorithmfwd.h| 15 ---
 libstdc++-v3/include/bits/c++config | 11 +--
 libstdc++-v3/include/bits/chrono.h  |  4 ++--
 libstdc++-v3/include/bits/stl_algo.h|  5 ++---
 libstdc++-v3/include/std/condition_variable |  4 ++--
 libstdc++-v3/include/std/system_error   |  5 +++--
 7 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index b095addd10c..ba85d4bb2a8 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -2348,6 +2348,8 @@ PREDEFINED = __cplusplus=202002L \
  "_GLIBCXX_END_NAMESPACE_CONTAINER= " \
  "_GLIBCXX_END_NAMESPACE_CXX11= " \
  "_GLIBCXX_END_NAMESPACE_LDBL= " \
+"-D_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)= " \
+"-D_GLIBCXX_END_INLINE_ABI_NAMESPACE(X)= " \
  "_GLIBCXX_TEMPLATE_ARGS=...  " \
  "_GLIBCXX_DEPRECATED= " \
  "_GLIBCXX_DEPRECATED_SUGGEST(E)= " \
diff --git a/libstdc++-v3/include/bits/algorithmfwd.h 
b/libstdc++-v3/include/bits/algorithmfwd.h
index 5b85b0bc60d..4cfc53f4968 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -601,13 +601,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _OIter
 reverse_copy(_BIter, _BIter, _OIter);
 
-  inline namespace _V2
-  {
-template
-  _GLIBCXX20_CONSTEXPR
-  _FIter
-  rotate(_FIter, _FIter, _FIter);
-  }
+_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
+
+  template
+_GLIBCXX20_CONSTEXPR
+_FIter
+rotate(_FIter, _FIter, _FIter);
+
+_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
 
   template
 _GLIBCXX20_CONSTEXPR
diff --git a/libstdc++-v3/include/bits/c++config 
b/libstdc++-v3/include/bits/c++config
index 2798b9786dc..150b0bc5834 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -345,13 +345,16 @@ namespace __gnu_cxx
 # define _GLIBCXX_DEFAULT_ABI_TAG
 #endif
 
-// Defined if inline namespaces are used for versioning.
+// Non-zero if inline namespaces are used for versioning the entire library.
 #define _GLIBCXX_INLINE_VERSION 
 
-// Inline namespace for symbol versioning.
 #if _GLIBCXX_INLINE_VERSION
+// Inline namespace for symbol versioning of (nearly) everything in std.
 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 {
 # define _GLIBCXX_END_NAMESPACE_VERSION }
+// Unused when everything in std is versioned anyway.
+# define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X)
+# define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X)
 
 namespace std
 {
@@ -376,8 +379,12 @@ _GLIBCXX_END_NAMESPACE_VERSION
 }
 
 #else
+// Unused.
 # define _GLIBCXX_BEGIN_NAMESPACE_VERSION
 # define _GLIBCXX_END_NAMESPACE_VERSION
+// Used to version individual components, e.g. std::_V2::error_category.
+# define _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(X) inline namespace X {
+# define _GLIBCXX_END_INLINE_ABI_NAMESPACE(X)   } // inline namespace X
 #endif
 
 // Inline namespaces for special modes: debug, parallel.
diff --git a/libstdc++-v3/include/bits/chrono.h 
b/libstdc++-v3/include/bits/chrono.h
index d09f8563a59..43d91b8713b 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chro

[gcc r12-10259] libstdc++: use grep -E instead of egrep in scripts

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:c6f80dca4e51eaab3f12884e19b3dbbfe9cdffd7

commit r12-10259-gc6f80dca4e51eaab3f12884e19b3dbbfe9cdffd7
Author: Xi Ruoyao 
Date:   Fri Jun 24 15:02:23 2022 +0800

libstdc++: use grep -E instead of egrep in scripts

egrep has been deprecated in favor of grep -E for a long time, and the
next grep release (3.8 or 4.0) will print a warning of egrep is used.
Stop using egrep so we won't see the warning.

grep's from GNU, BSD (including Mac OS X), AIX, BusyBox all support -E
and -F.  Solaris grep doesn't support -E, but extract_symvers.in already
contains a special case for Solaris and doxygen documentation generation
is already broken on non-GNU.

libstdc++-v3/ChangeLog:

* scripts/extract_symvers.in: Use grep -E instead of egrep.
* scripts/run_doxygen: Likewise.

(cherry picked from commit fa4e97907fc979f550c3f02cde03d9c35f99df9b)

Diff:
---
 libstdc++-v3/scripts/extract_symvers.in | 4 ++--
 libstdc++-v3/scripts/run_doxygen| 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/scripts/extract_symvers.in 
b/libstdc++-v3/scripts/extract_symvers.in
index dd9f63d4f16..d8ea62355ae 100755
--- a/libstdc++-v3/scripts/extract_symvers.in
+++ b/libstdc++-v3/scripts/extract_symvers.in
@@ -54,8 +54,8 @@ SunOS)
   ${readelf} ${lib} |\
   sed -e 's/ \[: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\
   sed -e 's/ \[: [0-9]*\] //' |\
-  egrep -v ' (LOCAL|UND) ' |\
-  egrep -v ' 
(_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_end|_etext)$' 
|\
+  grep -E -v ' (LOCAL|UND) ' |\
+  grep -E -v ' 
(_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_end|_etext)$' 
|\
   sed -e 's/ : / :_/g' |\
   sed -e 's/ : / :_/g' |\
   sed -e 's/ : / :_/g' |\
diff --git a/libstdc++-v3/scripts/run_doxygen b/libstdc++-v3/scripts/run_doxygen
index 86da071d86c..50514c744c9 100644
--- a/libstdc++-v3/scripts/run_doxygen
+++ b/libstdc++-v3/scripts/run_doxygen
@@ -291,7 +291,7 @@ cxxflags="-Og -g -std=gnu++23"
 $gxx $cppflags $cxxflags ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader || 
exit 1
 # Doxygen outputs something like "\fC#include \fP" and
 # we want that internal header to be replaced with something like .
-problematic=`egrep -l '#include <.*h>' [a-z]*.3`
+problematic=`grep -E -l '#include <.*h>' [a-z]*.3`
 for f in $problematic; do
 # this is also slow, but safe and easy to debug
 oldh=`sed -n '/fC#include .*/\1/p' $f`
@@ -303,7 +303,7 @@ rm stdheader
 # Some of the pages for generated modules have text that confuses certain
 # implementations of man(1), e.g. on GNU/Linux.  We need to have another
 # top-level *roff tag to /stop/ the .SH NAME entry.
-problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
+problematic=`grep -E --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
 #problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
 
 for f in $problematic; do


[gcc r12-10267] libstdc++: Improve doxygen docs for

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:f0db5dfce8c729def8ce12ff7e3ed3b1e4f49467

commit r12-10267-gf0db5dfce8c729def8ce12ff7e3ed3b1e4f49467
Author: Jonathan Wakely 
Date:   Wed May 11 23:52:20 2022 +0100

libstdc++: Improve doxygen docs for 

libstdc++-v3/ChangeLog:

* include/std/atomic: Suppress doxygen docs for
implementation details.
* include/bits/atomic_base.h: Likewise.
* include/bits/shared_ptr_atomic.h: Use markdown. Fix grouping
so that std::atomic is not added to the pointer abstractions
group.

(cherry picked from commit 1566ca0969ac4a14f7434d710e75dd89da303e75)

Diff:
---
 libstdc++-v3/include/bits/atomic_base.h   | 39 ---
 libstdc++-v3/include/bits/shared_ptr_atomic.h | 32 +-
 libstdc++-v3/include/std/atomic   |  8 +++---
 3 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/libstdc++-v3/include/bits/atomic_base.h 
b/libstdc++-v3/include/bits/atomic_base.h
index 5cf217dbf28..d29e4434177 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -86,6 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 } memory_order;
 #endif
 
+  /// @cond undocumented
   enum __memory_order_modifier
 {
   __memory_order_mask  = 0x0,
@@ -93,6 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __memory_order_hle_acquire   = 0x1,
   __memory_order_hle_release   = 0x2
 };
+  /// @endcond
 
   constexpr memory_order
   operator|(memory_order __m, __memory_order_modifier __mod)
@@ -106,6 +108,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 return memory_order(int(__m) & int(__mod));
   }
 
+  /// @cond undocumented
+
   // Drop release ordering as per [atomics.types.operations.req]/21
   constexpr memory_order
   __cmpexch_failure_order2(memory_order __m) noexcept
@@ -128,6 +132,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& (__m & __memory_order_mask) != memory_order_acq_rel;
   }
 
+  // Base types for atomics.
+  template
+struct __atomic_base;
+
+  /// @endcond
+
   _GLIBCXX_ALWAYS_INLINE void
   atomic_thread_fence(memory_order __m) noexcept
   { __atomic_thread_fence(int(__m)); }
@@ -145,16 +155,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return __ret;
 }
 
-  // Base types for atomics.
-  template
-struct __atomic_base;
-
-#if __cplusplus <= 201703L
-# define _GLIBCXX20_INIT(I)
-#else
+#if __cplusplus >= 202002L
 # define __cpp_lib_atomic_value_initialization 201911L
+#endif
+
+/// @cond undocumented
+#if __cpp_lib_atomic_value_initialization
 # define _GLIBCXX20_INIT(I) = I
+#else
+# define _GLIBCXX20_INIT(I)
 #endif
+/// @endcond
 
 #define ATOMIC_VAR_INIT(_VI) { _VI }
 
@@ -171,8 +182,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 typedef unsigned char __atomic_flag_data_type;
 #endif
 
-  /**
-   *  @brief Base type for atomic_flag.
+  /// @cond undocumented
+
+  /*
+   *  Base type for atomic_flag.
*
*  Base type is POD with data, allowing atomic_flag to derive from
*  it and meet the standard layout type requirement. In addition to
@@ -190,6 +203,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   _GLIBCXX_END_EXTERN_C
 
+  /// @endcond
+
 #define ATOMIC_FLAG_INIT { 0 }
 
   /// atomic_flag
@@ -295,6 +310,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; }
   };
 
+  /// @cond undocumented
 
   /// Base class for atomic integrals.
   //
@@ -936,7 +952,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); }
 };
 
+  /// @endcond
+
 #if __cplusplus > 201703L
+  /// @cond undocumented
+
   // Implementation details of atomic_ref and atomic.
   namespace __atomic_impl
   {
@@ -1936,6 +1956,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _Tp** _M_ptr;
 };
 
+  /// @endcond
 #endif // C++2a
 
   /// @} group atomics
diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h 
b/libstdc++-v3/include/bits/shared_ptr_atomic.h
index e903fe89424..51ad32ce21b 100644
--- a/libstdc++-v3/include/bits/shared_ptr_atomic.h
+++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h
@@ -64,9 +64,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
* @addtogroup pointer_abstractions
+   * @relates shared_ptr
* @{
*/
-  /// @relates shared_ptr @{
 
   /// @cond undocumented
 
@@ -120,8 +120,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @param  __p A non-null pointer to a shared_ptr object.
*  @return @c *__p
*
-   *  The memory order shall not be @c memory_order_release or
-   *  @c memory_order_acq_rel.
+   *  The memory order shall not be `memory_order_release` or
+   *  `memory_order_acq_rel`.
*  @{
   */
   template
@@ -156,8 +156,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @param  __p A non-null pointer to a shared_ptr object.
*  @param  __r The value to store.
*
-   *  The memory order shall not be @c memory_order_acquire or
-   *  @c memory_order_acq_rel.
+   *

[gcc r12-10260] libstdc++: Improve doxygen docs for std::pointer_traits

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:51e9dcc664293ee269bf18189646d9dd4e89382d

commit r12-10260-g51e9dcc664293ee269bf18189646d9dd4e89382d
Author: Jonathan Wakely 
Date:   Wed May 11 16:13:16 2022 +0100

libstdc++: Improve doxygen docs for std::pointer_traits

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h: Add some doxygen comments.

(cherry picked from commit 757146fb1c82b49e78ee82c882677814f25c2429)

Diff:
---
 libstdc++-v3/include/bits/ptr_traits.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/bits/ptr_traits.h 
b/libstdc++-v3/include/bits/ptr_traits.h
index 047efa5cf28..8360c3b6557 100644
--- a/libstdc++-v3/include/bits/ptr_traits.h
+++ b/libstdc++-v3/include/bits/ptr_traits.h
@@ -47,6 +47,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  /// @cond undocumented
+
   class __undefined;
 
   // For a specialization `SomeTemplate` the member `type` is T,
@@ -91,6 +93,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 using __ptr_traits_elem_t = typename __ptr_traits_elem<_Ptr>::type;
 #endif
 
+  /// @endcond
+
   // Define pointer_traits::pointer_to.
   template::value>
 struct __ptr_traits_ptr_to
@@ -187,6 +191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
* @brief  Uniform interface to all pointer-like types
+   * @headerfile memory
* @ingroup pointer_abstractions
* @since C++11
   */
@@ -203,6 +208,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
* @brief  Partial specialization for built-in pointers.
+   * @headerfile memory
* @ingroup pointer_abstractions
* @since C++11
   */


[gcc r12-10268] libstdc++: Improve doxygen docs for

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e1800b8dad5d7e207cc9617f530e5d4fb06a738c

commit r12-10268-ge1800b8dad5d7e207cc9617f530e5d4fb06a738c
Author: Jonathan Wakely 
Date:   Thu May 12 12:16:17 2022 +0100

libstdc++: Improve doxygen docs for 

Add @headerfile and @since tags. Improve grouping of non-member
functions via @relates tags.

Mark the std::pair base class of std::sub_match as undocumented, so that
the docs don't show all the related non-member functions are part of the
sub_match API. Use a new macro to re-add the data members for Doxygen
only.

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Define macro
_GLIBCXX_DOXYGEN_ONLY to expand its argument.
* include/bits/c++config (_GLIBCXX_DOXYGEN_ONLY): Define.
* include/bits/regex.h: Improve doxygen docs.
* include/bits/regex_constants.h: Likewise.
* include/bits/regex_error.h: Likewise.

(cherry picked from commit 1b01963a4ea87607f5af6578a49006c8fee4d527)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in|  1 +
 libstdc++-v3/include/bits/c++config |  3 ++
 libstdc++-v3/include/bits/regex.h   | 60 +
 libstdc++-v3/include/bits/regex_constants.h |  5 ++-
 libstdc++-v3/include/bits/regex_error.h |  7 +++-
 5 files changed, 66 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index ba85d4bb2a8..3950cd3a43e 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -2405,6 +2405,7 @@ PREDEFINED = __cplusplus=202002L \
  _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE \
  _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED \
  _GLIBCXX_HAVE_BUILTIN_LAUNDER \
+"_GLIBCXX_DOXYGEN_ONLY(X)=X " \
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
diff --git a/libstdc++-v3/include/bits/c++config 
b/libstdc++-v3/include/bits/c++config
index 150b0bc5834..191880fb99d 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -823,6 +823,9 @@ namespace std
 
 #undef _GLIBCXX_HAS_BUILTIN
 
+// Mark code that should be ignored by the compiler, but seen by Doxygen.
+#define _GLIBCXX_DOXYGEN_ONLY(X)
+
 // PSTL configuration
 
 #if __cplusplus >= 201703L
diff --git a/libstdc++-v3/include/bits/regex.h 
b/libstdc++-v3/include/bits/regex.h
index 04dad2c663a..ffa2d4aad74 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -88,6 +88,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* The class %regex is parameterized around a set of related types and
* functions used to complete the definition of its semantics.  This class
* satisfies the requirements of such a traits class.
+   *
+   * @headerfile regex
+   * @since C++11
*/
   template
 class regex_traits
@@ -392,11 +395,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
   // [7.8] Class basic_regex
   /**
-   * Objects of specializations of this class represent regular expressions
-   * constructed from sequences of character type @p _Ch_type.
+   * @brief A regular expression
+   *
+   * Specializations of this class template represent regular expressions
+   * constructed from sequences of character type `_Ch_type`.
+   * Use the `std::regex` typedef for `std::basic_regex`.
+   *
+   * A character sequence passed to the constructor will be parsed according
+   * to the chosen grammar, and used to create a state machine representing
+   * the regular expression. The regex object can then be passed to algorithms
+   * such as `std::regex_match` to match sequences of characters.
+   *
+   * The `syntax_option_type` flag passed to the constructor selects from
+   * one of the supported regular expression grammars. The default is
+   * `ECMAScript` and the others are `basic`, `extended`, `awk`, `grep`, and
+   * `egrep`, which are variations on POSIX regular expressions.
*
-   * Storage for the regular expression is allocated and deallocated as
-   * necessary by the member functions of this class.
+   * @headerfile regex
+   * @since C++11
*/
   template>
 class basic_regex
@@ -889,14 +905,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* An object of this class is essentially a pair of iterators marking a
* matched subexpression within a regular expression pattern match. Such
* objects can be converted to and compared with std::basic_string objects
-   * of a similar base character type as the pattern matched by the regular
+   * of the same character type as the pattern matched by the regular
* expression.
*
+   * A `sub_match` has a public base class of type `pair`,
+   * so inherits pair's data members named `first` and `second`.
* The iterators that make up t

[gcc r12-10261] libstdc++: Simplify detection idiom using concepts

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:1bb467f4910dc4abd90a7be98653b63113e5d6d3

commit r12-10261-g1bb467f4910dc4abd90a7be98653b63113e5d6d3
Author: Jonathan Wakely 
Date:   Fri Sep 23 23:16:30 2022 +0100

libstdc++: Simplify detection idiom using concepts

Add a simpler definition of std::__detected_or using concepts.  This
also replaces the __detector::value_t member which should have been using
a reserved name.

Use __detected_or in pointer_traits.

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h (allocator_traits::is_always_equal):
Only instantiate is_empty if needed.
* include/bits/ptr_traits.h (__ptr_traits_impl::difference_type)
(__ptr_traits_impl::rebind): Use __detected_or.
* include/experimental/type_traits (is_same_v): Add a partial
specialization instead of instantiating the std::is_same class
template.
(detected_t): Redefine in terms of detected_or_t.
(is_detected, is_detected_v): Redefine in terms of detected_t.
* include/std/type_traits [__cpp_concepts] (__detected_or): Add
new definition using concepts.
(__detector::value_t): Rename to __is_detected.
* testsuite/17_intro/names.cc: Check value_t isn't used.

(cherry picked from commit 2b667beba693e876322af7c6682f9bc885c5ec28)

Diff:
---
 libstdc++-v3/include/bits/alloc_traits.h  |  4 ++--
 libstdc++-v3/include/bits/ptr_traits.h| 27 +--
 libstdc++-v3/include/experimental/type_traits | 24 
 libstdc++-v3/include/std/type_traits  | 27 ---
 libstdc++-v3/testsuite/17_intro/names.cc  |  1 +
 5 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/libstdc++-v3/include/bits/alloc_traits.h 
b/libstdc++-v3/include/bits/alloc_traits.h
index 5cc52babef8..25496bc6f83 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 template
   using __pocs = typename _Tp::propagate_on_container_swap;
 template
-  using __equal = typename _Tp::is_always_equal;
+  using __equal = __type_identity;
   };
 
   template
@@ -207,7 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* otherwise @c is_empty::type
   */
   using is_always_equal
-   = __detected_or_t::type, __equal, _Alloc>;
+   = typename __detected_or_t, __equal, _Alloc>::type;
 
   template
using rebind_alloc = __alloc_rebind<_Alloc, _Tp>;
diff --git a/libstdc++-v3/include/bits/ptr_traits.h 
b/libstdc++-v3/include/bits/ptr_traits.h
index 8360c3b6557..ae8810706ab 100644
--- a/libstdc++-v3/include/bits/ptr_traits.h
+++ b/libstdc++-v3/include/bits/ptr_traits.h
@@ -144,29 +144,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct __ptr_traits_impl : __ptr_traits_ptr_to<_Ptr, _Elt>
 {
 private:
-  template
-   struct __difference { using type = ptrdiff_t; };
-
   template
-#if __cpp_concepts
-   requires requires { typename _Tp::difference_type; }
-   struct __difference<_Tp>
-#else
-   struct __difference<_Tp, __void_t>
-#endif
-   { using type = typename _Tp::difference_type; };
-
-  template
-   struct __rebind : __replace_first_arg<_Tp, _Up> { };
+   using __diff_t = typename _Tp::difference_type;
 
   template
-#if __cpp_concepts
-   requires requires { typename _Tp::template rebind<_Up>; }
-   struct __rebind<_Tp, _Up>
-#else
-   struct __rebind<_Tp, _Up, __void_t>>
-#endif
-   { using type = typename _Tp::template rebind<_Up>; };
+   using __rebind = __type_identity>;
 
 public:
   /// The pointer type.
@@ -176,11 +158,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using element_type = _Elt;
 
   /// The type used to represent the difference between two pointers.
-  using difference_type = typename __difference<_Ptr>::type;
+  using difference_type = __detected_or_t;
 
   /// A pointer to a different type.
   template
-using rebind = typename __rebind<_Ptr, _Up>::type;
+   using rebind = typename __detected_or_t<__replace_first_arg<_Ptr, _Up>,
+   __rebind, _Ptr, _Up>::type;
 };
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
diff --git a/libstdc++-v3/include/experimental/type_traits 
b/libstdc++-v3/include/experimental/type_traits
index af5970e80d0..fa25a1c2be2 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -223,7 +223,9 @@ template 
 
 // See C++14 20.10.6, type relations
 template 
-  constexpr bool is_same_v = is_same<_Tp, _Up>::value;
+  constexpr bool is_same_v = false;
+template 
+  constexpr bool is_same_v<_Tp, _Tp> = true;
 template 
   constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
 template 
@@ -266,23 +268,21 @@ struct nonesuch : pr

[gcc r12-10270] libstdc++: Improve doxygen docs for algorithms and more

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0d128f51e59c053be8da84c10acff722745862da

commit r12-10270-g0d128f51e59c053be8da84c10acff722745862da
Author: Jonathan Wakely 
Date:   Thu May 12 14:13:37 2022 +0100

libstdc++: Improve doxygen docs for algorithms and more

libstdc++-v3/ChangeLog:

* include/bits/ostream_insert.h: Mark helper functions as
undocumented by Doxygen.
* include/bits/stl_algo.h: Use markdown for formatting and mark
helper functions as undocumented.
* include/bits/stl_numeric.h:  Likewise.
* include/bits/stl_pair.h (pair): Add @headerfile.

(cherry picked from commit e61492549b95dff635395f69034b5fefa00e339a)

Diff:
---
 libstdc++-v3/include/bits/ostream_insert.h |   4 +
 libstdc++-v3/include/bits/stl_algo.h   | 198 +++--
 libstdc++-v3/include/bits/stl_numeric.h|  10 +-
 libstdc++-v3/include/bits/stl_pair.h   |   4 +
 4 files changed, 112 insertions(+), 104 deletions(-)

diff --git a/libstdc++-v3/include/bits/ostream_insert.h 
b/libstdc++-v3/include/bits/ostream_insert.h
index 9442ea130d3..f236353b2a6 100644
--- a/libstdc++-v3/include/bits/ostream_insert.h
+++ b/libstdc++-v3/include/bits/ostream_insert.h
@@ -40,6 +40,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  /// @cond undocumented
+
   template
 inline void
 __ostream_write(basic_ostream<_CharT, _Traits>& __out,
@@ -124,6 +126,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #endif
 
+  /// @endcond
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
diff --git a/libstdc++-v3/include/bits/stl_algo.h 
b/libstdc++-v3/include/bits/stl_algo.h
index 61f572d8d5f..ed7d262603d 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -1617,6 +1617,8 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
 __gnu_cxx::__ops::__pred_iter(__pred));
 }
 
+  /// @cond undocumented
+
   /// This is a helper function for the sort routines.
   template
 _GLIBCXX20_CONSTEXPR
@@ -1671,6 +1673,8 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
   return __result_real_last;
 }
 
+  /// @endcond
+
   /**
*  @brief Copy the smallest elements of a sequence.
*  @ingroup sorting_algorithms
@@ -1680,14 +1684,14 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
*  @param  __result_lastAnother random-access iterator.
*  @return   An iterator indicating the end of the resulting sequence.
*
-   *  Copies and sorts the smallest N values from the range @p [__first,__last)
-   *  to the range beginning at @p __result_first, where the number of
-   *  elements to be copied, @p N, is the smaller of @p (__last-__first) and
-   *  @p (__result_last-__result_first).
-   *  After the sort if @e i and @e j are iterators in the range
-   *  @p [__result_first,__result_first+N) such that i precedes j then
-   *  *j<*i is false.
-   *  The value returned is @p __result_first+N.
+   *  Copies and sorts the smallest `N` values from the range
+   *  `[__first, __last)` to the range beginning at `__result_first`, where
+   *  the number of elements to be copied, `N`, is the smaller of
+   *  `(__last - __first)` and `(__result_last - __result_first)`.
+   *  After the sort if `i` and `j` are iterators in the range
+   *  `[__result_first,__result_first + N)` such that `i` precedes `j` then
+   *  `*j < *i` is false.
+   *  The value returned is `__result_first + N`.
   */
   template
 _GLIBCXX20_CONSTEXPR
@@ -1730,14 +1734,14 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
*  @param  __compA comparison functor.
*  @return   An iterator indicating the end of the resulting sequence.
*
-   *  Copies and sorts the smallest N values from the range @p [__first,__last)
-   *  to the range beginning at @p result_first, where the number of
-   *  elements to be copied, @p N, is the smaller of @p (__last-__first) and
-   *  @p (__result_last-__result_first).
-   *  After the sort if @e i and @e j are iterators in the range
-   *  @p [__result_first,__result_first+N) such that i precedes j then
-   *  @p __comp(*j,*i) is false.
-   *  The value returned is @p __result_first+N.
+   *  Copies and sorts the smallest `N` values from the range
+   *  `[__first, __last)` to the range beginning at `result_first`, where
+   *  the number of elements to be copied, `N`, is the smaller of
+   *  `(__last - __first)` and `(__result_last - __result_first)`.
+   *  After the sort if `i` and `j` are iterators in the range
+   *  `[__result_first, __result_first + N)` such that `i` precedes `j` then
+   *  `__comp(*j, *i)` is false.
+   *  The value returned is `__result_first + N`.
   */
   template
@@ -1774,6 +1778,8 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
__gnu_cxx::__ops::__iter_comp_iter(__comp));
 }
 
+  /// @cond undocumented
+
   /// This is a helper function for the sort routine.
   template
 _GLIBCX

[gcc r12-10266] libstdc++: Stop defining C++0x compat symbols for versioned namespace

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:914a226e3cda5a640c9640580a21d780eb829057

commit r12-10266-g914a226e3cda5a640c9640580a21d780eb829057
Author: Jonathan Wakely 
Date:   Mon May 16 16:54:52 2022 +0100

libstdc++: Stop defining C++0x compat symbols for versioned namespace

The src/c++11/compatibility*-c++0x.cc files define symbols that need to
be exported for ancient versions of libstdc++.so.6 due to changes
between C++0x and the final C++11 standard. Those symbols are not needed
in the libstdc++.so.8 library, and we can skip building them entirely.

This also fixes the build failure I introduced last week when making the
versioned namespace config not use the _V2 namespace for compat symbols.

libstdc++-v3/ChangeLog:

* src/Makefile.am [ENABLE_SYMVERS_GNU_NAMESPACE] (cxx11_sources):
Do not build the compatibility*-c++0x.cc objects.
* src/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc [_GLIBCXX_INLINE_VERSION]:
Refuse to build for the versioned namespace.
* src/c++11/compatibility-chrono.cc: Likewise.
* src/c++11/compatibility-condvar.cc: Likewise.
* src/c++11/compatibility-thread-c++0x.cc: Likewise.
* src/c++11/chrono.cc (system_clock, steady_clock):
Use macros to define in inline namespace _V2, matching the
declarations in .
* src/c++11/system_error.cc (system_category, generic_category):
Likewise.

(cherry picked from commit 357d6fcd41e771128226b7916166f537b2d53a29)

Diff:
---
 libstdc++-v3/src/Makefile.am   | 16 +++
 libstdc++-v3/src/Makefile.in   | 31 +-
 libstdc++-v3/src/c++11/chrono.cc   |  5 ++--
 libstdc++-v3/src/c++11/compatibility-c++0x.cc  |  4 +++
 libstdc++-v3/src/c++11/compatibility-chrono.cc |  4 +++
 libstdc++-v3/src/c++11/compatibility-condvar.cc|  4 +++
 .../src/c++11/compatibility-thread-c++0x.cc|  4 +++
 libstdc++-v3/src/c++11/system_error.cc |  8 --
 8 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 9c3f4aca655..b83c222d51d 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -96,6 +96,16 @@ else
 ldbl_alt128_compat_sources =
 endif
 
+if ENABLE_SYMVERS_GNU_NAMESPACE
+cxx0x_compat_sources =
+else
+cxx0x_compat_sources = \
+   compatibility-atomic-c++0x.cc \
+   compatibility-c++0x.cc \
+   compatibility-chrono.cc \
+   compatibility-condvar.cc \
+   compatibility-thread-c++0x.cc
+endif
 
 parallel_compat_sources = \
compatibility-parallel_list.cc  compatibility-parallel_list-2.cc
@@ -108,11 +118,7 @@ cxx98_sources = \
${ldbl_compat_sources}
 
 cxx11_sources = \
-   compatibility-c++0x.cc \
-   compatibility-atomic-c++0x.cc \
-   compatibility-thread-c++0x.cc \
-   compatibility-chrono.cc \
-   compatibility-condvar.cc \
+   ${cxx0x_compat_sources} \
${ldbl_alt128_compat_sources}
 
 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 4a06f6cfec1..cef290c5d11 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -153,14 +153,17 @@ am__DEPENDENCIES_1 =
 @GLIBCXX_LDBL_COMPAT_TRUE@am__objects_1 = compatibility-ldbl.lo
 am__objects_2 = compatibility.lo compatibility-debug_list.lo \
compatibility-debug_list-2.lo $(am__objects_1)
-@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_3 = 
compatibility-ldbl-alt128-cxx11.lo
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 =  \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@am__objects_3 = 
compatibility-atomic-c++0x.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@   compatibility-c++0x.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@   compatibility-chrono.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@   compatibility-condvar.lo \
+@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@   compatibility-thread-c++0x.lo
+@ENABLE_DUAL_ABI_TRUE@@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_4 = 
compatibility-ldbl-alt128-cxx11.lo
+@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@am__objects_5 =  \
 @GLIBCXX_LDBL_ALT128_COMPAT_TRUE@  compatibility-ldbl-alt128.lo \
-@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@  $(am__objects_3)
-am__objects_5 = compatibility-c++0x.lo compatibility-atomic-c++0x.lo \
-   compatibility-thread-c++0x.lo compatibility-chrono.lo \
-   compatibility-condvar.lo $(am__objects_4)
-am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_5)
+@GLIBCXX_LDBL_ALT128_COMPAT_TRUE@  $(am__objects_4)
+am__objects_6 = $(am__objects_3) $(am__objects_5)
+am_libstdc___la_OBJECTS = $(am__objects_2) $(am__objects_6)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
 @VTV_CYGMIN_FALSE@am_libstdc___la_rpath = -rpath $(toolexeclibdir)
 @VTV_CYGMIN_TRUE@am_libstdc___la_rpat

[gcc r12-10273] libstdc++: Fix -Wsystem-headers warnings

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:2d174d4181896129d465cbf42dc454f4f906892b

commit r12-10273-g2d174d4181896129d465cbf42dc454f4f906892b
Author: Jonathan Wakely 
Date:   Sat Nov 5 12:35:55 2022 +

libstdc++: Fix -Wsystem-headers warnings

Fix some problems noticed with -Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/stl_tempbuf.h (_Temporary_buffer): Disable
warnings about get_temporary_buffer being deprecated.
* include/ext/functional (mem_fun1, mem_fun1_ref): Disable
warnings about mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t and
const_mem_fun1_ref_t being deprecated.
* include/std/spanstream (basic_spanbuf::setbuf): Add assertion
and adjust to avoid narrowing warning.
* libsupc++/exception_ptr.h [!__cpp_rtti && !__cpp_exceptions]
(make_exception_ptr): Add missing inline specifier.

(cherry picked from commit 8f6d25f19bae521c3d028bcdcd69019540b8c3b9)

Diff:
---
 libstdc++-v3/include/bits/stl_tempbuf.h | 3 +++
 libstdc++-v3/include/ext/functional | 4 ++--
 libstdc++-v3/include/std/spanstream | 3 ++-
 libstdc++-v3/libsupc++/exception_ptr.h  | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h 
b/libstdc++-v3/include/bits/stl_tempbuf.h
index db7cdb14ca9..f8323d4ab71 100644
--- a/libstdc++-v3/include/bits/stl_tempbuf.h
+++ b/libstdc++-v3/include/bits/stl_tempbuf.h
@@ -254,6 +254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  __ucr(__first, __last, __seed);
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
   template
 _Temporary_buffer<_ForwardIterator, _Tp>::
 _Temporary_buffer(_ForwardIterator __seed, size_type __original_len)
@@ -278,6 +280,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
 }
+#pragma GCC diagnostic pop
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
diff --git a/libstdc++-v3/include/ext/functional 
b/libstdc++-v3/include/ext/functional
index 19cd8d5b563..11c2de1294b 100644
--- a/libstdc++-v3/include/ext/functional
+++ b/libstdc++-v3/include/ext/functional
@@ -394,8 +394,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { _M_initialize(161803398u); }
   };
 
-#pragma GCC diagnostic pop
-
   // Mem_fun adaptor helper functions mem_fun1 and mem_fun1_ref,
   // provided for backward compatibility, they are no longer part of
   // the C++ standard.
@@ -420,6 +418,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
 { return std::const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
 
+#pragma GCC diagnostic pop
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/include/std/spanstream 
b/libstdc++-v3/include/std/spanstream
index 5855b286efe..8fd74b8f9cb 100644
--- a/libstdc++-v3/include/std/spanstream
+++ b/libstdc++-v3/include/std/spanstream
@@ -134,7 +134,8 @@ template
 basic_streambuf<_CharT, _Traits>*
 setbuf(_CharT* __s, streamsize __n) override
 {
-  span({__s, __n});
+  __glibcxx_assert(__n >= 0);
+  this->span(std::span<_CharT>(__s, __n));
   return this;
 }
 
diff --git a/libstdc++-v3/libsupc++/exception_ptr.h 
b/libstdc++-v3/libsupc++/exception_ptr.h
index 6433f059e9c..07e456237db 100644
--- a/libstdc++-v3/libsupc++/exception_ptr.h
+++ b/libstdc++-v3/libsupc++/exception_ptr.h
@@ -271,7 +271,7 @@ namespace std
   // instead of a working one compiled with RTTI and/or exceptions enabled.
   template
 __attribute__ ((__always_inline__))
-exception_ptr
+inline exception_ptr
 make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT
 { return exception_ptr(); }
 #endif


[gcc r12-10269] libstdc++: Improve doxygen docs for std::allocator

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:54de91d55980e063a8630193cd3a2ef457508735

commit r12-10269-g54de91d55980e063a8630193cd3a2ef457508735
Author: Jonathan Wakely 
Date:   Thu May 12 13:44:52 2022 +0100

libstdc++: Improve doxygen docs for std::allocator

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Define __allocator_base
so that Doxygen shows the right base-class for std::allocator.
* include/bits/alloc_traits.h: Improve doxygen docs.
* include/bits/allocator.h: Likewise.
* include/bits/new_allocator.h: Likewise.
* include/ext/new_allocator.h: Likewise.

(cherry picked from commit 171f41f124bc1d5d80a395d27833a578cceba9e7)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in  |  1 +
 libstdc++-v3/include/bits/alloc_traits.h  |  5 +
 libstdc++-v3/include/bits/allocator.h | 15 ++-
 libstdc++-v3/include/bits/new_allocator.h | 19 +--
 libstdc++-v3/include/ext/new_allocator.h  | 12 +---
 5 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index 3950cd3a43e..ac83e084412 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -2406,6 +2406,7 @@ PREDEFINED = __cplusplus=202002L \
  _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED \
  _GLIBCXX_HAVE_BUILTIN_LAUNDER \
 "_GLIBCXX_DOXYGEN_ONLY(X)=X " \
+__allocator_base=std::__new_allocator \
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
diff --git a/libstdc++-v3/include/bits/alloc_traits.h 
b/libstdc++-v3/include/bits/alloc_traits.h
index 25496bc6f83..4f40b362565 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -661,6 +661,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __rhs; }
 };
 
+  /// @cond undocumented
 #if __cplusplus < 201703L
   template
 inline void
@@ -818,8 +819,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __a.deallocate(__a.allocate(1u), 1u);
 };
 #endif
+  /// @endcond
 #endif // C++11
 
+  /// @cond undocumented
+
   /**
* Destroy a range of objects using the supplied allocator.  For
* non-default allocators we do not optimize away invocation of
@@ -849,6 +853,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 {
   std::_Destroy(__first, __last);
 }
+  /// @endcond
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
diff --git a/libstdc++-v3/include/bits/allocator.h 
b/libstdc++-v3/include/bits/allocator.h
index a4b80d924d6..aec0b374fd1 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -67,7 +67,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // explicit specialization, with the historical ABI properties, but with
   // the same members that are present in the primary template.
 
-  /// allocator specialization.
+  /** std::allocator specialization.
+   *
+   * @headerfile memory
+   */
   template<>
 class allocator
 {
@@ -119,6 +122,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  for further details.
*
*  @tparam  _Tp  Type of allocated object.
+   *
+   *  @headerfile memory
*/
   template
 class allocator : public __allocator_base<_Tp>
@@ -214,6 +219,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Inherit everything else.
 };
 
+  /** Equality comparison for std::allocator objects
+   *
+   * @return true, for all std::allocator objects.
+   * @relates std::allocator
+   */
   template
 inline _GLIBCXX20_CONSTEXPR bool
 operator==(const allocator<_T1>&, const allocator<_T2>&)
@@ -228,6 +238,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { return false; }
 #endif
 
+  /// @cond undocumented
+
   // Invalid allocator partial specializations.
   // allocator_traits::rebind_alloc can be used to form a valid allocator type.
   template
@@ -330,6 +342,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 };
 #endif
+  /// @endcond
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
diff --git a/libstdc++-v3/include/bits/new_allocator.h 
b/libstdc++-v3/include/bits/new_allocator.h
index d066d015a9d..e9eb103f549 100644
--- a/libstdc++-v3/include/bits/new_allocator.h
+++ b/libstdc++-v3/include/bits/new_allocator.h
@@ -43,14 +43,21 @@ namespace std _GLIBCXX_VISIBILITY(default)
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
-   *  @brief  An allocator that uses global new, as per C++03 [20.4.1].
-   *  @ingroup allocators
+   * @brief  An allocator that uses global `new`, as per C++03 [20.4.1].
+   * @ingroup allocators
*
-   *  This is precisely the allocator defined in the C++ Standard.
-   *- all allocation calls operator new
-   *- all deallocation calls operator delete
+   * This is precisely the allocator defined i

[gcc r12-10262] libstdc++: Update std::pointer_traits to match new LWG 3545 wording

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:57eb0358d0e0925f9e5aa282ed7f0274f6ff794e

commit r12-10262-g57eb0358d0e0925f9e5aa282ed7f0274f6ff794e
Author: Jonathan Wakely 
Date:   Mon Sep 26 18:59:45 2022 +0100

libstdc++: Update std::pointer_traits to match new LWG 3545 wording

It was pointed out in recent LWG 3545 discussion that having a
constrained partial specialization of std::pointer_traits can cause
ambiguities with program-defined specializations. For example, the
addition to the testcase has:

template requires std::derived_from;

This would be ambiguous with the library's own constrained partial
specialization:

template requires requires { typename Ptr::element_type; }
struct std::pointer_traits;

Neither specialization is more specialized than the other for a type
that is derived from base_type and also has an element_type member.

The solution is to remove the library's partial specialization, and do
the check for Ptr::element_type in the __ptr_traits_elem helper (which
is what we already do for !__cpp_concepts anyway).

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h (__ptr_traits_elem) [__cpp_concepts]:
Also define the __ptr_traits_elem class template for the
concepts case.
(pointer_traits): Remove constrained partial
specialization.
* testsuite/20_util/pointer_traits/lwg3545.cc: Check for
ambiguitiy with program-defined partial specialization.

(cherry picked from commit 03cb9ed8dd603dbb77762ca948fc6381ba190731)

Diff:
---
 libstdc++-v3/include/bits/ptr_traits.h   | 20 ++--
 .../testsuite/20_util/pointer_traits/lwg3545.cc  | 17 +
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/libstdc++-v3/include/bits/ptr_traits.h 
b/libstdc++-v3/include/bits/ptr_traits.h
index ae8810706ab..71370ff4fc9 100644
--- a/libstdc++-v3/include/bits/ptr_traits.h
+++ b/libstdc++-v3/include/bits/ptr_traits.h
@@ -73,25 +73,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct __replace_first_arg<_SomeTemplate<_Tp, _Types...>, _Up>
 { using type = _SomeTemplate<_Up, _Types...>; };
 
-#if __cpp_concepts
-  // When concepts are supported detection of _Ptr::element_type is done
-  // by a requires-clause, so __ptr_traits_elem_t only needs to do this:
-  template
-using __ptr_traits_elem_t = typename __get_first_arg<_Ptr>::type;
-#else
   // Detect the element type of a pointer-like type.
   template
 struct __ptr_traits_elem : __get_first_arg<_Ptr>
 { };
 
   // Use _Ptr::element_type if is a valid type.
+#if __cpp_concepts
+  template requires requires { typename _Ptr::element_type; }
+struct __ptr_traits_elem<_Ptr, void>
+{ using type = typename _Ptr::element_type; };
+#else
   template
 struct __ptr_traits_elem<_Ptr, __void_t>
 { using type = typename _Ptr::element_type; };
+#endif
 
   template
 using __ptr_traits_elem_t = typename __ptr_traits_elem<_Ptr>::type;
-#endif
 
   /// @endcond
 
@@ -182,13 +181,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 struct pointer_traits : __ptr_traits_impl<_Ptr, __ptr_traits_elem_t<_Ptr>>
 { };
 
-#if __cpp_concepts
-  template requires requires { typename _Ptr::element_type; }
-struct pointer_traits<_Ptr>
-: __ptr_traits_impl<_Ptr, typename _Ptr::element_type>
-{ };
-#endif
-
   /**
* @brief  Partial specialization for built-in pointers.
* @headerfile memory
diff --git a/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc 
b/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc
index 08c3ed01b75..93c64a353bd 100644
--- a/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc
+++ b/libstdc++-v3/testsuite/20_util/pointer_traits/lwg3545.cc
@@ -99,3 +99,20 @@ static_assert( is_same, 
clever_ptr>::value, "" );
 static_assert( is_same, std::ptrdiff_t>::value, "" );
 static_assert( is_same, clever_ptr>::value, "" );
 static_assert( is_same, clever_ptr>::value, "" );
+
+#ifdef __cpp_concepts
+struct ptr_base { };
+
+// Program-defined specialization must not be ambiguous with primary template.
+template requires std::derived_from
+struct std::pointer_traits
+{
+  using element_type = int;
+  using difference_type = long;
+  using pointer = P;
+};
+
+struct Ptr : ptr_base { using element_type = int; };
+
+using E = std::pointer_traits::element_type;
+#endif


[gcc r12-10271] libstdc++: Improve doxygen docs for some of

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0a9cfae13f8873aa95dc143d653f834e6f9a3576

commit r12-10271-g0a9cfae13f8873aa95dc143d653f834e6f9a3576
Author: Jonathan Wakely 
Date:   Thu May 12 23:04:29 2022 +0100

libstdc++: Improve doxygen docs for some of 

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Define
_GLIBCXX23_CONSTEXPR macro.
* include/backward/auto_ptr.h (auto_ptr): Use @deprecated.
* include/bits/unique_ptr.h (default_delete): Use @since and
@headerfile.
* include/std/scoped_allocator: Remove @ingroup from @file
block.

(cherry picked from commit a278402216e75d5d54e62d2cd2345ea130349f10)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in  |  1 +
 libstdc++-v3/include/backward/auto_ptr.h  |  4 
 libstdc++-v3/include/bits/unique_ptr.h| 13 ++---
 libstdc++-v3/include/std/scoped_allocator |  1 -
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index ac83e084412..0f67da64a60 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -2389,6 +2389,7 @@ PREDEFINED = __cplusplus=202002L \
  _GLIBCXX14_CONSTEXPR=constexpr \
  _GLIBCXX17_CONSTEXPR=constexpr \
  _GLIBCXX20_CONSTEXPR=constexpr \
+ _GLIBCXX23_CONSTEXPR=constexpr \
  "_GLIBCXX11_DEPRECATED= " \
  "_GLIBCXX11_DEPRECATED_SUGGEST(E)= " \
  "_GLIBCXX17_DEPRECATED= " \
diff --git a/libstdc++-v3/include/backward/auto_ptr.h 
b/libstdc++-v3/include/backward/auto_ptr.h
index 8725504d4c9..184ab403466 100644
--- a/libstdc++-v3/include/backward/auto_ptr.h
+++ b/libstdc++-v3/include/backward/auto_ptr.h
@@ -84,6 +84,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  _GLIBCXX_RESOLVE_LIB_DEFECTS
*  127.  auto_ptr<> conversion issues
*  These resolutions have all been incorporated.
+   *
+   * @headerfile memory
+   * @deprecated Deprecated in C++11, no longer in the standard since C++17.
+   * Use `unique_ptr` instead.
*/
   template
 class auto_ptr
diff --git a/libstdc++-v3/include/bits/unique_ptr.h 
b/libstdc++-v3/include/bits/unique_ptr.h
index ad60fada59b..e1ad7721a59 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -65,8 +65,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #pragma GCC diagnostic pop
 #endif
 
-  /// Primary template of default_delete, used by unique_ptr for single objects
-  /// @since C++11
+  /** Primary template of default_delete, used by unique_ptr for single objects
+   *
+   * @headerfile memory
+   * @since C++11
+   */
   template
 struct default_delete
 {
@@ -99,7 +102,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // DR 740 - omit specialization for array objects with a compile time length
 
-  /// Specialization of default_delete for arrays, used by `unique_ptr`
+  /** Specialization of default_delete for arrays, used by `unique_ptr`
+   *
+   * @headerfile memory
+   * @since C++11
+   */
   template
 struct default_delete<_Tp[]>
 {
diff --git a/libstdc++-v3/include/std/scoped_allocator 
b/libstdc++-v3/include/std/scoped_allocator
index dd00e8efdbb..61619ebd3e2 100644
--- a/libstdc++-v3/include/std/scoped_allocator
+++ b/libstdc++-v3/include/std/scoped_allocator
@@ -24,7 +24,6 @@
 
 /** @file include/scoped_allocator
  *  This is a Standard C++ Library header.
- *  @ingroup allocators
  */
 
 #ifndef _SCOPED_ALLOCATOR


[gcc r12-10263] libstdc++: Simplify fs::path construction using variable template

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:f3d4e25f4076cb9a829fbe24969dfc4627244bdd

commit r12-10263-gf3d4e25f4076cb9a829fbe24969dfc4627244bdd
Author: Jonathan Wakely 
Date:   Thu Jun 23 18:39:50 2022 +0100

libstdc++: Simplify fs::path construction using variable template

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (__is_path_iter_src): Replace class
template with variable template.

(cherry picked from commit 6177f60d914abcb8520b87ae62658e70a7c13759)

Diff:
---
 libstdc++-v3/include/bits/fs_path.h | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/include/bits/fs_path.h 
b/libstdc++-v3/include/bits/fs_path.h
index 1f87414c145..60bfd5f 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -102,19 +102,16 @@ namespace __detail
 #endif
 
   template
-struct __is_path_iter_src
-: false_type
-{ };
+inline constexpr bool __is_path_iter_src = false;
 
   template
-struct __is_path_iter_src<_Iter_traits,
- void_t>
-: bool_constant<__is_encoded_char>
-{ };
+inline constexpr bool
+__is_path_iter_src<_Iter_traits, void_t>
+  = __is_encoded_char;
 
   template
 inline constexpr bool __is_path_src
-  = __is_path_iter_src>>::value;
+  = __is_path_iter_src>>;
 
   template<>
 inline constexpr bool __is_path_src = false;
@@ -150,7 +147,7 @@ namespace __detail
 
   // SFINAE constraint for InputIterator parameters as required by [fs.req].
   template>
-using _Path2 = enable_if_t<__is_path_iter_src<_Tr>::value, path>;
+using _Path2 = enable_if_t<__is_path_iter_src<_Tr>, path>;
 
 #if __cpp_lib_concepts
   template


[gcc r12-10272] libstdc++: Improve doxygen docs for

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:14876f35419cd60c49df838ab72451acdd56d9ee

commit r12-10272-g14876f35419cd60c49df838ab72451acdd56d9ee
Author: Jonathan Wakely 
Date:   Thu May 12 23:06:04 2022 +0100

libstdc++: Improve doxygen docs for 

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Define
_GTHREAD_USE_MUTEX_TIMEDLOCK macro.
* include/bits/std_mutex.h (mutex, lock_guard): Use @since and
@headerfile.
* include/bits/unique_lock.h (unique_lock): Likewise.
* include/std/mutex (recursive_mutex, timed_mutex)
(recursive_timed_mutex, scoped_lock): Likewise.

(cherry picked from commit b584cbdb0829bb0ad4e6ed7488a304ae4e76b870)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in|  1 +
 libstdc++-v3/include/bits/std_mutex.h   | 21 +-
 libstdc++-v3/include/bits/unique_lock.h |  2 ++
 libstdc++-v3/include/std/mutex  | 38 ++---
 4 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index 0f67da64a60..4f7ae80d0e7 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -2326,6 +2326,7 @@ INCLUDE_FILE_PATTERNS  =
 PREDEFINED = __cplusplus=202002L \
  __GTHREADS \
  _GLIBCXX_HAS_GTHREADS \
+ _GTHREAD_USE_MUTEX_TIMEDLOCK \
  _GLIBCXX_HAVE_TLS \
  _GLIBCXX_INCLUDE_AS_CXX11 \
  "_GLIBCXX_PURE= " \
diff --git a/libstdc++-v3/include/bits/std_mutex.h 
b/libstdc++-v3/include/bits/std_mutex.h
index d3a1d5eaec9..b22e0e12793 100644
--- a/libstdc++-v3/include/bits/std_mutex.h
+++ b/libstdc++-v3/include/bits/std_mutex.h
@@ -53,6 +53,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
 
 #ifdef _GLIBCXX_HAS_GTHREADS
+  /// @cond undocumented
+
   // Common base class for std::mutex and std::timed_mutex
   class __mutex_base
   {
@@ -78,8 +80,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 __mutex_base(const __mutex_base&) = delete;
 __mutex_base& operator=(const __mutex_base&) = delete;
   };
+  /// @endcond
 
-  /// The standard mutex type.
+  /** The standard mutex type.
+   *
+   * A simple, non-recursive, non-timed mutex.
+   *
+   * Do not call `lock()` and `unlock()` directly, use a scoped lock type
+   * such as `std::unique_lock`, `std::lock_guard`, or (since C++17)
+   * `std::scoped_lock`.
+   *
+   * @headerfile mutex
+   * @since C++11
+   */
   class mutex : private __mutex_base
   {
   public:
@@ -123,6 +136,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { return &_M_mutex; }
   };
 
+  /// @cond undocumented
+
   // Implementation details for std::condition_variable
   class __condvar
   {
@@ -192,6 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 __gthread_cond_t _M_cond;
 #endif
   };
+  /// @endcond
 
 #endif // _GLIBCXX_HAS_GTHREADS
 
@@ -218,6 +234,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* A lock_guard controls mutex ownership within a scope, releasing
* ownership in the destructor.
+   *
+   * @headerfile mutex
+   * @since C++11
*/
   template
 class lock_guard
diff --git a/libstdc++-v3/include/bits/unique_lock.h 
b/libstdc++-v3/include/bits/unique_lock.h
index 1f1aa15c463..9ed7ba25766 100644
--- a/libstdc++-v3/include/bits/unique_lock.h
+++ b/libstdc++-v3/include/bits/unique_lock.h
@@ -51,7 +51,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* to another unique_lock by move construction or move assignment. If a
* mutex lock is owned when the destructor runs ownership will be released.
*
+   * @headerfile mutex
* @ingroup mutexes
+   * @since C++11
*/
   template
 class unique_lock
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index f500818d9c9..b9590bbf276 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -62,6 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
 
 #ifdef _GLIBCXX_HAS_GTHREADS
+  /// @cond undocumented
 
   // Common base class for std::recursive_mutex and std::recursive_timed_mutex
   class __recursive_mutex_base
@@ -89,8 +90,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { __gthread_recursive_mutex_destroy(&_M_mutex); }
 #endif
   };
+  /// @endcond
 
-  /// The standard recursive mutex type.
+  /** The standard recursive mutex type.
+   *
+   * A recursive mutex can be locked more than once by the same thread.
+   * Other threads cannot lock the mutex until the owning thread unlocks it
+   * as many times as it was locked.
+   *
+   * @headerfile mutex
+   * @since C++11
+   */
   class recursive_mutex : private __recursive_mutex_base
   {
   public:
@@ -132,6 +142,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
 #if _GTHREAD_USE_MUTEX_TIMEDLOCK
+  /// @cond undocumented
+
   template
 class __timed_mutex_impl
 {
@@ -207,8 +219,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

[gcc r12-10264] libstdc++: Disable Doxygen GROUP_NESTED_COMPOUNDS config option

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d9f006da30def40747792d3ea37add1d80e02444

commit r12-10264-gd9f006da30def40747792d3ea37add1d80e02444
Author: Jonathan Wakely 
Date:   Wed May 11 16:46:03 2022 +0100

libstdc++: Disable Doxygen GROUP_NESTED_COMPOUNDS config option

Before Doxygen version 1.9.2 this option is broken (see
https://github.com/doxygen/doxygen/issues/8638 for more details) and
classes are not added to the correct groups by @ingroup and @addtogroup.

Also remove the obsolete CLASS_DIAGRAMS option that causes a warning.

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (GROUP_NESTED_COMPOUNDS): Set to NO.
(CLASS_DIAGRAMS): Remove obsolete option.

(cherry picked from commit 9c3a8fe34aeacabc2f62acef7f8f9108cb109238)

Diff:
---
 libstdc++-v3/doc/doxygen/user.cfg.in | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in 
b/libstdc++-v3/doc/doxygen/user.cfg.in
index bdff43c5f0a..b095addd10c 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -388,7 +388,7 @@ DISTRIBUTE_GROUP_DOC   = YES
 # is disabled and one has to add nested compounds explicitly via \ingroup.
 # The default value is: NO.
 
-GROUP_NESTED_COMPOUNDS = YES
+GROUP_NESTED_COMPOUNDS = NO
 
 # Set the SUBGROUPING tag to YES to allow class member groups of the same type
 # (for instance a group of public functions) to be put as a subgroup of that
@@ -2473,15 +2473,6 @@ EXTERNAL_PAGES = YES
 # Configuration options related to the dot tool
 #---
 
-# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class 
diagram
-# (in HTML and LaTeX) for classes with base or super classes. Setting the tag 
to
-# NO turns the diagrams off. Note that this option also works with HAVE_DOT
-# disabled, but it is recommended to install and use dot, since it yields more
-# powerful graphs.
-# The default value is: YES.
-
-CLASS_DIAGRAMS = YES
-
 # You can include diagrams made with dia in doxygen documentation. Doxygen will
 # then run dia to produce the diagram and insert it in the documentation. The
 # DIA_PATH tag allows you to specify the directory where the dia binary 
resides.


[gcc r12-10274] libstdc++: Update synopsis test for C++11 and later

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:c0c1207d49d2870542866368da3ae30da7e99baa

commit r12-10274-gc0c1207d49d2870542866368da3ae30da7e99baa
Author: Jonathan Wakely 
Date:   Wed Sep 21 09:29:39 2022 +0100

libstdc++: Update  synopsis test for C++11 and later

libstdc++-v3/ChangeLog:

* testsuite/20_util/headers/memory/synopsis.cc: Add declarations
from C++11 and later.

(cherry picked from commit 980aa91e9cefe64245b7c32ee81ba372b7229aeb)

Diff:
---
 .../testsuite/20_util/headers/memory/synopsis.cc   | 66 +++---
 1 file changed, 59 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc 
b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc
index 03e3f80dac5..15437c72ee0 100644
--- a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc
+++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc
@@ -26,20 +26,35 @@
 # define NOTHROW
 #endif
 
-namespace std {
+namespace std
+{
+#if __cplusplus >= 201103L
+  template struct pointer_traits;
+  template struct pointer_traits;
+
+  void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+  struct allocator_arg_t;
+  extern const allocator_arg_t allocator_arg;
+
+  template struct uses_allocator;
+
+  template struct allocator_traits;
+#endif // C++11
+
+#if __STDC_HOSTED__
   //  lib.default.allocator, the default allocator:
   template  class allocator;
+#if __cplusplus >= 202002L
+  template 
+  constexpr bool operator==(const allocator&, const allocator&) throw();
+#else
   template <> class allocator;
   template 
-#if __cplusplus > 201703L
-  constexpr
-#endif
   bool operator==(const allocator&, const allocator&) throw();
   template 
-#if __cplusplus > 201703L
-  constexpr
-#endif
   bool operator!=(const allocator&, const allocator&) throw();
+#endif
 
   //  lib.storage.iterator, raw storage iterator:
   template  class raw_storage_iterator;
@@ -49,18 +64,55 @@ namespace std {
   pair get_temporary_buffer(ptrdiff_t n) NOTHROW;
   template 
   void return_temporary_buffer(T* p);
+#endif // HOSTED
 
   //  lib.specialized.algorithms, specialized algorithms:
+#if __cplusplus >= 201703L
+  template  constexpr T* addressof(T&) noexcept;
+#elif __cplusplus >= 201402L
+  template  T* addressof(T&) noexcept;
+#endif
   template 
   ForwardIterator
   uninitialized_copy(InputIterator first, InputIterator last,
 ForwardIterator result);
+#if __cplusplus >= 201103L
+  template 
+  ForwardIterator
+  uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
+#endif
   template 
   void uninitialized_fill(ForwardIterator first, ForwardIterator last,
  const T& x);
   template 
   void uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
 
+#if __cplusplus >= 201103L
+  template class default_delete;
+  template class default_delete;
+  template class unique_ptr;
+  template class unique_ptr;
+  template
+void swap(unique_ptr&, unique_ptr&) noexcept;
+#if __cplusplus >= 201402L
+  template unique_ptr make_unique(Args&&...);
+#endif
+
+  class bad_weak_ptr;
+  template class shared_ptr;
+  template shared_ptr make_shared(Args&&... args);
+  template
+  shared_ptr allocate_shared(const A& a, Args&&... args);
+  template void swap(shared_ptr&, shared_ptr&) noexcept;
+  template class weak_ptr;
+  template void swap(weak_ptr&, weak_ptr&) noexcept;
+  template class owner_less;
+  template class enable_shared_from_this;
+
+  template struct hash>;
+  template struct hash>;
+#endif
+
   //  lib.auto.ptr, pointers:
   template class auto_ptr;
 }


[gcc r12-10275] libstdc++: Fix -Wsystem-headers warnings in tests

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:7abc86119e4ebb13d3fffc7e2b038e2629aa2fc1

commit r12-10275-g7abc86119e4ebb13d3fffc7e2b038e2629aa2fc1
Author: Jonathan Wakely 
Date:   Mon Nov 7 15:00:34 2022 +

libstdc++: Fix -Wsystem-headers warnings in tests

libstdc++-v3/ChangeLog:

* testsuite/18_support/new_nothrow.cc: Add missing noexcept
to operator delete replacements.
* testsuite/20_util/any/cons/92156.cc: Disable
-Winit-list-lifetime warnings from instantiating invalid
specialization of manager function.
* testsuite/20_util/any/modifiers/92156.cc: Likewise.
* testsuite/20_util/default_delete/void_neg.cc: Prune additional
diagnostics.
* testsuite/20_util/headers/memory/synopsis.cc: Add missing
noexcept.
* testsuite/20_util/shared_ptr/cons/void_neg.cc: Prune
additional diagnostic.
* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: Add
missing noexcept to operator delete replacements.
* testsuite/21_strings/basic_string/cons/char/103919.cc:
Likewise.
* testsuite/23_containers/map/modifiers/emplace/92300.cc:
Likewise.
* testsuite/23_containers/map/modifiers/insert/92300.cc:
Likewise.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc:
Add missing noexcept to synopsis declarations.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc:
Likewise.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
Likewise.

(cherry picked from commit bbcb84bba0a21ff367c95d3d0970926992b20cdd)

Diff:
---
 libstdc++-v3/testsuite/18_support/new_nothrow.cc   | 14 ++
 libstdc++-v3/testsuite/20_util/any/cons/92156.cc   |  1 +
 libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc  |  1 +
 libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc  |  3 +++
 libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc  |  2 +-
 libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc |  2 ++
 .../testsuite/20_util/unique_ptr/creation/for_overwrite.cc |  4 ++--
 .../testsuite/21_strings/basic_string/cons/char/103919.cc  |  4 ++--
 .../testsuite/23_containers/map/modifiers/emplace/92300.cc |  4 ++--
 .../testsuite/23_containers/map/modifiers/insert/92300.cc  |  4 ++--
 .../24_iterators/headers/iterator/range_access_c++11.cc|  4 ++--
 .../24_iterators/headers/iterator/range_access_c++14.cc| 12 ++--
 .../24_iterators/headers/iterator/range_access_c++17.cc| 12 ++--
 13 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/libstdc++-v3/testsuite/18_support/new_nothrow.cc 
b/libstdc++-v3/testsuite/18_support/new_nothrow.cc
index b0ef4e966b8..a9e9da0ce81 100644
--- a/libstdc++-v3/testsuite/18_support/new_nothrow.cc
+++ b/libstdc++-v3/testsuite/18_support/new_nothrow.cc
@@ -63,7 +63,13 @@ void* operator new (size_t n)
 }
 }
 
-void operator delete (void *p)
+#if __cplusplus >= 201103L
+#define NOEXCEPT noexcept
+#else
+#define NOEXCEPT
+#endif
+
+void operator delete (void *p) NOEXCEPT
 {
 ++delete_called;
 if (p)
@@ -76,18 +82,18 @@ void* operator new[] (size_t n)
 return operator new(n);
 }
 
-void operator delete[] (void *p)
+void operator delete[] (void *p) NOEXCEPT
 {
 ++delete_vec_called;
 operator delete(p);
 }
 
 #if __cplusplus >= 201402L
-void operator delete (void *p, std::size_t)
+void operator delete (void *p, std::size_t) noexcept
 {
   ::operator delete(p);
 }
-void operator delete[] (void *p, std::size_t)
+void operator delete[] (void *p, std::size_t) noexcept
 {
   ::operator delete[](p);
 }
diff --git a/libstdc++-v3/testsuite/20_util/any/cons/92156.cc 
b/libstdc++-v3/testsuite/20_util/any/cons/92156.cc
index 71e9dd94090..0e768df9a00 100644
--- a/libstdc++-v3/testsuite/20_util/any/cons/92156.cc
+++ b/libstdc++-v3/testsuite/20_util/any/cons/92156.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-options "-Wno-init-list-lifetime" }
 
 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc 
b/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc
index d8f9893667b..b98d0e8e92a 100644
--- a/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc
+++ b/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-options "-Wno-init-list-lifetime" }
 
 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
 //
diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc 
b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
index f6aefc0a7ff..04042c2d745 100644
--- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
@@ -27,3 +27,6 @@ void test01()
   d(nullptr);  

[gcc r12-10278] libstdc++: Add @headerfile and @since to doxygen comments [PR40380]

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:afefe951acd8bae13be0e1b700262316254ce935

commit r12-10278-gafefe951acd8bae13be0e1b700262316254ce935
Author: Jonathan Wakely 
Date:   Wed Apr 26 22:48:35 2023 +0100

libstdc++: Add @headerfile and @since to doxygen comments [PR40380]

libstdc++-v3/ChangeLog:

PR libstdc++/40380
* include/bits/basic_string.h: Improve doxygen comments.
* include/bits/cow_string.h: Likewise.
* include/bits/forward_list.h: Likewise.
* include/bits/fs_dir.h: Likewise.
* include/bits/fs_path.h: Likewise.
* include/bits/quoted_string.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/bits/stl_set.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/unordered_map.h: Likewise.
* include/bits/unordered_set.h: Likewise.
* include/std/filesystem: Likewise.
* include/std/iomanip: Likewise.

(cherry picked from commit 865869dc6943eb5dee855bc1ea88b09b7dabc641)

Diff:
---
 libstdc++-v3/include/bits/basic_string.h  |  2 ++
 libstdc++-v3/include/bits/cow_string.h|  2 ++
 libstdc++-v3/include/bits/forward_list.h  |  2 ++
 libstdc++-v3/include/bits/fs_dir.h| 35 +--
 libstdc++-v3/include/bits/fs_path.h   | 18 +++-
 libstdc++-v3/include/bits/quoted_string.h | 12 +++
 libstdc++-v3/include/bits/stl_bvector.h   |  2 ++
 libstdc++-v3/include/bits/stl_map.h   |  2 ++
 libstdc++-v3/include/bits/stl_multimap.h  |  2 ++
 libstdc++-v3/include/bits/stl_multiset.h  |  3 ++-
 libstdc++-v3/include/bits/stl_set.h   |  2 ++
 libstdc++-v3/include/bits/stl_vector.h|  2 ++
 libstdc++-v3/include/bits/unordered_map.h |  4 
 libstdc++-v3/include/bits/unordered_set.h |  4 
 libstdc++-v3/include/std/filesystem   |  2 ++
 libstdc++-v3/include/std/iomanip  |  1 +
 16 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index 3f38f20dd18..e02b1b97c5c 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -69,6 +69,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*
*  @ingroup strings
*  @ingroup sequences
+   *  @headerfile string
+   *  @since C++98
*
*  @tparam _CharT  Type of character
*  @tparam _Traits  Traits for character type, defaults to
diff --git a/libstdc++-v3/include/bits/cow_string.h 
b/libstdc++-v3/include/bits/cow_string.h
index 87720690cd3..6dd23883429 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -54,6 +54,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
*  @ingroup strings
*  @ingroup sequences
+   *  @headerfile string
+   *  @since C++98
*
*  @tparam _CharT  Type of character
*  @tparam _Traits  Traits for character type, defaults to
diff --git a/libstdc++-v3/include/bits/forward_list.h 
b/libstdc++-v3/include/bits/forward_list.h
index bbb1740296b..69725a255e8 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -406,6 +406,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  and fixed time insertion/deletion at any point in the sequence.
*
*  @ingroup sequences
+   *  @headerfile forward_list
+   *  @since C++11
*
*  @tparam _Tp  Type of element.
*  @tparam _Alloc  Allocator type, defaults to allocator<_Tp>.
diff --git a/libstdc++-v3/include/bits/fs_dir.h 
b/libstdc++-v3/include/bits/fs_dir.h
index 84e8e8984e8..968a5cf52a0 100644
--- a/libstdc++-v3/include/bits/fs_dir.h
+++ b/libstdc++-v3/include/bits/fs_dir.h
@@ -52,6 +52,10 @@ namespace filesystem
*/
 
   /// Information about a file's type and permissions.
+  /**
+   * @headerfile filesystem
+   * @since C++17
+   */
   class file_status
   {
   public:
@@ -94,6 +98,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   class recursive_directory_iterator;
 
   /// The value type used by directory iterators
+  /**
+   * @headerfile filesystem
+   * @since C++17
+   */
   class directory_entry
   {
   public:
@@ -354,7 +362,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 file_type  _M_type = file_type::none;
   };
 
+  /// @cond undocumented
+
   /// Proxy returned by post-increment on directory iterators.
+  /**
+   * @headerfile filesystem
+   * @since C++17
+   */
   struct __directory_iterator_proxy
   {
 const directory_entry& operator*() const& noexcept { return _M_entry; }
@@ -370,8 +384,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
 directory_entry _M_entry;
   };
+  /// @endcond
 
   /// Iterator type for traversing the entries in a single directory.
+  /**
+   * @headerfile filesystem
+   * @since C++17
+   */
   class directory_ite

[gcc r12-10279] libstdc++: Implement P2538R1 ADL-proof std::projected

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:2d604183c99ef0cea5d7540a7a466fb1d1453a58

commit r12-10279-g2d604183c99ef0cea5d7540a7a466fb1d1453a58
Author: Jonathan Wakely 
Date:   Fri Jun 23 12:18:11 2023 +0100

libstdc++: Implement P2538R1 ADL-proof std::projected

This was recently approved for C++26, but there's no harm in
implementing it unconditionally for C++20 and C++23. As it says in the
paper, it doesn't change the meaning of any valid code. It only enables
things that were previously ill-formed for questionable reasons.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (projected): Replace class
template with alias template denoting an ADL-proofed helper.
(incremental_traits>): Remove.
* testsuite/24_iterators/indirect_callable/projected-adl.cc:
New test.

(cherry picked from commit 6eafdfc73c21d7a5e59e18c9dee275af5bf6d979)

Diff:
---
 libstdc++-v3/include/bits/iterator_concepts.h  | 35 --
 .../indirect_callable/projected-adl.cc | 42 ++
 2 files changed, 67 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/include/bits/iterator_concepts.h 
b/libstdc++-v3/include/bits/iterator_concepts.h
index cf66c63f395..6e032b08eb7 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -771,19 +771,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   && invocable<_Fn, iter_reference_t<_Is>...>
 using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>;
 
+  namespace __detail
+  {
+template
+  struct __projected
+  {
+   struct __type
+   {
+ using value_type = remove_cvref_t>;
+ indirect_result_t<_Proj&, _Iter> operator*() const; // not defined
+   };
+  };
+
+template
+  struct __projected<_Iter, _Proj>
+  {
+   struct __type
+   {
+ using value_type = remove_cvref_t>;
+ using difference_type = iter_difference_t<_Iter>;
+ indirect_result_t<_Proj&, _Iter> operator*() const; // not defined
+   };
+  };
+  } // namespace __detail
+
   /// [projected], projected
   template _Proj>
-struct projected
-{
-  using value_type = remove_cvref_t>;
-
-  indirect_result_t<_Proj&, _Iter> operator*() const; // not defined
-};
-
-  template
-struct incrementable_traits>
-{ using difference_type = iter_difference_t<_Iter>; };
+using projected = typename __detail::__projected<_Iter, _Proj>::__type;
 
   // [alg.req], common algorithm requirements
 
diff --git 
a/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected-adl.cc 
b/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected-adl.cc
new file mode 100644
index 000..4c2a0955c6e
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/indirect_callable/projected-adl.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+// P2538R1 ADL-proof std::projected
+// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2538r1.html
+
+#include 
+
+template
+  concept has_diff_type = requires { typename T::difference_type; };
+
+static_assert( has_diff_type> );
+
+struct Indy {
+  using value_type = int;
+  int operator*() const { return 0; }
+};
+static_assert( ! std::weakly_incrementable );
+static_assert( ! has_diff_type> );
+
+
+// Examples from the paper:
+
+template struct Holder { T t; };
+struct Incomplete;
+
+void test_concepts()
+{
+  using T = Holder*;
+  static_assert(std::equality_comparable);
+  (void) std::indirectly_comparable>;
+  (void) std::sortable;
+}
+
+#include 
+
+void test_count()
+{
+  Holder* a = nullptr;
+  (void) std::count(&a, &a, nullptr);
+  (void) std::ranges::count(&a, &a, nullptr); // { dg-bogus "." }
+}


[gcc r12-10281] libstdc++: Remove test dependencies on _GLIBCXX_USE_C99_STDINT_TR1

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:5546859455fd876fdd1b7233e8c2d8a3a7bc2fe4

commit r12-10281-g5546859455fd876fdd1b7233e8c2d8a3a7bc2fe4
Author: Jonathan Wakely 
Date:   Fri May 12 13:34:37 2023 +0100

libstdc++: Remove test dependencies on _GLIBCXX_USE_C99_STDINT_TR1

These #ifdef checks should have been removed in r9-2029-g612c9c702e2c9e
when the u16string_view and u32string_view aliases were changed to be
defined unconditionally.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string_view/typedefs.cc: Remove
dependency on _GLIBCXX_USE_C99_STDINT_TR1.
* testsuite/experimental/string_view/typedefs.cc: Likewise.

(cherry picked from commit fe0e3df6f3751a0164c8e92a0d6519f2e10527a8)

Diff:
---
 libstdc++-v3/testsuite/21_strings/basic_string_view/typedefs.cc | 2 --
 libstdc++-v3/testsuite/experimental/string_view/typedefs.cc | 2 --
 2 files changed, 4 deletions(-)

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/typedefs.cc 
b/libstdc++-v3/testsuite/21_strings/basic_string_view/typedefs.cc
index 6ead90d7b25..20fad10257b 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/typedefs.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/typedefs.cc
@@ -28,9 +28,7 @@ using check2_t = std::string_view;
 using check3_t = std::u8string_view;
 #endif
 
-#ifdef _GLIBCXX_USE_C99_STDINT_TR1
 using check4_t = std::u16string_view;
 using check5_t = std::u32string_view;
-#endif
 
 using check6_t = std::wstring_view;
diff --git a/libstdc++-v3/testsuite/experimental/string_view/typedefs.cc 
b/libstdc++-v3/testsuite/experimental/string_view/typedefs.cc
index 800a5beaeae..d4a2030aa10 100644
--- a/libstdc++-v3/testsuite/experimental/string_view/typedefs.cc
+++ b/libstdc++-v3/testsuite/experimental/string_view/typedefs.cc
@@ -28,9 +28,7 @@ using check2_t = 
std::experimental::fundamentals_v1::string_view;
 using check3_t = std::experimental::fundamentals_v1::u8string_view;
 #endif
 
-#ifdef _GLIBCXX_USE_C99_STDINT_TR1
 using check4_t = std::experimental::fundamentals_v1::u16string_view;
 using check5_t = std::experimental::fundamentals_v1::u32string_view;
-#endif
 
 using check6_t = std::experimental::fundamentals_v1::wstring_view;


[gcc r12-10282] libstdc++: Remove test dependency on _GLIBCXX_USE_C99_STDINT_TR1

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:5371d1d7f98af405b31ec8461dc5976c8e32bfe0

commit r12-10282-g5371d1d7f98af405b31ec8461dc5976c8e32bfe0
Author: Jonathan Wakely 
Date:   Fri May 12 13:44:21 2023 +0100

libstdc++: Remove test dependency on _GLIBCXX_USE_C99_STDINT_TR1

This should have been done in r9-2028-g8ba7f29e3dd064 when
std::shared_mutex was changed to be defined without depending on
_GLIBCXX_USE_C99_STDINT_TR1.

libstdc++-v3/ChangeLog:

* testsuite/experimental/feat-cxx14.cc: Remove dependency on
_GLIBCXX_USE_C99_STDINT_TR1.

(cherry picked from commit 2c04284abe5d5f1148c709a769f3b83bee2485d0)

Diff:
---
 libstdc++-v3/testsuite/experimental/feat-cxx14.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/experimental/feat-cxx14.cc 
b/libstdc++-v3/testsuite/experimental/feat-cxx14.cc
index 8c0061eddbf..effe382e06e 100644
--- a/libstdc++-v3/testsuite/experimental/feat-cxx14.cc
+++ b/libstdc++-v3/testsuite/experimental/feat-cxx14.cc
@@ -107,7 +107,7 @@
 #  error ""
 #endif
 
-#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+#if defined(_GLIBCXX_HAS_GTHREADS)
 #  ifndef  __cpp_lib_shared_timed_mutex
 #error "__cpp_lib_shared_timed_mutex"
 #  elif  __cpp_lib_shared_timed_mutex != 201402


[gcc r12-10280] libstdc++: Move __glibcxx_assert_fail to its own file

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:413b91e1faacf5fd5d5ffe099898f46750c7f601

commit r12-10280-g413b91e1faacf5fd5d5ffe099898f46750c7f601
Author: Jonathan Wakely 
Date:   Mon Sep 11 15:58:48 2023 +0100

libstdc++: Move __glibcxx_assert_fail to its own file

This avoids a dependency on the other symbols in src/c++11/debug.o when
linking statically to libstdc++.a without using -Wl,--gc-sections.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add new file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/debug.cc (__glibcxx_assert_fail): Move to ...
* src/c++11/assert_fail.cc: New file.

(cherry picked from commit c7db9000fa7caceadb4e72dcc6226abebf7a6239)

Diff:
---
 libstdc++-v3/src/c++11/Makefile.am|  1 +
 libstdc++-v3/src/c++11/Makefile.in|  7 +++---
 libstdc++-v3/src/c++11/assert_fail.cc | 44 +++
 libstdc++-v3/src/c++11/debug.cc   | 18 --
 4 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/libstdc++-v3/src/c++11/Makefile.am 
b/libstdc++-v3/src/c++11/Makefile.am
index 222e2a8c618..2198db1617d 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -52,6 +52,7 @@ cxx11_abi_sources =
 endif
 
 sources = \
+   assert_fail.cc \
chrono.cc \
codecvt.cc \
condition_variable.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.in 
b/libstdc++-v3/src/c++11/Makefile.in
index 892c505eddc..8005fa6253c 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -127,9 +127,9 @@ libc__11convenience_la_LIBADD =
 @ENABLE_DUAL_ABI_TRUE@ cxx11-ios_failure.lo \
 @ENABLE_DUAL_ABI_TRUE@ cxx11-shim_facets.lo cxx11-stdexcept.lo
 am__objects_2 = ctype_configure_char.lo ctype_members.lo
-am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \
-   cow-stdexcept.lo ctype.lo debug.lo functexcept.lo \
-   functional.lo futex.lo future.lo hash_c++0x.lo \
+am__objects_3 = assert_fail.lo chrono.lo codecvt.lo \
+   condition_variable.lo cow-stdexcept.lo ctype.lo debug.lo \
+   functexcept.lo functional.lo futex.lo future.lo hash_c++0x.lo \
hashtable_c++0x.lo ios.lo limits.lo mutex.lo placeholders.lo \
random.lo regex.lo shared_ptr.lo snprintf_lite.lo \
system_error.lo thread.lo $(am__objects_1) $(am__objects_2)
@@ -466,6 +466,7 @@ host_sources = \
 @ENABLE_DUAL_ABI_TRUE@ cxx11-stdexcept.cc
 
 sources = \
+   assert_fail.cc \
chrono.cc \
codecvt.cc \
condition_variable.cc \
diff --git a/libstdc++-v3/src/c++11/assert_fail.cc 
b/libstdc++-v3/src/c++11/assert_fail.cc
new file mode 100644
index 000..540e953da2e
--- /dev/null
+++ b/libstdc++-v3/src/c++11/assert_fail.cc
@@ -0,0 +1,44 @@
+// Debugging mode support code -*- C++ -*-
+
+// Copyright (C) 2021-2023 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+#include   // for std::fprintf, stderr
+#include  // for std::abort
+
+#ifdef _GLIBCXX_VERBOSE_ASSERT
+namespace std
+{
+  [[__noreturn__]]
+  void
+  __glibcxx_assert_fail(const char* file, int line,
+   const char* function, const char* condition) noexcept
+  {
+if (file && function && condition)
+  fprintf(stderr, "%s:%d: %s: Assertion '%s' failed.\n",
+ file, line, function, condition);
+else if (function)
+  fprintf(stderr, "%s: Undefined behavior detected.\n", function);
+abort();
+  }
+}
+#endif
diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index 1bfc6ccc581..88dca83ce1a 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -45,24 +45,6 @@
 
 #include "mutex_pool.h"
 
-#ifdef _GLIBCXX_VERBOSE_ASSERT
-namespace std
-{
-  [[__noreturn__]]
-  void
-  __glibcxx_assert_fail(const char* file, int line,
-   const char* function, const char* condition) noexcept
-  {
-if (file && function && condition)
-  fprintf(std

[gcc r12-10276] libstdc++: Improve Doxygen comments in

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:819d63e09950cff6761c2427ead4266b7838e5ea

commit r12-10276-g819d63e09950cff6761c2427ead4266b7838e5ea
Author: Jonathan Wakely 
Date:   Mon Nov 21 14:12:52 2022 +

libstdc++: Improve Doxygen comments in 

libstdc++-v3/ChangeLog:

* include/std/tuple: Add better Doxygen comments.

(cherry picked from commit 94f7baf2194e2d20108c9d34d2766e6b14e25cef)

Diff:
---
 libstdc++-v3/include/std/tuple | 28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 04b77113a84..b93252e434e 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1586,6 +1586,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif // three_way_comparison
 
   // NB: DR 705.
+  /// Create a tuple containing copies of the arguments
   template
 constexpr tuple::__type...>
 make_tuple(_Elements&&... __args)
@@ -1597,7 +1598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 2275. Why is forward_as_tuple not constexpr?
-  /// std::forward_as_tuple
+  /// Create a tuple of lvalue or rvalue references to the arguments
   template
 constexpr tuple<_Elements&&...>
 forward_as_tuple(_Elements&&... __args) noexcept
@@ -1624,7 +1625,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 constexpr const _Tp&&
 get(const array<_Tp, _Nm>&&) noexcept;
 
-
+  /// @cond undocumented
   template
 struct __make_tuple_impl;
 
@@ -1736,8 +1737,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 struct __is_tuple_like_impl> : true_type
 { };
+  /// @endcond
 
-  /// tuple_cat
+  /// Create a `tuple` containing all elements from multiple tuple-like objects
   template...>::value>::type>
 constexpr auto
@@ -1752,13 +1754,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 2301. Why is tie not constexpr?
-  /// tie
+  /// Return a tuple of lvalue references bound to the arguments
   template
 constexpr tuple<_Elements&...>
 tie(_Elements&... __args) noexcept
 { return tuple<_Elements&...>(__args...); }
 
-  /// swap
+  /// Exchange the values of two tuples
   template
 _GLIBCXX20_CONSTEXPR
 inline
@@ -1774,6 +1776,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { __x.swap(__y); }
 
 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
+  /// Exchange the values of two const tuples (if const elements can be 
swapped)
   template
 _GLIBCXX20_CONSTEXPR
 typename enable_if...>::value>::type
@@ -1794,6 +1797,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 2773. Making std::ignore constexpr
+  /** Used with `std::tie` to ignore an element of a tuple
+   *
+   * When using `std::tie` to assign the elements of a tuple to variables,
+   * unwanted elements can be ignored by using `std::ignore`. For example:
+   *
+   * ```
+   * int x, y;
+   * std::tie(x, std::ignore, y) = std::make_tuple(1, 2, 3);
+   * ```
+   *
+   * This assignment will perform `x=1; std::ignore=2; y=3;` which results
+   * in the second element being ignored.
+   *
+   * @since C++11
+   */
   _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
 
   /// Partial specialization for tuples


[gcc r12-10277] libstdc++: Fix Doxygen warning

2024-03-18 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:5558c3f14517d7471b0e3e2a0169a49f23a8b98a

commit r12-10277-g5558c3f14517d7471b0e3e2a0169a49f23a8b98a
Author: Jonathan Wakely 
Date:   Thu Nov 17 10:20:50 2022 +

libstdc++: Fix Doxygen warning

This fixes a Doxygen warning about a mismatched parameter name. The
standard uses 'r' here, like the Doxygen comment, so use '__r' instead
of '__e'.

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h (pointer_traits::pointer_to): Rename
parameter.

(cherry picked from commit fca0f50b145048afda17f0f10ac968afe6be0fad)

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

diff --git a/libstdc++-v3/include/bits/ptr_traits.h 
b/libstdc++-v3/include/bits/ptr_traits.h
index 71370ff4fc9..b46a1ac34c9 100644
--- a/libstdc++-v3/include/bits/ptr_traits.h
+++ b/libstdc++-v3/include/bits/ptr_traits.h
@@ -104,17 +104,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /**
*  @brief  Obtain a pointer to an object
*  @param  __r  A reference to an object of type `element_type`
-   *  @return `pointer::pointer_to(__e)`
-   *  @pre `pointer::pointer_to(__e)` is a valid expression.
+   *  @return `pointer::pointer_to(__r)`
+   *  @pre `pointer::pointer_to(__r)` is a valid expression.
   */
   static pointer
-  pointer_to(element_type& __e)
+  pointer_to(element_type& __r)
 #if __cpp_lib_concepts
   requires requires {
-   { pointer::pointer_to(__e) } -> convertible_to;
+   { pointer::pointer_to(__r) } -> convertible_to;
   }
 #endif
-  { return pointer::pointer_to(__e); }
+  { return pointer::pointer_to(__r); }
 };
 
   // Do not define pointer_traits::pointer_to if element type is void.


[gcc r14-9518] gcc_update: Add missing generated files

2024-03-18 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:fd776d092642d7b9d429a5e45454594a93ccd819

commit r14-9518-gfd776d092642d7b9d429a5e45454594a93ccd819
Author: Jonathan Wakely 
Date:   Fri Mar 1 16:46:29 2024 +

gcc_update: Add missing generated files

I'm seeing errors for --enable-maintainer-mode builds due to incorrectly
regenerating these files. They should be touched by gcc_update so they
aren't regenerated incorrectly.

contrib/ChangeLog:

* gcc_update: Add more generated files in libcc1, lto-plugin,
fixincludes, and libstdc++-v3.

Diff:
---
 contrib/gcc_update | 8 
 1 file changed, 8 insertions(+)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 774c926e723..fac86d0e33e 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -70,6 +70,7 @@ files_and_dependencies () {
 # fixincludes
 fixincludes/configure: fixincludes/configure.ac fixincludes/aclocal.m4
 fixincludes/config.h.in: fixincludes/configure.ac fixincludes/aclocal.m4
+fixincludes/fixincl.x: fixincludes/inclhack.def fixincludes/fixincl.tpl
 # intl library
 intl/plural.c: intl/plural.y
 intl/plural-config.h: intl/plural.y
@@ -106,6 +107,7 @@ gcc/testsuite/gcc.dg/cpp/_Pragma3.c: 
gcc/testsuite/gcc.dg/cpp/mi1c.h
 # direct2s.c:35: warning: current file is older than direct2.c
 gcc/testsuite/gcc.dg/cpp/direct2s.c: gcc/testsuite/gcc.dg/cpp/direct2.c
 # lto-plugin
+lto-plugin/aclocal.m4: lto-plugin/configure.ac
 lto-plugin/configure: lto-plugin/configure.ac lto-plugin/aclocal.m4
 lto-plugin/Makefile.in: lto-plugin/Makefile.am lto-plugin/aclocal.m4
 # tools
@@ -186,7 +188,13 @@ libphobos/config.h.in: libphobos/configure.ac 
libphobos/aclocal.m4
 libphobos/configure: libphobos/configure.ac libphobos/aclocal.m4
 libphobos/src/Makefile.in: libphobos/src/Makefile.am libphobos/aclocal.m4
 libphobos/testsuite/Makefile.in: libphobos/testsuite/Makefile.am 
libphobos/aclocal.m4
+libstdc++-v3/aclocal.m4: libstdc++-v3/configure.ac libstdc++-v3/acinclude.m4
+libstdc++-v3/Makefile.in: libstdc++-v3/Makefile.am libstdc++-v3/aclocal.m4
+libstdc++-v3/configure: libstdc++-v3/configure.ac libstdc++-v3/acinclude.m4
 libstdc++-v3/include/bits/version.h: libstdc++-v3/include/bits/version.def 
libstdc++-v3/include/bits/version.tpl
+libcc1/aclocal.m4: libcc1/configure.ac
+libcc1/Makefile.in: libcc1/Makefile.am libcc1/configure.ac libcc1/aclocal.m4
+libcc1/configure: libcc1/configure.ac
 # Top level
 Makefile.in: Makefile.tpl Makefile.def
 configure: configure.ac config/acx.m4


[gcc r14-9520] PR modula2/114380 Incorrect type specified in an error message

2024-03-18 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:d2029bbc69df7341775faf6cf1aa13d978c223a1

commit r14-9520-gd2029bbc69df7341775faf6cf1aa13d978c223a1
Author: Gaius Mulley 
Date:   Mon Mar 18 16:40:35 2024 +

PR modula2/114380 Incorrect type specified in an error message

This patch corrects an error message relating to a variable of
a SET type. The bugfix is not to skip over set types (in
GetLowestType).

gcc/m2/ChangeLog:

PR modula2/114380
* gm2-compiler/SymbolTable.mod (GetLowestType): Do not
skip over a set type, but return sym.

gcc/testsuite/ChangeLog:

PR modula2/114380
* gm2/pim/fail/badset7.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/SymbolTable.mod|  2 +-
 gcc/testsuite/gm2/pim/fail/badset7.mod | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/m2/gm2-compiler/SymbolTable.mod 
b/gcc/m2/gm2-compiler/SymbolTable.mod
index c08de6a97c3..9d572cff19c 100644
--- a/gcc/m2/gm2-compiler/SymbolTable.mod
+++ b/gcc/m2/gm2-compiler/SymbolTable.mod
@@ -6154,7 +6154,7 @@ BEGIN
   SubrangeSym : type := Subrange.Type |
   ArraySym: type := Array.Type |
   SubscriptSym: type := Subscript.Type |
-  SetSym  : type := Set.Type |
+  SetSym  : type := Sym |(* Stop at the set type.  *)
   UnboundedSym: type := Unbounded.Type |
   UndefinedSym: type := NulSym |
   DummySym: type := NulSym
diff --git a/gcc/testsuite/gm2/pim/fail/badset7.mod 
b/gcc/testsuite/gm2/pim/fail/badset7.mod
new file mode 100644
index 000..5c2499be739
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/badset7.mod
@@ -0,0 +1,14 @@
+MODULE badset7 ;
+
+FROM SYSTEM IMPORT WORD ;
+
+PROCEDURE func () : WORD ;
+BEGIN
+   RETURN WORD (0)
+END func ;
+
+VAR
+   b: BITSET ;
+BEGIN
+   b := func () - {6..31}
+END badset7.


[gcc r14-9521] testsuite: Turn errors back into warnings in arm/acle/cde-mve-error-2.c

2024-03-18 Thread Richard Earnshaw via Gcc-cvs
https://gcc.gnu.org/g:9316d021ebb95062f5e3ed9d67734863279671fe

commit r14-9521-g9316d021ebb95062f5e3ed9d67734863279671fe
Author: Thiago Jung Bauermann 
Date:   Fri Mar 15 12:13:29 2024 -0300

testsuite: Turn errors back into warnings in arm/acle/cde-mve-error-2.c

Since commit 2c3db94d9fd ("c: Turn int-conversion warnings into
permerrors") the test fails with errors such as:

  FAIL: gcc.target/arm/acle/cde-mve-error-2.c   -O0   (test for errors, 
line 32)
  FAIL: gcc.target/arm/acle/cde-mve-error-2.c   -O0   (test for errors, 
line 33)
  FAIL: gcc.target/arm/acle/cde-mve-error-2.c   -O0   (test for errors, 
line 34)
  FAIL: gcc.target/arm/acle/cde-mve-error-2.c   -O0   (test for errors, 
line 35)
⋮
  FAIL: gcc.target/arm/acle/cde-mve-error-2.c   -O0  (test for excess 
errors)

There's a total of 1016 errors.  Here's a sample of the excess errors:

  Excess errors:
  /path/gcc.git/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c:117:31: 
error: passing argument 2 of '__builtin_arm_vcx1qv16qi' makes integer from 
pointer without a cast [-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c:119:3: 
error: passing argument 3 of '__builtin_arm_vcx1qav16qi' makes integer from 
pointer without a cast [-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c:121:3: 
error: passing argument 3 of '__builtin_arm_vcx2qv16qi' makes integer from 
pointer without a cast [-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c:123:3: 
error: passing argument 3 of '__builtin_arm_vcx2qv16qi' makes integer from 
pointer without a cast [-Wint-conversion]

The test expects these messages to be warnings, not errors.  My first
try was to change it to expect them as errors instead.  This didn't
work, IIUC because the error prevents the compiler from continuing
processing the file and thus other errors which are expected by the
test don't get emitted.

Therefore, add -fpermissive so that the test behaves as it did
previously.  Because of the additional line in the header, the line
numbers of the expected warnings don't match anymore so replace them
with ".-1" as suggested by Richard Earnshaw.

Tested on armv8l-linux-gnueabihf.

gcc/testsuite/ChangeLog:
* gcc.target/arm/acle/cde-mve-error-2.c: Add -fpermissive.  Use
relative offsets for line numbers.

Diff:
---
 .../gcc.target/arm/acle/cde-mve-error-2.c  | 63 +++---
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c 
b/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c
index 5b777482544..0f605083c5c 100644
--- a/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c
+++ b/gcc/testsuite/gcc.target/arm/acle/cde-mve-error-2.c
@@ -2,6 +2,7 @@
 
 /* { dg-do assemble } */
 /* { dg-require-effective-target arm_v8_1m_main_cde_mve_fp_ok } */
+/* { dg-options "-fpermissive" } */
 /* { dg-add-options arm_v8_1m_main_cde_mve_fp } */
 
 /* The error checking files are split since there are three kinds of
@@ -115,73 +116,73 @@ uint8x16_t test_bad_immediates (uint8x16_t n, uint8x16_t 
m, int someval,
 
   /* `imm' is of wrong type.  */
   accum += __arm_vcx1q_u8 (0, "");/* { dg-error {argument 
2 to '__builtin_arm_vcx1qv16qi' must be a constant immediate in range 
\[0-4095\]} } */
-  /* { dg-warning {passing argument 2 of '__builtin_arm_vcx1qv16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
117 } */
+  /* { dg-warning {passing argument 2 of '__builtin_arm_vcx1qv16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
.-1 } */
   accum += __arm_vcx1qa (0, accum, "");   /* { dg-error {argument 
3 to '__builtin_arm_vcx1qav16qi' must be a constant immediate in range 
\[0-4095\]} } */
-  /* { dg-warning {passing argument 3 of '__builtin_arm_vcx1qav16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
119 } */
+  /* { dg-warning {passing argument 3 of '__builtin_arm_vcx1qav16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
.-1 } */
   accum += __arm_vcx2q (0, n, "");/* { dg-error {argument 
3 to '__builtin_arm_vcx2qv16qi' must be a constant immediate in range 
\[0-127\]} } */
-  /* { dg-warning {passing argument 3 of '__builtin_arm_vcx2qv16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
121 } */
+  /* { dg-warning {passing argument 3 of '__builtin_arm_vcx2qv16qi' makes 
integer from pointer without a cast \[-Wint-conversion\]} "" { target *-*-* } 
.-1 } */
   accum += __arm_vcx2q_u8 (0, n, "x");/* { dg-error {argument 
3 to '__builtin_arm_vcx2qv16qi' must be a constant immediate in range 
\[0-127\]} 

[gcc r14-9522] Fortran: error recovery in frontend optimization [PR103715]

2024-03-18 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:3be2b8f475f22c531d6cef1b041c0573b3ea5133

commit r14-9522-g3be2b8f475f22c531d6cef1b041c0573b3ea5133
Author: Harald Anlauf 
Date:   Mon Mar 18 19:36:59 2024 +0100

Fortran: error recovery in frontend optimization [PR103715]

gcc/fortran/ChangeLog:

PR fortran/103715
* frontend-passes.cc (check_externals_expr): Prevent invalid read
in case of mismatch of external subroutine with function.

gcc/testsuite/ChangeLog:

PR fortran/103715
* gfortran.dg/pr103715.f90: New test.

Diff:
---
 gcc/fortran/frontend-passes.cc |  3 +++
 gcc/testsuite/gfortran.dg/pr103715.f90 | 12 
 2 files changed, 15 insertions(+)

diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 06dfa1a3232..3c06018fdbb 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -5807,6 +5807,9 @@ check_externals_expr (gfc_expr **ep, int *walk_subtrees 
ATTRIBUTE_UNUSED,
   if (e->expr_type != EXPR_FUNCTION)
 return 0;
 
+  if (e->symtree && e->symtree->n.sym->attr.subroutine)
+return 0;
+
   sym = e->value.function.esym;
   if (sym == NULL)
 return 0;
diff --git a/gcc/testsuite/gfortran.dg/pr103715.f90 
b/gcc/testsuite/gfortran.dg/pr103715.f90
new file mode 100644
index 000..72c5a31fb21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103715.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/103715 - ICE in gfc_find_gsymbol
+!
+! valgrind did report an invalid read in check_externals_procedure
+
+program p
+  select type (y => g()) ! { dg-error "Selector shall be polymorphic" }
+  end select
+  call g()
+end
+
+! { dg-prune-output "already being used as a FUNCTION" }


[gcc r14-9523] i386: Unify {general, timode}_scalar_chain::convert_op [PR111822]

2024-03-18 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:b96c5436880d7926299314a33c953171082ab59e

commit r14-9523-gb96c5436880d7926299314a33c953171082ab59e
Author: Uros Bizjak 
Date:   Mon Mar 18 20:40:29 2024 +0100

i386: Unify {general,timode}_scalar_chain::convert_op [PR111822]

Recent PR111822 fix implemented REG_EH_REGION note copying to a STV 
converted
preload instruction in general_scalar_chain::convert_op.  However, the same
issue remains in timode_scalar_chain::convert_op.  Instead of copying the
newly introduced code to timode_scalar_chain::convert_op, the patch unifies
both functions to a common function.

PR target/111822

gcc/ChangeLog:

* config/i386/i386-features.cc (smode_convert_cst): New function
to handle SImode, DImode and TImode immediates, generalized from
timode_convert_cst.
(timode_convert_cst): Remove.
(scalar_chain::convert_op): Unify from
general_scalar_chain::convert_op and 
timode_scalar_chain::convert_op.
(general_scalar_chain::convert_op): Remove.
(timode_scalar_chain::convert_op): Remove.
(timode_scalar_chain::convert_insn): Update the call to
renamed timode_convert_cst.
* config/i386/i386-features.h (class scalar_chain):
Redeclare convert_op as protected class member.
(class general_calar_chain): Remove convert_op.
(class timode_scalar_chain): Ditto.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr111822.C (dg-do): Compile only for ia32 targets.
(dg-options): Add -march=x86-64.

Diff:
---
 gcc/config/i386/i386-features.cc | 127 +--
 gcc/config/i386/i386-features.h  |   4 +-
 gcc/testsuite/g++.target/i386/pr111822.C |   4 +-
 3 files changed, 40 insertions(+), 95 deletions(-)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index c7d7a965901..e3e004d5526 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -980,14 +980,35 @@ scalar_chain::convert_reg (rtx_insn *insn, rtx dst, rtx 
src)
 REGNO (src), REGNO (dst), INSN_UID (insn));
 }
 
+/* Helper function to convert immediate constant X to vmode.  */
+static rtx
+smode_convert_cst (rtx x, enum machine_mode vmode)
+{
+  /* Prefer all ones vector in case of -1.  */
+  if (constm1_operand (x, GET_MODE (x)))
+return CONSTM1_RTX (vmode);
+
+  unsigned n = GET_MODE_NUNITS (vmode);
+  rtx *v = XALLOCAVEC (rtx, n);
+  v[0] = x;
+  for (unsigned i = 1; i < n; ++i)
+v[i] = const0_rtx;
+  return gen_rtx_CONST_VECTOR (vmode, gen_rtvec_v (n, v));
+}
+
 /* Convert operand OP in INSN.  We should handle
memory operands and uninitialized registers.
All other register uses are converted during
registers conversion.  */
 
 void
-general_scalar_chain::convert_op (rtx *op, rtx_insn *insn)
+scalar_chain::convert_op (rtx *op, rtx_insn *insn)
 {
+  rtx tmp;
+
+  if (GET_MODE (*op) == V1TImode)
+return;
+
   *op = copy_rtx_if_shared (*op);
 
   if (GET_CODE (*op) == NOT
@@ -998,20 +1019,21 @@ general_scalar_chain::convert_op (rtx *op, rtx_insn 
*insn)
 }
   else if (MEM_P (*op))
 {
-  rtx_insn* eh_insn, *movabs = NULL;
-  rtx tmp = gen_reg_rtx (GET_MODE (*op));
+  rtx_insn *movabs = NULL;
 
   /* Emit MOVABS to load from a 64-bit absolute address to a GPR.  */
   if (!memory_operand (*op, GET_MODE (*op)))
{
- rtx tmp2 = gen_reg_rtx (GET_MODE (*op));
- movabs = emit_insn_before (gen_rtx_SET (tmp2, *op), insn);
+ tmp = gen_reg_rtx (GET_MODE (*op));
+ movabs = emit_insn_before (gen_rtx_SET (tmp, *op), insn);
 
- *op = tmp2;
+ *op = tmp;
}
 
-  eh_insn
-   = emit_insn_before (gen_rtx_SET (gen_rtx_SUBREG (vmode, tmp, 0),
+  tmp = gen_rtx_SUBREG (vmode, gen_reg_rtx (GET_MODE (*op)), 0);
+
+  rtx_insn *eh_insn
+   = emit_insn_before (gen_rtx_SET (copy_rtx (tmp),
 gen_gpr_to_xmm_move_src (vmode, *op)),
insn);
 
@@ -1028,33 +1050,17 @@ general_scalar_chain::convert_op (rtx *op, rtx_insn 
*insn)
}
}
 
-  *op = gen_rtx_SUBREG (vmode, tmp, 0);
+  *op = tmp;
 
   if (dump_file)
fprintf (dump_file, "  Preloading operand for insn %d into r%d\n",
 INSN_UID (insn), REGNO (tmp));
 }
   else if (REG_P (*op))
+*op = gen_rtx_SUBREG (vmode, *op, 0);
+  else if (CONST_SCALAR_INT_P (*op))
 {
-  *op = gen_rtx_SUBREG (vmode, *op, 0);
-}
-  else if (CONST_INT_P (*op))
-{
-  rtx vec_cst;
-  rtx tmp = gen_rtx_SUBREG (vmode, gen_reg_rtx (smode), 0);
-
-  /* Prefer all ones vector in case of -1.  */
-  if (constm1_operand (*op, GET_MODE (*op)))
-   vec_cst = CONSTM1_RTX (vmode);
-  else
-   {
- unsigned n = GET_MODE_NUNITS 

[gcc] Created branch 'meissner/heads/work163' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163' was created in namespace 'refs/users' 
pointing to:

 b96c5436880... i386: Unify {general,timode}_scalar_chain::convert_op [PR11


[gcc(refs/users/meissner/heads/work163)] Add ChangeLog.meissner and REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:3c66db034e3bb01a4b8ed67456fac25621afc5d3

commit 3c66db034e3bb01a4b8ed67456fac25621afc5d3
Author: Michael Meissner 
Date:   Mon Mar 18 15:53:38 2024 -0400

Add ChangeLog.meissner and REVISION.

2024-03-18  Michael Meissner  

gcc/

* REVISION: New file for branch.
* ChangeLog.meissner: New file.

gcc/c-family/

* ChangeLog.meissner: New file.

gcc/c/

* ChangeLog.meissner: New file.

gcc/cp/

* ChangeLog.meissner: New file.

gcc/fortran/

* ChangeLog.meissner: New file.

gcc/testsuite/

* ChangeLog.meissner: New file.

libgcc/

* ChangeLog.meissner: New file.

Diff:
---
 gcc/ChangeLog.meissner   | 6 ++
 gcc/REVISION | 1 +
 gcc/c-family/ChangeLog.meissner  | 6 ++
 gcc/c/ChangeLog.meissner | 6 ++
 gcc/cp/ChangeLog.meissner| 6 ++
 gcc/fortran/ChangeLog.meissner   | 6 ++
 gcc/testsuite/ChangeLog.meissner | 6 ++
 libgcc/ChangeLog.meissner| 6 ++
 libstdc++-v3/ChangeLog.meissner  | 6 ++
 9 files changed, 49 insertions(+)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index 000..f37c7e5ef94
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work163 branch
diff --git a/gcc/c-family/ChangeLog.meissner b/gcc/c-family/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/c-family/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/c/ChangeLog.meissner b/gcc/c/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/c/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/cp/ChangeLog.meissner b/gcc/cp/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/cp/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/fortran/ChangeLog.meissner b/gcc/fortran/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/fortran/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/testsuite/ChangeLog.meissner b/gcc/testsuite/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/gcc/testsuite/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/libgcc/ChangeLog.meissner b/libgcc/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/libgcc/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/libstdc++-v3/ChangeLog.meissner b/libstdc++-v3/ChangeLog.meissner
new file mode 100644
index 000..2ac430b565b
--- /dev/null
+++ b/libstdc++-v3/ChangeLog.meissner
@@ -0,0 +1,6 @@
+ Branch work163, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+


[gcc] Created branch 'meissner/heads/work163-dmf' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-dmf' was created in namespace 'refs/users' 
pointing to:

 3c66db034e3... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work163-dmf)] Add ChangeLog.dmf and update REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:dc53c10f6bfd00c8d3d0ef01bd10d05ca7d58d56

commit dc53c10f6bfd00c8d3d0ef01bd10d05ca7d58d56
Author: Michael Meissner 
Date:   Mon Mar 18 15:54:31 2024 -0400

Add ChangeLog.dmf and update REVISION.

2024-03-18  Michael Meissner  

gcc/

* ChangeLog.dmf: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.dmf | 6 ++
 gcc/REVISION  | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.dmf b/gcc/ChangeLog.dmf
new file mode 100644
index 000..1599736218a
--- /dev/null
+++ b/gcc/ChangeLog.dmf
@@ -0,0 +1,6 @@
+ Branch work163-dmf, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
index f37c7e5ef94..1116969d5bd 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work163 branch
+work163-dmf branch


[gcc] Created branch 'meissner/heads/work163-vpair' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-vpair' was created in namespace 'refs/users' 
pointing to:

 3c66db034e3... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work163-vpair)] Add ChangeLog.vpair and update REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:2e2242bfc6f17fbae05a670a25bcde598fc1778a

commit 2e2242bfc6f17fbae05a670a25bcde598fc1778a
Author: Michael Meissner 
Date:   Mon Mar 18 15:55:27 2024 -0400

Add ChangeLog.vpair and update REVISION.

2024-03-18  Michael Meissner  

gcc/

* ChangeLog.vpair: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.vpair | 6 ++
 gcc/REVISION| 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.vpair b/gcc/ChangeLog.vpair
new file mode 100644
index 000..c6226335975
--- /dev/null
+++ b/gcc/ChangeLog.vpair
@@ -0,0 +1,6 @@
+ Branch work163-vpair, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
index f37c7e5ef94..e5f8c9811d3 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work163 branch
+work163-vpair branch


[gcc] Created branch 'meissner/heads/work163-ajit' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-ajit' was created in namespace 'refs/users' 
pointing to:

 3c66db034e3... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work163-ajit)] Add ChangeLog.ajit and update REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:ebe79795a9e691f8f3209996bcab7b67e6239198

commit ebe79795a9e691f8f3209996bcab7b67e6239198
Author: Michael Meissner 
Date:   Mon Mar 18 15:56:21 2024 -0400

Add ChangeLog.ajit and update REVISION.

2024-03-18  Michael Meissner  

gcc/

* ChangeLog.ajit: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.ajit | 6 ++
 gcc/REVISION   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.ajit b/gcc/ChangeLog.ajit
new file mode 100644
index 000..01cf332c638
--- /dev/null
+++ b/gcc/ChangeLog.ajit
@@ -0,0 +1,6 @@
+ Branch work163-ajit, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
index f37c7e5ef94..cb3f7c4e90b 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work163 branch
+work163-ajit branch


[gcc] Created branch 'meissner/heads/work163-test' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-test' was created in namespace 'refs/users' 
pointing to:

 3c66db034e3... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work163-test)] Add ChangeLog.test and update REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:43b3c9b7beeb1f4944a12144d8c19325d5894555

commit 43b3c9b7beeb1f4944a12144d8c19325d5894555
Author: Michael Meissner 
Date:   Mon Mar 18 15:57:16 2024 -0400

Add ChangeLog.test and update REVISION.

2024-03-18  Michael Meissner  

gcc/

* ChangeLog.test: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.test | 6 ++
 gcc/REVISION   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.test b/gcc/ChangeLog.test
new file mode 100644
index 000..07f6729db60
--- /dev/null
+++ b/gcc/ChangeLog.test
@@ -0,0 +1,6 @@
+ Branch work163-test, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
index f37c7e5ef94..604bf44a62f 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work163 branch
+work163-test branch


[gcc] Created branch 'meissner/heads/work163-orig' in namespace 'refs/users'

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-orig' was created in namespace 'refs/users' 
pointing to:

 b96c5436880... i386: Unify {general,timode}_scalar_chain::convert_op [PR11


[gcc(refs/users/meissner/heads/work163-orig)] Add REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:731c9f3f8bb1faab0ade69e6c66a8e29ab890a8e

commit 731c9f3f8bb1faab0ade69e6c66a8e29ab890a8e
Author: Michael Meissner 
Date:   Mon Mar 18 15:58:04 2024 -0400

Add REVISION.

2024-03-18  Michael Meissner  

gcc/

* REVISION: New file for branch.

Diff:
---
 gcc/REVISION | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index 000..3da06f0dfb1
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work163-orig branch


[gcc r14-9524] libstdc++: Fix _Safe_local_iterator<>::_M_valid_range

2024-03-18 Thread Francois Dumont via Libstdc++-cvs
https://gcc.gnu.org/g:5f6e0853c30fec72d977afaa6f7a5633a8d910be

commit r14-9524-g5f6e0853c30fec72d977afaa6f7a5633a8d910be
Author: François Dumont 
Date:   Sun Mar 17 17:30:58 2024 +0100

libstdc++: Fix _Safe_local_iterator<>::_M_valid_range

Unordered container local_iterator range shall not contain any singular
iterator unless both iterators are both value-initialized.

libstdc++-v3/ChangeLog:

* include/debug/safe_local_iterator.tcc
(_Safe_local_iterator::_M_valid_range): Add _M_value_initialized and
_M_singular checks.
* testsuite/23_containers/unordered_set/debug/114316.cc: New test 
case.

Diff:
---
 libstdc++-v3/include/debug/safe_local_iterator.tcc |  8 ++-
 .../23_containers/unordered_set/debug/114316.cc| 28 ++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/debug/safe_local_iterator.tcc 
b/libstdc++-v3/include/debug/safe_local_iterator.tcc
index 90e60e37c32..6d546ec040c 100644
--- a/libstdc++-v3/include/debug/safe_local_iterator.tcc
+++ b/libstdc++-v3/include/debug/safe_local_iterator.tcc
@@ -78,7 +78,13 @@ namespace __gnu_debug
 _M_valid_range(const _Safe_local_iterator& __rhs,
std::pair& __dist) const
 {
-  if (!_M_can_compare(__rhs))
+  if (_M_value_initialized() && __rhs._M_value_initialized())
+   {
+ __dist = { 0, __dp_exact };
+ return true;
+   }
+
+  if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs))
return false;
 
   if (bucket() != __rhs.bucket())
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/114316.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/114316.cc
new file mode 100644
index 000..41b649a9cbd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/114316.cc
@@ -0,0 +1,28 @@
+// { dg-do run { target c++11 } }
+// { dg-require-debug-mode "" }
+
+// PR libstdc++/114316
+
+#include 
+#include 
+
+#include 
+
+void test01()
+{
+  std::unordered_set::iterator it{};
+  VERIFY( std::find(it, it, 0) == it );
+}
+
+void test02()
+{
+  std::unordered_set::local_iterator it{};
+  VERIFY( std::find(it, it, 0) == it );
+}
+
+int main()
+{
+  test01();
+  test02();
+  return 0;
+}


[gcc r14-9525] libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_advance

2024-03-18 Thread Francois Dumont via Gcc-cvs
https://gcc.gnu.org/g:dda96a9d942d73a587e174dd5efe061208a195af

commit r14-9525-gdda96a9d942d73a587e174dd5efe061208a195af
Author: François Dumont 
Date:   Sun Mar 17 19:06:55 2024 +0100

libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_advance

We shall be able to advance from a 0 offset a value-initialized iterator.

libstdc++-v3/ChangeLog:

* include/debug/safe_iterator.tcc 
(_Safe_iterator<>::_M_can_advance):
Accept 0 offset advance on value-initialized iterator.
* testsuite/23_containers/vector/debug/n3644.cc: New test case.

Diff:
---
 libstdc++-v3/include/debug/safe_iterator.tcc |  3 +++
 .../testsuite/23_containers/vector/debug/n3644.cc| 16 
 2 files changed, 19 insertions(+)

diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc 
b/libstdc++-v3/include/debug/safe_iterator.tcc
index 4b2baf2980e..deaa84d0a1f 100644
--- a/libstdc++-v3/include/debug/safe_iterator.tcc
+++ b/libstdc++-v3/include/debug/safe_iterator.tcc
@@ -86,6 +86,9 @@ namespace __gnu_debug
 _Safe_iterator<_Iterator, _Sequence, _Category>::
 _M_can_advance(difference_type __n, bool __strict) const
 {
+  if (this->_M_value_initialized() && __n == 0)
+   return true;
+
   if (this->_M_singular())
return false;
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/n3644.cc 
b/libstdc++-v3/testsuite/23_containers/vector/debug/n3644.cc
new file mode 100644
index 000..052c52f26b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/debug/n3644.cc
@@ -0,0 +1,16 @@
+// { dg-do run { target c++11 } }
+// { dg-require-debug-mode "" }
+
+#include 
+#include 
+
+#include 
+
+int main()
+{
+  std::vector::iterator it{};
+  auto cpy = it;
+  std::advance(it, 0);
+  VERIFY( it == cpy );
+  return 0;
+}


[gcc r14-9526] analyzer: support null operands in remove_ssa_names

2024-03-18 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:3c2827d75ea8fbf7b84bd69e8d10dc239e5daffe

commit r14-9526-g3c2827d75ea8fbf7b84bd69e8d10dc239e5daffe
Author: David Malcolm 
Date:   Mon Mar 18 18:44:32 2024 -0400

analyzer: support null operands in remove_ssa_names

gcc/analyzer/ChangeLog:
* access-diagram.cc (remove_ssa_names): Support operands being
NULL_TREE, such as e.g. for COMPONENT_REF's operand 2.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/analyzer/access-diagram.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc
index 2836308c019..a9c5c899950 100644
--- a/gcc/analyzer/access-diagram.cc
+++ b/gcc/analyzer/access-diagram.cc
@@ -311,7 +311,8 @@ remove_ssa_names (tree expr)
 return SSA_NAME_VAR (expr);
   tree t = copy_node (expr);
   for (int i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
-TREE_OPERAND (t, i) = remove_ssa_names (TREE_OPERAND (expr, i));
+if (TREE_OPERAND (expr, i))
+  TREE_OPERAND (t, i) = remove_ssa_names (TREE_OPERAND (expr, i));
   return t;
 }


[gcc r14-9527] analyzer: fix ICEs due to sloppy types in bounds-checking [PR110902, PR110928, PR111305, PR111441]

2024-03-18 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:1579394c9ecf3d1f678daa54b835c7fc3b76fb6d

commit r14-9527-g1579394c9ecf3d1f678daa54b835c7fc3b76fb6d
Author: David Malcolm 
Date:   Mon Mar 18 18:44:34 2024 -0400

analyzer: fix ICEs due to sloppy types in bounds-checking 
[PR110902,PR110928,PR111305,PR111441]

Various analyzer ICEs in our bugzilla relate to sloppy use of types
within bounds-checking.

The bounds-checking code works by comparing symbolic *bit* offsets, and
we don't have a good user-facing type that can represent such an offset
(ptrdiff_type_node is for *byte* offsets).

ana::svalue doesn't enforce valid combinations of types for things like
binary operations.  When I added the access diagrams for GCC 14, this
could lead to attempts to generate trees for such svalues, leading to
trees with invalid combinations of types (e.g. PLUS_EXPR or MULT_EXPR of
incompatible types), leading to ICEs inside the tree folding logic.

I tried two approaches to fixing this.

My first approach was to fix the type-handling throughout the
bounds-checking code to use correct types, using size_type_node for
sizes, ptrdiff_type_node for byte offsets, and trying ptrdiff_type_node
for bit offsets.  I implemented this, and it fixed the crashes, but
unfortunately it led to:
(a) numerous false negatives from the bounds-checking code, due to it
becoming unable to be sure that the accessed offset was beyond the valid
bounds, due to the expressions involved gaining complicated sets of
nested casts.
(b) ugly access diagrams full of nested casts (for capacities, gap
measurements, etc)

So my second approach, implemented in this patch, is to accept that we
don't have a tree type for representing bit offsets.  The patch
represents bit offsets using "typeless" symbolic values i.e. ones for
which get_type () is NULL_TREE, and implements enough support for basic
arithemetic as if these are mathematical integers (albeit ones for which
concrete values within an expression must fit within a signed wide int).
Such values can't be converted to tree, so the patch avoids such
conversions, instead implementing a new svalue::maybe_print_for_user for
printing them to a pretty_printer.  The patch uses ptrdiff_type_node for
byte offsets.

Doing so fixes the crashes, whilst appearing to preserve the behavior of
-Wanalyzer-out-of-bounds in my testing.

gcc/analyzer/ChangeLog:
PR analyzer/110902
PR analyzer/110928
PR analyzer/111305
PR analyzer/111441
* access-diagram.cc: Include "analyzer/analyzer-selftests.h".
(get_access_size_str): Reimplement for conversion of
implmementation of bit_size_expr from tree to const svalue &.  Use
svalue::maybe_print_for_user rather than tree printing routines.
(remove_ssa_names): Make non-static.
(bit_size_expr::get_formatted_str): Rename to...
(bit_size_expr::maybe_get_formatted_str): ...this, adding "model"
param and converting return type to a unique_ptr.  Update for
conversion of implementation of bit_size_expr from tree to
const svalue &.  Use svalue::maybe_print_for_user rather than tree
printing routines.
(bit_size_expr::print): Rename to...
(bit_size_expr::maybe_print_for_user): ...this, adding "model"
param and converting return type to bool.  Update for
conversion of implementation of bit_size_expr from tree to
const svalue &.  Use svalue::maybe_print_for_user rather than tree
printing routines.
(bit_size_expr::maybe_get_as_bytes): Add "mgr" param and convert
return type from tree to const svalue *; reimplement.
(access_range::access_range): Call strip_types when on region_offset
intializations.
(access_range::get_size): Update for conversion of implementation
of bit_size_expr from tree to const svalue &.
(access_operation::get_valid_bits): Pass manager to access_range
ctor.
(access_operation::maybe_get_invalid_before_bits): Likewise.
(access_operation::maybe_get_invalid_after_bits): Likewise.
(boundaries::add): Likewise.
(bit_to_table_map::populate): Add "mgr" param and pass it to
access_range ctor.
(access_diagram_impl::access_diagram_impl): Pass manager to
bit_to_table_map::populate.
(access_diagram_impl::maybe_add_gap): Use svalue rather than tree
for symbolic bit offsets.  Port to new bit_size_expr
representation.
(access_diagram_impl::add_valid_vs_invalid_ruler): Port to new
bit_size_expr representation.
(selftest::assert_eq_typeless_integer): New.

[gcc r14-9528] c-c++-common/Wrestrict.c: fix some typos and enable for LLP64

2024-03-18 Thread Jonathan Yong via Gcc-cvs
https://gcc.gnu.org/g:9ee19f9b99ad1f877eb3e93382a437d951f737c8

commit r14-9528-g9ee19f9b99ad1f877eb3e93382a437d951f737c8
Author: Jonathan Yong <10wa...@gmail.com>
Date:   Sun Feb 11 09:25:25 2024 +

c-c++-common/Wrestrict.c: fix some typos and enable for LLP64

Signed-off-by: Jonathan Yong <10wa...@gmail.com>

gcc/testsuite:

* c-c++-common/Wrestrict.c: Fix typos in comments and
enable for LLP64 testing.

Diff:
---
 gcc/testsuite/c-c++-common/Wrestrict.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/Wrestrict.c 
b/gcc/testsuite/c-c++-common/Wrestrict.c
index 4d005a618b3..57a3f67e21e 100644
--- a/gcc/testsuite/c-c++-common/Wrestrict.c
+++ b/gcc/testsuite/c-c++-common/Wrestrict.c
@@ -381,14 +381,14 @@ void test_memcpy_range_exceed (char *d, const char *s)
   T (d + i, s + 1, 3);   /* { dg-warning "accessing 3 bytes at offsets 
\\\[\[0-9\]+, \[0-9\]+] and 1 overlaps 1 byte" "memcpy" } */
 
 #if __SIZEOF_SIZE_T__ == 8
-  /* Verfiy the offset and size computation is correct.  The overlap
- offset mentioned in the warning plus sthe size of the access must
+  /* Verify the offset and size computation is correct.  The overlap
+ offset mentioned in the warning plus the size of the access must
  not exceed DIFF_MAX.  */
-  T (d, d + i, 5);   /* { dg-warning "accessing 5 bytes at offsets 0 and 
\\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target lp64 } } */
-  T (d + i, d, 5);   /* { dg-warning "accessing 5 bytes at offsets 
\\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target lp64 } } */
+  T (d, d + i, 5);   /* { dg-warning "accessing 5 bytes at offsets 0 and 
\\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target { lp64 || llp64 } } } */
+  T (d + i, d, 5);   /* { dg-warning "accessing 5 bytes at offsets 
\\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target { lp64 || llp64 } } } */
 
-  T (d, s + i, 5);   /* { dg-warning "accessing 5 bytes at offsets 0 and 
\\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target lp64 } } */
-  T (d + i, s, 5);   /* { dg-warning "accessing 5 bytes at offsets 
\\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target lp64 } } */
+  T (d, s + i, 5);   /* { dg-warning "accessing 5 bytes at offsets 0 and 
\\\[9223372036854775805, 9223372036854775807] overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target { lp64 || llp64 } } } */
+  T (d + i, s, 5);   /* { dg-warning "accessing 5 bytes at offsets 
\\\[9223372036854775805, 9223372036854775807] and 0 overlaps 3 bytes at offset 
9223372036854775802" "LP64" { target { lp64 || llp64 } } } */
 #elif __SIZEOF_SIZE_T__ == 4
   T (d, d + i, 5);   /* { dg-warning "accessing 5 bytes at offsets 0 and 
\\\[2147483645, 2147483647] overlaps 3 bytes at offset 2147483642" "ILP32" { 
target ilp32 } } */
   T (d + i, d, 5);   /* { dg-warning "accessing 5 bytes at offsets 
\\\[2147483645, 2147483647] and 0 overlaps 3 bytes at offset 2147483642" 
"ILP32" { target ilp32 } } */


[gcc(refs/users/meissner/heads/work163)] Add -mcpu=power11 support.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:dc0f9a7461a31bf03afea453df423651aa96c999

commit dc0f9a7461a31bf03afea453df423651aa96c999
Author: Michael Meissner 
Date:   Mon Mar 18 19:49:25 2024 -0400

Add -mcpu=power11 support.

This patch adds the power11 option to the -mcpu= and -mtune= switches.

This patch treats the power11 like a power10 in terms of costs and 
reassociation
width.

This patch issues a ".machine power11" to the assembly file if you use
-mcpu=power11.

This patch defines _ARCH_PWR11 if the user uses -mcpu=power11.

This patch allows GCC to be configured with the --with-cpu=power11 and
--with-tune=power11 options.

This patch passes -mpwr11 to the assembler if the user uses -mcpu=power11.

This patch adds support for using "power11" in the __builtin_cpu_is built-in
function.

2024-03-18  Michael Meissner  

gcc/

* config.gcc (rs6000*-*-*, powerpc*-*-*): Add support for power11.
* config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for 
-mcpu=power11.
* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/driver-rs6000.cc (asm_names): Likewise.
* config/rs6000/ppc-auxv.h (PPC_PLATFORM_POWER11): New define.
* config/rs6000/rs6000-builtin.cc (cpu_is_info): Add power11.
* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
_ARCH_PWR11 if -mcpu=power11.
* config/rs6000/rs6000-cpus.def (ISA_POWER11_MASKS_SERVER): New 
define.
(POWERPC_MASKS): Add power11 isa bit.
(power11 cpu): Add power11 definition.
* config/rs6000/rs6000-opts.h (PROCESSOR_POWER11): Add power11 
processor.
* config/rs6000/rs6000-string.cc (expand_compare_loop): Likewise.
* config/rs6000/rs6000-tables.opt: Regenerate.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Add 
power11
support.
(rs6000_machine_from_flags): Likewise.
(rs6000_reassociation_width): Likewise.
(rs6000_adjust_cost): Likewise.
(rs6000_issue_rate): Likewise.
(rs6000_sched_reorder): Likewise.
(rs6000_sched_reorder2): Likewise.
(rs6000_register_move_cost): Likewise.
(rs6000_opt_masks): Likewise.
* config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/rs6000.md (cpu attribute): Add power11.
* config/rs6000/rs6000.opt (-mpower11): Add internal power11 ISA 
flag.
* doc/invoke.texi (RS/6000 and PowerPC Options): Document 
-mcpu=power11.

Diff:
---
 gcc/config.gcc  |  6 --
 gcc/config/rs6000/aix71.h   |  1 +
 gcc/config/rs6000/aix72.h   |  1 +
 gcc/config/rs6000/aix73.h   |  1 +
 gcc/config/rs6000/driver-rs6000.cc  |  2 ++
 gcc/config/rs6000/ppc-auxv.h|  3 +--
 gcc/config/rs6000/rs6000-builtin.cc |  1 +
 gcc/config/rs6000/rs6000-c.cc   |  2 ++
 gcc/config/rs6000/rs6000-cpus.def   |  5 +
 gcc/config/rs6000/rs6000-opts.h |  3 ++-
 gcc/config/rs6000/rs6000-string.cc  |  1 +
 gcc/config/rs6000/rs6000-tables.opt |  3 +++
 gcc/config/rs6000/rs6000.cc | 32 
 gcc/config/rs6000/rs6000.h  |  1 +
 gcc/config/rs6000/rs6000.md |  2 +-
 gcc/config/rs6000/rs6000.opt|  3 +++
 gcc/doc/invoke.texi |  5 +++--
 17 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 040afabd9ec..f8036b6476e 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -531,7 +531,9 @@ powerpc*-*-*)
extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h 
si2vmx.h"
extra_headers="${extra_headers} amo.h"
case x$with_cpu in
-   
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower10|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
+   xpowerpc64 | xdefault64 | x6[23]0 | x970 | xG5 | xpower[3456789] \
+   | xpower1[01] | xpower6x | xrs64a | xcell | xa2 | xe500mc64 \
+   | xe5500 | xe6500)
cpu_is_64bit=yes
;;
esac
@@ -5566,7 +5568,7 @@ case "${target}" in
eval "with_$which=405"
;;
"" | common | native \
-   | power[3456789] | power10 | power5+ | power6x \
+   | power[3456789] | power1[01] | power5+ | power6x \
| powerpc | powerpc64 | powerpc64le \
| rs64 \
| 401 | 403 | 405 | 405fp | 440 | 440fp | 464 | 464fp \
diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
index 24bc301e37d..41037b3852d 100644
--- a/gcc/config/rs6000/aix71.h
+++ b/gcc/config/rs6000/aix71.h
@@ -79,6 +79,7 @@ do { 

[gcc(refs/users/meissner/heads/work163)] Add -mcpu=power11 tests.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:eec50ab293c5c25a2d980786eeb860fed93947b9

commit eec50ab293c5c25a2d980786eeb860fed93947b9
Author: Michael Meissner 
Date:   Mon Mar 18 19:56:17 2024 -0400

Add -mcpu=power11 tests.

This patch adds some simple tests for -mcpu=power11 support.  In order to 
run
these tests, you need an assembler that supports the appropriate option for
supporting the Power11 processor (-mpower11 under Linux or -mpwr11 under 
AIX).

2024-03-18  Michael Meissner  

gcc/testsuite/

* gcc.target/powerpc/power11-1.c: New test.
* gcc.target/powerpc/power11-2.c: Likewise.
* gcc.target/powerpc/power11-3.c: Likewise.
* lib/target-supports.exp (check_effective_target_power11_ok): Add 
new
effective target.

Diff:
---
 gcc/testsuite/gcc.target/powerpc/power11-1.c | 13 +
 gcc/testsuite/gcc.target/powerpc/power11-2.c | 20 
 gcc/testsuite/gcc.target/powerpc/power11-3.c | 10 ++
 gcc/testsuite/lib/target-supports.exp| 17 +
 4 files changed, 60 insertions(+)

diff --git a/gcc/testsuite/gcc.target/powerpc/power11-1.c 
b/gcc/testsuite/gcc.target/powerpc/power11-1.c
new file mode 100644
index 000..6a2e802eedf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-mdejagnu-cpu=power11 -O2" } */
+
+/* Basic check to see if the compiler supports -mcpu=power11.  */
+
+#ifndef _ARCH_PWR11
+#error "-mcpu=power11 is not supported"
+#endif
+
+void foo (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/power11-2.c 
b/gcc/testsuite/gcc.target/powerpc/power11-2.c
new file mode 100644
index 000..7b9904c1d29
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-2.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-O2" } */
+
+/* Check if we can set the power11 target via a target attribute.  */
+
+__attribute__((__target__("cpu=power9")))
+void foo_p9 (void)
+{
+}
+
+__attribute__((__target__("cpu=power10")))
+void foo_p10 (void)
+{
+}
+
+__attribute__((__target__("cpu=power11")))
+void foo_p11 (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/power11-3.c 
b/gcc/testsuite/gcc.target/powerpc/power11-3.c
new file mode 100644
index 000..9b2d643cc0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-3.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target powerpc*-*-* } }  */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-mdejagnu-cpu=power8 -O2" }  */
+
+/* Check if we can set the power11 target via a target_clones attribute.  */
+
+__attribute__((__target_clones__("cpu=power11,cpu=power9,default")))
+void foo (void)
+{
+}
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 467b539b20d..be80494be80 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7104,6 +7104,23 @@ proc check_effective_target_power10_ok { } {
 }
 }
 
+# Return 1 if this is a PowerPC target supporting -mcpu=power11.
+
+proc check_effective_target_power11_ok { } {
+if { ([istarget powerpc*-*-*]) } {
+   return [check_no_compiler_messages power11_ok object {
+   int main (void) {
+   #ifndef _ARCH_PWR11
+   #error "-mcpu=power11 is not supported"
+   #endif
+   return 0;
+   }
+   } "-mcpu=power11"]
+} else {
+   return 0
+}
+}
+
 # Return 1 if this is a PowerPC target supporting -mfloat128 via either
 # software emulation on power7/power8 systems or hardware support on power9.


[gcc(refs/users/meissner/heads/work163)] Add -mcpu=power11 tuning support.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:55ca975edf52e04e97362768ace113bd3337c292

commit 55ca975edf52e04e97362768ace113bd3337c292
Author: Michael Meissner 
Date:   Mon Mar 18 19:53:47 2024 -0400

Add -mcpu=power11 tuning support.

This patch makes -mtune=power11 use the same tuning decision as 
-mtune=power10.

2024-03-18  Michael Meissner  

gcc/

* config/rs6000/power10.md (all reservations): Add power11 as an
alternative to power10.

Diff:
---
 gcc/config/rs6000/power10.md | 144 +--
 1 file changed, 72 insertions(+), 72 deletions(-)

diff --git a/gcc/config/rs6000/power10.md b/gcc/config/rs6000/power10.md
index fcc2199ab29..90312643858 100644
--- a/gcc/config/rs6000/power10.md
+++ b/gcc/config/rs6000/power10.md
@@ -1,4 +1,4 @@
-;; Scheduling description for the IBM POWER10 processor.
+;; Scheduling description for the IBM POWER10 and POWER11 processors.
 ;; Copyright (C) 2020-2024 Free Software Foundation, Inc.
 ;;
 ;; Contributed by Pat Haugen (pthau...@us.ibm.com).
@@ -97,12 +97,12 @@
(eq_attr "update" "no")
(eq_attr "size" "!128")
(eq_attr "prefixed" "no")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_any_power10,LU_power10")
 
 (define_insn_reservation "power10-fused-load" 4
   (and (eq_attr "type" "fused_load_cmpi,fused_addis_load,fused_load_load")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-prefixed-load" 4
@@ -110,13 +110,13 @@
(eq_attr "update" "no")
(eq_attr "size" "!128")
(eq_attr "prefixed" "yes")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-load-update" 4
   (and (eq_attr "type" "load")
(eq_attr "update" "yes")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 (define_insn_reservation "power10-fpload-double" 4
@@ -124,7 +124,7 @@
(eq_attr "update" "no")
(eq_attr "size" "64")
(eq_attr "prefixed" "no")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_any_power10,LU_power10")
 
 (define_insn_reservation "power10-prefixed-fpload-double" 4
@@ -132,14 +132,14 @@
(eq_attr "update" "no")
(eq_attr "size" "64")
(eq_attr "prefixed" "yes")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-fpload-update-double" 4
   (and (eq_attr "type" "fpload")
(eq_attr "update" "yes")
(eq_attr "size" "64")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 ; SFmode loads are cracked and have additional 3 cycles over DFmode
@@ -148,27 +148,27 @@
   (and (eq_attr "type" "fpload")
(eq_attr "update" "no")
(eq_attr "size" "32")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-fpload-update-single" 7
   (and (eq_attr "type" "fpload")
(eq_attr "update" "yes")
(eq_attr "size" "32")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 (define_insn_reservation "power10-vecload" 4
   (and (eq_attr "type" "vecload")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_any_power10,LU_power10")
 
 ; lxvp
 (define_insn_reservation "power10-vecload-pair" 4
   (and (eq_attr "type" "vecload")
(eq_attr "size" "256")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 ; Store Unit
@@ -178,12 +178,12 @@
(eq_attr "prefixed" "no")
(eq_attr "size" "!128")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_any_power10,STU_power10")
 
 (define_insn_reservation "power10-fused-store" 0
   (and (eq_attr "type" "fused_store_store")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,STU_power10")
 
 (define_insn_reservation "power10-prefixed-store" 0
@@ -191,52 +191,52 @@
(eq_attr "prefixed" "yes")
(eq_attr "size" "!128")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_even_power10,STU_power10")
 
 ; Update forms have 2 cycle latency for updated addr reg
 (define_insn_reservation "power10-store-update" 2
   (and (eq_attr "type" "store,fpstore")
(eq_attr "update" "yes")
-   (eq_attr "cpu" "power10"))
+   (eq_attr "cpu" "power10,power11"))
   "DU_any_power10,STU_powe

[gcc(refs/users/meissner/heads/work163)] Update ChangeLog.*

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:6cf5203e14c2a04d2407886dde211e6b134570fa

commit 6cf5203e14c2a04d2407886dde211e6b134570fa
Author: Michael Meissner 
Date:   Mon Mar 18 19:58:44 2024 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.meissner | 121 -
 1 file changed, 120 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
index 2ac430b565b..a9ae7620cd9 100644
--- a/gcc/ChangeLog.meissner
+++ b/gcc/ChangeLog.meissner
@@ -1,6 +1,125 @@
+ Branch work163, patch #3 
+
+Add -mcpu=power11 tests.
+
+This patch adds some simple tests for -mcpu=power11 support.  In order to run
+these tests, you need an assembler that supports the appropriate option for
+supporting the Power11 processor (-mpower11 under Linux or -mpwr11 under AIX).
+
+2024-03-18  Michael Meissner  
+
+gcc/testsuite/
+
+   * gcc.target/powerpc/power11-1.c: New test.
+   * gcc.target/powerpc/power11-2.c: Likewise.
+   * gcc.target/powerpc/power11-3.c: Likewise.
+   * lib/target-supports.exp (check_effective_target_power11_ok): Add new
+   effective target.
+
+ Branch work163, patch #2 
+
+Add -mcpu=power11 tuning support.
+
+This patch makes -mtune=power11 use the same tuning decision as -mtune=power10.
+
+2024-03-18  Michael Meissner  
+
+gcc/
+
+   * config/rs6000/power10.md (all reservations): Add power11 as an
+   alternative to power10.
+
+ Branch work163, patch #1 
+
+Add -mcpu=power11 support.
+
+This patch adds the power11 option to the -mcpu= and -mtune= switches.
+
+This patch treats the power11 like a power10 in terms of costs and 
reassociation
+width.
+
+This patch issues a ".machine power11" to the assembly file if you use
+-mcpu=power11.
+
+This patch defines _ARCH_PWR11 if the user uses -mcpu=power11.
+
+This patch allows GCC to be configured with the --with-cpu=power11 and
+--with-tune=power11 options.
+
+This patch passes -mpwr11 to the assembler if the user uses -mcpu=power11.
+
+This patch adds support for using "power11" in the __builtin_cpu_is built-in
+function.
+
+2024-03-18  Michael Meissner  
+
+gcc/
+
+   * config.gcc (rs6000*-*-*, powerpc*-*-*): Add support for power11.
+   * config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for -mcpu=power11.
+   * config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/driver-rs6000.cc (asm_names): Likewise.
+   * config/rs6000/ppc-auxv.h (PPC_PLATFORM_POWER11): New define.
+   * config/rs6000/rs6000-builtin.cc (cpu_is_info): Add power11.
+   * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
+   _ARCH_PWR11 if -mcpu=power11.
+   * config/rs6000/rs6000-cpus.def (ISA_POWER11_MASKS_SERVER): New define.
+   (POWERPC_MASKS): Add power11 isa bit.
+   (power11 cpu): Add power11 definition.
+   * config/rs6000/rs6000-opts.h (PROCESSOR_POWER11): Add power11 
processor.
+   * config/rs6000/rs6000-string.cc (expand_compare_loop): Likewise.
+   * config/rs6000/rs6000-tables.opt: Regenerate.
+   * config/rs6000/rs6000.cc (rs6000_option_override_internal): Add power11
+   support.
+   (rs6000_machine_from_flags): Likewise.
+   (rs6000_reassociation_width): Likewise.
+   (rs6000_adjust_cost): Likewise.
+   (rs6000_issue_rate): Likewise.
+   (rs6000_sched_reorder): Likewise.
+   (rs6000_sched_reorder2): Likewise.
+   (rs6000_register_move_cost): Likewise.
+   (rs6000_opt_masks): Likewise.
+   * config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/rs6000.md (cpu attribute): Add power11.
+   * config/rs6000/rs6000.opt (-mpower11): Add internal power11 ISA flag.
+   * doc/invoke.texi (RS/6000 and PowerPC Options): Document -mcpu=power11.
+
  Branch work163, baseline 
 
+Add ChangeLog.meissner and REVISION.
+
+2024-03-18  Michael Meissner  
+
+gcc/
+
+   * REVISION: New file for branch.
+   * ChangeLog.meissner: New file.
+
+gcc/c-family/
+
+   * ChangeLog.meissner: New file.
+
+gcc/c/
+
+   * ChangeLog.meissner: New file.
+
+gcc/cp/
+
+   * ChangeLog.meissner: New file.
+
+gcc/fortran/
+
+   * ChangeLog.meissner: New file.
+
+gcc/testsuite/
+
+   * ChangeLog.meissner: New file.
+
+libgcc/
+
+   * ChangeLog.meissner: New file.
+
 2024-03-18   Michael Meissner  
 
Clone branch
-


[gcc/meissner/heads/work163-ajit] (6 commits) Merge commit 'refs/users/meissner/heads/work163-ajit' of gi

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-ajit' was updated to point to:

 4e4714f52e4... Merge commit 'refs/users/meissner/heads/work163-ajit' of gi

It previously pointed to:

 ebe79795a9e... Add ChangeLog.ajit and update REVISION.

Diff:

Summary of changes (added commits):
---

  4e4714f... Merge commit 'refs/users/meissner/heads/work163-ajit' of gi
  42df1a4... Add ChangeLog.ajit and update REVISION.
  6cf5203... Update ChangeLog.* (*)
  eec50ab... Add -mcpu=power11 tests. (*)
  55ca975... Add -mcpu=power11 tuning support. (*)
  dc0f9a7... Add -mcpu=power11 support. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work163-ajit' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work163-ajit)] Add ChangeLog.ajit and update REVISION.

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:42df1a4065345a56e96c26782d35f0261bad32bc

commit 42df1a4065345a56e96c26782d35f0261bad32bc
Author: Michael Meissner 
Date:   Mon Mar 18 15:56:21 2024 -0400

Add ChangeLog.ajit and update REVISION.

2024-03-18  Michael Meissner  

gcc/

* ChangeLog.ajit: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.ajit | 6 ++
 gcc/REVISION   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.ajit b/gcc/ChangeLog.ajit
new file mode 100644
index 000..01cf332c638
--- /dev/null
+++ b/gcc/ChangeLog.ajit
@@ -0,0 +1,6 @@
+ Branch work163-ajit, baseline 
+
+2024-03-18   Michael Meissner  
+
+   Clone branch
+
diff --git a/gcc/REVISION b/gcc/REVISION
index f37c7e5ef94..cb3f7c4e90b 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work163 branch
+work163-ajit branch


[gcc(refs/users/meissner/heads/work163-ajit)] Merge commit 'refs/users/meissner/heads/work163-ajit' of git+ssh://gcc.gnu.org/git/gcc into me/work1

2024-03-18 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:4e4714f52e47a79dc72384f977dae4bb7dea6bad

commit 4e4714f52e47a79dc72384f977dae4bb7dea6bad
Merge: 42df1a40653 ebe79795a9e
Author: Michael Meissner 
Date:   Mon Mar 18 19:59:54 2024 -0400

Merge commit 'refs/users/meissner/heads/work163-ajit' of 
git+ssh://gcc.gnu.org/git/gcc into me/work163-ajit

Diff:


[gcc/meissner/heads/work163-dmf] (6 commits) Merge commit 'refs/users/meissner/heads/work163-dmf' of git

2024-03-18 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work163-dmf' was updated to point to:

 33ae477516e... Merge commit 'refs/users/meissner/heads/work163-dmf' of git

It previously pointed to:

 dc53c10f6bf... Add ChangeLog.dmf and update REVISION.

Diff:

Summary of changes (added commits):
---

  33ae477... Merge commit 'refs/users/meissner/heads/work163-dmf' of git
  d2951fb... Add ChangeLog.dmf and update REVISION.
  6cf5203... Update ChangeLog.* (*)
  eec50ab... Add -mcpu=power11 tests. (*)
  55ca975... Add -mcpu=power11 tuning support. (*)
  dc0f9a7... Add -mcpu=power11 support. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work163-dmf' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


  1   2   >