[gcc/devel/nothrow-detection] Updated code for unlinking regions

2024-10-04 Thread Pranil Dey via Gcc-cvs
https://gcc.gnu.org/g:cd716809b8bd878fd5748b26129b347ede4b81ff

commit cd716809b8bd878fd5748b26129b347ede4b81ff
Author: Pranil Dey 
Date:   Fri Oct 4 13:12:12 2024 +0530

Updated code for unlinking regions

Diff:
---
 gcc/tree-eh.cc | 55 ---
 1 file changed, 36 insertions(+), 19 deletions(-)

diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 464a033dbf20..ef7d773d8372 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2326,18 +2326,32 @@ bool match_lp (eh_landing_pad lp, vec 
*exception_types) {
 return false;
 }
 
-void unlink_eh_region (eh_region region, eh_region prev_region) {
-if (region->outer && region->outer->inner == region) {
-region->outer->inner = region->next_peer;
+void unlink_eh_region(eh_region region) {
+gcc_assert(!region->inner);
+eh_region *link;
+
+// Check if region is root
+if (!region->outer) {
+gcc_unreachable();
+return;
 }
-if (prev_region && prev_region->next_peer == region) {
-prev_region->next_peer = region->next_peer;
+
+link = ®ion->outer->inner;
+
+while (*link && *link != region) {
+link = &(*link)->next_peer;
 }
-region->next_peer = NULL;
+
+// Ensure the region is in the peer chain
+gcc_assert(*link == region);
+
+*link = region->next_peer;
+
 region->outer = NULL;
+region->next_peer = NULL;
 }
 
-void reinsert_eh_region(eh_region region, eh_landing_pad lp) {
+void reinsert_eh_region (eh_region region, eh_landing_pad lp) {
 eh_region new_outer = lp->region;
 region->outer = new_outer;
 
@@ -2351,8 +2365,8 @@ void reinsert_eh_region(eh_region region, eh_landing_pad 
lp) {
 }
 
 // Set the region index in the region array
-region->index = vec_safe_length(cfun->eh->region_array);
-vec_safe_push(cfun->eh->region_array, region);
+region->index = vec_safe_length (cfun->eh->region_array);
+vec_safe_push (cfun->eh->region_array, region);
 }
 
 // Function to update landing pad and region in throw_stmt_table for a given 
statement
@@ -2385,7 +2399,7 @@ void update_stmt_eh_region (gimple *stmt) {
 }
 else *cfun->eh->throw_stmt_table->get (const_cast 
(stmt)) = lp->index;
 
-unlink_eh_region (region, prev_region);
+unlink_eh_region (region);
 reinsert_eh_region (region, lp);
 return;
 
@@ -2397,7 +2411,7 @@ void update_stmt_eh_region (gimple *stmt) {
   }
   else *cfun->eh->throw_stmt_table->get (const_cast 
(stmt)) = lp->index;
 
-  unlink_eh_region (region, prev_region);
+  unlink_eh_region (region);
   reinsert_eh_region (region, lp);
   return;
 }
@@ -2422,7 +2436,7 @@ void update_stmt_eh_region (gimple *stmt) {
 
 if (gimple_code (stmt) == GIMPLE_RESX){
   gresx *resx_stmt = as_a  (stmt);
-  gimple_resx_set_region (resx_stmt, region->index);
+  gimple_resx_set_region (resx_stmt, 0);
 }
 else remove_stmt_from_eh_lp_fn (cfun, stmt);
 }
@@ -3089,7 +3103,8 @@ bool extract_types_for_call (gcall *call_stmt, vec 
*ret_vector) {
 }
 }
 return true;
-  }
+}
+return true;
 }
 
 // Determine which types can be thrown by a GIMPLE statement and convert them 
to compile-time types
@@ -3097,14 +3112,14 @@ bool stmt_throw_types (function *fun, gimple *stmt, 
vec *ret_vector) {
 if (!flag_exceptions) {
 return false;
 }
+bool type_exists = true;
 
 switch (gimple_code (stmt)) {
-case GIMPLE_RESX:
-extract_fun_resx_types (fun, ret_vector);
-return !ret_vector->is_empty ();
+// case GIMPLE_RESX:
+// extract_fun_resx_types (fun, ret_vector);
+// return !ret_vector->is_empty ();
 
 case GIMPLE_CALL:
-bool type_exists = false;
 type_exists =  extract_types_for_call (as_a (stmt), 
ret_vector);
 return type_exists && !ret_vector->is_empty ();
   
@@ -3131,7 +3146,7 @@ void extract_types_for_resx (gimple *resx_stmt, vec 
*ret_vector) {
  if (bb->aux)continue;
  bb->aux = (void*)1;

- if (e->flags & EDGE_EH && last_stmt!= NULL){
+ if (!last_stmt && (e->flags & EDGE_EH)){
   if (gimple_code (last_stmt) == GIMPLE_CALL) {
 // check if its a throw
 extract_types_for_call (as_a (last_stmt), ret_vector);
@@ -3154,6 +3169,8 @@ void extract_fun_resx_types (function *fun, vec 
*ret_vector) {
gimple_stmt_iterator gsi;
   hash_set types;
 
+  clear_aux_for_blocks ();
+
FOR_EACH_BB_FN (bb, fun)
{
bb->aux = (void*)1;
@@ -3161,7 +3178,7 @@ void extract_fun_resx_types (function *fun, vec 
*ret_vector) {
gimple *stmt = gsi_stmt (gsi);
auto_vec resx_types;
 
-   if (stmt_can

[gcc r15-4063] i386: Fix up ix86_expand_int_compare with TImode comparisons of SUBREGs from V8{H, B}Fmode against ze

2024-10-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:92e9e971ced90af5a825ae4b35ad6c98c9ab86da

commit r15-4063-g92e9e971ced90af5a825ae4b35ad6c98c9ab86da
Author: Jakub Jelinek 
Date:   Fri Oct 4 13:12:45 2024 +0200

i386: Fix up ix86_expand_int_compare with TImode comparisons of SUBREGs 
from V8{H,B}Fmode against zero [PR116921]

The following testcase ICEs, because the ix86_expand_int_compare
optimization to use {,v}ptest assumes there are instructions for all
16-byte vector modes.  That isn't the case, we only have one for
V16QI, V8HI, V4SI, V2DI, V1TI, V4SF and V2DF, not for
V8HF nor V8BF.

The following patch fixes that by using the V8HI instruction instead
for those 2 modes.  tmp can't be a SUBREG, because it is SUBREG_REG
of another SUBREG, so we don't need to worry about gen_lowpart
failing.

2024-10-04  Jakub Jelinek  

PR target/116921
* config/i386/i386-expand.cc (ix86_expand_int_compare): Add a SUBREG
to V8HImode from V8HFmode or V8BFmode before generating a ptest.

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

Diff:
---
 gcc/config/i386/i386-expand.cc   |  2 ++
 gcc/testsuite/gcc.target/i386/pr116921.c | 12 
 2 files changed, 14 insertions(+)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 39ee9b8662ad..a9f83a299e3a 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -3095,6 +3095,8 @@ ix86_expand_int_compare (enum rtx_code code, rtx op0, rtx 
op1)
   && GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0))) == 16)
 {
   tmp = SUBREG_REG (op0);
+  if (GET_MODE (tmp) == V8HFmode || GET_MODE (tmp) == V8BFmode)
+   tmp = gen_lowpart (V8HImode, tmp);
   tmp = gen_rtx_UNSPEC (CCZmode, gen_rtvec (2, tmp, tmp), UNSPEC_PTEST);
 }
   else
diff --git a/gcc/testsuite/gcc.target/i386/pr116921.c 
b/gcc/testsuite/gcc.target/i386/pr116921.c
new file mode 100644
index ..8cd4cf93b76d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116921.c
@@ -0,0 +1,12 @@
+/* PR target/116921 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -msse4" } */
+
+long x;
+_Float16 __attribute__((__vector_size__ (16))) f;
+
+void
+foo (void)
+{
+  x -= !(__int128) (f / 2);
+}


[gcc r15-4054] testsuite - Fix gcc.c-torture/execute/ieee/pr108540-1.c

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:a0cc6941d8c8fa88441fdae1ffb35396a412ec6b

commit r15-4054-ga0cc6941d8c8fa88441fdae1ffb35396a412ec6b
Author: Georg-Johann Lay 
Date:   Thu Oct 3 13:14:52 2024 +0200

testsuite - Fix gcc.c-torture/execute/ieee/pr108540-1.c

  PR testsuite/108540
gcc/testsuite/
* gcc.c-torture/execute/ieee/pr108540-1.c: Un-preprocess
__SIZE_TYPE__ and __INT64_TYPE__.
* gcc.c-torture/execute/ieee/pr108540-1.x: New file, requires 
double64.

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.c | 6 +++---
 gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.x | 7 +++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.c 
b/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.c
index ebd4c502ee5d..db094418a791 100644
--- a/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.c
@@ -1,7 +1,7 @@
 /* PR tree-optimization/108540 */
 
 __attribute__((noipa)) void
-bar (const char *cp, unsigned long size, char sign, int dsgn)
+bar (const char *cp, __SIZE_TYPE__ size, char sign, int dsgn)
 {
   if (__builtin_strcmp (cp, "ZERO") != 0 || size != 4 || sign != '-' || dsgn 
!= 1)
 __builtin_abort ();
@@ -11,7 +11,7 @@ __attribute__((noipa)) void
 foo (int x, int ch, double d)
 {
   const char *cp = "";
-  unsigned long size = 0;
+  __SIZE_TYPE__ size = 0;
   char sign = '\0';
   switch (x)
 {
@@ -41,7 +41,7 @@ foo (int x, int ch, double d)
sign = '\0';
   if (ch == 'a' || ch == 'A')
{
- union U { long long l; double d; } u;
+ union U { __INT64_TYPE__ l; double d; } u;
  int dsgn;
  u.d = d;
  if (u.l < 0)
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.x 
b/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.x
new file mode 100644
index ..06d93efeb991
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/pr108540-1.x
@@ -0,0 +1,7 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_double64] } {
+return 1
+}
+
+return 0


[gcc r14-10744] Fix crash with subunit of local package

2024-10-04 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:7363d73e26351f42406f7ae31e985768e9a1109a

commit r14-10744-g7363d73e26351f42406f7ae31e985768e9a1109a
Author: Eric Botcazou 
Date:   Fri Oct 4 11:27:33 2024 +0200

Fix crash with subunit of local package

This is a regression present on the 14 branch only: the expander gets
confused when trying to insert the finalizer of a procedure that contains
a package as a subunit.  The offending code no longer exists on the
mainline so this adds the minimal fix to address the issue.

gcc/ada
PR ada/116430
* exp_ch7.adb (Build_Finalizer.Create_Finalizer): For the insertion
point of the finalizer, deal with package bodies that are subunits.

Diff:
---
 gcc/ada/exp_ch7.adb | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index e594a5342445..123abb632894 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2051,6 +2051,12 @@ package body Exp_Ch7 is
 and then List_Containing (Finalizer_Insert_Nod) = Stmts)
then
   Finalizer_Insert_Nod := Last_Top_Level_Ctrl_Construct;
+  if Nkind (Finalizer_Insert_Nod) = N_Package_Body
+and then Nkind (Parent (Finalizer_Insert_Nod)) = N_Subunit
+  then
+ Finalizer_Insert_Nod :=
+Corresponding_Stub (Parent (Finalizer_Insert_Nod));
+  end if;
end if;
 
Insert_After (Finalizer_Insert_Nod, Fin_Body);


[gcc r15-4073] AVR: Implement TARGET_FLOATN_MODE.

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:98a1a886e4c0c58ad9f9846caf5697ff00e4f24a

commit r15-4073-g98a1a886e4c0c58ad9f9846caf5697ff00e4f24a
Author: Georg-Johann Lay 
Date:   Fri Oct 4 15:38:59 2024 +0200

AVR: Implement TARGET_FLOATN_MODE.

gcc/
* config/avr/avr.cc (avr_floatn_mode): New static function.
(TARGET_FLOATN_MODE): New define.

Diff:
---
 gcc/config/avr/avr.cc | 21 +
 1 file changed, 21 insertions(+)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 92013c3845db..b73c251b64b4 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -15473,6 +15473,24 @@ avr_c_mode_for_floating_type (tree_index ti)
 }
 
 
+/* Implement `TARGET_FLOATN_MODE'.  */
+
+static opt_scalar_float_mode
+avr_floatn_mode (int n, bool /*extended*/)
+{
+  if (n == 32)
+return SFmode;
+
+  // Notice that -m[long-]double= just tells which library (AVR-LibC
+  // or libgcc/libf7) is providing symbols like sin.  DFmode support
+  // is provided by libf7 no matter what.
+  if (n == 64)
+return DFmode;
+
+  return opt_scalar_float_mode ();
+}
+
+
 /* Worker function for `FLOAT_LIB_COMPARE_RETURNS_BOOL'.  */
 
 bool
@@ -15705,6 +15723,9 @@ avr_use_lra_p ()
 #undef TARGET_C_MODE_FOR_FLOATING_TYPE
 #define TARGET_C_MODE_FOR_FLOATING_TYPE avr_c_mode_for_floating_type
 
+#undef  TARGET_FLOATN_MODE
+#define TARGET_FLOATN_MODE avr_floatn_mode
+
 gcc_target targetm = TARGET_INITIALIZER;


[gcc r15-4075] testsuite: Fix fallout of turning warnings into errors on 32-bit Arm

2024-10-04 Thread Thiago Bauermann via Gcc-cvs
https://gcc.gnu.org/g:115857bf1e32637e258a9329fdf25cf924d01e90

commit r15-4075-g115857bf1e32637e258a9329fdf25cf924d01e90
Author: Thiago Jung Bauermann 
Date:   Fri Jan 12 00:30:20 2024 -0300

testsuite: Fix fallout of turning warnings into errors on 32-bit Arm

Since commits 2c3db94d9fd ("c: Turn int-conversion warnings into
permerrors") and 55e94561e97e ("c: Turn -Wimplicit-function-declaration
into a permerror") these tests fail with errors such as:

  FAIL: gcc.target/arm/pr59858.c (test for excess errors)
  FAIL: gcc.target/arm/pr65647.c (test for excess errors)
  FAIL: gcc.target/arm/pr65710.c (test for excess errors)
  FAIL: gcc.target/arm/pr97969.c (test for excess errors)

Here's one example of the excess errors:

  FAIL: gcc.target/arm/pr65647.c (test for excess errors)
  Excess errors:
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:6:17: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:6:51: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:6:62: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:7:48: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:8:9: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:24:5: error: 
initialization of 'int' from 'int *' makes integer from pointer without a cast 
[-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:25:5: error: 
initialization of 'int' from 'struct S1 *' makes integer from pointer without a 
cast [-Wint-conversion]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:41:3: error: 
implicit declaration of function 'fn3'; did you mean 'fn2'? 
[-Wimplicit-function-declaration]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:46:3: error: 
implicit declaration of function 'fn5'; did you mean 'fn4'? 
[-Wimplicit-function-declaration]
  /path/gcc.git/gcc/testsuite/gcc.target/arm/pr65647.c:57:16: error: 
implicit declaration of function 'fn6'; did you mean 'fn4'? 
[-Wimplicit-function-declaration]

PR rtl-optimization/59858 and PR target/65710 test the fix of an ICE.
PR target/65647 and PR target/97969 test for a compilation infinite loop.

Therefore, add -fpermissive so that the tests behave as they did previously.
Tested on armv8l-linux-gnueabihf.

gcc/testsuite/ChangeLog:
* gcc.target/arm/pr59858.c: Add -fpermissive.
* gcc.target/arm/pr65647.c: Likewise.
* gcc.target/arm/pr65710.c: Likewise.
* gcc.target/arm/pr97969.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/arm/pr59858.c | 2 +-
 gcc/testsuite/gcc.target/arm/pr65647.c | 2 +-
 gcc/testsuite/gcc.target/arm/pr65710.c | 2 +-
 gcc/testsuite/gcc.target/arm/pr97969.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/pr59858.c 
b/gcc/testsuite/gcc.target/arm/pr59858.c
index 3360b48e8586..9336edfce277 100644
--- a/gcc/testsuite/gcc.target/arm/pr59858.c
+++ b/gcc/testsuite/gcc.target/arm/pr59858.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=armv5te -fno-builtin -mfloat-abi=soft -mthumb 
-fno-stack-protector -Os -fno-tree-loop-optimize -fno-tree-dominator-opts -fPIC 
-w" } */
+/* { dg-options "-march=armv5te -fno-builtin -mfloat-abi=soft -mthumb 
-fno-stack-protector -Os -fno-tree-loop-optimize -fno-tree-dominator-opts -fPIC 
-w -fpermissive" } */
 /* { dg-require-effective-target fpic } */
 /* { dg-skip-if "Incompatible command line options: -mfloat-abi=soft 
-mfloat-abi=hard" { *-*-* } { "-mfloat-abi=hard" } { "" } } */
 /* { dg-require-effective-target arm_arch_v5te_thumb_ok } */
diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c 
b/gcc/testsuite/gcc.target/arm/pr65647.c
index 26b4e399f6be..3cbf6b804ec0 100644
--- a/gcc/testsuite/gcc.target/arm/pr65647.c
+++ b/gcc/testsuite/gcc.target/arm/pr65647.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-require-effective-target arm_arch_v6m_ok } */
 /* { dg-skip-if "do not override -mfloat-abi" { *-*-* } { "-mfloat-abi=*" } 
{"-mfloat-abi=soft" } } */
-/* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft" } */
+/* { dg-options "-march=armv6-m -mthumb -O3 -w -mfloat-abi=soft -fpermissive" 
} */
 
 a, b, c, e, g = &e, h, i = 7, l = 1, m, n, o, q = &m, r, s = &r, u, w = 9, x,
   y = 6, z, t6 = 7, t8, t9 = 1, t11 = 5, t12 = &t8, t13 = 3, t15,
diff --git a/gcc/testsuite/gcc.target/arm/pr65710.c 
b/gcc/testsuite/gcc.

[gcc r15-4076] cfgexpand: Expand comment on when non-var clobbers can show up

2024-10-04 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:6064420ebddede802904a740363047b5403598d1

commit r15-4076-g6064420ebddede802904a740363047b5403598d1
Author: Andrew Pinski 
Date:   Thu Oct 3 02:23:55 2024 +

cfgexpand: Expand comment on when non-var clobbers can show up

The comment here is not wrong, just it would be better if mentioning
the C++ front-end instead of just the nested function lowering.

gcc/ChangeLog:

* cfgexpand.cc (add_scope_conflicts_1): Expand comment
on when non-var clobbers show up.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/cfgexpand.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index f32cf1b20c9a..6c1096363afb 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -639,8 +639,9 @@ add_scope_conflicts_1 (basic_block bb, bitmap work, bool 
for_conflict)
{
  tree lhs = gimple_assign_lhs (stmt);
  unsigned *v;
- /* Nested function lowering might introduce LHSs
-that are COMPONENT_REFs.  */
+ /* Handle only plain var clobbers.
+Nested functions lowering and C++ front-end inserts clobbers
+which are not just plain variables.  */
  if (!VAR_P (lhs))
continue;
  if (DECL_RTL_IF_SET (lhs) == pc_rtx


[gcc r15-4074] Revert: AVR: Implement TARGET_FLOATN_MODE.

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:f139cbe761fa14a0893051048b41a9b33a3386d2

commit r15-4074-gf139cbe761fa14a0893051048b41a9b33a3386d2
Author: Georg-Johann Lay 
Date:   Fri Oct 4 17:03:24 2024 +0200

Revert: AVR: Implement TARGET_FLOATN_MODE.

Revert r15-4073 / 98a1a886e4c0c58ad9f9846caf5697ff00e4f24a
The default TARGET_FLOATN_MODE is just fine.
gcc/
* config/avr/avr.cc (avr_floatn_mode): Remove.
(TARGET_FLOATN_MODE): Remove.

Diff:
---
 gcc/config/avr/avr.cc | 21 -
 1 file changed, 21 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index b73c251b64b4..92013c3845db 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -15473,24 +15473,6 @@ avr_c_mode_for_floating_type (tree_index ti)
 }
 
 
-/* Implement `TARGET_FLOATN_MODE'.  */
-
-static opt_scalar_float_mode
-avr_floatn_mode (int n, bool /*extended*/)
-{
-  if (n == 32)
-return SFmode;
-
-  // Notice that -m[long-]double= just tells which library (AVR-LibC
-  // or libgcc/libf7) is providing symbols like sin.  DFmode support
-  // is provided by libf7 no matter what.
-  if (n == 64)
-return DFmode;
-
-  return opt_scalar_float_mode ();
-}
-
-
 /* Worker function for `FLOAT_LIB_COMPARE_RETURNS_BOOL'.  */
 
 bool
@@ -15723,9 +15705,6 @@ avr_use_lra_p ()
 #undef TARGET_C_MODE_FOR_FLOATING_TYPE
 #define TARGET_C_MODE_FOR_FLOATING_TYPE avr_c_mode_for_floating_type
 
-#undef  TARGET_FLOATN_MODE
-#define TARGET_FLOATN_MODE avr_floatn_mode
-
 gcc_target targetm = TARGET_INITIALIZER;


[gcc r15-4070] libstdc++/ranges: Implement various small LWG issues

2024-10-04 Thread Patrick Palka via Libstdc++-cvs
https://gcc.gnu.org/g:20165d0107abd0f839f2519818b904f029f4ae55

commit r15-4070-g20165d0107abd0f839f2519818b904f029f4ae55
Author: Patrick Palka 
Date:   Fri Oct 4 10:01:39 2024 -0400

libstdc++/ranges: Implement various small LWG issues

This implements the following small LWG issues:

  3848. adjacent_view, adjacent_transform_view and slide_view missing base 
accessor
  3851. chunk_view::inner-iterator missing custom iter_move and iter_swap
  3947. Unexpected constraints on adjacent_transform_view::base()
  4001. iota_view should provide empty
  4012. common_view::begin/end are missing the simple-view check
  4013. lazy_split_view::outer-iterator::value_type should not provide 
default constructor
  4035. single_view should provide empty
  4053. Unary call to std::views::repeat does not decay the argument
  4054. Repeating a repeat_view should repeat the view

libstdc++-v3/ChangeLog:

* include/std/ranges (single_view::empty): Define as per LWG 4035.
(iota_view::empty): Define as per LWG 4001.
(lazy_split_view::_OuterIter::value_type): Remove default
constructor and make other constructor private as per LWG 4013.
(common_view::begin): Disable non-const overload for simple
views as per LWG 4012.
(common_view::end): Likewise.
(adjacent_view::base): Define as per LWG 3848.
(adjacent_transform_view::base): Likewise.
(chunk_view::_InnerIter::iter_move): Define as per LWG 3851.
(chunk_view::_InnerIter::itep_swap): Likewise.
(slide_view::base): Define as per LWG 3848.
(repeat_view): Adjust deduction guide as per LWG 4053.
(_Repeat::operator()): Adjust single-parameter overload as per
LWG 4054.
* testsuite/std/ranges/adaptors/adjacent/1.cc: Verify existence
of base member function.
* testsuite/std/ranges/adaptors/adjacent_transform/1.cc: Likewise.
* testsuite/std/ranges/adaptors/chunk/1.cc: Test LWG 3851 example.
* testsuite/std/ranges/adaptors/slide/1.cc: Verify existence of
base member function.
* testsuite/std/ranges/iota/iota_view.cc: Test LWG 4001 example.
* testsuite/std/ranges/repeat/1.cc: Test LWG 4053/4054 examples.

Reviewed-by: Jonathan Wakely 

Diff:
---
 libstdc++-v3/include/std/ranges| 84 +++---
 .../testsuite/std/ranges/adaptors/adjacent/1.cc|  3 +
 .../std/ranges/adaptors/adjacent_transform/1.cc|  3 +
 .../testsuite/std/ranges/adaptors/chunk/1.cc   | 15 
 .../testsuite/std/ranges/adaptors/slide/1.cc   |  3 +
 .../testsuite/std/ranges/iota/iota_view.cc | 12 
 libstdc++-v3/testsuite/std/ranges/repeat/1.cc  | 23 ++
 7 files changed, 135 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 30f45e0a750d..6e6e3b97d82f 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -335,6 +335,12 @@ namespace ranges
   end() const noexcept
   { return data() + 1; }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4035. single_view should provide empty
+  static constexpr bool
+  empty() noexcept
+  { return false; }
+
   static constexpr size_t
   size() noexcept
   { return 1; }
@@ -695,6 +701,12 @@ namespace ranges
   end() const requires same_as<_Winc, _Bound>
   { return _Iterator{_M_bound}; }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4001. iota_view should provide empty
+  constexpr bool
+  empty() const
+  { return _M_value == _M_bound; }
+
   constexpr auto
   size() const
   requires (same_as<_Winc, _Bound> && __detail::__advanceable<_Winc>)
@@ -3349,14 +3361,17 @@ namespace views::__adaptor
  private:
_OuterIter _M_i = _OuterIter();
 
- public:
-   value_type() = default;
-
+   // _GLIBCXX_RESOLVE_LIB_DEFECTS
+   // 4013. lazy_split_view::outer-iterator::value_type should not
+   // provide default constructor
constexpr explicit
value_type(_OuterIter __i)
  : _M_i(std::move(__i))
{ }
 
+   friend _OuterIter;
+
+ public:
constexpr _InnerIter<_Const>
begin() const
{ return _InnerIter<_Const>{_M_i}; }
@@ -3948,8 +3963,10 @@ namespace views::__adaptor
   base() &&
   { return std::move(_M_base); }
 
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 4012. common_view::begin/end are missing the simple-view check
   constexpr auto
-  begin()
+  begin() requires (!__detail::__simple_view<_Vp>)
   {
if constexpr (random_access_range<_Vp> && sized_range<_Vp>)
  return ranges::begin(_M_base);
@@ -3969,7 +3986,7 @@ namespace views::__adapt

[gcc r15-4071] [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in __riscv_save_[0-3] on ilp32e.

2024-10-04 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:78d2af1fa53fe232ae00673f53c8b168d099c70f

commit r15-4071-g78d2af1fa53fe232ae00673f53c8b168d099c70f
Author: Tsung Chun Lin 
Date:   Fri Oct 4 08:02:07 2024 -0600

[PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in 
__riscv_save_[0-3] on ilp32e.

From 8b3c5ebe8aacbcc4ddf1be8dea9a555e7e1bcc39 Mon Sep 17 00:00:00 2001
From: Jim Lin 
Date: Fri, 4 Oct 2024 14:48:12 +0800
Subject: [PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in
 __riscv_save_[0-3] on ilp32e.

libgcc/ChangeLog:

* config/riscv/save-restore.S: Fix .cfi_offset for saving ra in
__riscv_save_[0-3] on ilp32e.

Diff:
---
 libgcc/config/riscv/save-restore.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/config/riscv/save-restore.S 
b/libgcc/config/riscv/save-restore.S
index 30d06cc6e5bb..2c5d6bcea1a3 100644
--- a/libgcc/config/riscv/save-restore.S
+++ b/libgcc/config/riscv/save-restore.S
@@ -309,7 +309,7 @@ FUNC_BEGIN(__riscv_save_0)
   sw s0, 4(sp)
   .cfi_offset 8, -8
   sw ra, 8(sp)
-  .cfi_offset 1, 0
+  .cfi_offset 1, -4
   jr t0
   .cfi_endproc
 FUNC_END(__riscv_save_2)


[gcc r15-4055] testsuite: add missing braces around dejagnu directives

2024-10-04 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:a2b7a6fe28a695a7cb6791e072d55ad84dde16bd

commit r15-4055-ga2b7a6fe28a695a7cb6791e072d55ad84dde16bd
Author: Sam James 
Date:   Fri Oct 4 06:07:42 2024 +0100

testsuite: add missing braces around dejagnu directives

gcc/testsuite/ChangeLog:

* c-c++-common/analyzer/flex-without-call-summaries.c: Add missing 
brace.
* c-c++-common/analyzer/malloc-callbacks.c: Ditto.
* gcc.dg/Wstringop-overflow-79.c: Ditto.
* gcc.dg/Wstringop-overflow-80.c: Ditto.

Diff:
---
 .../analyzer/flex-without-call-summaries.c |  2 +-
 .../c-c++-common/analyzer/malloc-callbacks.c   |  2 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-79.c   | 28 +++---
 gcc/testsuite/gcc.dg/Wstringop-overflow-80.c   | 28 +++---
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/analyzer/flex-without-call-summaries.c 
b/gcc/testsuite/c-c++-common/analyzer/flex-without-call-summaries.c
index 092d78486219..e68ac2f3b749 100644
--- a/gcc/testsuite/c-c++-common/analyzer/flex-without-call-summaries.c
+++ b/gcc/testsuite/c-c++-common/analyzer/flex-without-call-summaries.c
@@ -889,7 +889,7 @@ static int yy_get_next_buffer (void)
}
else
/* Can't grow it, we don't own it. */
-   b->yy_ch_buf = NULL;  /* { dg-bogus "leak" "PR 
analyzer/103546"  */
+   b->yy_ch_buf = NULL;  /* { dg-bogus "leak" "PR 
analyzer/103546" } */
 
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
diff --git a/gcc/testsuite/c-c++-common/analyzer/malloc-callbacks.c 
b/gcc/testsuite/c-c++-common/analyzer/malloc-callbacks.c
index 0ba4f3824c62..422b40373634 100644
--- a/gcc/testsuite/c-c++-common/analyzer/malloc-callbacks.c
+++ b/gcc/testsuite/c-c++-common/analyzer/malloc-callbacks.c
@@ -64,7 +64,7 @@ void test_5 (void)
 {
   allocator_t alloc_fn = get_alloca ();
   deallocator_t dealloc_fn = get_free ();
-  int *ptr = (int *) alloc_fn (sizeof (int)); /* dg-message "region created on 
stack here" } */
+  int *ptr = (int *) alloc_fn (sizeof (int)); /* { dg-message "region created 
on stack here" } */
   dealloc_fn (ptr); /* { dg-warning "'free' of 'ptr' which points to memory on 
the stack" } */
 }
 
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c 
b/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
index 15eb26fbdb73..e97cb91ba18d 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
@@ -5,8 +5,8 @@
{ dg-do compile }
{ dg-options "-O0 -Wno-array-bounds" } */
 
-extern char a[8]; // dg-message at offset \\\[3, 6] into 
destination object 'a'" "note 1" }
-  // dg-message at offset \\\[5, 8] into 
destination object 'a'" "note 2" { target *-*-* } .-1 }
+extern char a[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'a'" "note 1" }
+  // { dg-message "at offset \\\[5, 8] into 
destination object 'a'" "note 2" { target *-*-* } .-1 }
 
 void test_2_notes (int i)
 {
@@ -15,9 +15,9 @@ void test_2_notes (int i)
 }
 
 
-extern char b[8]; // dg-message at offset \\\[3, 6] into 
destination object 'b'" "note 1" }
-  // dg-message at offset \\\[4, 7] into 
destination object 'b'" "note 2" { target *-*-* } .-1 }
-  // dg-message at offset \\\[5, 8] into 
destination object 'b'" "note 3" { target *-*-* } .-2 }
+extern char b[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'b'" "note 1" }
+  // { dg-message "at offset \\\[4, 7] into 
destination object 'b'" "note 2" { target *-*-* } .-1 }
+  // { dg-message "at offset \\\[5, 8] into 
destination object 'b'" "note 3" { target *-*-* } .-2 }
 
 void test_3_notes (int i)
 {
@@ -26,10 +26,10 @@ void test_3_notes (int i)
 }
 
 
-extern char c[8]; // dg-message at offset \\\[3, 6] into 
destination object 'c'" "note 1" }
-  // dg-message at offset \\\[4, 7] into 
destination object 'c'" "note 2" { target *-*-* } .-1 }
-  // dg-message at offset \\\[5, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
-  // dg-message at offset \\\[6, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
+extern char c[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'c'" "note 1" }
+  // { dg-message "at offset \\\[4, 7] into 
destination object 'c'" "note 2" { target *-*-* } .-1 }
+  // { dg-message "at offset \\\[5, 8] into 
destination obje

[gcc r15-4056] testsuite: fix two newly-running -Wstringop-overflow test directives

2024-10-04 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:0fae155090f2ce77fe876b2d16059dbeac6ded6e

commit r15-4056-g0fae155090f2ce77fe876b2d16059dbeac6ded6e
Author: Sam James 
Date:   Fri Oct 4 07:47:54 2024 +0100

testsuite: fix two newly-running -Wstringop-overflow test directives

This didn't show up until the previous commit which fixed the directive
syntax. The indexing was off for the notes.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overflow-79.c: Fix index for notes.
* gcc.dg/Wstringop-overflow-80.c: Ditto.

Diff:
---
 gcc/testsuite/gcc.dg/Wstringop-overflow-79.c | 6 +++---
 gcc/testsuite/gcc.dg/Wstringop-overflow-80.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c 
b/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
index e97cb91ba18d..87bf775c0b2b 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-79.c
@@ -29,7 +29,7 @@ void test_3_notes (int i)
 extern char c[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'c'" "note 1" }
   // { dg-message "at offset \\\[4, 7] into 
destination object 'c'" "note 2" { target *-*-* } .-1 }
   // { dg-message "at offset \\\[5, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
-  // { dg-message "at offset \\\[6, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
+  // { dg-message "at offset \\\[6, 8] into 
destination object 'c'" "note 4" { target *-*-* } .-3 }
 
 void test_4_notes (int i)
 {
@@ -50,8 +50,8 @@ void test_4_notes (int i)
 extern char d[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'd'" "note 1" }
   // { dg-message "at offset \\\[4, 7] into 
destination object 'd'" "note 2" { target *-*-* } .-1 }
   // { dg-message "at offset \\\[5, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-2 }
-  // { dg-message "at offset \\\[6, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-3 }
-  // { dg-message "at offset \\\[7, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-4 }
+  // { dg-message "at offset \\\[6, 8] into 
destination object 'd'" "note 4" { target *-*-* } .-3 }
+  // { dg-message "at offset \\\[7, 8] into 
destination object 'd'" "note 5" { target *-*-* } .-4 }
 
 void test_5_notes (int i)
 {
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-80.c 
b/gcc/testsuite/gcc.dg/Wstringop-overflow-80.c
index c74ca3a7918b..f49b5ffc636b 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-80.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-80.c
@@ -29,7 +29,7 @@ void test_3_notes (int i)
 extern char c[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'c'" "note 1" }
   // { dg-message "at offset \\\[4, 7] into 
destination object 'c'" "note 2" { target *-*-* } .-1 }
   // { dg-message "at offset \\\[5, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
-  // { dg-message "at offset \\\[6, 8] into 
destination object 'c'" "note 3" { target *-*-* } .-2 }
+  // { dg-message "at offset \\\[6, 8] into 
destination object 'c'" "note 4" { target *-*-* } .-3 }
 
 void test_4_notes (int i)
 {
@@ -50,8 +50,8 @@ void test_4_notes (int i)
 extern char d[8]; // { dg-message "at offset \\\[3, 6] into 
destination object 'd'" "note 1" }
   // { dg-message "at offset \\\[4, 7] into 
destination object 'd'" "note 2" { target *-*-* } .-1 }
   // { dg-message "at offset \\\[5, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-2 }
-  // { dg-message "at offset \\\[6, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-3 }
-  // { dg-message "at offset \\\[7, 8] into 
destination object 'd'" "note 3" { target *-*-* } .-4 }
+  // { dg-message "at offset \\\[6, 8] into 
destination object 'd'" "note 4" { target *-*-* } .-3 }
+  // { dg-message "at offset \\\[7, 8] into 
destination object 'd'" "note 5" { target *-*-* } .-4 }
 
 void test_5_notes (int i)
 {


[gcc r15-4062] i386: Fix up *minmax3_2 splitter [PR116925]

2024-10-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:67b750c20e1f9428ef89a6fed0103e912bea8679

commit r15-4062-g67b750c20e1f9428ef89a6fed0103e912bea8679
Author: Jakub Jelinek 
Date:   Fri Oct 4 12:36:52 2024 +0200

i386: Fix up *minmax3_2 splitter [PR116925]

While *minmax3_1 correctly uses
   if (MEM_P (operands[1]))
 operands[1] = force_reg (mode, operands[1]);
to ensure operands[1] is not a MEM, *minmax3_2 does it wrongly
by calling force_reg but ignoring its return value.

The following borderingly obvious patch fixes that.

Didn't find similar other errors in the backend with force_reg calls.

2024-10-04  Jakub Jelinek  

PR target/116925
* config/i386/sse.md (*minmax3_2): Assign force_reg result
back to operands[2] instead of throwing it away.

* g++.target/i386/avx-pr116925.C: New test.

Diff:
---
 gcc/config/i386/sse.md   |  2 +-
 gcc/testsuite/g++.target/i386/avx-pr116925.C | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 183c1953f913..d6e2135423d0 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -3269,7 +3269,7 @@
  u = UNSPEC_IEEE_MAX;
 
if (MEM_P (operands[2]))
- force_reg (mode, operands[2]);
+ operands[2] = force_reg (mode, operands[2]);
rtvec v = gen_rtvec (2, operands[2], operands[1]);
rtx tmp = gen_rtx_UNSPEC (mode, v, u);
emit_move_insn (operands[0], tmp);
diff --git a/gcc/testsuite/g++.target/i386/avx-pr116925.C 
b/gcc/testsuite/g++.target/i386/avx-pr116925.C
new file mode 100644
index ..b2d6fc1856bf
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/avx-pr116925.C
@@ -0,0 +1,12 @@
+// PR target/116925
+// { dg-do compile }
+// { dg-options "-O2 -mavx -ffloat-store" }
+
+typedef float V __attribute__((vector_size (16)));
+V a, b, c;
+
+void
+foo ()
+{
+  c = a > b ? a : b;
+}


[gcc r15-4069] testsuite: Fix up unevalstr2.C test

2024-10-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:c679cafb0d7e58fd699f9f73e736417765f349bc

commit r15-4069-gc679cafb0d7e58fd699f9f73e736417765f349bc
Author: Jakub Jelinek 
Date:   Fri Oct 4 15:24:24 2024 +0200

testsuite: Fix up unevalstr2.C test

The CWG2521 changes adjusted the unevalstr1.C test but didn't adjust
unevalstr2.C test, which now FAILs in C++23 mode.

The intent in both of those tests was to test the separate (now deprecated)
syntax, so instead of removing the space between closing " and _ I've
adjusted the testcase to expect those 17 extra warnings.  And I've also
adjusted the unevalstr1.C testcase to do the same, when it is removed from
C++29 or whatever, that can be just guarded by #if.

But it is actually useful to also test the UDL variant without space between
closing " and _, so I've added new test coverage for that too to both tests.

2024-10-04  Jakub Jelinek  

* g++.dg/cpp26/unevalstr1.C: Revert the 2024-10-03 changes, instead
expect extra warnings.  Add another set of tests without space
between " and _.
* g++.dg/cpp26/unevalstr2.C: Expect extra warnings for C++23.  Add
another set of tests without space between " and _.

Diff:
---
 gcc/testsuite/g++.dg/cpp26/unevalstr1.C | 70 +
 gcc/testsuite/g++.dg/cpp26/unevalstr2.C | 42 ++--
 2 files changed, 92 insertions(+), 20 deletions(-)

diff --git a/gcc/testsuite/g++.dg/cpp26/unevalstr1.C 
b/gcc/testsuite/g++.dg/cpp26/unevalstr1.C
index 5317d696de8e..478c5ee330da 100644
--- a/gcc/testsuite/g++.dg/cpp26/unevalstr1.C
+++ b/gcc/testsuite/g++.dg/cpp26/unevalstr1.C
@@ -83,21 +83,57 @@ extern "\o{0103}" { int f14 (); }   // { dg-error "numeric 
escape sequence in unev
 [[nodiscard ("\x{20}")]] int h19 ();   // { dg-error "numeric escape sequence 
in unevaluated string" }
 [[nodiscard ("\h")]] int h20 ();   // { dg-error "unknown escape sequence" 
}
 
-float operator ""_my0 (const char *);
-float operator "" ""_my1 (const char *);
-float operator L""_my2 (const char *); // { dg-error "invalid encoding prefix 
in literal operator" }
-float operator u""_my3 (const char *); // { dg-error "invalid encoding prefix 
in literal operator" }
-float operator U""_my4 (const char *); // { dg-error "invalid encoding prefix 
in literal operator" }
-float operator u8""_my5 (const char *);// { dg-error "invalid encoding 
prefix in literal operator" }
-float operator L"" ""_my6 (const char *);  // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator u"" ""_my7 (const char *);  // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator U"" ""_my8 (const char *);  // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator u8"" ""_my9 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator "" L""_my10 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator "" u""_my11 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator "" U""_my12 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
-float operator "" u8""_my13 (const char *);// { dg-error "invalid encoding 
prefix in literal operator" }
-float operator "\0"_my14 (const char *);   // { dg-error "expected empty 
string after 'operator' keyword" }
-float operator "\x00"_my15 (const char *); // { dg-error "expected empty 
string after 'operator' keyword" }
-float operator "\h"_my16 (const char *);   // { dg-error "expected empty 
string after 'operator' keyword" }
+float operator "" _my0 (const char *);
+float operator "" "" _my1 (const char *);
+float operator L"" _my2 (const char *);// { dg-error "invalid 
encoding prefix in literal operator" }
+float operator u"" _my3 (const char *);// { dg-error "invalid 
encoding prefix in literal operator" }
+float operator U"" _my4 (const char *);// { dg-error "invalid 
encoding prefix in literal operator" }
+float operator u8"" _my5 (const char *);   // { dg-error "invalid encoding 
prefix in literal operator" }
+float operator L"" "" _my6 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
+float operator u"" "" _my7 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
+float operator U"" "" _my8 (const char *); // { dg-error "invalid encoding 
prefix in literal operator" }
+float operator u8"" "" _my9 (const char *);// { dg-error "invalid encoding 
prefix in literal operator" }
+float operator "" L"" _my10 (const char *);// { dg-error "invalid encoding 
prefix in literal operator" }
+float operator "" u"" _my11 (const char *);// { dg-error "invalid encoding 
prefix in literal operator" }
+float operator "" U"" _my12 (const char *);// { dg-

[gcc r15-4057] tree-optimization/99856 - fix testcase

2024-10-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a96ebb2cd4de205c6d4ac6691117e4e96f8533e9

commit r15-4057-ga96ebb2cd4de205c6d4ac6691117e4e96f8533e9
Author: Richard Biener 
Date:   Fri Oct 4 11:46:52 2024 +0200

tree-optimization/99856 - fix testcase

When making the testcase use aligned accesses I botched up the
copy&paste.  Fixed.

PR tree-optimization/99856
* gcc.dg/vect/pr99856.c: Fix copy&paste errors.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr99856.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr99856.c 
b/gcc/testsuite/gcc.dg/vect/pr99856.c
index e5d2a45be57f..1ff20c7bc564 100644
--- a/gcc/testsuite/gcc.dg/vect/pr99856.c
+++ b/gcc/testsuite/gcc.dg/vect/pr99856.c
@@ -17,8 +17,8 @@ opSourceOver_premul(uint8_t* restrict Rrgba,
 const uint8_t* restrict Drgba, int len)
 {
   Rrgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
-  Srgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
-  Drgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+  Srgba = __builtin_assume_aligned (Srgba, __BIGGEST_ALIGNMENT__);
+  Drgba = __builtin_assume_aligned (Drgba, __BIGGEST_ALIGNMENT__);
   int i = 0;
   for (; i < len*4; i += 4)
 {


[gcc r15-4058] libstdc++: Replace implicit lambda capture of 'this' [PR116964]

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:f135278f559914c0336cd8ad0af0deac2a0c86fd

commit r15-4058-gf135278f559914c0336cd8ad0af0deac2a0c86fd
Author: Jonathan Wakely 
Date:   Fri Oct 4 10:44:46 2024 +0100

libstdc++: Replace implicit lambda capture of 'this' [PR116964]

C++20 deprecates implicit capture of 'this', so change [=] to [this] for
all lambda expressions in . This only shows up on targets
where _GLIBCXX_USE_PTHREAD_RWLOCK_T is not defined, as we have an
alternative implementation of shared mutexes in that case.

libstdc++-v3/ChangeLog:

PR libstdc++/116964
* include/std/shared_mutex (__shared_mutex_cv): Use [this] for
lambda captures.
(shared_timed_mutex) [!_GLIBCXX_USE_PTHREAD_RWLOCK_T]: Likewise.

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

diff --git a/libstdc++-v3/include/std/shared_mutex 
b/libstdc++-v3/include/std/shared_mutex
index 9bf98c0b0405..b369a15cc608 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -332,10 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 {
   unique_lock __lk(_M_mut);
   // Wait until we can set the write-entered flag.
-  _M_gate1.wait(__lk, [=]{ return !_M_write_entered(); });
+  _M_gate1.wait(__lk, [this]{ return !_M_write_entered(); });
   _M_state |= _S_write_entered;
   // Then wait until there are no more readers.
-  _M_gate2.wait(__lk, [=]{ return _M_readers() == 0; });
+  _M_gate2.wait(__lk, [this]{ return _M_readers() == 0; });
 }
 
 bool
@@ -367,7 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 lock_shared()
 {
   unique_lock __lk(_M_mut);
-  _M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; });
+  _M_gate1.wait(__lk, [this]{ return _M_state < _S_max_readers; });
   ++_M_state;
 }
 
@@ -690,13 +690,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
unique_lock __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
-[=]{ return !_M_write_entered(); }))
+[this]{ return !_M_write_entered(); }))
  {
return false;
  }
_M_state |= _S_write_entered;
if (!_M_gate2.wait_until(__lk, __abs_time,
-[=]{ return _M_readers() == 0; }))
+[this]{ return _M_readers() == 0; }))
  {
_M_state ^= _S_write_entered;
// Wake all threads blocked while the write-entered flag was set.
@@ -716,7 +716,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
unique_lock __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
-[=]{ return _M_state < _S_max_readers; }))
+[this]{ return _M_state < _S_max_readers; }))
  {
return false;
  }


[gcc r15-4067] libstdc++: Fix some Parallel Mode testsuite failures

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e1205218936e416881c4f465d51c033b29044d79

commit r15-4067-ge1205218936e416881c4f465d51c033b29044d79
Author: Jonathan Wakely 
Date:   Thu Oct 3 18:52:12 2024 +0100

libstdc++: Fix some Parallel Mode testsuite failures

Some of these are due to no longer using #pragma GCC system_header in
libstdc++ headers, some have been failing for longer and weren't
noticed.

libstdc++-v3/ChangeLog:

* include/parallel/algobase.h (search): Use sequential algorithm
for constant evaluation.
* include/parallel/algorithmfwd.h (search): Add
_GLIBCXX20_CONSTEXPR.
* include/parallel/multiway_merge.h: Remove stray semi-colon.
* include/parallel/multiseq_selection.h: Add diagnostic pragmas
for -Wlong-long warning.
* include/parallel/quicksort.h: Likewise.
* include/parallel/random_number.h: Likewise.
* include/parallel/settings.h: Likewise.
* include/parallel/workstealing.h: Replace ++ and -- on volatile
variables.
* testsuite/17_intro/names.cc: Skip names defined by
.
* testsuite/20_util/pair/dangling_ref.cc: Skip test if Parallel
Mode is enabled.
* testsuite/20_util/tuple/dangling_ref.cc: Likewise.

Diff:
---
 libstdc++-v3/include/parallel/algobase.h | 6 ++
 libstdc++-v3/include/parallel/algorithmfwd.h | 1 +
 libstdc++-v3/include/parallel/multiseq_selection.h   | 3 +++
 libstdc++-v3/include/parallel/multiway_merge.h   | 2 +-
 libstdc++-v3/include/parallel/quicksort.h| 3 +++
 libstdc++-v3/include/parallel/random_number.h| 5 +
 libstdc++-v3/include/parallel/settings.h | 5 +
 libstdc++-v3/include/parallel/workstealing.h | 4 ++--
 libstdc++-v3/testsuite/17_intro/names.cc | 6 --
 libstdc++-v3/testsuite/20_util/pair/dangling_ref.cc  | 2 +-
 libstdc++-v3/testsuite/20_util/tuple/dangling_ref.cc | 2 +-
 11 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/parallel/algobase.h 
b/libstdc++-v3/include/parallel/algobase.h
index 67362f4ecaa3..b46ed610661b 100644
--- a/libstdc++-v3/include/parallel/algobase.h
+++ b/libstdc++-v3/include/parallel/algobase.h
@@ -515,11 +515,17 @@ namespace __parallel
   // Public interface
   template
+_GLIBCXX20_CONSTEXPR
 inline _FIterator1
 search(_FIterator1 __begin1, _FIterator1 __end1,
   _FIterator2 __begin2, _FIterator2 __end2,
   _BinaryPredicate  __pred)
 {
+#if __cplusplus > 201703L
+  if (std::is_constant_evaluated())
+   return _GLIBCXX_STD_A::search(__begin1, __end1, __begin2, __end2,
+ std::move(__pred));
+#endif
   return __search_switch(__begin1, __end1, __begin2, __end2, __pred,
 std::__iterator_category(__begin1),
 std::__iterator_category(__begin2));
diff --git a/libstdc++-v3/include/parallel/algorithmfwd.h 
b/libstdc++-v3/include/parallel/algorithmfwd.h
index 476072b860ab..7c9843ab161b 100644
--- a/libstdc++-v3/include/parallel/algorithmfwd.h
+++ b/libstdc++-v3/include/parallel/algorithmfwd.h
@@ -353,6 +353,7 @@ namespace __parallel
__gnu_parallel::sequential_tag);
 
   template
+_GLIBCXX20_CONSTEXPR
 _FIter1
 search(_FIter1, _FIter1, _FIter2, _FIter2, _BiPredicate);
 
diff --git a/libstdc++-v3/include/parallel/multiseq_selection.h 
b/libstdc++-v3/include/parallel/multiseq_selection.h
index 22bd97e6432b..53264fd156b6 100644
--- a/libstdc++-v3/include/parallel/multiseq_selection.h
+++ b/libstdc++-v3/include/parallel/multiseq_selection.h
@@ -189,9 +189,12 @@ namespace __gnu_parallel
 
   __r = __rd_log2(__nmax) + 1;
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long" // LL literal
   // Pad all lists to this length, at least as long as any ns[__i],
   // equality iff __nmax = 2^__k - 1.
   __l = (1ULL << __r) - 1;
+#pragma GCC diagnostic pop
 
   for (_SeqNumber __i = 0; __i < __m; __i++)
 {
diff --git a/libstdc++-v3/include/parallel/multiway_merge.h 
b/libstdc++-v3/include/parallel/multiway_merge.h
index e4bd00422828..d894e636a3e9 100644
--- a/libstdc++-v3/include/parallel/multiway_merge.h
+++ b/libstdc++-v3/include/parallel/multiway_merge.h
@@ -2067,6 +2067,6 @@ namespace __gnu_parallel
(__seqs_begin, __seqs_end, __target, __length, __comp,
 exact_tag(__tag.__get_num_threads()));
 }
-}; // namespace __gnu_parallel
+} // namespace __gnu_parallel
 
 #endif /* _GLIBCXX_PARALLEL_MULTIWAY_MERGE_H */
diff --git a/libstdc++-v3/include/parallel/quicksort.h 
b/libstdc++-v3/include/parallel/quicksort.h
index a678b6d46906..c728cd91c24c 100644
--- a/libstdc++-v3/include/parallel/quicksort.h
+++ b/libstdc++-v3/include/parallel/quicksort.h
@@ -66,12 +66,15 @@ namespace __gnu_parallel
   _ValueType*

[gcc r15-4068] aarch64: Set Armv9-A generic L1 cache line size to 64 bytes

2024-10-04 Thread Kyrylo Tkachov via Gcc-cvs
https://gcc.gnu.org/g:f000cb8cbc58b23a91c84d47d69481904981a1d9

commit r15-4068-gf000cb8cbc58b23a91c84d47d69481904981a1d9
Author: Kyrylo Tkachov 
Date:   Fri Sep 20 05:11:39 2024 -0700

aarch64: Set Armv9-A generic L1 cache line size to 64 bytes

I'd like to use a value of 64 bytes for the L1 cache size for Armv9-A
generic tuning.
As described in g:9a99559a478111f7fbeec29bd78344df7651c707 this value is 
used
to set the std::hardware_destructive_interference_size value which we want 
to
be not overly large when running concurrent applications on large core-count
systems.

The generic value for Armv8-A systems and the port baseline is 256 bytes
because that's what the A64FX CPU has, as set de-facto in
aarch64_override_options_internal.

But for Armv9-A CPUs as far as I know there isn't anything larger
than 64 bytes, so we should be able to use the smaller value here and reduce
the size of concurrent structs that use
std::hardware_destructive_interference_size to pad their fields.

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

Signed-off-by: Kyrylo Tkachov 

* config/aarch64/tuning_models/generic_armv9_a.h
(generic_armv9a_prefetch_tune): Define.
(generic_armv9_a_tunings): Use the above.

Diff:
---
 gcc/config/aarch64/tuning_models/generic_armv9_a.h | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/tuning_models/generic_armv9_a.h 
b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
index 85ed40f6..76b3e4c9cf73 100644
--- a/gcc/config/aarch64/tuning_models/generic_armv9_a.h
+++ b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
@@ -207,6 +207,18 @@ static const struct cpu_vector_cost 
generic_armv9_a_vector_cost =
   &generic_armv9_a_vec_issue_info /* issue_info  */
 };
 
+/* Generic prefetch settings (which disable prefetch).  */
+static const cpu_prefetch_tune generic_armv9a_prefetch_tune =
+{
+  0,   /* num_slots  */
+  -1,  /* l1_cache_size  */
+  64,  /* l1_cache_line_size  */
+  -1,  /* l2_cache_size  */
+  true,/* prefetch_dynamic_strides */
+  -1,  /* minimum_stride */
+  -1   /* default_opt_level  */
+};
+
 static const struct tune_params generic_armv9_a_tunings =
 {
   &cortexa76_extra_costs,
@@ -239,7 +251,7 @@ static const struct tune_params generic_armv9_a_tunings =
   (AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND
| AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS
| AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT),/* tune_flags.  */
-  &generic_prefetch_tune,
+  &generic_armv9a_prefetch_tune,
   AARCH64_LDP_STP_POLICY_ALWAYS,   /* ldp_policy_model.  */
   AARCH64_LDP_STP_POLICY_ALWAYS   /* stp_policy_model.  */
 };


[gcc r15-4066] arm: Fix missed CE optimization for armv8.1-m.main [PR 116444]

2024-10-04 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:7766a2c1eb683352ce117e8ed014665f392f

commit r15-4066-g7766a2c1eb683352ce117e8ed014665f392f
Author: Andre Vieira 
Date:   Fri Oct 4 13:43:46 2024 +0100

arm: Fix missed CE optimization for armv8.1-m.main [PR 116444]

This patch restores missed optimizations for armv8.1-m.main targets that 
were
missed when the generation of csinc, csinv and csneg were enabled for the 
same
with patch series containing:

commit c2bb84be4a6e581bbf45891457ee632a07416982
Author: Sudi Das 
Date:   Fri Sep 18 15:47:46 2020 +0100

[PATCH 2/5][Arm] New pattern for CSINV instructions

The original patch series makes use of the "noce" machinery to transform RTL
into patterns that later match the Armv8.1-M Mainline, by getting the target
hook TARGET_HAVE_CONDITIONAL_EXECUTION, to return FALSE for such targets 
prior
to reload_completed.  The same machinery however was transforming other RTL
patterns which were later on causing the "ce" pass post reload_completed to 
no
longer optimize conditional execution opportunities, which was causing the
regression observed in PR target/116444, a regression of 
'testsuite/gcc.target/arm/thumb-ifcvt-2.c'
when ran for an Armv8.1-M Mainline target.

This patch implements the target hook TARGET_NOCE_CONVERSION_PROFITABLE_P to
only allow "noce" to generate patterns that match CSINV, CSINC and CSNEG.  
Thus
ensuring that the early "ce" passes do not ruin things for later ones.

gcc/ChangeLog:

PR target/116444
* config/arm/arm-protos.h (arm_noce_conversion_profitable_p): New
declaration.
* config/arm/arm.cc (arm_is_v81m_cond_insn): New helper function 
used
in ...
(arm_noce_conversion_profitable_p): ... here. New function to 
implement
...
(TARGET_NOCE_PROFITABLE_P): ... this target hook.  New define.

Diff:
---
 gcc/config/arm/arm-protos.h |  1 +
 gcc/config/arm/arm.cc   | 87 +
 2 files changed, 88 insertions(+)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 50cae2b513a2..b694589cab4b 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -210,6 +210,7 @@ extern bool arm_pad_reg_upward (machine_mode, tree, int);
 #endif
 extern int arm_apply_result_size (void);
 extern opt_machine_mode arm_get_mask_mode (machine_mode mode);
+extern bool arm_noce_conversion_profitable_p (rtx_insn *,struct noce_if_info 
*);
 
 #endif /* RTX_CODE */
 
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 62eea50f1634..077c80df4482 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -815,6 +815,9 @@ static const scoped_attribute_specs *const 
arm_attribute_table[] =
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P arm_modes_tieable_p
 
+#undef TARGET_NOCE_CONVERSION_PROFITABLE_P
+#define TARGET_NOCE_CONVERSION_PROFITABLE_P arm_noce_conversion_profitable_p
+
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS arm_can_change_mode_class
 
@@ -36089,6 +36092,90 @@ arm_get_mask_mode (machine_mode mode)
   return default_get_mask_mode (mode);
 }
 
+/* Helper function to determine whether SEQ represents a sequence of
+   instructions representing the Armv8.1-M Mainline conditional arithmetic
+   instructions: csinc, csneg and csinv. The cinc instruction is generated
+   using a different mechanism.  */
+
+static bool
+arm_is_v81m_cond_insn (rtx_insn *seq)
+{
+  rtx_insn *curr_insn = seq;
+  rtx set;
+  /* The pattern may start with a simple set with register operands.  Skip
+ through any of those.  */
+  while (curr_insn)
+{
+  set = single_set (curr_insn);
+  if (!set
+ || !REG_P (SET_DEST (set)))
+   return false;
+
+  if (!REG_P (SET_SRC (set)))
+   break;
+  curr_insn = NEXT_INSN (curr_insn);
+}
+
+  if (!set)
+return false;
+
+  /* The next instruction should be one of:
+ NEG: for csneg,
+ PLUS: for csinc,
+ NOT: for csinv.  */
+  if (GET_CODE (SET_SRC (set)) != NEG
+  && GET_CODE (SET_SRC (set)) != PLUS
+  && GET_CODE (SET_SRC (set)) != NOT)
+return false;
+
+  curr_insn = NEXT_INSN (curr_insn);
+  if (!curr_insn)
+return false;
+
+  /* The next instruction should be a COMPARE.  */
+  set = single_set (curr_insn);
+  if (!set
+  || !REG_P (SET_DEST (set))
+  || GET_CODE (SET_SRC (set)) != COMPARE)
+return false;
+
+  curr_insn = NEXT_INSN (curr_insn);
+  if (!curr_insn)
+return false;
+
+  /* And the last instruction should be an IF_THEN_ELSE.  */
+  set = single_set (curr_insn);
+  if (!set
+  || !REG_P (SET_DEST (set))
+  || GET_CODE (SET_SRC (set)) != IF_THEN_ELSE)
+return false;
+
+  return !NEXT_INSN (curr_insn);
+}
+
+/* For Armv8.1-M Mainline we have both conditional execution through IT blocks,
+   as well as conditio

[gcc r15-4072] PR modula2/116918 -fswig correct syntax fixup

2024-10-04 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:e2a701cd0419a1898a2a359711572a8bcf4f8eb3

commit r15-4072-ge2a701cd0419a1898a2a359711572a8bcf4f8eb3
Author: Gaius Mulley 
Date:   Fri Oct 4 15:30:10 2024 +0100

PR modula2/116918 -fswig correct syntax fixup

This patch adds a missing % escape in DoCheckUnbounded.

gcc/m2/ChangeLog:

PR modula2/116918
* gm2-compiler/M2Swig.mod (DoCheckUnbounded): Escape
the % character used in array_functions with %%.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Swig.mod | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/m2/gm2-compiler/M2Swig.mod b/gcc/m2/gm2-compiler/M2Swig.mod
index b7f34426adb8..7ef8ff36da77 100644
--- a/gcc/m2/gm2-compiler/M2Swig.mod
+++ b/gcc/m2/gm2-compiler/M2Swig.mod
@@ -887,7 +887,7 @@ BEGIN
  fprintf0(f, ') };\n') ;
  IF typeUnique
  THEN
-fprintf0(f, '%array_functions(') ;
+fprintf0(f, '%%array_functions(') ;
 DoType(type) ;
 fprintf0(f, ', ') ;
 DoType(type) ;


[gcc r15-4077] testsuite - Some float64 and float32x test require double64plus.

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:0f39769ab39ba74c9890c1553c016469c043965c

commit r15-4077-g0f39769ab39ba74c9890c1553c016469c043965c
Author: Georg-Johann Lay 
Date:   Fri Oct 4 17:43:47 2024 +0200

testsuite - Some float64 and float32x test require double64plus.

Some of the float64 and float32x test cases are using double built-ins
and hence require double64plus resp. that double is at least as good
as float32x (double_float32xplus).

gcc/testsuite/
* lib/target-supports.exp 
(check_effective_target_double_float32xplus):
New proc.
* gcc.dg/torture/float32x-builtin.c: Add
dg-require-effective-target double_float32xplus.
* gcc.dg/torture/float32x-tg-2.c: Same.
* gcc.dg/torture/float32x-tg.c: Same.
* gcc.dg/torture/float64-builtin.c: Add
dg-require-effective-target double64plus.
* gcc.dg/torture/float64-tg-2.c: Same.
* gcc.dg/torture/float64-tg.c: Same.

Diff:
---
 gcc/testsuite/gcc.dg/torture/float32x-builtin.c |  1 +
 gcc/testsuite/gcc.dg/torture/float32x-tg-2.c|  1 +
 gcc/testsuite/gcc.dg/torture/float32x-tg.c  |  1 +
 gcc/testsuite/gcc.dg/torture/float64-builtin.c  |  1 +
 gcc/testsuite/gcc.dg/torture/float64-tg-2.c |  1 +
 gcc/testsuite/gcc.dg/torture/float64-tg.c   |  1 +
 gcc/testsuite/lib/target-supports.exp   | 11 +++
 7 files changed, 17 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c 
b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c
index 71eb7e2cdc89..0404d3927053 100644
--- a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c
+++ b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float32x } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float32x_runtime } */
+/* { dg-require-effective-target double_float32xplus } */
 
 #define WIDTH 32
 #define EXT 1
diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c 
b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
index 6179aba7cdd0..dd7e2064a1a5 100644
--- a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
+++ b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float32x } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float32x_runtime } */
+/* { dg-require-effective-target double_float32xplus } */
 
 #define WIDTH 32
 #define EXT 1
diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg.c 
b/gcc/testsuite/gcc.dg/torture/float32x-tg.c
index b65b03f558bb..87d9bef2b030 100644
--- a/gcc/testsuite/gcc.dg/torture/float32x-tg.c
+++ b/gcc/testsuite/gcc.dg/torture/float32x-tg.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float32x } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float32x_runtime } */
+/* { dg-require-effective-target double_float32xplus } */
 
 #define WIDTH 32
 #define EXT 1
diff --git a/gcc/testsuite/gcc.dg/torture/float64-builtin.c 
b/gcc/testsuite/gcc.dg/torture/float64-builtin.c
index 413768443aee..2462017e4d59 100644
--- a/gcc/testsuite/gcc.dg/torture/float64-builtin.c
+++ b/gcc/testsuite/gcc.dg/torture/float64-builtin.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float64 } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float64_runtime } */
+/* { dg-require-effective-target double64plus } */
 
 #define WIDTH 64
 #define EXT 0
diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c 
b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
index d0e4316611fd..f034e76cfeb9 100644
--- a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
+++ b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float64 } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float64_runtime } */
+/* { dg-require-effective-target double64plus } */
 
 #define WIDTH 64
 #define EXT 0
diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg.c 
b/gcc/testsuite/gcc.dg/torture/float64-tg.c
index a7188312d574..d17ee0ecb199 100644
--- a/gcc/testsuite/gcc.dg/torture/float64-tg.c
+++ b/gcc/testsuite/gcc.dg/torture/float64-tg.c
@@ -4,6 +4,7 @@
 /* { dg-add-options float64 } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target float64_runtime } */
+/* { dg-require-effective-target double64plus } */
 
 #define WIDTH 64
 #define EXT 0
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index f92f7f1af9c6..459af8e58c66 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3965,6 +3965,17 @@ proc check_effective_target_floatn_nx_runtime {} {
 return 1
 }
 
+# Return 1 when double is at least as good as _Float32x, i.e. double can
+# be used to emulate _Float32x.
+
+proc check_effective_target_double_float32xplus {} {
+return [check_no_compiler_messages_nocache double_float32xplus object {
+   _Float32x x;
+   int dummy1[__DBL_MANT_DIG__ >= __FLT32X_MANT_DIG__ ? 1 : -1];
+   int dummy2[__DBL_MAX_EXP__ >= __FLT32X_MAX_EXP__

[gcc r15-4078] AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:58b9024c996951f8d768f1c83a74e5f3eef8a1c7

commit r15-4078-g58b9024c996951f8d768f1c83a74e5f3eef8a1c7
Author: Georg-Johann Lay 
Date:   Thu Oct 3 09:34:08 2024 +0200

AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.

PR target/116953
gcc/
* config/avr/avr.cc (avr_out_sbxx_branch): Work on a copy of
the operands rather than on operands itself, which is just
recog_data.operand and may be clobbered by jump_over_one_insn_p.
gcc/testsuite/
* gcc.target/avr/torture/pr116953.c: New test.

Diff:
---
 gcc/config/avr/avr.cc   | 6 +-
 gcc/testsuite/gcc.target/avr/torture/pr116953.c | 7 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 92013c3845db..735d05b1e747 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -13603,8 +13603,12 @@ avr_hard_regno_rename_ok (unsigned int old_reg, 
unsigned int new_reg)
Operand 3: label to jump to if the test is true.  */
 
 const char *
-avr_out_sbxx_branch (rtx_insn *insn, rtx operands[])
+avr_out_sbxx_branch (rtx_insn *insn, rtx xop[])
 {
+  // jump_over_one_insn_p may call extract on the next insn, clobbering
+  // recog_data.operand.  Hence make a copy of the operands (PR116953).
+  rtx operands[] = { xop[0], xop[1], xop[2], xop[3] };
+
   rtx_code comp = GET_CODE (operands[0]);
   bool long_jump = get_attr_length (insn) >= 4;
   bool reverse = long_jump || jump_over_one_insn_p (insn, operands[3]);
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr116953.c 
b/gcc/testsuite/gcc.target/avr/torture/pr116953.c
new file mode 100644
index ..f8e5a38ec65f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr116953.c
@@ -0,0 +1,7 @@
+unsigned foo (unsigned x, unsigned y)
+{
+  int i;
+  for (i = 8; i--; x <<= 1)
+y ^= (x ^ y) & 0x80 ? 79U : 0U;
+  return y;
+}


[gcc r15-4080] x86: Disable stack protector for naked functions

2024-10-04 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:7d2845da112214f064e7b24531cc67e256b5177e

commit r15-4080-g7d2845da112214f064e7b24531cc67e256b5177e
Author: H.J. Lu 
Date:   Fri Oct 4 16:21:15 2024 +0800

x86: Disable stack protector for naked functions

Since naked functions should not enable stack protector, define
TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable stack protector
for naked functions.

gcc/

PR target/116962
* config/i386/i386.cc (ix86_stack_protect_runtime_enabled_p): New
function.
(TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): New.

gcc/testsuite/

PR target/116962
* gcc.target/i386/pr116962.c: New file.

Signed-off-by: H.J. Lu 

Diff:
---
 gcc/config/i386/i386.cc  | 11 +++
 gcc/testsuite/gcc.target/i386/pr116962.c | 10 ++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index ad2e7b447ffa..90a564b2ffaa 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -24435,6 +24435,13 @@ ix86_stack_protect_guard (void)
   return default_stack_protect_guard ();
 }
 
+static bool
+ix86_stack_protect_runtime_enabled_p (void)
+{
+  /* Naked functions should not enable stack protector.  */
+  return !ix86_function_naked (current_function_decl);
+}
+
 /* For 32-bit code we can save PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly.  64-bit code doesn't need to setup any PIC
@@ -26821,6 +26828,10 @@ ix86_libgcc_floating_mode_supported_p
 #undef TARGET_STACK_PROTECT_GUARD
 #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard
 
+#undef TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
+#define TARGET_STACK_PROTECT_RUNTIME_ENABLED_P \
+  ix86_stack_protect_runtime_enabled_p
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail
diff --git a/gcc/testsuite/gcc.target/i386/pr116962.c 
b/gcc/testsuite/gcc.target/i386/pr116962.c
new file mode 100644
index ..ced16eee746b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116962.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target fstack_protector } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+/* { dg-final { scan-assembler-not "__stack_chk_fail" } } */
+
+__attribute__ ((naked))
+void
+foo (void)
+{
+  asm ("ret");
+}


[gcc r15-4082] MAINTAINERS: Add myself to write after approval

2024-10-04 Thread Thiago Bauermann via Gcc-cvs
https://gcc.gnu.org/g:3f10a2421c2b9c41e7c1b1c0d956743709f5d0be

commit r15-4082-g3f10a2421c2b9c41e7c1b1c0d956743709f5d0be
Author: Thiago Jung Bauermann 
Date:   Fri Oct 4 20:29:45 2024 -0300

MAINTAINERS: Add myself to write after approval

ChangeLog:
* MAINTAINERS: Add myself to write after approval.

Diff:
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ded5b3d4f643..9257b33ff089 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -344,6 +344,7 @@ Richard Ballricbal02

 Scott Bambrough -   
 Wolfgang Bangerth   -   
 Gergö Barany-   
+Thiago Jung Bauermann   -   
 Charles Baylis  cbaylis 
 Tejas Belagod   belagod 
 Andrey Belevantsev  abel


[gcc r15-4079] aarch64: Fix bug with max/min (PR116934)

2024-10-04 Thread Saurabh Jha via Gcc-cvs
https://gcc.gnu.org/g:20ce363c557d6458ec3193ab4e7df760fbe34976

commit r15-4079-g20ce363c557d6458ec3193ab4e7df760fbe34976
Author: Saurabh Jha 
Date:   Thu Oct 3 13:16:31 2024 +

aarch64: Fix bug with max/min (PR116934)

In ac4cdf5cb43c0b09e81760e2a1902ceebcf1a135, I introduced a bug where
I put the new unspecs, UNSPEC_COND_SMAX and UNSPEC_COND_SMIN, into the
wrong iterator.

I should have put new unspecs in SVE_COND_FP_MAXMIN but I put it in
SVE_COND_FP_BINARY_REG instead. That was incorrect because the
SVE_COND_FP_MAXMIN iterator is being used for predicated floating-point
maximum/minimum, not SVE_COND_FP_BINARY_REG.

Also added a testcase to validate the new change.

Regression tested on aarch64-unknown-linux-gnu and found no regressions.
There are some test cases with "libitm" in their directory names which
appear in compare_tests output as changed tests but it looks like they
are in the output just because of changed build directories, like from
build-patched/aarch64-unknown-linux-gnu/./libitm/* to
build-pristine/aarch64-unknown-linux-gnu/./libitm/*. I didn't think it
was a cause of concern and have pushed this for review.

gcc/ChangeLog:

PR target/116934
* config/aarch64/iterators.md: Move UNSPEC_COND_SMAX and
UNSPEC_COND_SMIN to correct iterators.

gcc/testsuite/ChangeLog:

PR target/116934
* gcc.target/aarch64/sve2/pr116934.c: New test.

Diff:
---
 gcc/config/aarch64/iterators.md  |  8 
 gcc/testsuite/gcc.target/aarch64/sve2/pr116934.c | 13 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index 0836dee61c9f..fcad236eee9f 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -3125,9 +3125,7 @@
 
 (define_int_iterator SVE_COND_FP_BINARY_REG
   [UNSPEC_COND_FDIV
-   UNSPEC_COND_FMULX
-   UNSPEC_COND_SMAX
-   UNSPEC_COND_SMIN])
+   UNSPEC_COND_FMULX])
 
 (define_int_iterator SVE_COND_FCADD [UNSPEC_COND_FCADD90
 UNSPEC_COND_FCADD270])
@@ -3135,7 +3133,9 @@
 (define_int_iterator SVE_COND_FP_MAXMIN [UNSPEC_COND_FMAX
 UNSPEC_COND_FMAXNM
 UNSPEC_COND_FMIN
-UNSPEC_COND_FMINNM])
+UNSPEC_COND_FMINNM
+UNSPEC_COND_SMAX
+UNSPEC_COND_SMIN])
 
 (define_int_iterator SVE_COND_FP_TERNARY [UNSPEC_COND_FMLA
  UNSPEC_COND_FMLS
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr116934.c 
b/gcc/testsuite/gcc.target/aarch64/sve2/pr116934.c
new file mode 100644
index ..94fb96ffa7db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/pr116934.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Ofast -mcpu=neoverse-v2" } */
+
+int a;
+float *b;
+
+void foo() {
+  for (; a; a--, b += 4) {
+b[0] = b[1] = b[2] = b[2] > 0 ?: 0;
+if (b[3] < 0)
+  b[3] = 0;
+  }
+}


[gcc r14-10745] AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.

2024-10-04 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:93a6fab364343218e58fd7618e87e5202ae18542

commit r14-10745-g93a6fab364343218e58fd7618e87e5202ae18542
Author: Georg-Johann Lay 
Date:   Thu Oct 3 09:34:08 2024 +0200

AVR: target/116953 - ICE due to operands clobber in avr_out_sbxx_branch.

PR target/116953
gcc/
* config/avr/avr.cc (avr_out_sbxx_branch): Work on a copy of
the operands rather than on operands itself, which is just
recog_data.operand and may be clobbered by jump_over_one_insn_p.
gcc/testsuite/
* gcc.target/avr/torture/pr116953.c: New test.

(cherry picked from commit 58b9024c996951f8d768f1c83a74e5f3eef8a1c7)

Diff:
---
 gcc/config/avr/avr.cc   | 6 +-
 gcc/testsuite/gcc.target/avr/torture/pr116953.c | 7 +++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index c6f29fd48f98..5891465cd277 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -14409,8 +14409,12 @@ avr_hard_regno_rename_ok (unsigned int old_reg, 
unsigned int new_reg)
Operand 3: label to jump to if the test is true.  */
 
 const char *
-avr_out_sbxx_branch (rtx_insn *insn, rtx operands[])
+avr_out_sbxx_branch (rtx_insn *insn, rtx xop[])
 {
+  // jump_over_one_insn_p may call extract on the next insn, clobbering
+  // recog_data.operand.  Hence make a copy of the operands (PR116953).
+  rtx operands[] = { xop[0], xop[1], xop[2], xop[3] };
+
   enum rtx_code comp = GET_CODE (operands[0]);
   bool long_jump = get_attr_length (insn) >= 4;
   bool reverse = long_jump || jump_over_one_insn_p (insn, operands[3]);
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr116953.c 
b/gcc/testsuite/gcc.target/avr/torture/pr116953.c
new file mode 100644
index ..f8e5a38ec65f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr116953.c
@@ -0,0 +1,7 @@
+unsigned foo (unsigned x, unsigned y)
+{
+  int i;
+  for (i = 8; i--; x <<= 1)
+y ^= (x ^ y) & 0x80 ? 79U : 0U;
+  return y;
+}


[gcc r13-9085] x86: Disable stack protector for naked functions

2024-10-04 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:bd9f62324853686c65e1b4331a187102e1e526b0

commit r13-9085-gbd9f62324853686c65e1b4331a187102e1e526b0
Author: H.J. Lu 
Date:   Fri Oct 4 16:21:15 2024 +0800

x86: Disable stack protector for naked functions

Since naked functions should not enable stack protector, define
TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable stack protector
for naked functions.

gcc/

PR target/116962
* config/i386/i386.cc (ix86_stack_protect_runtime_enabled_p): New
function.
(TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): New.

gcc/testsuite/

PR target/116962
* gcc.target/i386/pr116962.c: New file.

Signed-off-by: H.J. Lu 
(cherry picked from commit 7d2845da112214f064e7b24531cc67e256b5177e)

Diff:
---
 gcc/config/i386/i386.cc  | 11 +++
 gcc/testsuite/gcc.target/i386/pr116962.c | 10 ++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index f8bd772d74a4..1e43ae15d7bd 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -22983,6 +22983,13 @@ ix86_stack_protect_guard (void)
   return default_stack_protect_guard ();
 }
 
+static bool
+ix86_stack_protect_runtime_enabled_p (void)
+{
+  /* Naked functions should not enable stack protector.  */
+  return !ix86_function_naked (current_function_decl);
+}
+
 /* For 32-bit code we can save PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly.  64-bit code doesn't need to setup any PIC
@@ -25107,6 +25114,10 @@ ix86_libgcc_floating_mode_supported_p
 #undef TARGET_STACK_PROTECT_GUARD
 #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard
 
+#undef TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
+#define TARGET_STACK_PROTECT_RUNTIME_ENABLED_P \
+  ix86_stack_protect_runtime_enabled_p
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail
diff --git a/gcc/testsuite/gcc.target/i386/pr116962.c 
b/gcc/testsuite/gcc.target/i386/pr116962.c
new file mode 100644
index ..ced16eee746b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116962.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target fstack_protector } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+/* { dg-final { scan-assembler-not "__stack_chk_fail" } } */
+
+__attribute__ ((naked))
+void
+foo (void)
+{
+  asm ("ret");
+}


[gcc r12-10742] x86: Disable stack protector for naked functions

2024-10-04 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:7a51946e00fa2fb2ffacdd7c8d0a80e056c1f7ff

commit r12-10742-g7a51946e00fa2fb2ffacdd7c8d0a80e056c1f7ff
Author: H.J. Lu 
Date:   Fri Oct 4 16:21:15 2024 +0800

x86: Disable stack protector for naked functions

Since naked functions should not enable stack protector, define
TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable stack protector
for naked functions.

gcc/

PR target/116962
* config/i386/i386.cc (ix86_stack_protect_runtime_enabled_p): New
function.
(TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): New.

gcc/testsuite/

PR target/116962
* gcc.target/i386/pr116962.c: New file.

Signed-off-by: H.J. Lu 
(cherry picked from commit 7d2845da112214f064e7b24531cc67e256b5177e)

Diff:
---
 gcc/config/i386/i386.cc  | 11 +++
 gcc/testsuite/gcc.target/i386/pr116962.c | 10 ++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 882de00610ff..2087f8633eb8 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -22644,6 +22644,13 @@ ix86_stack_protect_guard (void)
   return default_stack_protect_guard ();
 }
 
+static bool
+ix86_stack_protect_runtime_enabled_p (void)
+{
+  /* Naked functions should not enable stack protector.  */
+  return !ix86_function_naked (current_function_decl);
+}
+
 /* For 32-bit code we can save PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly.  64-bit code doesn't need to setup any PIC
@@ -24650,6 +24657,10 @@ ix86_libgcc_floating_mode_supported_p
 #undef TARGET_STACK_PROTECT_GUARD
 #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard
 
+#undef TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
+#define TARGET_STACK_PROTECT_RUNTIME_ENABLED_P \
+  ix86_stack_protect_runtime_enabled_p
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail
diff --git a/gcc/testsuite/gcc.target/i386/pr116962.c 
b/gcc/testsuite/gcc.target/i386/pr116962.c
new file mode 100644
index ..ced16eee746b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116962.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target fstack_protector } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+/* { dg-final { scan-assembler-not "__stack_chk_fail" } } */
+
+__attribute__ ((naked))
+void
+foo (void)
+{
+  asm ("ret");
+}


[gcc/devel/nothrow-detection] Updated code for unlinking regions and update stmt_eh_regions as well

2024-10-04 Thread Pranil Dey via Gcc-cvs
https://gcc.gnu.org/g:da431b3514d93d70e2894c9076fd8908af70f069

commit da431b3514d93d70e2894c9076fd8908af70f069
Author: Pranil Dey 
Date:   Sat Oct 5 10:26:15 2024 +0530

Updated code for unlinking regions and update stmt_eh_regions as well

Diff:
---
 gcc/tree-eh.cc | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index ef7d773d8372..89daf32046e3 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2327,7 +2327,6 @@ bool match_lp (eh_landing_pad lp, vec 
*exception_types) {
 }
 
 void unlink_eh_region(eh_region region) {
-gcc_assert(!region->inner);
 eh_region *link;
 
 // Check if region is root
@@ -2389,14 +2388,22 @@ void update_stmt_eh_region (gimple *stmt) {
 eh_region region = lp->region;
 eh_region prev_region = NULL;
 
+bool update = false;
+if (gimple_code (stmt) == GIMPLE_RESX)
+region = region->outer;
+
 // Walk up the region tree
 while (region) {
 switch (region->type) {
 case ERT_CLEANUP:
+if (!update)
+ return;
+
 if (gimple_code (stmt) == GIMPLE_RESX){
   gresx *resx_stmt = as_a  (stmt);
   gimple_resx_set_region (resx_stmt, region->index);
 }
+
 else *cfun->eh->throw_stmt_table->get (const_cast 
(stmt)) = lp->index;
 
 unlink_eh_region (region);
@@ -2404,11 +2411,15 @@ void update_stmt_eh_region (gimple *stmt) {
 return;
 
 case ERT_TRY:
+if (update)
+return;
+
 if (match_lp (lp, &exception_types)) {
   if (gimple_code (stmt) == GIMPLE_RESX){
 gresx *resx_stmt = as_a  (stmt);
 gimple_resx_set_region (resx_stmt, region->index);
   }
+
   else *cfun->eh->throw_stmt_table->get (const_cast 
(stmt)) = lp->index;
 
   unlink_eh_region (region);
@@ -2432,8 +2443,12 @@ void update_stmt_eh_region (gimple *stmt) {
 }
 prev_region = region;
 region = region->outer;
+update = true;
 }
 
+if (!update)
+return;
+
 if (gimple_code (stmt) == GIMPLE_RESX){
   gresx *resx_stmt = as_a  (stmt);
   gimple_resx_set_region (resx_stmt, 0);
@@ -3115,9 +3130,9 @@ bool stmt_throw_types (function *fun, gimple *stmt, 
vec *ret_vector) {
 bool type_exists = true;
 
 switch (gimple_code (stmt)) {
-// case GIMPLE_RESX:
-// extract_fun_resx_types (fun, ret_vector);
-// return !ret_vector->is_empty ();
+case GIMPLE_RESX:
+extract_fun_resx_types (fun, ret_vector);
+return !ret_vector->is_empty ();
 
 case GIMPLE_CALL:
 type_exists =  extract_types_for_call (as_a (stmt), 
ret_vector);


[gcc r13-9083] libstdc++: Handle EMLINK and EFTYPE in std::filesystem::remove_all

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e9575f6248a8fd185640ab78ebc4bf63bb205e3a

commit r13-9083-ge9575f6248a8fd185640ab78ebc4bf63bb205e3a
Author: Jonathan Wakely 
Date:   Mon Apr 8 17:41:00 2024 +0100

libstdc++: Handle EMLINK and EFTYPE in std::filesystem::remove_all

Although POSIX requires ELOOP, FreeBSD documents that openat with
O_NOFOLLOW returns EMLINK if the last component of a filename is a
symbolic link.  Check for EMLINK as well as ELOOP, so that the TOCTTOU
mitigation in remove_all works correctly.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214633 or the
FreeBSD man page for reference.

According to its man page, DragonFlyBSD also uses EMLINK for this error,
and NetBSD uses its own EFTYPE. OpenBSD follows POSIX and uses EMLINK.

This fixes these failures on FreeBSD:
FAIL: 27_io/filesystem/operations/remove_all.cc  -std=gnu++17 execution test
FAIL: experimental/filesystem/operations/remove_all.cc  -std=gnu++17 
execution test

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (remove_all) [__FreeBSD__ || __DragonFly__]:
Check for EMLINK as well as ELOOP.
[__NetBSD__]: Check for EFTYPE as well as ELOOP.

Diff:
---
 libstdc++-v3/src/c++17/fs_ops.cc | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++17/fs_ops.cc b/libstdc++-v3/src/c++17/fs_ops.cc
index 6d84d4293d2a..785d75328cab 100644
--- a/libstdc++-v3/src/c++17/fs_ops.cc
+++ b/libstdc++-v3/src/c++17/fs_ops.cc
@@ -1311,7 +1311,13 @@ fs::remove_all(const path& p)
 // Our work here is done.
 return 0;
   case ENOTDIR:
-  case ELOOP:
+  case ELOOP:  // POSIX says openat with O_NOFOLLOW sets ELOOP for a symlink.
+#if defined __FreeBSD__ || defined __DragonFly__
+  case EMLINK: // Used instead of ELOOP
+#endif
+#if defined __NetBSD__ && defined EFTYPE
+  case EFTYPE: // Used instead of ELOOP
+#endif
 // Not a directory, will remove below.
 break;
 #endif
@@ -1351,7 +1357,13 @@ fs::remove_all(const path& p, error_code& ec)
 ec.clear();
 return 0;
   case ENOTDIR:
-  case ELOOP:
+  case ELOOP:  // POSIX says openat with O_NOFOLLOW sets ELOOP for a symlink.
+#if defined __FreeBSD__ || defined __DragonFly__
+  case EMLINK: // Used instead of ELOOP
+#endif
+#if defined __NetBSD__ && defined EFTYPE
+  case EFTYPE: // Used instead of ELOOP
+#endif
 // Not a directory, will remove below.
 break;
 #endif


[gcc r13-9081] libstdc++: Fix @headername for bits/cpp_type_traits.h

2024-10-04 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:995725189e5107c40f10b960549fab0a2b3bb976

commit r13-9081-g995725189e5107c40f10b960549fab0a2b3bb976
Author: Kim Gräsman 
Date:   Tue Aug 27 17:08:47 2024 +0100

libstdc++: Fix @headername for bits/cpp_type_traits.h

There is no file ext/type_traits, point it to ext/type_traits.h instead.

libstdc++-v3/ChangeLog:

* include/bits/cpp_type_traits.h: Improve doxygen file docs.

(cherry picked from commit f6ed7a61a7c906f8fb7f8059132225c9bc41f3b2)

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

diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h 
b/libstdc++-v3/include/bits/cpp_type_traits.h
index 4312f32a4e07..e466ee9291bd 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -24,7 +24,7 @@
 
 /** @file bits/cpp_type_traits.h
  *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{ext/type_traits}
+ *  Do not attempt to use it directly. @headername{ext/type_traits.h}
  */
 
 // Written by Gabriel Dos Reis 


[gcc r13-9084] libstdc++: Initialize base in test allocator's constructor

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:bf60352052b162fc32b6c6b9c46bf397c295412c

commit r13-9084-gbf60352052b162fc32b6c6b9c46bf397c295412c
Author: Jonathan Wakely 
Date:   Thu Jun 20 16:13:10 2024 +0100

libstdc++: Initialize base in test allocator's constructor

This fixes a warning from one of the test allocators:
warning: base class 'class std::allocator<__gnu_test::copy_tracker>' should 
be explicitly initialized in the copy constructor [-Wextra]

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_allocator.h (tracker_allocator):
Initialize base class in copy constructor.

(cherry picked from commit e2fb245b07f489ed5bfd9a945e0053b4a3211245)

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 24b86e825167..de3ab493a691 100644
--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -154,7 +154,7 @@ namespace __gnu_test
   tracker_allocator()
   { }
 
-  tracker_allocator(const tracker_allocator&)
+  tracker_allocator(const tracker_allocator& a) : Alloc(a)
   { }
 
   ~tracker_allocator()


[gcc r13-9077] libstdc++: std::string move assignment should not use POCCA trait [PR116641]

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:b91eff42ecb25c5dfc1e2e08be64d365376cab80

commit r13-9077-gb91eff42ecb25c5dfc1e2e08be64d365376cab80
Author: Jonathan Wakely 
Date:   Tue Sep 10 14:25:41 2024 +0100

libstdc++: std::string move assignment should not use POCCA trait [PR116641]

The changes to implement LWG 2579 (r10-327-gdb33efde17932f) made
std::string::assign use the propagate_on_container_copy_assignment
(POCCA) trait, for consistency with operator=(const basic_string&).
However, this also unintentionally affected operator=(basic_string&&)
which calls assign(str) to make a deep copy when performing a move is
not possible. The fix is for the move assignment operator to call
_M_assign(str) instead of assign(str), as this just does the deep copy
and doesn't check the POCCA trait first.

The bug only affects the unlikely/useless combination of POCCA==true and
POCMA==false, but we should fix it for correctness anyway. it should
also make move assignment slightly cheaper to compile and execute,
because we skip the extra code in assign(const basic_string&).

libstdc++-v3/ChangeLog:

PR libstdc++/116641
* include/bits/basic_string.h (operator=(basic_string&&)): Call
_M_assign instead of assign.
* testsuite/21_strings/basic_string/allocator/116641.cc: New
test.

(cherry picked from commit c07cf418fdde0c192e370a8d76a991cc7215e9c4)

Diff:
---
 libstdc++-v3/include/bits/basic_string.h   |  2 +-
 .../21_strings/basic_string/allocator/116641.cc| 53 ++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index 36598803f00c..4afe9419c1fd 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -907,7 +907,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
  __str._M_data(__str._M_use_local_data());
  }
else // Need to do a deep copy
- assign(__str);
+ _M_assign(__str);
__str.clear();
return *this;
   }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc 
b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc
new file mode 100644
index ..a1a411b87faa
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/allocator/116641.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target c++11 } }
+// { dg-require-effective-target cxx11_abi }
+
+// Bug 116641 - std::string move assignment incorrectly depends on POCCA
+
+#include 
+#include 
+
+template
+struct Alloc
+{
+  using value_type = T;
+  using propagate_on_container_swap = std::false_type;
+  using propagate_on_container_copy_assignment = std::true_type;
+  using propagate_on_container_move_assignment = std::false_type;
+
+  Alloc(int id) : id(id) { }
+
+  template
+Alloc(const Alloc& a) : id(a.id) { }
+
+  T* allocate(unsigned long n)
+  { return std::allocator().allocate(n); }
+
+  void deallocate(T* p, unsigned long n)
+  { std::allocator().deallocate(p, n); }
+
+  Alloc& operator=(const Alloc&) { throw; }
+
+  bool operator==(const Alloc& a) const { return id == a.id; }
+  bool operator!=(const Alloc& a) const { return id != a.id; }
+
+  int id;
+};
+
+void
+test_pr116641()
+{
+  Alloc a1(1), a2(2);
+  std::basic_string, Alloc> s1(a1), s2(a2);
+
+  s1 = "allocator should not propagate on move assignment";
+  VERIFY( s1.get_allocator() == a1 );
+  VERIFY( s2.get_allocator() == a2 );
+  s2 = std::move(s1);
+  VERIFY( s1.get_allocator() == a1 );
+  VERIFY( s2.get_allocator() == a2 );
+}
+
+int main()
+{
+  test_pr116641();
+}


[gcc r13-9082] libstdc++: Fix std::tr2::dynamic_bitset shift operations [PR115399]

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0fa5c0340fa6b897e1fd7c62a107e93eb05fb557

commit r13-9082-g0fa5c0340fa6b897e1fd7c62a107e93eb05fb557
Author: Jonathan Wakely 
Date:   Mon Jun 10 14:08:16 2024 +0100

libstdc++: Fix std::tr2::dynamic_bitset shift operations [PR115399]

The shift operations for dynamic_bitset fail to zero out words where the
non-zero bits were shifted to a completely different word.

For a right shift we don't need to sanitize the unused bits in the high
word, because we know they were already clear and a right shift doesn't
change that.

libstdc++-v3/ChangeLog:

PR libstdc++/115399
* include/tr2/dynamic_bitset (operator>>=): Remove redundant
call to _M_do_sanitize.
* include/tr2/dynamic_bitset.tcc (_M_do_left_shift): Zero out
low bits in words that should no longer be populated.
(_M_do_right_shift): Likewise for high bits.
* testsuite/tr2/dynamic_bitset/pr115399.cc: New test.

(cherry picked from commit bd3a312728fbf8c35a09239b9180269f938f872e)

Diff:
---
 libstdc++-v3/include/tr2/dynamic_bitset|  5 +--
 libstdc++-v3/include/tr2/dynamic_bitset.tcc|  6 ++--
 .../testsuite/tr2/dynamic_bitset/pr115399.cc   | 37 ++
 3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/tr2/dynamic_bitset 
b/libstdc++-v3/include/tr2/dynamic_bitset
index ffdce82590fd..6bdfa7c53ef7 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset
+++ b/libstdc++-v3/include/tr2/dynamic_bitset
@@ -815,10 +815,7 @@ namespace tr2
   operator>>=(size_type __pos)
   {
if (__builtin_expect(__pos < this->_M_Nb, 1))
- {
-   this->_M_do_right_shift(__pos);
-   this->_M_do_sanitize();
- }
+ this->_M_do_right_shift(__pos);
else
  this->_M_do_reset();
return *this;
diff --git a/libstdc++-v3/include/tr2/dynamic_bitset.tcc 
b/libstdc++-v3/include/tr2/dynamic_bitset.tcc
index aba262d7dd86..1e04e6998f96 100644
--- a/libstdc++-v3/include/tr2/dynamic_bitset.tcc
+++ b/libstdc++-v3/include/tr2/dynamic_bitset.tcc
@@ -60,8 +60,7 @@ namespace tr2
  this->_M_w[__wshift] = this->_M_w[0] << __offset;
}
 
-  std::fill(this->_M_w.begin(), this->_M_w.begin() + __wshift,
-   static_cast<_WordT>(0));
+ std::fill_n(this->_M_w.begin(), __wshift, _WordT(0));
}
 }
 
@@ -88,8 +87,7 @@ namespace tr2
  this->_M_w[__limit] = this->_M_w[_M_w.size()-1] >> __offset;
}
 
- std::fill(this->_M_w.begin() + __limit + 1, this->_M_w.end(),
-   static_cast<_WordT>(0));
+ std::fill_n(this->_M_w.end() - __wshift, __wshift, _WordT(0));
}
 }
 
diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc 
b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc
new file mode 100644
index ..e626e4a5d156
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc
@@ -0,0 +1,37 @@
+// { dg-do run { target c++11 } }
+
+// PR libstdc++/115399
+// std::tr2::dynamic_bitset shift behaves differently from std::bitset
+
+#include 
+#include 
+
+void
+test_left_shift()
+{
+  std::tr2::dynamic_bitset<> b(65);
+  b[0] = 1;
+  auto b2 = b << 64;
+  VERIFY(b2[64] == 1);
+  VERIFY(b2[0] == 0);
+  b <<= 64;
+  VERIFY( b2 == b );
+}
+
+void
+test_right_shift()
+{
+  std::tr2::dynamic_bitset<> b(65);
+  b[64] = 1;
+  auto b2 = b >> 64;
+  VERIFY(b2[64] == 0);
+  VERIFY(b2[0] == 1);
+  b >>= 64;
+  VERIFY( b2 == b );
+}
+
+int main()
+{
+  test_left_shift();
+  test_right_shift();
+}


[gcc r13-9080] libstdc++: Fix @file for target-specific opt_random.h

2024-10-04 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:2a30e7f9dc59ebcb8350959e94f61a9c68710f52

commit r13-9080-g2a30e7f9dc59ebcb8350959e94f61a9c68710f52
Author: Kim Gräsman 
Date:   Tue Aug 27 17:11:29 2024 +0100

libstdc++: Fix @file for target-specific opt_random.h

A few of these files self-identified as ext/random.tcc, update to use
the actual basename.

libstdc++-v3/ChangeLog:

* config/cpu/aarch64/opt/ext/opt_random.h: Improve doxygen file
docs.
* config/cpu/i486/opt/ext/opt_random.h: Likewise.

(cherry picked from commit c2ad7b2d5247cf2ddee98d7f46274775a3fa1268)

Diff:
---
 libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h | 2 +-
 libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h 
b/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
index 93981eb08f67..a1c05e8f7a79 100644
--- a/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
+++ b/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
@@ -22,7 +22,7 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
-/** @file ext/random.tcc
+/** @file ext/opt_random.h
  *  This is an internal header file, included by other library headers.
  *  Do not attempt to use it directly. @headername{ext/random}
  */
diff --git a/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h 
b/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
index 148d90e5023b..3a0f99bb9e0b 100644
--- a/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
+++ b/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
@@ -22,7 +22,7 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
-/** @file ext/random.tcc
+/** @file ext/opt_random.h
  *  This is an internal header file, included by other library headers.
  *  Do not attempt to use it directly. @headername{ext/random}
  */


[gcc r13-9079] libstdc++: Use reserved form of [[__likely__]] in

2024-10-04 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:cd53e6a50567fe890b5c2266a3b318321fc19a55

commit r13-9079-gcd53e6a50567fe890b5c2266a3b318321fc19a55
Author: Jonathan Wakely 
Date:   Fri Jul 5 20:00:04 2024 +0100

libstdc++: Use reserved form of [[__likely__]] in 

We should not use [[unlikely]] before C++20, so use [[__unlikely__]]
instead.

libstdc++-v3/ChangeLog:

* include/std/variant (_Variant_storage::_M_reset): Use
__unlikely__ form of attribute instead of unlikely.

(cherry picked from commit 9f1cd51766f251aafe0f1b898892f79855892729)

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

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index a31b7e772388..1a34a2f2e7f5 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -490,7 +490,7 @@ namespace __variant
   constexpr void
   _M_reset()
   {
-   if (!_M_valid()) [[unlikely]]
+   if (!_M_valid()) [[__unlikely__]]
  return;
 
std::__do_visit([](auto&& __this_mem) mutable


[gcc r13-9078] libstdc++: Fix autoconf check for O_NONBLOCK in

2024-10-04 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:fe7940dcea535c2ea07b65dca1d0ad99c767a62c

commit r13-9078-gfe7940dcea535c2ea07b65dca1d0ad99c767a62c
Author: Jonathan Wakely 
Date:   Wed Aug 28 12:38:18 2024 +0100

libstdc++: Fix autoconf check for O_NONBLOCK in 

I misused the AC_CHECK_DECL macro, assuming that it behaved like
AC_CHECK_DECLS and always defined a HAVE_xxx macro if the decl was
found. Instead, the [action-if-found] shell commands are needed to
defined HAVE_O_NONBLOCK explicitly.

libstdc++-v3/ChangeLog:

* configure.ac: Fix check for O_NONBLOCK.
* config.h.in: Regenerate.
* configure: Regenerate.

(cherry picked from commit b68561dd7925dfee1836f75d3fa8d33fff5c2498)

Diff:
---
 libstdc++-v3/config.h.in  | 3 +++
 libstdc++-v3/configure| 2 ++
 libstdc++-v3/configure.ac | 5 -
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 0f34f65e428a..1d146d18359e 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -295,6 +295,9 @@
 /* Define if openat is available in . */
 #undef HAVE_OPENAT
 
+/* Define if O_NONBLOCK is defined in  */
+#undef HAVE_O_NONBLOCK
+
 /* Define if poll is available in . */
 #undef HAVE_POLL
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d35baaf7c6ec..81329bba8e5a 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -71665,6 +71665,8 @@ if test 
"$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
 "
 if test "x$ac_cv_have_decl_O_NONBLOCK" = xyes; then :
 
+$as_echo "#define HAVE_O_NONBLOCK 1" >>confdefs.h
+
 fi
 
 fi
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 0c3c7a2c11ce..7b13f37bd5b3 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -530,7 +530,10 @@ AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/socket.h 
sys/uio.h poll.h netdb.h arpa
 AC_CHECK_DECL(F_GETFL,,,[#include ])
 AC_CHECK_DECL(F_SETFL,,,[#include ])
 if test "$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
-  AC_CHECK_DECL(O_NONBLOCK,,,[#include ])
+  AC_CHECK_DECL(O_NONBLOCK,
+AC_DEFINE(HAVE_O_NONBLOCK,1,[Define if O_NONBLOCK is defined in 
]),
+[],
+[#include ])
 fi
 
 # For Transactional Memory TS


[gcc r15-4065] Fixup dumping of re-trying without/with single-lane SLP

2024-10-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:16cd00a10035992f52ed67ff77eab20039555b03

commit r15-4065-g16cd00a10035992f52ed67ff77eab20039555b03
Author: Richard Biener 
Date:   Fri Oct 4 14:12:04 2024 +0200

Fixup dumping of re-trying without/with single-lane SLP

The following fixes the order of decrementing the SLP mode and
the dumping.

* tree-vect-loop.cc (vect_analyze_loop_2): Derement 'slp'
before dumping which stage we're starting.

Diff:
---
 gcc/tree-vect-loop.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 730888f62755..f1b3fb2e44ac 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -3275,6 +3275,9 @@ again:
}
 }
 
+  /* Roll back state appropriately.  Degrade SLP this time.  From multi-
+ to single-lane to disabled.  */
+  --slp;
   if (dump_enabled_p ())
 {
   if (slp)
@@ -3285,9 +3288,6 @@ again:
 "re-trying with SLP disabled\n");
 }
 
-  /* Roll back state appropriately.  Degrade SLP this time.  From multi-
- to single-lane to disabled.  */
-  --slp;
   /* Restore vectorization factor as it were without SLP.  */
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = saved_vectorization_factor;
   /* Free the SLP instances.  */


[gcc r15-4061] c++: Allow references to internal-linkage vars in C++11 [PR113266]

2024-10-04 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:247643c7e21b087e6c93b8b8d49b4268bf84b03b

commit r15-4061-g247643c7e21b087e6c93b8b8d49b4268bf84b03b
Author: Nathaniel Shead 
Date:   Fri Oct 4 12:01:38 2024 +1000

c++: Allow references to internal-linkage vars in C++11 [PR113266]

[temp.arg.nontype] changed in C++11 to allow naming internal-linkage
variables and functions.  We currently already handle internal-linkage
functions, but variables were missed; this patch updates this.

PR c++/113266
PR c++/116911

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_argument): Allow
internal-linkage variables since C++11.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nontype6.C: New test.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/cp/parser.cc  | 17 -
 gcc/testsuite/g++.dg/cpp0x/nontype6.C | 19 +++
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 08f9c89f1f04..9d31a975dcf9 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -19864,9 +19864,11 @@ cp_parser_template_argument (cp_parser* parser)
 
  -- the name of a non-type template-parameter; or
 
- -- the name of an object or function with external linkage...
+ -- the name of an object or function with external (or internal,
+   since C++11) linkage...
 
- -- the address of an object or function with external linkage...
+ -- the address of an object or function with external (or internal,
+   since C++11) linkage...
 
  -- a pointer to member...  */
   /* Look for a non-type template parameter.  */
@@ -19929,11 +19931,16 @@ cp_parser_template_argument (cp_parser* parser)
probe = TREE_OPERAND (probe, 1);
  if (VAR_P (probe))
{
- /* A variable without external linkage might still be a
+ /* A variable without valid linkage might still be a
 valid constant-expression, so no error is issued here
 if the external-linkage check fails.  */
- if (!address_p && !DECL_EXTERNAL_LINKAGE_P (probe))
-   cp_parser_simulate_error (parser);
+ if (!address_p)
+   {
+ linkage_kind linkage = decl_linkage (probe);
+ if (linkage != lk_external
+ && (cxx_dialect < cxx11 || linkage != lk_internal))
+   cp_parser_simulate_error (parser);
+   }
}
  else if (is_overloaded_fn (argument))
/* All overloaded functions are allowed; if the external
diff --git a/gcc/testsuite/g++.dg/cpp0x/nontype6.C 
b/gcc/testsuite/g++.dg/cpp0x/nontype6.C
new file mode 100644
index ..5543d1e8b6d2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nontype6.C
@@ -0,0 +1,19 @@
+// PR c++/113266, PR c++/116911
+// { dg-do compile }
+
+template  struct a {};
+static int guard1;
+a b;  // { dg-error "constant-expression|invalid" "" { target 
c++98_only } }
+
+namespace {
+  int guard2;
+}
+a c;  // OK in C++98 because guard2 has external linkage
+  // OK since C++11 because we can refer to an internal linkage 
decl
+
+void nolinkage() {
+  static int guard3;
+  a d;  // { dg-error "constant-expression|invalid" "" { target 
c++98_only } }
+  // { dg-error "constant expression|no linkage" "" { target { c++11 && 
c++14_down } } .-1 }
+  // OK since C++17 since we can now refer to no-linkage decls
+}


[gcc r15-4060] c++: Return the underlying decl rather than the USING_DECL from update_binding [PR116913]

2024-10-04 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de

commit r15-4060-g6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de
Author: Nathaniel Shead 
Date:   Fri Oct 4 10:46:57 2024 +1000

c++: Return the underlying decl rather than the USING_DECL from 
update_binding [PR116913]

Users of pushdecl assume that the returned decl will be a possibly
updated decl matching the one that was passed in.  My r15-3910 change
broke this since in some cases we would now return USING_DECLs; this
patch fixes the situation.

PR c++/116913

gcc/cp/ChangeLog:

* name-lookup.cc (update_binding): Return the strip_using'd old
decl rather than the binding.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/using70.C: New test.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/cp/name-lookup.cc |  4 ++--
 gcc/testsuite/g++.dg/lookup/using70.C | 13 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 4754ef5a5229..609bd6e8c9b5 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -3101,7 +3101,7 @@ update_binding (cp_binding_level *level, cxx_binding 
*binding, tree *slot,
{
  if (same_type_p (TREE_TYPE (old), TREE_TYPE (decl)))
/* Two type decls to the same type.  Do nothing.  */
-   return old_bval;
+   return old;
  else
goto conflict;
}
@@ -3114,7 +3114,7 @@ update_binding (cp_binding_level *level, cxx_binding 
*binding, tree *slot,
 
  /* The new one must be an alias at this point.  */
  gcc_assert (DECL_NAMESPACE_ALIAS (decl));
- return old_bval;
+ return old;
}
   else if (TREE_CODE (old) == VAR_DECL)
{
diff --git a/gcc/testsuite/g++.dg/lookup/using70.C 
b/gcc/testsuite/g++.dg/lookup/using70.C
new file mode 100644
index ..14838eea7ec3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using70.C
@@ -0,0 +1,13 @@
+// PR c++/116913
+// { dg-do compile { target c++11 } }
+
+namespace ns {
+  struct c {};
+  using d = int;
+}
+
+using ns::c;
+using ns::d;
+
+using c = ns::c;
+using d = ns::d;


[gcc r15-4064] diagnostic, pch: Fix up the new diagnostic PCH methods for ubsan checking [PR116936]

2024-10-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f82055f8247478d9e2c00f2a442248e42188b8d1

commit r15-4064-gf82055f8247478d9e2c00f2a442248e42188b8d1
Author: Jakub Jelinek 
Date:   Fri Oct 4 14:02:13 2024 +0200

diagnostic, pch: Fix up the new diagnostic PCH methods for ubsan checking 
[PR116936]

The PR notes that the new pch_save/pch_restore methods I've added
recently invoke UB if either m_classification_history.address ()
or m_push_list.address () is NULL (which can happen if those vectors
are empty (and in the pch_save case nothing has been pushed into them
before either).  While the corresponding length is necessarily 0,
fwrite (NULL, something, 0, f) or
fread (NULL, something, 0, f) still invoke UB.

The following patch fixes that by not calling fwrite/fread if the
corresponding length is 0.

2024-10-04  Jakub Jelinek  

PR pch/116936
* diagnostic.cc (diagnostic_option_classifier::pch_save): Only call
fwrite if corresponding length is non-zero.
(diagnostic_option_classifier::pch_restore): Only call fread if
corresponding length is non-zero.

Diff:
---
 gcc/diagnostic.cc | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 73ed2ea154cc..27ac2bd67b9b 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -167,11 +167,13 @@ diagnostic_option_classifier::pch_save (FILE *f)
   unsigned int lengths[2] = { m_classification_history.length (),
  m_push_list.length () };
   if (fwrite (lengths, sizeof (lengths), 1, f) != 1
-  || fwrite (m_classification_history.address (),
-sizeof (diagnostic_classification_change_t),
-lengths[0], f) != lengths[0]
-  || fwrite (m_push_list.address (), sizeof (int),
-lengths[1], f) != lengths[1])
+  || (lengths[0]
+ && fwrite (m_classification_history.address (),
+sizeof (diagnostic_classification_change_t),
+lengths[0], f) != lengths[0])
+  || (lengths[1]
+ && fwrite (m_push_list.address (), sizeof (int),
+lengths[1], f) != lengths[1]))
 return -1;
   return 0;
 }
@@ -189,11 +191,13 @@ diagnostic_option_classifier::pch_restore (FILE *f)
   gcc_checking_assert (m_push_list.is_empty ());
   m_classification_history.safe_grow (lengths[0]);
   m_push_list.safe_grow (lengths[1]);
-  if (fread (m_classification_history.address (),
-sizeof (diagnostic_classification_change_t),
-lengths[0], f) != lengths[0]
-  || fread (m_push_list.address (), sizeof (int),
-   lengths[1], f) != lengths[1])
+  if ((lengths[0]
+   && fread (m_classification_history.address (),
+sizeof (diagnostic_classification_change_t),
+lengths[0], f) != lengths[0])
+  || (lengths[1]
+ && fread (m_push_list.address (), sizeof (int),
+   lengths[1], f) != lengths[1]))
 return -1;
   return 0;
 }


[gcc r15-4059] Relax gcc.dg/vect/pr65947-8.c

2024-10-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:7fb6526652ddd722931407f749a176cfea779147

commit r15-4059-g7fb6526652ddd722931407f749a176cfea779147
Author: Richard Biener 
Date:   Fri Oct 4 11:53:54 2024 +0200

Relax gcc.dg/vect/pr65947-8.c

When failing using forced SLP we do not print the non-SLP failure
mode which reads slightly different.  Massage the expectation a bit.

* gcc.dg/vect/pr65947-8.c: Adjust.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr65947-8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr65947-8.c 
b/gcc/testsuite/gcc.dg/vect/pr65947-8.c
index 9ced4dbb69fd..827575778f80 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65947-8.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65947-8.c
@@ -43,4 +43,4 @@ main (void)
 
 /* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! { 
vect_fold_extract_last } } } } } */
 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target { 
vect_fold_extract_last } } } } */
-/* { dg-final { scan-tree-dump "multiple types in double reduction or 
condition reduction" "vect" { target { ! { vect_fold_extract_last } } } } } */
+/* { dg-final { scan-tree-dump "multiple types in\[^\\n\\r\]* condition 
reduction" "vect" { target { ! { vect_fold_extract_last } } } } } */


[gcc r14-10746] x86: Disable stack protector for naked functions

2024-10-04 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:1032b72548c47a199e0407c69d6740d6c3341f43

commit r14-10746-g1032b72548c47a199e0407c69d6740d6c3341f43
Author: H.J. Lu 
Date:   Fri Oct 4 16:21:15 2024 +0800

x86: Disable stack protector for naked functions

Since naked functions should not enable stack protector, define
TARGET_STACK_PROTECT_RUNTIME_ENABLED_P to disable stack protector
for naked functions.

gcc/

PR target/116962
* config/i386/i386.cc (ix86_stack_protect_runtime_enabled_p): New
function.
(TARGET_STACK_PROTECT_RUNTIME_ENABLED_P): New.

gcc/testsuite/

PR target/116962
* gcc.target/i386/pr116962.c: New file.

Signed-off-by: H.J. Lu 
(cherry picked from commit 7d2845da112214f064e7b24531cc67e256b5177e)

Diff:
---
 gcc/config/i386/i386.cc  | 11 +++
 gcc/testsuite/gcc.target/i386/pr116962.c | 10 ++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2a0a79888be3..f8ab1893985c 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -24265,6 +24265,13 @@ ix86_stack_protect_guard (void)
   return default_stack_protect_guard ();
 }
 
+static bool
+ix86_stack_protect_runtime_enabled_p (void)
+{
+  /* Naked functions should not enable stack protector.  */
+  return !ix86_function_naked (current_function_decl);
+}
+
 /* For 32-bit code we can save PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly.  64-bit code doesn't need to setup any PIC
@@ -26582,6 +26589,10 @@ ix86_libgcc_floating_mode_supported_p
 #undef TARGET_STACK_PROTECT_GUARD
 #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard
 
+#undef TARGET_STACK_PROTECT_RUNTIME_ENABLED_P
+#define TARGET_STACK_PROTECT_RUNTIME_ENABLED_P \
+  ix86_stack_protect_runtime_enabled_p
+
 #if !TARGET_MACHO
 #undef TARGET_STACK_PROTECT_FAIL
 #define TARGET_STACK_PROTECT_FAIL ix86_stack_protect_fail
diff --git a/gcc/testsuite/gcc.target/i386/pr116962.c 
b/gcc/testsuite/gcc.target/i386/pr116962.c
new file mode 100644
index ..ced16eee746b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116962.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target fstack_protector } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+/* { dg-final { scan-assembler-not "__stack_chk_fail" } } */
+
+__attribute__ ((naked))
+void
+foo (void)
+{
+  asm ("ret");
+}


[gcc r15-4081] diagnostics: bulletproof opening of SARIF output [PR116978]

2024-10-04 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:385a232229a5b4ee3f4d2a2472bcda28cd8d17b2

commit r15-4081-g385a232229a5b4ee3f4d2a2472bcda28cd8d17b2
Author: David Malcolm 
Date:   Fri Oct 4 18:31:17 2024 -0400

diagnostics: bulletproof opening of SARIF output [PR116978]

Introduce a new RAII class diagnostic_output_file to track ownership
of the FILE * for SARIF output.

In particular, the .sarif file is now opened immediately, rather
than at the end of the compile, and so will fail earlier if the
file can't be opened.

Doing so fixes a couple of ICEs in -fdiagnostics-format=sarif-file when
invoking, say, cc1 directly, rather than from the driver.

gcc/ChangeLog:
PR other/116978
* diagnostic-format-sarif.cc (sarif_builder::sarif_builder):
Gracefully handle "main_input_filename_" being NULL.
(sarif_output_format::sarif_output_format): Replace param
"base_file_name" with "output_file" and assert that the file
was opened successfully and has a non-NULL filename.
(sarif_output_format::~sarif_file_output_format): Move
responsibility for building the filename and opening the file from
here to the creator of the instance.
(sarif_output_format::m_base_file_name): Replace with...
(sarif_output_format::m_output_file): ...this.
(diagnostic_output_format_init_sarif_file): Make "line_maps" param
non-const.  Gracefully handle "base_file_name" being NULL.
Construct the filename and open the file here, rather than in
~sarif_file_output_format, and handle failures immediately here,
rather than at the end of the compile.
* diagnostic-format-sarif.h: Include "diagnostic-output-file.h".
(diagnostic_output_format_init_sarif_file): Make "line_maps" param
non-const.
* diagnostic-output-file.h: New file.
* diagnostic.cc (diagnostic_context::emit_diagnostic): New.
(diagnostic_context::emit_diagnostic_va): New.
* diagnostic.h (diagnostic_context::emit_diagnostic): New decl.
(diagnostic_context::emit_diagnostic_va): New decl.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/diagnostic-format-sarif.cc | 57 +++-
 gcc/diagnostic-format-sarif.h  |  3 +-
 gcc/diagnostic-output-file.h   | 75 ++
 gcc/diagnostic.cc  | 41 +++
 gcc/diagnostic.h   | 13 
 5 files changed, 165 insertions(+), 24 deletions(-)

diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index aeba9f9ceef3..f053dec19205 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -1510,9 +1510,10 @@ sarif_builder::sarif_builder (diagnostic_context 
&context,
  since otherwise the "no diagnostics" case would quote the main input
  file, and doing so noticeably bloated the output seen in analyzer
  integration testing (build directory went from 20G -> 21G).  */
-  get_or_create_artifact (main_input_filename_,
- diagnostic_artifact_role::analysis_target,
- false);
+  if (main_input_filename_)
+get_or_create_artifact (main_input_filename_,
+   diagnostic_artifact_role::analysis_target,
+   false);
 }
 
 sarif_builder::~sarif_builder ()
@@ -3239,29 +3240,17 @@ public:
const char *main_input_filename_,
bool formatted,
enum sarif_version version,
-   const char *base_file_name)
+   diagnostic_output_file output_file)
   : sarif_output_format (context, line_maps, main_input_filename_,
 formatted, version),
-m_base_file_name (xstrdup (base_file_name))
+m_output_file (std::move (output_file))
   {
+gcc_assert (m_output_file.get_open_file ());
+gcc_assert (m_output_file.get_filename ());
   }
   ~sarif_file_output_format ()
   {
-char *filename = concat (m_base_file_name, ".sarif", nullptr);
-free (m_base_file_name);
-m_base_file_name = nullptr;
-FILE *outf = fopen (filename, "w");
-if (!outf)
-  {
-   const char *errstr = xstrerror (errno);
-   fnotice (stderr, "error: unable to open '%s' for writing: %s\n",
-filename, errstr);
-   free (filename);
-   return;
-  }
-m_builder.flush_to_file (outf);
-fclose (outf);
-free (filename);
+m_builder.flush_to_file (m_output_file.get_open_file ());
   }
   bool machine_readable_stderr_p () const final override
   {
@@ -3269,7 +3258,7 @@ public:
   }
 
 private:
-  char *m_base_file_name;
+  diagnostic_output_file m_output_file;
 };
 
 /* Print the start of an embedded link to PP, as per 3.11.6.  */
@@ -3435,13 +3