[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Nettoyage correction

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:25d531ca762f73c070684cf83f0087727709cab7

commit 25d531ca762f73c070684cf83f0087727709cab7
Author: Mikael Morin 
Date:   Tue Feb 4 15:30:43 2025 +0100

Nettoyage correction

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 1d3bb40a8383..9ea0f255a3ef 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -895,7 +895,7 @@ get_descriptor_init (tree type, gfc_typespec *ts, int rank,
   if (init.set_span ())
 {
   tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-  tree span_value = build_int_cst (TREE_TYPE (span_field), 0);
+  tree span_value = build_zero_cst (TREE_TYPE (span_field));
   CONSTRUCTOR_APPEND_ELT (v, span_field, span_value);
 }


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression allocate_with_source_15.f03

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:a4bd082c5ed576bf21547f822a5a653c19c2aa38

commit a4bd082c5ed576bf21547f822a5a653c19c2aa38
Author: Mikael Morin 
Date:   Tue Feb 4 12:19:20 2025 +0100

Correction régression allocate_with_source_15.f03

Diff:
---
 gcc/fortran/trans-array.cc | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 60ce464ee032..1d3bb40a8383 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -681,7 +681,7 @@ public:
   virtual bool set_span () const { return false; }
   virtual tree get_data_value () const { return NULL_TREE; }
   virtual bt get_type_type (const gfc_typespec &) const { return BT_UNKNOWN; }
-  virtual tree get_length (gfc_typespec &ts) const { return get_size_info 
(ts); }
+  virtual tree get_length (gfc_typespec *ts) const { return get_size_info 
(*ts); }
 };
 
 class nullification : public modify_info
@@ -742,27 +742,29 @@ public:
   virtual gfc_typespec *get_type () const { return &ts; }
 };
 
-class scalar_value : public init_info
+
+class scalar_value : public modify_info
 {
 private:
+  bool initialisation;
   gfc_typespec *ts;
   tree value;
   bool use_tree_type_;
   tree get_elt_type () const;
 
-
 public:
   scalar_value(gfc_typespec &arg_ts, tree arg_value)
-: ts(&arg_ts), value(arg_value), use_tree_type_ (false) { }
+: initialisation(true), ts(&arg_ts), value(arg_value), use_tree_type_ 
(false) { }
   scalar_value(tree arg_value)
-: ts(nullptr), value(arg_value), use_tree_type_ (true) { }
+: initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true) { }
+  virtual bool is_initialization () const { return initialisation; }
   virtual bool initialize_data () const { return true; }
   virtual tree get_data_value () const { return value; }
   virtual gfc_typespec *get_type () const { return ts; }
   virtual bool set_span () const { return true; }
   virtual bool use_tree_type () const { return use_tree_type_; }
   virtual bt get_type_type (const gfc_typespec &) const;
-  virtual tree get_length (gfc_typespec &ts) const;
+  virtual tree get_length (gfc_typespec *ts) const;
 };
 
 
@@ -799,7 +801,7 @@ scalar_value::get_type_type (const gfc_typespec & 
type_info) const
 }
 
 tree
-scalar_value::get_length (gfc_typespec & type_info) const
+scalar_value::get_length (gfc_typespec * type_info) const
 {
   bt n;
   tree size;
@@ -809,14 +811,14 @@ scalar_value::get_length (gfc_typespec & type_info) const
   gfc_get_type_info (etype, &n, &size);
 }
   else
-size = init_info::get_length (type_info);
+size = modify_info::get_length (type_info);
 
   return size;
 }
 
 
 static tree
-build_dtype (gfc_typespec &ts, int rank, const symbol_attribute &,
+build_dtype (gfc_typespec *ts, int rank, const symbol_attribute &,
 const init_info &init)
 {
   vec *v = nullptr;
@@ -827,16 +829,17 @@ build_dtype (gfc_typespec &ts, int rank, const 
symbol_attribute &,
 
   gfc_typespec *type_info = init.get_type ();
   if (type_info == nullptr)
-type_info = &ts;
+type_info = ts;
 
   if (!(init.is_initialization ()
+   && type_info
&& (type_info->type == BT_CLASS
|| (type_info->type == BT_CHARACTER
&& type_info->deferred
 {
   tree elem_len_field = gfc_advance_chain (fields, GFC_DTYPE_ELEM_LEN);
   tree elem_len_val = fold_convert (TREE_TYPE (elem_len_field),
-   init.get_length (*type_info));
+   init.get_length (type_info));
   CONSTRUCTOR_APPEND_ELT (v, elem_len_field, elem_len_val);
 }
 
@@ -877,13 +880,14 @@ get_descriptor_init (tree type, gfc_typespec *ts, int 
rank,
 {
   tree data_field = gfc_advance_chain (fields, DATA_FIELD);
   tree data_value = init.get_data_value ();
+  data_value = fold_convert (TREE_TYPE (data_field), data_value);
   CONSTRUCTOR_APPEND_ELT (v, data_field, data_value);
 }
 
   if (init.is_initialization ())
 {
   tree dtype_field = gfc_advance_chain (fields, DTYPE_FIELD);
-  tree dtype_value = build_dtype (*ts, rank, *attr,
+  tree dtype_value = build_dtype (ts, rank, *attr,
  static_cast (init));
   CONSTRUCTOR_APPEND_ELT (v, dtype_field, dtype_value);
 }
@@ -891,7 +895,8 @@ get_descriptor_init (tree type, gfc_typespec *ts, int rank,
   if (init.set_span ())
 {
   tree span_field = gfc_advance_chain (fields, SPAN_FIELD);
-  CONSTRUCTOR_APPEND_ELT (v, span_field, integer_zero_node);
+  tree span_value = build_int_cst (TREE_TYPE (span_field), 0);
+  CONSTRUCTOR_APPEND_ELT (v, span_field, span_value);
 }
 
   if (flag_coarray == GFC_FCOARRAY_LIB && attr->codimension)


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression assumed_rank_21.f90

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:41b07d9c969bfc99f07a33078feeddf4852d0bda

commit 41b07d9c969bfc99f07a33078feeddf4852d0bda
Author: Mikael Morin 
Date:   Tue Feb 4 17:03:58 2025 +0100

Correction régression assumed_rank_21.f90

Diff:
---
 gcc/fortran/trans-array.cc | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 8b34ca189f1e..6f582d34e53e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -759,7 +759,7 @@ public:
 : initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true) { }
   virtual bool is_initialization () const { return initialisation; }
   virtual bool initialize_data () const { return true; }
-  virtual tree get_data_value () const { return value; }
+  virtual tree get_data_value () const;
   virtual gfc_typespec *get_type () const { return ts; }
   virtual bool set_span () const { return true; }
   virtual bool use_tree_type () const { return use_tree_type_; }
@@ -768,6 +768,15 @@ public:
 };
 
 
+tree
+scalar_value::get_data_value () const
+{
+  if (POINTER_TYPE_P (TREE_TYPE (value)))
+return value;
+  else
+return gfc_build_addr_expr (NULL_TREE, value);
+}
+
 tree
 scalar_value::get_elt_type () const
 {


[gcc r14-11273] RTEMS: Add Cortex-M33 multilib

2025-02-04 Thread Sebastian Huber via Gcc-cvs
https://gcc.gnu.org/g:6a4df914f62dce69910724ee793cdffeef3ba1df

commit r14-11273-g6a4df914f62dce69910724ee793cdffeef3ba1df
Author: Sebastian Huber 
Date:   Tue Feb 4 04:09:02 2025 +0100

RTEMS: Add Cortex-M33 multilib

Enable use of Armv8-M instruction set.

Account for CVE-2021-35465 mitigation [PR102035].
The -mfix-cmse-cve-2021-35465 option is enabled by default,
if -mcpu=cortex-m33 is used.

gcc/

* config/arm/t-rtems: Add Cortex-M33 multilib.

(cherry picked from commit f2a8f3c364a0d196efb0687ea421190b46d041d5)

Diff:
---
 gcc/config/arm/t-rtems | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/t-rtems b/gcc/config/arm/t-rtems
index b2fcf572bca9..797640bd4f45 100644
--- a/gcc/config/arm/t-rtems
+++ b/gcc/config/arm/t-rtems
@@ -17,8 +17,8 @@ MULTILIB_DIRNAMES += eb
 MULTILIB_OPTIONS   += mthumb
 MULTILIB_DIRNAMES  += thumb
 
-MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
-MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m4  cortex-m4+nofp  cortex-m7
+MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m33/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
+MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m33  cortex-m4  cortex-m4+nofp  cortex-m7
 
 MULTILIB_OPTIONS   += mfloat-abi=hard
 MULTILIB_DIRNAMES  += hard
@@ -33,6 +33,7 @@ MULTILIB_REQUIRED += 
mthumb/march=armv7-r+fp/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/march=armv7-r
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-r52/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m3
+MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m33
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4+nofp
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m7/mfloat-abi=hard


[gcc r15-7365] Fortran: Fix PR 47485.

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

commit r15-7365-ge41a5a2a0832509fa1c0b7cab0c8001fadbd23d4
Author: Jerry DeLisle 
Date:   Tue Feb 4 17:21:42 2025 -0800

Fortran: Fix PR 47485.

The -MT and -MQ options should replace the default target in the
generated dependency file. deps_add_target needs to be called before
cpp_read_main_file, otherwise the original object name is added.

Contributed by Vincent Vanlaer 

PR fortran/47485

gcc/fortran/ChangeLog:

* cpp.cc: fix -MT/-MQ adding additional target instead of
replacing the default.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Vincent Vanlaer 

Diff:
---
 gcc/fortran/cpp.cc| 18 --
 gcc/testsuite/gfortran.dg/dependency_generation_1.f90 | 15 +++
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc
index 69567995b6a8..1b7042056460 100644
--- a/gcc/fortran/cpp.cc
+++ b/gcc/fortran/cpp.cc
@@ -96,6 +96,8 @@ struct gfc_cpp_option_data
   int deps_skip_system; /* -MM */
   const char *deps_filename;/* -M[M]D */
   const char *deps_filename_user;   /* -MF  */
+  const char *deps_target_filename; /* -MT / -MQ  */
+  bool quote_deps_target_filename;  /* -MQ */
   int deps_missing_are_generated;   /* -MG */
   int deps_phony;   /* -MP */
   int warn_date_time;   /* -Wdate-time */
@@ -287,6 +289,8 @@ gfc_cpp_init_options (unsigned int decoded_options_count,
   gfc_cpp_option.deps_missing_are_generated = 0;
   gfc_cpp_option.deps_filename = NULL;
   gfc_cpp_option.deps_filename_user = NULL;
+  gfc_cpp_option.deps_target_filename = NULL;
+  gfc_cpp_option.quote_deps_target_filename = false;
 
   gfc_cpp_option.multilib = NULL;
   gfc_cpp_option.prefix = NULL;
@@ -439,9 +443,8 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int 
value ATTRIBUTE_UNUSED
 
 case OPT_MQ:
 case OPT_MT:
-  gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].code = 
code;
-  gfc_cpp_option.deferred_opt[gfc_cpp_option.deferred_opt_count].arg = arg;
-  gfc_cpp_option.deferred_opt_count++;
+  gfc_cpp_option.quote_deps_target_filename = (code == OPT_MQ);
+  gfc_cpp_option.deps_target_filename = arg;
   break;
 
 case OPT_P:
@@ -593,6 +596,12 @@ gfc_cpp_init_0 (void)
 }
 
   gcc_assert(cpp_in);
+
+  if (gfc_cpp_option.deps_target_filename)
+if (mkdeps *deps = cpp_get_deps (cpp_in))
+  deps_add_target (deps, gfc_cpp_option.deps_target_filename,
+  gfc_cpp_option.quote_deps_target_filename);
+
   if (!cpp_read_main_file (cpp_in, gfc_source_file))
 errorcount++;
 }
@@ -635,9 +644,6 @@ gfc_cpp_init (void)
  else
cpp_assert (cpp_in, opt->arg);
}
-  else if (opt->code == OPT_MT || opt->code == OPT_MQ)
-   if (mkdeps *deps = cpp_get_deps (cpp_in))
- deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
 }
 
   /* Pre-defined macros for non-required INTEGER kind types.  */
diff --git a/gcc/testsuite/gfortran.dg/dependency_generation_1.f90 
b/gcc/testsuite/gfortran.dg/dependency_generation_1.f90
new file mode 100644
index ..d42a257f83a8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependency_generation_1.f90
@@ -0,0 +1,15 @@
+! This test case ensures that the -MT flag is correctly replacing the object 
name in the dependency file.
+! See PR 47485
+!
+! Contributed by Vincent Vanlaer 
+!
+! { dg-do preprocess }
+! { dg-additional-options "-cpp" }
+! { dg-additional-options "-M" }
+! { dg-additional-options "-MF deps" }
+! { dg-additional-options "-MT obj.o" }
+
+module test
+end module
+
+! { dg-final { scan-file "deps" "obj.o:.*" } }


[gcc r15-7364] RTEMS: Add Cortex-M33 multilib

2025-02-04 Thread Sebastian Huber via Gcc-cvs
https://gcc.gnu.org/g:f2a8f3c364a0d196efb0687ea421190b46d041d5

commit r15-7364-gf2a8f3c364a0d196efb0687ea421190b46d041d5
Author: Sebastian Huber 
Date:   Tue Feb 4 04:09:02 2025 +0100

RTEMS: Add Cortex-M33 multilib

Enable use of Armv8-M instruction set.

Account for CVE-2021-35465 mitigation [PR102035].
The -mfix-cmse-cve-2021-35465 option is enabled by default,
if -mcpu=cortex-m33 is used.

gcc/

* config/arm/t-rtems: Add Cortex-M33 multilib.

Diff:
---
 gcc/config/arm/t-rtems | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/t-rtems b/gcc/config/arm/t-rtems
index b2fcf572bca9..797640bd4f45 100644
--- a/gcc/config/arm/t-rtems
+++ b/gcc/config/arm/t-rtems
@@ -17,8 +17,8 @@ MULTILIB_DIRNAMES += eb
 MULTILIB_OPTIONS   += mthumb
 MULTILIB_DIRNAMES  += thumb
 
-MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
-MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m4  cortex-m4+nofp  cortex-m7
+MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m33/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
+MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m33  cortex-m4  cortex-m4+nofp  cortex-m7
 
 MULTILIB_OPTIONS   += mfloat-abi=hard
 MULTILIB_DIRNAMES  += hard
@@ -33,6 +33,7 @@ MULTILIB_REQUIRED += 
mthumb/march=armv7-r+fp/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/march=armv7-r
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-r52/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m3
+MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m33
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4+nofp
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m7/mfloat-abi=hard


[gcc r13-9364] RTEMS: Add Cortex-M33 multilib

2025-02-04 Thread Sebastian Huber via Gcc-cvs
https://gcc.gnu.org/g:e6f526ba6f580a94faf4ad47b16df7c8bf3bfd41

commit r13-9364-ge6f526ba6f580a94faf4ad47b16df7c8bf3bfd41
Author: Sebastian Huber 
Date:   Tue Feb 4 04:09:02 2025 +0100

RTEMS: Add Cortex-M33 multilib

Enable use of Armv8-M instruction set.

Account for CVE-2021-35465 mitigation [PR102035].
The -mfix-cmse-cve-2021-35465 option is enabled by default,
if -mcpu=cortex-m33 is used.

gcc/

* config/arm/t-rtems: Add Cortex-M33 multilib.

(cherry picked from commit f2a8f3c364a0d196efb0687ea421190b46d041d5)

Diff:
---
 gcc/config/arm/t-rtems | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/t-rtems b/gcc/config/arm/t-rtems
index b2fcf572bca9..797640bd4f45 100644
--- a/gcc/config/arm/t-rtems
+++ b/gcc/config/arm/t-rtems
@@ -17,8 +17,8 @@ MULTILIB_DIRNAMES += eb
 MULTILIB_OPTIONS   += mthumb
 MULTILIB_DIRNAMES  += thumb
 
-MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
-MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m4  cortex-m4+nofp  cortex-m7
+MULTILIB_OPTIONS   += 
march=armv5te+fp/march=armv6-m/march=armv7-a/march=armv7-a+simd/march=armv7-r/march=armv7-r+fp/mcpu=cortex-r52/mcpu=cortex-m3/mcpu=cortex-m33/mcpu=cortex-m4/mcpu=cortex-m4+nofp/mcpu=cortex-m7
+MULTILIB_DIRNAMES  += armv5te+fp   armv6-m   armv7-a   
armv7-a+simd   armv7-r   armv7-r+fp   cortex-r52  cortex-m3 
 cortex-m33  cortex-m4  cortex-m4+nofp  cortex-m7
 
 MULTILIB_OPTIONS   += mfloat-abi=hard
 MULTILIB_DIRNAMES  += hard
@@ -33,6 +33,7 @@ MULTILIB_REQUIRED += 
mthumb/march=armv7-r+fp/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/march=armv7-r
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-r52/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m3
+MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m33
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4/mfloat-abi=hard
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m4+nofp
 MULTILIB_REQUIRED  += mthumb/mcpu=cortex-m7/mfloat-abi=hard


[gcc/redhat/heads/gcc-15-branch] (46 commits) Merge commit 'r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72a

2025-02-04 Thread Jakub Jelinek via Gcc-cvs
The branch 'redhat/heads/gcc-15-branch' was updated to point to:

 785011ff892f... Merge commit 'r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72a

It previously pointed to:

 3e0244fe1959... Merge commit 'r15-7314-gd3ba88308426b3db55793831b0ae8c760aa

Diff:

Summary of changes (added commits):
---

  785011f... Merge commit 'r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72a
  64c66f5... Ada: Fix assertion failure with iterator in container aggre (*)
  88c9c4a... testsuite: RISC-V: Ignore pr118170.c for E ABI (*)
  a506abf... Fix file cache tunables documentation (*)
  bcd3886... arm: testsuite: Adapt mve-vabs.c to improved codegen (*)
  e6e40cb... c++: auto in trailing-return-type in parameter [PR117778] (*)
  53d1f6c... c++: bogus -Wvexing-parse with trailing-return-type [PR1187 (*)
  adf1da7... testsuite: XFAIL test in pr109393.c for ilp32 targets [PR11 (*)
  4c8c9c9... c/118742 - gimple FE parsing of unary operators of C promot (*)
  a2e0a30... IBM zSystems: Do not use @PLT with larl (*)
  d346af2... c++: Fix overeager Woverloaded-virtual with conversion oper (*)
  0675eb1... tree-optimization/117113 - ICE with unroll-and-jam (*)
  887bdab... c++: Properly detect calls to digest_init in build_vec_init (*)
  4b2726a... c++: Fix up pedwarn for capturing structured bindings in la (*)
  4c98b38... optabs: Fix widening optabs for vec-mode -> scalar-mode [PR (*)
  c2a0ee5... Add modular exponentiation for UNSIGNED. (*)
  5b46c01... rtl-optimization/117611 - ICE in simplify_shift_const_1 (*)
  a55e14b... lto/113207 - fix free_lang_data_in_type (*)
  d3627c7... c++: Improve contracts support in modules [PR108205] (*)
  736e8ee... c++: Modularise start_cleanup_fn [PR98893] (*)
  a5b54be... Daily bump. (*)
  26d3424... c++: find A pack from B in ...B> [PR1 (*)
  4c74379... c++/coroutines: Fix awaiter var creation [PR116506] (*)
  ec716ad... c++: coroutines and range for [PR118491] (*)
  f3a41e6... Fortran: different character lengths in array constructor [ (*)
  214224c... i386: Fix and improve TARGET_INDIRECT_BRANCH_REGISTER handl (*)
  606527f... aarch64: Fix dupq_* testsuite failures (*)
  88bb18c... hppa: Revise various millicode insn patterns to use match_o (*)
  6ec1982... c++/79786 - bougs invocation of DATA_ABI_ALIGNMENT macro (*)
  fbcbbfe... tree-optimization/118717 - store commoning vs. abnormals (*)
  75ab30f... Add a unit test for random access in the file cache (*)
  baf26fc... Size input line cache based on file size (*)
  33acec6... Remove m_total_lines support from input cache (*)
  4a992ec... Rebalance file_cache input line cache dynamically (*)
  ae814af... Add tunables for input buffer (*)
  6fef385... Daily bump. (*)
  969c308... PR modula2/117411 Request for documentation to include exce (*)
  c0008df... options: Adjust cl_optimization_compare to avoid checking I (*)
  427b871... Daily bump. (*)
  e8262c9... x86: Add a test for PR rtl-optimization/111673 (*)
  dceec9e... x86: Change "if (TARGET_X32 ...)" back to "else if (TARGET_ (*)
  e2d32c8... PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr (*)
  dd6247c... x86: Handle TARGET_INDIRECT_BRANCH_REGISTER for -fno-plt (*)
  cf24c0f... sarif-replay: support "cached" logical locations [§3.33.3] (*)
  8ca6bbf... Ada: Fix segfault on uninitialized variable as operand of p (*)
  b38efaf... x86: Add a -mstack-protector-guard=global test (*)

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


[gcc] Created branch 'majin/heads/master' in namespace 'refs/users'

2025-02-04 Thread Ma Jin via Gcc-cvs
The branch 'majin/heads/master' was created in namespace 'refs/users' pointing 
to:

 d0acb7b2b26d... PR modula2/118010 m2 libc lseek procedure interface correct


[gcc] Created branch 'majin/heads/dev' in namespace 'refs/users'

2025-02-04 Thread Ma Jin via Gcc-cvs
The branch 'majin/heads/dev' was created in namespace 'refs/users' pointing to:

 d0acb7b2b26d... PR modula2/118010 m2 libc lseek procedure interface correct


[gcc r15-7366] fortran/trans-openmp.cc: Use the correct member in gfc_omp_namelist [PR118745]

2025-02-04 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:3a5882707df50ed29905b3c47cbaa0868ea248c9

commit r15-7366-g3a5882707df50ed29905b3c47cbaa0868ea248c9
Author: Tobias Burnus 
Date:   Wed Feb 5 08:44:41 2025 +0100

fortran/trans-openmp.cc: Use the correct member in gfc_omp_namelist 
[PR118745]

gcc/fortran/ChangeLog:

PR fortran/118745
* trans-openmp.cc (gfc_trans_omp_declare_variant): Use
append_args_list in the condition for the append_arg location.

Diff:
---
 gcc/fortran/trans-openmp.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index a593f5a8e5e9..e29ef85ae398 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -8839,7 +8839,7 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
last_arg->next = extra_arg;
  else if (extra_arg)
variant_proc_sym->formal = extra_arg;
- locus *loc = (odv->adjust_args_list
+ locus *loc = (odv->append_args_list
? &odv->append_args_list->where :  &odv->where);
  int nextra_arg = 0;
  for (; extra_arg; extra_arg = extra_arg->next)


[gcc/majin/heads/master] (160 commits) Fortran: Fix PR 47485.

2025-02-04 Thread Ma Jin via Gcc-cvs
The branch 'majin/heads/master' was updated to point to:

 e41a5a2a0832... Fortran: Fix PR 47485.

It previously pointed to:

 d0acb7b2b26d... PR modula2/118010 m2 libc lseek procedure interface correct

Diff:

Summary of changes (added commits):
---

  e41a5a2... Fortran: Fix PR 47485. (*)
  f2a8f3c... RTEMS: Add Cortex-M33 multilib (*)
  432f988... Daily bump. (*)
  4d0faaa... PR modula2/115112 Incorrect line debugging information occu (*)
  f176028... c++: add fixed test [PR94100] (*)
  a64d9c9... c++: Fix ICE with #embed/RAW_DATA_CST after list conversion (*)
  64c66f5... Ada: Fix assertion failure with iterator in container aggre (*)
  88c9c4a... testsuite: RISC-V: Ignore pr118170.c for E ABI (*)
  a506abf... Fix file cache tunables documentation (*)
  bcd3886... arm: testsuite: Adapt mve-vabs.c to improved codegen (*)
  e6e40cb... c++: auto in trailing-return-type in parameter [PR117778] (*)
  53d1f6c... c++: bogus -Wvexing-parse with trailing-return-type [PR1187 (*)
  adf1da7... testsuite: XFAIL test in pr109393.c for ilp32 targets [PR11 (*)
  4c8c9c9... c/118742 - gimple FE parsing of unary operators of C promot (*)
  a2e0a30... IBM zSystems: Do not use @PLT with larl (*)
  d346af2... c++: Fix overeager Woverloaded-virtual with conversion oper (*)
  0675eb1... tree-optimization/117113 - ICE with unroll-and-jam (*)
  887bdab... c++: Properly detect calls to digest_init in build_vec_init (*)
  4b2726a... c++: Fix up pedwarn for capturing structured bindings in la (*)
  4c98b38... optabs: Fix widening optabs for vec-mode -> scalar-mode [PR (*)
  c2a0ee5... Add modular exponentiation for UNSIGNED. (*)
  5b46c01... rtl-optimization/117611 - ICE in simplify_shift_const_1 (*)
  a55e14b... lto/113207 - fix free_lang_data_in_type (*)
  d3627c7... c++: Improve contracts support in modules [PR108205] (*)
  736e8ee... c++: Modularise start_cleanup_fn [PR98893] (*)
  a5b54be... Daily bump. (*)
  26d3424... c++: find A pack from B in ...B> [PR1 (*)
  4c74379... c++/coroutines: Fix awaiter var creation [PR116506] (*)
  ec716ad... c++: coroutines and range for [PR118491] (*)
  f3a41e6... Fortran: different character lengths in array constructor [ (*)
  214224c... i386: Fix and improve TARGET_INDIRECT_BRANCH_REGISTER handl (*)
  606527f... aarch64: Fix dupq_* testsuite failures (*)
  88bb18c... hppa: Revise various millicode insn patterns to use match_o (*)
  6ec1982... c++/79786 - bougs invocation of DATA_ABI_ALIGNMENT macro (*)
  fbcbbfe... tree-optimization/118717 - store commoning vs. abnormals (*)
  75ab30f... Add a unit test for random access in the file cache (*)
  baf26fc... Size input line cache based on file size (*)
  33acec6... Remove m_total_lines support from input cache (*)
  4a992ec... Rebalance file_cache input line cache dynamically (*)
  ae814af... Add tunables for input buffer (*)
  6fef385... Daily bump. (*)
  969c308... PR modula2/117411 Request for documentation to include exce (*)
  c0008df... options: Adjust cl_optimization_compare to avoid checking I (*)
  427b871... Daily bump. (*)
  e8262c9... x86: Add a test for PR rtl-optimization/111673 (*)
  dceec9e... x86: Change "if (TARGET_X32 ...)" back to "else if (TARGET_ (*)
  e2d32c8... PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr (*)
  dd6247c... x86: Handle TARGET_INDIRECT_BRANCH_REGISTER for -fno-plt (*)
  cf24c0f... sarif-replay: support "cached" logical locations [§3.33.3] (*)
  8ca6bbf... Ada: Fix segfault on uninitialized variable as operand of p (*)
  b38efaf... x86: Add a -mstack-protector-guard=global test (*)
  d3ba883... Daily bump. (*)
  2c0a9b7... [committed][PR tree-optimization/114277] Fix missed optimiz (*)
  ebd111a... icf: Compare call argument types in certain cases and asm o (*)
  6141fd5... c++: check_flexarray fixes [PR117516] (*)
  a9172b1... libstdc++: Fix flat_foo::insert_range for non-common ranges (*)
  ee79773... libstdc++: Fix return value of vector::insert_range (*)
  d6418fe... Fortran: host association issue with symbol in COMMON block (*)
  af51fe9... OpenMP/Fortran: Add missing pop_state in parse_omp_dispatch (*)
  0d97700... c++: wrong-code with consteval constructor [PR117501] (*)
  decc6c0... [PR116234][LRA]: Check debug insn when looking at one insn  (*)
  3b49727... Fix wrong elaboration for allocator at library level of dyn (*)
  9fc0683... testsuite: Add testcase for already fixed PR [PR117498] (*)
  5f34558... force-indirect-call-2.c: Allow indirect branch via GOT (*)
  319f1d0... debug/100530 - Revert QUAL_ADDR_SPACE handling from dwarf2o (*)
  85e1714... niter: Make build_cltz_expr more robust [PR118689] (*)
  9e3ceed... Do not rely on non-SLP analysis for SLP outer loop vectoriz (*)
  c8cc686... Daily bump. (*)
  5d43c3f... libbacktrace: add casts to avoid undefined shifts (*)
  dd5978b... [testsuite] require profiling support [PR113689] (*)
  2ca288d... [testsuite] require -Ofast for vect-ifcvt-18 even without a (*)
  1e819a9... AVR: Provide built-ins 

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression allocate_with_mold_3

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:6ba496df0b27b84f7080726e57bfaaec54ce9e01

commit 6ba496df0b27b84f7080726e57bfaaec54ce9e01
Author: Mikael Morin 
Date:   Tue Feb 4 15:58:37 2025 +0100

Correction régression allocate_with_mold_3

Diff:
---
 gcc/fortran/trans-array.cc | 7 +++
 gcc/fortran/trans-types.cc | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 9ea0f255a3ef..cfc9ab95d863 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -807,6 +807,13 @@ scalar_value::get_length (gfc_typespec * type_info) const
   tree size;
   if (use_tree_type ())
 {
+  if (TREE_CODE (value) == COMPONENT_REF)
+   {
+ tree parent_obj = TREE_OPERAND (value, 0);
+ if (GFC_CLASS_TYPE_P (TREE_TYPE (parent_obj)))
+   return gfc_class_len_get (parent_obj);
+   }
+
   tree etype = get_elt_type ();
   gfc_get_type_info (etype, &n, &size);
 }
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 5f8100b9d45e..83d35236c19d 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1742,6 +1742,9 @@ gfc_get_type_info (tree etype, bt *type, tree *psize)
   if (type)
 *type = n;
 
+  if (psize == nullptr)
+return;
+
   switch (n)
 {
 case BT_CHARACTER:


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction allocate_with_source_16.f90

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:488b4bb00455438400780bad3a8c7c86a6597db0

commit 488b4bb00455438400780bad3a8c7c86a6597db0
Author: Mikael Morin 
Date:   Tue Feb 4 16:18:27 2025 +0100

Correction allocate_with_source_16.f90

Diff:
---
 gcc/fortran/trans-array.cc |  6 --
 gcc/fortran/trans-expr.cc  | 42 +++---
 gcc/fortran/trans.h|  1 +
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index cfc9ab95d863..8b34ca189f1e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -810,8 +810,10 @@ scalar_value::get_length (gfc_typespec * type_info) const
   if (TREE_CODE (value) == COMPONENT_REF)
{
  tree parent_obj = TREE_OPERAND (value, 0);
- if (GFC_CLASS_TYPE_P (TREE_TYPE (parent_obj)))
-   return gfc_class_len_get (parent_obj);
+ tree len;
+ if (GFC_CLASS_TYPE_P (TREE_TYPE (parent_obj))
+ && gfc_class_len_get (parent_obj, &len))
+   return len;
}
 
   tree etype = get_elt_type ();
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index f514edd32bae..39bd7178c3c0 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -310,8 +310,8 @@ gfc_class_vptr_get (tree decl)
 }
 
 
-tree
-gfc_class_len_get (tree decl)
+bool
+gfc_class_len_get (tree decl, tree * result)
 {
   tree len;
   /* For class arrays decl may be a temporary descriptor handle, the len is
@@ -323,9 +323,22 @@ gfc_class_len_get (tree decl)
 decl = build_fold_indirect_ref_loc (input_location, decl);
   len = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (decl)),
   CLASS_LEN_FIELD);
-  return fold_build3_loc (input_location, COMPONENT_REF,
- TREE_TYPE (len), decl, len,
- NULL_TREE);
+  if (len == NULL_TREE)
+return false;
+
+  *result = fold_build3_loc (input_location, COMPONENT_REF,
+TREE_TYPE (len), decl, len,
+NULL_TREE);
+  return true;
+}
+
+
+tree
+gfc_class_len_get (tree decl)
+{
+  tree result;
+  gfc_class_len_get (decl, &result);
+  return result;
 }
 
 
@@ -335,20 +348,11 @@ gfc_class_len_get (tree decl)
 static tree
 gfc_class_len_or_zero_get (tree decl)
 {
-  tree len;
-  /* For class arrays decl may be a temporary descriptor handle, the vptr is
- then available through the saved descriptor.  */
-  if (VAR_P (decl) && DECL_LANG_SPECIFIC (decl)
-  && GFC_DECL_SAVED_DESCRIPTOR (decl))
-decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
-  if (POINTER_TYPE_P (TREE_TYPE (decl)))
-decl = build_fold_indirect_ref_loc (input_location, decl);
-  len = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (decl)),
-  CLASS_LEN_FIELD);
-  return len != NULL_TREE ? fold_build3_loc (input_location, COMPONENT_REF,
-TREE_TYPE (len), decl, len,
-NULL_TREE)
-: build_zero_cst (gfc_charlen_type_node);
+  tree result;
+  if (gfc_class_len_get (decl, &result))
+return result;
+  else
+return build_zero_cst (gfc_charlen_type_node);
 }
 
 
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index e9a9c24db0cd..e2bfd0013a6e 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -430,6 +430,7 @@ gfc_wrapped_block;
 tree gfc_class_set_static_fields (tree, tree, tree);
 tree gfc_class_data_get (tree);
 tree gfc_class_vptr_get (tree);
+bool gfc_class_len_get (tree, tree *);
 tree gfc_class_len_get (tree);
 tree gfc_resize_class_size_with_len (stmtblock_t *, tree, tree);
 gfc_expr * gfc_find_and_cut_at_last_class_ref (gfc_expr *, bool is_mold = 
false,


[gcc r15-7356] arm: testsuite: Adapt mve-vabs.c to improved codegen

2025-02-04 Thread Thiago Bauermann via Gcc-cvs
https://gcc.gnu.org/g:bcd3886e6692ba4b7127debcdfe4890199ec9e54

commit r15-7356-gbcd3886e6692ba4b7127debcdfe4890199ec9e54
Author: Thiago Jung Bauermann 
Date:   Sun Feb 2 16:46:07 2025 -0300

arm: testsuite: Adapt mve-vabs.c to improved codegen

Since commit r15-491-gc290e6a0b7a9de this failure happens on
armv8l-linux-gnueabihf and arm-eabi:

Running gcc:gcc.target/arm/simd/simd.exp ...
gcc.target/arm/simd/mve-vabs.c: memmove found 0 times
FAIL: gcc.target/arm/simd/mve-vabs.c scan-assembler-times memmove 3

In PR PR target/116010, Andrew Pinski noted that
"gcc.target/arm/simd/mve-vabs.c now calls memcpy because of the restrict
instead of memmove. That should be a simple fix there."

Therefore change the test to expect memcpy rather than memmove.

Another change is that memcpy is inlined rather than called, so also change
the test to check the optimized tree dump rather than the generated
assembly.

Tested on armv8l-linux-gnueabihf and arm-eabi.

gcc/testsuite/ChangeLog:
PR target/116010
* gcc.target/arm/simd/mve-vabs.c: Test tree dump and adjust to new
code.

Suggested-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/gcc.target/arm/simd/mve-vabs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c 
b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
index f2f9ee349906..e85d0b18ee71 100644
--- a/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
+++ b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c
@@ -1,7 +1,7 @@
 /* { dg-do assemble } */
 /* { dg-require-effective-target arm_v8_1m_mve_fp_ok } */
 /* { dg-add-options arm_v8_1m_mve_fp } */
-/* { dg-additional-options "-O3 -funsafe-math-optimizations" } */
+/* { dg-additional-options "-O3 -funsafe-math-optimizations 
-fdump-tree-optimized" } */
 
 #include 
 #include 
@@ -35,10 +35,10 @@ FUNC_FLOAT(f, float, 32, 4, vabs)
 FUNC(f, float, 16, 8, vabs)
 
 /* Taking the absolute value of an unsigned value is a no-op, so half of the
-   integer optimizations actually generate a call to memmove, the other ones a
+   integer optimizations actually generate a call to memcpy, the other ones a
'vabs'.  */
 /* { dg-final { scan-assembler-times {vabs.s[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */
 /* { dg-final { scan-assembler-times {vabs.f[0-9]+\tq[0-9]+, q[0-9]+} 2 } } */
 /* { dg-final { scan-assembler-times {vldr[bhw].[0-9]+\tq[0-9]+} 5 } } */
 /* { dg-final { scan-assembler-times {vstr[bhw].[0-9]+\tq[0-9]+} 5 } } */
-/* { dg-final { scan-assembler-times {memmove} 3 } } */
+/* { dg-final { scan-tree-dump-times "memcpy" 3 "optimized" } } */


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction coarray_allocate_8.f08

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0d6f58c63178f7166aa5e5ef48fd2c4a0a35eb7e

commit 0d6f58c63178f7166aa5e5ef48fd2c4a0a35eb7e
Author: Mikael Morin 
Date:   Tue Feb 4 17:42:38 2025 +0100

Correction coarray_allocate_8.f08

Diff:
---
 gcc/fortran/trans-array.cc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 6f582d34e53e..f3322af9157c 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -923,7 +923,10 @@ get_descriptor_init (tree type, gfc_typespec *ts, int rank,
 after leaving the scope.  It may still be accessed through another
 image.  This may happen, for example, with the caf_mpi
 implementation.  */
-  tree token_field = gfc_advance_chain (fields, CAF_TOKEN_FIELD);
+  bool dim_present = GFC_TYPE_ARRAY_RANK (type) > 0
+|| GFC_TYPE_ARRAY_CORANK (type) > 0;
+  tree token_field = gfc_advance_chain (fields,
+   CAF_TOKEN_FIELD - (!dim_present));
   tree token_value = fold_convert (TREE_TYPE (token_field),
   null_pointer_node);
   CONSTRUCTOR_APPEND_ELT (v, token_field, token_value);


[gcc r15-7357] Fix file cache tunables documentation

2025-02-04 Thread Andi Kleen via Gcc-cvs
https://gcc.gnu.org/g:a506abfa07bbc4298bf6a2d73e25051c8496dc46

commit r15-7357-ga506abfa07bbc4298bf6a2d73e25051c8496dc46
Author: Andi Kleen 
Date:   Tue Feb 4 08:42:36 2025 -0800

Fix file cache tunables documentation

Document new params in invoke.texi.

The auto tuning description was on the wrong tunable, move to lines.

Comitted as obvious.

gcc/ChangeLog:

* doc/invoke.texi: Document file cache tunables.
* params.opt: Move auto tuning description to lines.

Diff:
---
 gcc/doc/invoke.texi | 10 ++
 gcc/params.opt  |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e54a287d..9050ffa59dd0 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -13010,6 +13010,16 @@ having large chains of nested wrapper functions.
 
 Enabled by default.
 
+@item -ffile-cache-files=
+Max number of files in the file cache.
+The file cache is used to print source lines in diagnostics and do some
+source checks like @option{-Wmisleading-indentation}.
+
+@item -ffile-cache-files=
+Max number of lines to index into file cache. When 0 this is automatically 
sized.
+The file cache is used to print source lines in diagnostics and do some
+source checks like @option{-Wmisleading-indentation}.
+
 @opindex fipa-sra
 @item -fipa-sra
 Perform interprocedural scalar replacement of aggregates, removal of
diff --git a/gcc/params.opt b/gcc/params.opt
index d84e35679e6d..4f4eb4d7a2a5 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -136,11 +136,11 @@ Maximal estimated growth of function body caused by early 
inlining of single cal
 
 -param=file-cache-files=
 Common Joined UInteger Var(param_file_cache_files) Init(16) Param
-Max number of files in the file cache. When 0 this is automatically sized.
+Max number of files in the file cache.
 
 -param=file-cache-lines=
 Common Joined UInteger Var(param_file_cache_lines) Init(0) Param
-Max number of lines to index into file cache.
+Max number of lines to index into file cache. When 0 this is automatically 
sized.
 
 -param=fsm-scale-path-stmts=
 Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(2) IntegerRange(1, 
10) Param Optimization


[gcc r15-7346] optabs: Fix widening optabs for vec-mode -> scalar-mode [PR116926]

2025-02-04 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:4c98b3825f99fcec8fd921550e2dc45f2d966cbb

commit r15-7346-g4c98b3825f99fcec8fd921550e2dc45f2d966cbb
Author: Andrew Pinski 
Date:   Mon Feb 3 19:58:45 2025 -0800

optabs: Fix widening optabs for vec-mode -> scalar-mode [PR116926]

r15-4317-ga6f4404689f12 tried to add support for widending optabs
for vec-mode -> scalar-mode but it misunderstood how FOR_EACH_MODE worked,
the limit in this case is not inclusive. Which means setting limit to from,
would cause the loop not be executed at all. This fixes by setting the
limit to be the next mode after from mode.

Note the original version that added the widening optabs for vec-mode -> 
scalar-mode
(https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665021.html) didn't 
have this
bug, only the second version with suggested change
(https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665068.html) dud. 
The suggested
change missed this issue with FOR_EACH_MODE.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116926

gcc/ChangeLog:

* optabs-query.cc (find_widening_optab_handler_and_mode): Fix
limit for `vec-mode -> scalar-mode` case.

Signed-off-by: Andrew Pinski 

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

diff --git a/gcc/optabs-query.cc b/gcc/optabs-query.cc
index 65eeb5d8e519..f5ca98da818a 100644
--- a/gcc/optabs-query.cc
+++ b/gcc/optabs-query.cc
@@ -492,7 +492,7 @@ find_widening_optab_handler_and_mode (optab op, 
machine_mode to_mode,
 {
   gcc_checking_assert (VECTOR_MODE_P (from_mode)
   && GET_MODE_INNER (from_mode) < to_mode);
-  limit_mode = from_mode;
+  limit_mode = GET_MODE_NEXT_MODE (from_mode).require ();
 }
   else
 gcc_checking_assert (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)


[gcc r15-7347] c++: Fix up pedwarn for capturing structured bindings in lambdas [PR118719]

2025-02-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:4b2726a62ddfe958302d6790725503ac09b28f11

commit r15-7347-g4b2726a62ddfe958302d6790725503ac09b28f11
Author: Jakub Jelinek 
Date:   Tue Feb 4 09:23:15 2025 +0100

c++: Fix up pedwarn for capturing structured bindings in lambdas [PR118719]

As mentioned in the PR, this pedwarni is desirable for the implicit or
explicit capturing of structured bindings in C++17, but in the case of
init-captures the initializer is just some expression and that can include
structured bindings.

So, the following patch limits the warning to non-explicit_init_p.

2025-02-04  Jakub Jelinek  

PR c++/118719
* lambda.cc (add_capture): Only pedwarn about capturing structured
binding if !explicit_init_p.

* g++.dg/cpp1z/decomp63.C: New test.

Diff:
---
 gcc/cp/lambda.cc  |  2 +-
 gcc/testsuite/g++.dg/cpp1z/decomp63.C | 18 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
index 5593636eaf8e..2d86e9892f99 100644
--- a/gcc/cp/lambda.cc
+++ b/gcc/cp/lambda.cc
@@ -613,7 +613,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool 
by_reference_p,
return error_mark_node;
}
 
-  if (cxx_dialect < cxx20)
+  if (cxx_dialect < cxx20 && !explicit_init_p)
{
  auto_diagnostic_group d;
  tree stripped_init = tree_strip_any_location_wrapper (initializer);
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp63.C 
b/gcc/testsuite/g++.dg/cpp1z/decomp63.C
new file mode 100644
index ..50049255efb1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp63.C
@@ -0,0 +1,18 @@
+// PR c++/118719
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int
+main ()
+{
+  int a[] = { 42 };
+  auto [x] = a;// { dg-warning 
"structured bindings only available with" "" { target c++14_down } }
+   // { dg-message "declared here" 
"" { target c++17_down } .-1 }
+  [=] () { int b = x; (void) b; }; // { dg-warning "captured 
structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [&] () { int b = x; (void) b; }; // { dg-warning "captured 
structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [x] () { int b = x; (void) b; }; // { dg-warning "captured 
structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [&x] () { int b = x; (void) b; };// { dg-warning "captured 
structured bindings are a C\\\+\\\+20 extension" "" { target c++17_down } }
+  [x = x] () { int b = x; (void) b; }; // { dg-warning "lambda capture 
initializers only available with" "" { target c++11_only } }
+  [y = x] () { int b = y; (void) b; }; // { dg-warning "lambda capture 
initializers only available with" "" { target c++11_only } }
+  [y = x * 2] () { int b = y; (void) b; }; // { dg-warning "lambda capture 
initializers only available with" "" { target c++11_only } }
+}


[gcc r12-10942] options: Adjust cl_optimization_compare to avoid checking ICE [PR115913]

2025-02-04 Thread Lewis Hyatt via Gcc-cvs
https://gcc.gnu.org/g:251f6ba9131ebc8deab463c052e099a065796c2a

commit r12-10942-g251f6ba9131ebc8deab463c052e099a065796c2a
Author: Lewis Hyatt 
Date:   Sun Jan 26 18:57:00 2025 -0500

options: Adjust cl_optimization_compare to avoid checking ICE [PR115913]

At the end of a sequence like:
 #pragma GCC push_options
 ...
 #pragma GCC pop_options

the handler for pop_options calls cl_optimization_compare() (as generated by
optc-save-gen.awk) to make sure that all global state has been restored to
the value it had prior to the push_options call. The verification is
performed for almost all entries in the global_options struct. This leads to
unexpected checking asserts, as discussed in the PR, in case the state of
warnings-related options has been intentionally modified in between
push_options and pop_options via a call to #pragma GCC diagnostic. Address
that by skipping the verification for CL_WARNING-flagged options.

gcc/ChangeLog:

PR middle-end/115913
* optc-save-gen.awk (cl_optimization_compare): Skip options with
CL_WARNING flag.

gcc/testsuite/ChangeLog:

PR middle-end/115913
* c-c++-common/cpp/pr115913.c: New test.

Diff:
---
 gcc/optc-save-gen.awk | 5 +
 gcc/testsuite/c-c++-common/cpp/pr115913.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 76e9b3cb9402..dd09fd38c87b 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1451,6 +1451,11 @@ for (i = 0; i < n_opts; i++) {
if (name == "")
continue;
 
+   # We do not want to compare warning-related options, since they
+   # might have been modified by a #pragma GCC diagnostic.
+   if (flag_set_p("Warning", flags[i]))
+   continue;
+
if (name in checked_options)
continue;
checked_options[name]++
diff --git a/gcc/testsuite/c-c++-common/cpp/pr115913.c 
b/gcc/testsuite/c-c++-common/cpp/pr115913.c
new file mode 100644
index ..b9d10cda8d24
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr115913.c
@@ -0,0 +1,7 @@
+/* { dg-do preprocess } */
+/* PR middle-end/115913 */
+#pragma GCC push_options
+#pragma GCC diagnostic warning "-Wundef"
+/* The call to cl_optimization_compare performed by pop_options should not
+   lead to a checking failure.  */
+#pragma GCC pop_options


[gcc r15-7353] testsuite: XFAIL test in pr109393.c for ilp32 targets [PR116845]

2025-02-04 Thread Philipp Tomsich via Gcc-cvs
https://gcc.gnu.org/g:adf1da77593f8851c6b78d22ebbc1124bbaf1de5

commit r15-7353-gadf1da77593f8851c6b78d22ebbc1124bbaf1de5
Author: kelefth 
Date:   Tue Feb 4 11:49:03 2025 +0100

testsuite: XFAIL test in pr109393.c for ilp32 targets [PR116845]

The match.pd canonicalization that this testcase checks for,
is not applied on ilp32 targets.

This XFAILs the test on ilp32 targets.

PR testsuite/116845

gcc/testsuite/ChangeLog:

* gcc.dg/pr109393.c: XFAIL on ilp32 targets.

Diff:
---
 gcc/testsuite/gcc.dg/pr109393.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr109393.c b/gcc/testsuite/gcc.dg/pr109393.c
index b2dd5a0b645c..108d30913894 100644
--- a/gcc/testsuite/gcc.dg/pr109393.c
+++ b/gcc/testsuite/gcc.dg/pr109393.c
@@ -20,4 +20,5 @@ int bar(int *a, int j)
   return (&a[j + 1] - 2) == &a[k];
 }
 
-/* { dg-final { scan-tree-dump-times "return 1;" 3 "optimized" } } */
+/* The pattern is not applied on ilp32 targets (PR116845).  */
+/* { dg-final { scan-tree-dump-times "return 1;" 3 "optimized" { xfail { ilp32 
} } } } */


[gcc r15-7352] c/118742 - gimple FE parsing of unary operators of C promoted args

2025-02-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:4c8c9c9ee22bdb306439020a5a8fc5b4ee935f5b

commit r15-7352-g4c8c9c9ee22bdb306439020a5a8fc5b4ee935f5b
Author: Richard Biener 
Date:   Tue Feb 4 10:54:48 2025 +0100

c/118742 - gimple FE parsing of unary operators of C promoted args

The GIMPLE FE currently invokes parser_build_unary_op to build
unary GENERIC which has the operand subject to C promotion rules
which does not match GIMPLE.  The following adds a wrapper around
the build_unary_op worker which conveniently has an argument to
indicate whether to skip such promotion.

PR c/118742
gcc/c/
* gimple-parser.cc (gimple_parser_build_unary_op): New
wrapper around build_unary_op.
(c_parser_gimple_unary_expression): Use it.

gcc/testsuite/
* gcc.dg/gimplefe-56.c: New testcase.

Diff:
---
 gcc/c/gimple-parser.cc | 49 +++---
 gcc/testsuite/gcc.dg/gimplefe-56.c | 24 +++
 2 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 54ecf22151ca..90b9beb1e9f3 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -125,6 +125,39 @@ static tree c_parser_gimple_paren_condition (gimple_parser 
&);
 static void c_parser_gimple_expr_list (gimple_parser &, vec *);
 
 
+/* Much like parser_build_unary_op, but avoid applying default conversions.  */
+
+static c_expr
+gimple_parser_build_unary_op (location_t loc,
+ enum tree_code code, struct c_expr arg)
+{
+  struct c_expr result;
+
+  result.original_code = code;
+  result.original_type = NULL;
+  result.m_decimal = 0;
+
+  if (reject_gcc_builtin (arg.value))
+{
+  result.value = error_mark_node;
+}
+  else
+{
+  result.value = build_unary_op (loc, code, arg.value, true);
+
+  if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
+   overflow_warning (loc, result.value, arg.value);
+}
+
+  /* We are typically called when parsing a prefix token at LOC acting on
+ ARG.  Reflect this by updating the source range of the result to
+ start at LOC and end at the end of ARG.  */
+  set_c_expr_source_range (&result,
+  loc, arg.get_finish ());
+
+  return result;
+}
+
 /* See if VAL is an identifier matching __BB and return 
in *INDEX.  */
 
@@ -1203,7 +1236,7 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
   c_parser_consume_token (parser);
   op = c_parser_gimple_postfix_expression (parser);
   mark_exp_read (op.value);
-  return parser_build_unary_op (op_loc, ADDR_EXPR, op);
+  return gimple_parser_build_unary_op (op_loc, ADDR_EXPR, op);
 case CPP_MULT:
   {
c_parser_consume_token (parser);
@@ -1228,15 +1261,15 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
 case CPP_PLUS:
   c_parser_consume_token (parser);
   op = c_parser_gimple_postfix_expression (parser);
-  return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
+  return gimple_parser_build_unary_op (op_loc, CONVERT_EXPR, op);
 case CPP_MINUS:
   c_parser_consume_token (parser);
   op = c_parser_gimple_postfix_expression (parser);
-  return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
+  return gimple_parser_build_unary_op (op_loc, NEGATE_EXPR, op);
 case CPP_COMPL:
   c_parser_consume_token (parser);
   op = c_parser_gimple_postfix_expression (parser);
-  return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
+  return gimple_parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
 case CPP_NOT:
   c_parser_error (parser, "% not valid in GIMPLE");
   return ret;
@@ -1246,11 +1279,11 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
case RID_REALPART:
  c_parser_consume_token (parser);
  op = c_parser_gimple_postfix_expression (parser);
- return parser_build_unary_op (op_loc, REALPART_EXPR, op);
+ return gimple_parser_build_unary_op (op_loc, REALPART_EXPR, op);
case RID_IMAGPART:
  c_parser_consume_token (parser);
  op = c_parser_gimple_postfix_expression (parser);
- return parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
+ return gimple_parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
default:
  return c_parser_gimple_postfix_expression (parser);
}
@@ -1261,13 +1294,13 @@ c_parser_gimple_unary_expression (gimple_parser &parser)
{
  c_parser_consume_token (parser);
  op = c_parser_gimple_postfix_expression (parser);
- return parser_build_unary_op (op_loc, ABS_EXPR, op);
+ return gimple_parser_build_unary_op (op_loc, ABS_EXPR, op);
}
  else if (strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0)
{
  c_parser_consume_token (parser);
  op = c_parser_gimple

[gcc r15-7348] c++: Properly detect calls to digest_init in build_vec_init [PR114619]

2025-02-04 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:887bdabfe3e315d661bed55800cd4f64542c7029

commit r15-7348-g887bdabfe3e315d661bed55800cd4f64542c7029
Author: Simon Martin 
Date:   Tue Feb 4 10:44:10 2025 +0100

c++: Properly detect calls to digest_init in build_vec_init [PR114619]

We currently ICE in checking mode with cxx_dialect < 17 on the following
valid code

=== cut here ===
struct X {
  X(const X&) {}
};
extern X x;
void foo () {
  new X[1]{x};
}
=== cut here ===

We trip on a gcc_checking_assert in cp_gimplify_expr due to a
TARGET_EXPR that is not TARGET_EXPR_ELIDING_P. As pointed by Jason, the
problem is that build_vec_init does not recognize that digest_init has
been called, and we end up calling the copy constructor twice.

This happens because the detection in build_vec_init assumes that BASE
is a reference to the array, while it's a pointer to its first element
here. This patch makes sure that the detection works in both cases.

PR c++/114619

gcc/cp/ChangeLog:

* init.cc (build_vec_init): Properly determine whether
digest_init has been called.

gcc/testsuite/ChangeLog:

* g++.dg/init/no-elide4.C: New test.

Diff:
---
 gcc/cp/init.cc|  3 ++-
 gcc/testsuite/g++.dg/init/no-elide4.C | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 3ab7f96335c9..613775c5a7c8 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4786,7 +4786,8 @@ build_vec_init (tree base, tree maxindex, tree init,
   tree field, elt;
   /* If the constructor already has the array type, it's been through
 digest_init, so we shouldn't try to do anything more.  */
-  bool digested = same_type_p (atype, TREE_TYPE (init));
+  bool digested = (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
+  && same_type_p (type, TREE_TYPE (TREE_TYPE (init;
   from_array = 0;
 
   if (length_check)
diff --git a/gcc/testsuite/g++.dg/init/no-elide4.C 
b/gcc/testsuite/g++.dg/init/no-elide4.C
new file mode 100644
index ..9377d9f01611
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/no-elide4.C
@@ -0,0 +1,11 @@
+// PR c++/114619
+// { dg-do "compile" { target c++11 } }
+// { dg-options "-fno-elide-constructors" }
+
+struct X {
+  X(const X&) {}
+};
+extern X x;
+void foo () {
+  new X[1]{x};
+}


[gcc r15-7349] tree-optimization/117113 - ICE with unroll-and-jam

2025-02-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:0675eb17480bada678bf2769d39732027abcd6d0

commit r15-7349-g0675eb17480bada678bf2769d39732027abcd6d0
Author: Richard Biener 
Date:   Mon Feb 3 15:12:52 2025 +0100

tree-optimization/117113 - ICE with unroll-and-jam

When there's an inner loop without virtual header PHI but the outer
loop has one the fusion process cannot handle the need to create
an inner loop virtual header PHI.  Punt in this case.

PR tree-optimization/117113
* gimple-loop-jam.cc (unroll_jam_possible_p): Detect when
we cannot handle virtual SSA update.

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

Diff:
---
 gcc/gimple-loop-jam.cc  | 12 +++-
 gcc/testsuite/gcc.dg/torture/pr117113.c | 20 
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-loop-jam.cc b/gcc/gimple-loop-jam.cc
index 9a2eba02dd97..5e6c04a7d7f2 100644
--- a/gcc/gimple-loop-jam.cc
+++ b/gcc/gimple-loop-jam.cc
@@ -279,13 +279,17 @@ unroll_jam_possible_p (class loop *outer, class loop 
*loop)
  body would be the after-iter value of the first body) if it's over
  an associative and commutative operation.  We wouldn't
  be able to handle unknown cycles.  */
+  bool inner_vdef = false;
   for (psi = gsi_start_phis (loop->header); !gsi_end_p (psi); gsi_next (&psi))
 {
   affine_iv iv;
   tree op = gimple_phi_result (psi.phi ());
 
   if (virtual_operand_p (op))
-   continue;
+   {
+ inner_vdef = true;
+ continue;
+   }
   if (!simple_iv (loop, loop, op, &iv, true))
return false;
   /* The inductions must be regular, loop invariant step and initial
@@ -301,6 +305,12 @@ unroll_jam_possible_p (class loop *outer, class loop *loop)
 copy, _not_ the next value of the second body.  */
 }
 
+  /* When there's no inner loop virtual PHI IV we cannot handle the update
+ required to the inner loop if that doesn't already have one.  See
+ PR117113.  */
+  if (!inner_vdef && get_virtual_phi (outer->header))
+return false;
+
   return true;
 }
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr117113.c 
b/gcc/testsuite/gcc.dg/torture/pr117113.c
new file mode 100644
index ..e90ad034a4d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117113.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-dce -fno-inline" } */
+
+int a, b, c;
+volatile int d[1];
+void e() {}
+void f(int g) {}
+int main() {
+  int i;
+  for (; b; b--) {
+for (i = 0; i < 3; i++) {
+  e();
+  f(d[0]);
+  d[0];
+}
+if (a)
+  c++;
+  }
+  return 0;
+}


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Sauvegarde factorisation set_descriptor_from_scalar

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:98b94a1a2699a73092154f7f8a58bd661b33b8d9

commit 98b94a1a2699a73092154f7f8a58bd661b33b8d9
Author: Mikael Morin 
Date:   Tue Feb 4 11:16:32 2025 +0100

Sauvegarde factorisation set_descriptor_from_scalar

Diff:
---
 gcc/fortran/trans-array.cc | 153 +
 gcc/fortran/trans-array.h  |   2 +-
 gcc/fortran/trans-expr.cc  |  25 +---
 gcc/fortran/trans-types.cc |  44 -
 gcc/fortran/trans-types.h  |   1 +
 5 files changed, 149 insertions(+), 76 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index d6e7c9829ff2..60ce464ee032 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -600,7 +600,7 @@ gfc_conv_descriptor_sm_get (tree desc, tree dim)
 }
 
 
-static int
+static bt
 get_type_info (const bt &type)
 {
   switch (type)
@@ -611,11 +611,13 @@ get_type_info (const bt &type)
 case BT_COMPLEX:
 case BT_DERIVED:
 case BT_CHARACTER:
-case BT_CLASS:
 case BT_VOID:
 case BT_UNSIGNED:
   return type;
 
+case BT_CLASS:
+  return BT_DERIVED;
+
 case BT_PROCEDURE:
 case BT_ASSUMED:
   return BT_VOID;
@@ -672,9 +674,14 @@ get_size_info (gfc_typespec &ts)
 class modify_info
 {
 public:
+  virtual bool set_dtype () const { return is_initialization (); }
+  virtual bool use_tree_type () const { return false; }
   virtual bool is_initialization () const { return false; }
   virtual bool initialize_data () const { return false; }
+  virtual bool set_span () const { return false; }
   virtual tree get_data_value () const { return NULL_TREE; }
+  virtual bt get_type_type (const gfc_typespec &) const { return BT_UNKNOWN; }
+  virtual tree get_length (gfc_typespec &ts) const { return get_size_info 
(ts); }
 };
 
 class nullification : public modify_info
@@ -698,8 +705,14 @@ class init_info : public modify_info
 public:
   virtual bool is_initialization () const { return true; }
   virtual gfc_typespec *get_type () const { return nullptr; }
+  virtual bt get_type_type (const gfc_typespec &) const;
 };
 
+bt
+init_info::get_type_type (const gfc_typespec & type_info) const
+{
+  return get_type_info (type_info.type);
+}
 
 class default_init : public init_info
 {
@@ -732,18 +745,76 @@ public:
 class scalar_value : public init_info
 {
 private:
-  gfc_typespec &ts;
+  gfc_typespec *ts;
   tree value;
+  bool use_tree_type_;
+  tree get_elt_type () const;
+
 
 public:
   scalar_value(gfc_typespec &arg_ts, tree arg_value)
-: ts(arg_ts), value(arg_value) { }
+: ts(&arg_ts), value(arg_value), use_tree_type_ (false) { }
+  scalar_value(tree arg_value)
+: ts(nullptr), value(arg_value), use_tree_type_ (true) { }
   virtual bool initialize_data () const { return true; }
   virtual tree get_data_value () const { return value; }
-  virtual gfc_typespec *get_type () const { return &ts; }
+  virtual gfc_typespec *get_type () const { return ts; }
+  virtual bool set_span () const { return true; }
+  virtual bool use_tree_type () const { return use_tree_type_; }
+  virtual bt get_type_type (const gfc_typespec &) const;
+  virtual tree get_length (gfc_typespec &ts) const;
 };
 
 
+tree
+scalar_value::get_elt_type () const
+{
+  tree tmp = value;
+
+  if (POINTER_TYPE_P (TREE_TYPE (tmp)))
+tmp = TREE_TYPE (tmp);
+
+  tree etype = TREE_TYPE (tmp);
+
+  /* For arrays, which are not scalar coarrays.  */
+  if (TREE_CODE (etype) == ARRAY_TYPE && !TYPE_STRING_FLAG (etype))
+etype = TREE_TYPE (etype);
+
+  return etype;
+}
+
+bt
+scalar_value::get_type_type (const gfc_typespec & type_info) const
+{
+  bt n;
+  if (use_tree_type ())
+{
+  tree etype = get_elt_type ();
+  gfc_get_type_info (etype, &n, nullptr);
+}
+  else
+n = get_type_info (type_info.type);
+
+  return n;
+}
+
+tree
+scalar_value::get_length (gfc_typespec & type_info) const
+{
+  bt n;
+  tree size;
+  if (use_tree_type ())
+{
+  tree etype = get_elt_type ();
+  gfc_get_type_info (etype, &n, &size);
+}
+  else
+size = init_info::get_length (type_info);
+
+  return size;
+}
+
+
 static tree
 build_dtype (gfc_typespec &ts, int rank, const symbol_attribute &,
 const init_info &init)
@@ -758,13 +829,14 @@ build_dtype (gfc_typespec &ts, int rank, const 
symbol_attribute &,
   if (type_info == nullptr)
 type_info = &ts;
 
-  if (!(type_info->type == BT_CLASS
-   || (type_info->type == BT_CHARACTER
-   && type_info->deferred)))
+  if (!(init.is_initialization ()
+   && (type_info->type == BT_CLASS
+   || (type_info->type == BT_CHARACTER
+   && type_info->deferred
 {
   tree elem_len_field = gfc_advance_chain (fields, GFC_DTYPE_ELEM_LEN);
   tree elem_len_val = fold_convert (TREE_TYPE (elem_len_field),
-   get_size_info (*type_info));
+   init.get_length (*type_info));
   CONSTRUCTOR_APPEND_ELT (v, elem_len_field, el

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression pr86470.f90

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:5373fc616e71ce297fd2e5a017700cab0d4e8910

commit 5373fc616e71ce297fd2e5a017700cab0d4e8910
Author: Mikael Morin 
Date:   Tue Feb 4 18:36:28 2025 +0100

Correction régression pr86470.f90

Diff:
---
 gcc/fortran/trans-array.cc | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index f3322af9157c..32e03509b8c6 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -92,6 +92,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "trans-array.h"
 #include "trans-const.h"
 #include "dependency.h"
+#include "gimplify.h"
 
 static bool gfc_get_array_constructor_size (mpz_t *, gfc_constructor_base);
 
@@ -1163,7 +1164,8 @@ init_struct (stmtblock_t *block, tree data_ref, init_kind 
kind,
  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (value), i, field, 
field_init)
{
  tree ref = fold_build3_loc (input_location, COMPONENT_REF,
- TREE_TYPE (field), data_ref,
+ TREE_TYPE (field),
+ unshare_expr (data_ref),
  field, NULL_TREE);
  init_struct (block, ref, field_init);
}
@@ -1184,7 +1186,8 @@ init_struct (stmtblock_t *block, tree data_ref, init_kind 
kind,
{
  tree field_decl = ce->index;
  tree ref = fold_build3_loc (input_location, COMPONENT_REF,
- TREE_TYPE (field_decl), data_ref,
+ TREE_TYPE (field_decl),
+ unshare_expr (data_ref),
  field_decl, NULL_TREE);
  init_struct (block, ref, ce->value);
}


[gcc r15-7359] Ada: Fix assertion failure with iterator in container aggregate

2025-02-04 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:64c66f5bce60fcc4a943bcac1865db2a72aaa1bd

commit r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72aaa1bd
Author: Eric Botcazou 
Date:   Tue Feb 4 19:48:09 2025 +0100

Ada: Fix assertion failure with iterator in container aggregate

It's just a missing test for the presence of a nonempty parameter.

gcc/ada/
PR ada/118731
* sem_aggr.adb (Resolve_Iterated_Association): Add missing guard.

Diff:
---
 gcc/ada/sem_aggr.adb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index f6db5cb97a4a..a7ec772823f6 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3933,6 +3933,7 @@ package body Sem_Aggr is
 
 if Is_Entity_Name (Choice)
   and then Is_Type (Entity (Choice))
+  and then Present (Key_Type)
   and then Base_Type (Entity (Choice)) = Base_Type (Key_Type)
 then
null;


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression dummy_3.f90

2025-02-04 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:ca157c84903b7e4e58a95aff75418c309ee31e4a

commit ca157c84903b7e4e58a95aff75418c309ee31e4a
Author: Mikael Morin 
Date:   Tue Feb 4 20:28:06 2025 +0100

Correction régression dummy_3.f90

Diff:
---
 gcc/fortran/trans-array.cc | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 32e03509b8c6..90eafe7ffe18 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -680,6 +680,7 @@ public:
   virtual bool is_initialization () const { return false; }
   virtual bool initialize_data () const { return false; }
   virtual bool set_span () const { return false; }
+  virtual bool set_token () const { return true; }
   virtual tree get_data_value () const { return NULL_TREE; }
   virtual bt get_type_type (const gfc_typespec &) const { return BT_UNKNOWN; }
   virtual tree get_length (gfc_typespec *ts) const { return get_size_info 
(*ts); }
@@ -751,19 +752,21 @@ private:
   gfc_typespec *ts;
   tree value;
   bool use_tree_type_;
+  bool clear_token;
   tree get_elt_type () const;
 
 public:
   scalar_value(gfc_typespec &arg_ts, tree arg_value)
-: initialisation(true), ts(&arg_ts), value(arg_value), use_tree_type_ 
(false) { }
+: initialisation(true), ts(&arg_ts), value(arg_value), use_tree_type_ 
(false), clear_token(true) { }
   scalar_value(tree arg_value)
-: initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true) { }
+: initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true), clear_token(false) { }
   virtual bool is_initialization () const { return initialisation; }
   virtual bool initialize_data () const { return true; }
   virtual tree get_data_value () const;
   virtual gfc_typespec *get_type () const { return ts; }
   virtual bool set_span () const { return true; }
   virtual bool use_tree_type () const { return use_tree_type_; }
+  virtual bool set_token () const { return clear_token; }
   virtual bt get_type_type (const gfc_typespec &) const;
   virtual tree get_length (gfc_typespec *ts) const;
 };
@@ -918,7 +921,8 @@ get_descriptor_init (tree type, gfc_typespec *ts, int rank,
   CONSTRUCTOR_APPEND_ELT (v, span_field, span_value);
 }
 
-  if (flag_coarray == GFC_FCOARRAY_LIB && attr->codimension)
+  if (flag_coarray == GFC_FCOARRAY_LIB && attr->codimension
+  && init.set_token ())
 {
   /* Declare the variable static so its array descriptor stays present
 after leaving the scope.  It may still be accessed through another


[gcc r15-7361] c++: add fixed test [PR94100]

2025-02-04 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:f176028371c5b5339ca6d8d975d47b2347234af9

commit r15-7361-gf176028371c5b5339ca6d8d975d47b2347234af9
Author: Marek Polacek 
Date:   Tue Feb 4 17:32:50 2025 -0500

c++: add fixed test [PR94100]

The recent r15-7339-g26d3424ca5d9f4 fixed this test too.

PR c++/94100

gcc/testsuite/ChangeLog:

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

Diff:
---
 gcc/testsuite/g++.dg/cpp0x/variadic188.C | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic188.C 
b/gcc/testsuite/g++.dg/cpp0x/variadic188.C
new file mode 100644
index ..04732a5e68fb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic188.C
@@ -0,0 +1,23 @@
+// PR c++/94100
+// { dg-do compile { target c++11 } }
+
+template  struct ValListWithTypes {
+  template  struct WithVals {
+using TypeList = ValListWithTypes;
+  };
+};
+
+template 
+struct Widget;
+
+template 
+struct Widget> {
+  template  struct Impl {};
+};
+
+template 
+template 
+struct Widget>::Impl<
+typename ValListWithTypes::template WithVals> {};
+
+int main(void) { Widget::WithVals<0>>::Impl<> impl; }


[gcc r15-7362] PR modula2/115112 Incorrect line debugging information occurs during INC builtin

2025-02-04 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:4d0ff917528d1c59bfad5401274c5be71b7b

commit r15-7362-g4d0ff917528d1c59bfad5401274c5be71b7b
Author: Gaius Mulley 
Date:   Tue Feb 4 23:21:52 2025 +

PR modula2/115112 Incorrect line debugging information occurs during INC 
builtin

This patch fixes location bugs in BuildDecProcedure,
BuildIncProcedure, BuildInclProcedure, BuildExclProcedure and
BuildThrow.  All these procedure functions use the token position
passed as a parameter (rather than from the quad stack).  It also
fixes location bugs in CheckRangeIncDec to ensure that the token
position is stored on the quad stack before calling subsidiary
procedure functions.

gcc/m2/ChangeLog:

PR modula2/115112
* gm2-compiler/M2Quads.mod (BuildPseudoProcedureCall): Pass
tokno to each build procedure.
(BuildThrowProcedure): New parameter functok.
(BuildIncProcedure): New parameter proctok.
Pass proctok on the quad stack during every push.
(BuildDecProcedure): Ditto.
(BuildInclProcedure): New parameter proctok.
(BuildExclProcedure): New parameter proctok.

gcc/testsuite/ChangeLog:

PR modula2/115112
* gm2/pim/run/pass/dectest.mod: New test.
* gm2/pim/run/pass/inctest.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Quads.mod| 64 +-
 gcc/testsuite/gm2/pim/run/pass/dectest.mod | 10 +
 gcc/testsuite/gm2/pim/run/pass/inctest.mod | 10 +
 3 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 785a6e9885a8..46db4a6556da 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -7021,19 +7021,19 @@ BEGIN
   BuildDisposeProcedure (tokno)
ELSIF ProcSym = Inc
THEN
-  BuildIncProcedure
+  BuildIncProcedure (tokno)
ELSIF ProcSym = Dec
THEN
-  BuildDecProcedure
+  BuildDecProcedure (tokno)
ELSIF ProcSym = Incl
THEN
-  BuildInclProcedure
+  BuildInclProcedure (tokno)
ELSIF ProcSym = Excl
THEN
-  BuildExclProcedure
+  BuildExclProcedure (tokno)
ELSIF ProcSym = Throw
THEN
-  BuildThrowProcedure
+  BuildThrowProcedure (tokno)
ELSE
   InternalError  ('pseudo procedure not implemented yet')
END
@@ -7084,14 +7084,12 @@ END GetItemPointedTo ;
  ||
 *)
 
-PROCEDURE BuildThrowProcedure ;
+PROCEDURE BuildThrowProcedure (functok: CARDINAL) ;
 VAR
-   functok  : CARDINAL ;
op   : CARDINAL ;
NoOfParam: CARDINAL ;
 BEGIN
PopT (NoOfParam) ;
-   functok  := OperandTtok (NoOfParam + 1) ;
IF NoOfParam = 1
THEN
   op := OperandT (NoOfParam) ;
@@ -7328,19 +7326,19 @@ BEGIN
IF IsExpressionCompatible (dtype, etype)
THEN
   (* the easy case simulate a straightforward macro *)
-  PushTF (des, dtype) ;
+  PushTFtok (des, dtype, tokenpos) ;
   PushT (tok) ;
-  PushTF (expr, etype) ;
+  PushTFtok (expr, etype, tokenpos) ;
   doBuildBinaryOp (FALSE, TRUE)
ELSE
   IF (IsOrdinalType (dtype) OR (dtype = Address) OR IsPointer (dtype)) AND
  (IsOrdinalType (etype) OR (etype = Address) OR IsPointer (etype))
   THEN
- PushTF (des, dtype) ;
+ PushTFtok (des, dtype, tokenpos) ;
  PushT (tok) ;
- PushTF (Convert, NulSym) ;
- PushT (dtype) ;
- PushT (expr) ;
+ PushTFtok (Convert, NulSym, tokenpos) ;
+ PushTtok (dtype, tokenpos) ;
+ PushTtok (expr, tokenpos) ;
  PushT (2) ;  (* Two parameters *)
  BuildConvertFunction (Convert, FALSE) ;
  doBuildBinaryOp (FALSE, TRUE)
@@ -7387,9 +7385,8 @@ END CheckRangeIncDec ;
||
 *)
 
-PROCEDURE BuildIncProcedure ;
+PROCEDURE BuildIncProcedure (proctok: CARDINAL) ;
 VAR
-   proctok   : CARDINAL ;
NoOfParam,
dtype,
OperandSym,
@@ -7397,26 +7394,25 @@ VAR
TempSym   : CARDINAL ;
 BEGIN
PopT (NoOfParam) ;
-   proctok := OperandTtok (NoOfParam + 1) ;
IF (NoOfParam = 1) OR (NoOfParam = 2)
THEN
-  VarSym := OperandT (NoOfParam) ;  (* bottom/first parameter *)
+  VarSym := OperandT (NoOfParam) ;  (* Bottom/first parameter.  *)
   IF IsVar (VarSym)
   THEN
  dtype := GetDType (VarSym) ;
  IF NoOfParam = 2
  THEN
-OperandSym := DereferenceLValue (OperandTok (1), OperandT (1))
+OperandSym := DereferenceLValue (proctok, OperandT (1))
  ELSE
 PushOne (proctok, dtype,
  'the {%EkINC} will cause an overflow {%1ad}') ;
PopT (OperandSym)
  END ;
 
- PushT (VarSym) ;
- TempSym := DereferenceLValue (OperandTok (NoOfParam), VarSym) ;
- CheckRan

[gcc r15-7358] testsuite: RISC-V: Ignore pr118170.c for E ABI

2025-02-04 Thread Dimitar Dimitrov via Gcc-cvs
https://gcc.gnu.org/g:88c9c4a2605db2b5f29f849ee33b92b31b95b887

commit r15-7358-g88c9c4a2605db2b5f29f849ee33b92b31b95b887
Author: Dimitar Dimitrov 
Date:   Wed Jan 29 20:42:56 2025 +0200

testsuite: RISC-V: Ignore pr118170.c for E ABI

The -mcpu=tt-ascalon-d8 option for the test implies D extension, which
is not compatible with the ILP32E and ILP64E ABIs.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr118170.c: Ignore for E ABI.

Signed-off-by: Dimitar Dimitrov 

Diff:
---
 gcc/testsuite/gcc.target/riscv/pr118170.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/riscv/pr118170.c 
b/gcc/testsuite/gcc.target/riscv/pr118170.c
index 306ff888aebd..baa7f8d3d9e6 100644
--- a/gcc/testsuite/gcc.target/riscv/pr118170.c
+++ b/gcc/testsuite/gcc.target/riscv/pr118170.c
@@ -1,4 +1,4 @@
-/* { dg-do "compile" } */
+/* { dg-do "compile" { target { ! riscv_abi_e } } } */
 /* { dg-options "-O2 -mcpu=tt-ascalon-d8" } */
 _Float16 f;


[gcc(refs/users/jmelcr/heads/omp-cp)] omp-cp: Refactor code, improve callback handler, add multiple callbacks support

2025-02-04 Thread Josef Melcr via Gcc-cvs
https://gcc.gnu.org/g:28fbf4db2cb28be3df399d4eb2ac61ab5ea0d465

commit 28fbf4db2cb28be3df399d4eb2ac61ab5ea0d465
Author: Josef Melcr 
Date:   Tue Feb 4 19:33:02 2025 +0100

omp-cp: Refactor code, improve callback handler, add multiple callbacks 
support

gcc/ChangeLog:

* builtin-attrs.def (0): Add new list with 0.
(DEF_CALLBACK_ATTRIBUTE_NOTHROW): Remove macro.
(GOMP): Add callback for GOMP functions.
(ATTR_NOTHROW_CALLBACK_GOMP_LIST): Remove list.
(DEF_CALLBACK_ATTRIBUTE): New macro for callback attribute
creation.
(OACC): Callback attribute for OACC functions.
(ATTR_CALLBACK_GOMP_LIST): Add list for for GOMP functions with
callbacks as their first argument and data as their second
argument.
(ATTR_CALLBACK_GOMP_TASK_HELPER_LIST): Helper list for
GOMP_task, needed because it has 2 callbacks.
(ATTR_CALLBACK_GOMP_TASK_LIST): Attribute list for GOMP_task
(ATTR_CALLBACK_OACC_LIST): Attribute list for OACC functions
with callbacks.
* cgraph.cc (cgraph_edge::set_call_stmt): Refactor callback
section.
(symbol_table::create_edge): Add check for callback to creation
assert.
(cgraph_edge::get_callback_parent_edge): Refactor function.
(cgraph_edge::redirect_call_stmt_to_callee): Refactor callback
redirection.
(cgraph_edge::maybe_hot_p): Make callback edge hot when it's
parent is hot, not working for now.
(cgraph_node::verify_node): Add verifiers for callbacks.
* cgraph.h: Add docs for callback utils.
* doc/extend.texi: Add callback attr docs.
* ipa-fnsummary.cc (analyze_function_body): Refactor.
(compute_fn_summary): Refactor.
* ipa-inline.cc (can_inline_edge_p): Refactor.
* ipa-prop.cc (calc_callback_args_idx): Remove function.
(init_callback_edge_summary): New function.
(ipa_compute_jump_functions_for_edge): Refactor, add multiple
callback support.
* ipa-prop.h (struct cb_arg_info): Remove struct.
(class ipa_edge_args): Remove cb_arg_info uses.
* omp-builtins.def (BUILT_IN_GOACC_PARALLEL): Use new attr list.
(BUILT_IN_GOMP_PARALLEL_LOOP_STATIC): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_GUIDED): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME): Likewise.
(BUILT_IN_GOMP_PARALLEL): Likewise.
(BUILT_IN_GOMP_TASK): Likewise.
(BUILT_IN_GOMP_PARALLEL_SECTIONS): Likewise.
(BUILT_IN_GOMP_TEAMS_REG): Likewise.
* attr-callback.h: New file.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_callback_attribute): Move handler to
attr_callback.h, add more checks.

Signed-off-by: Josef Melcr 

Diff:
---
 gcc/attr-callback.h   | 273 ++
 gcc/builtin-attrs.def |  25 +++--
 gcc/c-family/c-attribs.cc |  35 +-
 gcc/cgraph.cc | 121 ++--
 gcc/cgraph.h  |  56 +-
 gcc/doc/extend.texi   |  37 +++
 gcc/ipa-fnsummary.cc  |  26 +++--
 gcc/ipa-inline.cc |   6 +-
 gcc/ipa-prop.cc   | 113 +--
 gcc/ipa-prop.h|  11 +-
 gcc/omp-builtins.def  |  28 ++---
 11 files changed, 535 insertions(+), 196 deletions(-)

diff --git a/gcc/attr-callback.h b/gcc/attr-callback.h
new file mode 100644
index ..ea9c9cbbc780
--- /dev/null
+++ b/gcc/attr-callback.h
@@ -0,0 +1,273 @@
+/* Callback attribute handling
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   Contributed by Josef Melcr 
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+#ifndef ATTR_CALLBACK_H
+#define ATTR_CALLBACK_H
+#include "attribs.h"
+#include "system.h"
+#include "tree.h"
+#include "function.h"
+#include "basic-block.h"
+#include "coretypes.h"
+#include "is-a.h"
+#include "predict.h"
+#include "internal-fn.h"
+#include "tree-ssa-alias.h"
+#include "gimple-expr.h"
+#include "gimple.h"
+#include "vec.h"
+
+enum callback_

[gcc(refs/vendors/redhat/heads/gcc-15-branch)] Merge commit 'r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72aaa1bd' into redhat/gcc-15-branch

2025-02-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:785011ff892f91b1fedd8ba7812ff3203bc17b1a

commit 785011ff892f91b1fedd8ba7812ff3203bc17b1a
Merge: 3e0244fe1959 64c66f5bce60
Author: Jakub Jelinek 
Date:   Tue Feb 4 20:11:11 2025 +0100

Merge commit 'r15-7359-g64c66f5bce60fcc4a943bcac1865db2a72aaa1bd' into 
redhat/gcc-15-branch

Diff:

 gcc/ChangeLog  |   129 +
 gcc/DATESTAMP  | 2 +-
 gcc/ada/ChangeLog  | 6 +
 gcc/ada/sem_aggr.adb   | 1 +
 gcc/ada/sem_warn.adb   | 4 +
 gcc/c/gimple-parser.cc |49 +-
 gcc/combine.cc | 6 +-
 gcc/config/aarch64/aarch64.cc  |   110 +-
 gcc/config/i386/constraints.md |22 +-
 gcc/config/i386/i386-expand.cc |16 +-
 gcc/config/i386/i386-protos.h  | 1 +
 gcc/config/i386/i386.cc| 2 +-
 gcc/config/i386/i386.md|29 +-
 gcc/config/i386/predicates.md  |16 +-
 gcc/config/pa/pa.md|56 +-
 gcc/config/pa/predicates.md|16 +
 gcc/config/s390/s390.cc|16 +-
 gcc/config/s390/s390.md| 8 +-
 gcc/cp/ChangeLog   |31 +
 gcc/cp/class.cc|92 +-
 gcc/cp/contracts.cc|27 +-
 gcc/cp/coroutines.cc   |59 +-
 gcc/cp/decl.cc |20 +-
 gcc/cp/error.cc| 3 +-
 gcc/cp/init.cc | 3 +-
 gcc/cp/lambda.cc   | 2 +-
 gcc/cp/parser.cc   |43 +-
 gcc/cp/pt.cc   | 5 +
 gcc/cp/rtti.cc | 3 +-
 gcc/cp/semantics.cc| 1 -
 gcc/doc/gm2.texi   |   162 +-
 gcc/doc/invoke.texi|10 +
 gcc/fortran/ChangeLog  | 6 +
 gcc/fortran/arith.cc   |22 +-
 gcc/fortran/decl.cc|20 +-
 gcc/fortran/expr.cc| 8 +
 gcc/fortran/gfortran.texi  | 7 +-
 gcc/fortran/resolve.cc |13 -
 gcc/fortran/trans-decl.cc  |28 +-
 gcc/fortran/trans-expr.cc  |   160 +-
 gcc/fortran/trans.h| 2 +
 gcc/gimple-loop-jam.cc |12 +-
 gcc/input.cc   |   243 +-
 gcc/input.h| 4 +-
 gcc/ipa-free-lang-data.cc  | 3 +-
 gcc/libsarifreplay.cc  |70 +-
 gcc/m2/ChangeLog   |18 +
 gcc/m2/gm2-gcc/m2builtins.cc   |36 +
 gcc/m2/gm2-libs/Builtins.def   | 5 +
 gcc/m2/gm2-libs/Builtins.mod   |20 +
 gcc/m2/gm2-libs/cbuiltin.def   |11 +-
 gcc/optabs-query.cc| 2 +-
 gcc/optc-save-gen.awk  | 5 +
 gcc/params.opt | 8 +
 gcc/testsuite/ChangeLog|   103 +
 gcc/testsuite/c-c++-common/cpp/pr115913.c  | 7 +
 gcc/testsuite/g++.dg/coroutines/coro-range-for1.C  |38 +
 gcc/testsuite/g++.dg/coroutines/pr116506.C |53 +
 gcc/testsuite/g++.dg/coroutines/pr116880.C |36 +
 gcc/testsuite/g++.dg/cpp1y/lambda-generic-117778.C |12 +
 gcc/testsuite/g++.dg/cpp1z/decomp63.C  |18 +
 gcc/testsuite/g++.dg/cpp1z/variadic-nontype1.C |18 +
 gcc/testsuite/g++.dg/cpp2a/abbrev-fn2.C|49 +
 gcc/testsuite/g++.dg/cpp2a/abbrev-fn3.C|15 +
 gcc/testsuite/g++.dg/init/no-elide4.C  |11 +
 gcc/testsuite/g++.dg/modules/contracts-5_a.C   | 8 +
 gcc/testsuite/g++.dg/modules/contracts-5_b.C   |20 +
 gcc/testsuite/g++.dg/modules/pr98893_a.H   | 9 +
 gcc/testsuite/g++.dg/modules/pr98893_b.C   |10 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C  | 2 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt10.C |11 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt11.C |25 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt12.C |23 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt13.C |28 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt5.C  |12 +
 gc

[gcc r15-7360] c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]

2025-02-04 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:a64d9c96d8ebb0ba2a52daec85779b1a99c2f7fd

commit r15-7360-ga64d9c96d8ebb0ba2a52daec85779b1a99c2f7fd
Author: Jakub Jelinek 
Date:   Tue Feb 4 21:16:57 2025 +0100

c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]

The following testcases ICE with RAW_DATA_CSTs (so the first one since
introduction of #embed C++ optimizations and the latter since optimization
of large sequences of comma separated literals).
I've missed the fact that implicit_conversion can embed the exact expression
passed to it into stuff pointed out by conversion * (e.g. for user
conversions in sub->cand->args).
So, it isn't enough in convert_like_internal to pass the right INTEGER_CST
for each element of the RAW_DATA_CST because the whole RAW_DATA_CST might be
in sub->cand->args etc.
Either I'd need to chase for wherever the RAW_DATA_CST is found and update
those for each element processed, or, as implemented in the following patch,
build_list_conv detects the easy optimizable case where
convert_like_internal can be kept as the whole RAW_DATA_CST with changed
type and possibly narrowing diagnostics, and otherwise instead of having
a single subconversion it has RAW_DATA_CST separate subconversions.
Instead of trying to reallocate the subconvs array when we detect that case,
the patch instead uses an artificial ck_list inside of the u.list array
to hold the individual subconversions.
Seems the only places where u.list is used are build_list_conv and
convert_like_internal.

2025-02-04  Jakub Jelinek  

PR c++/118671
* call.cc (build_list_conv): For RAW_DATA_CST, call
implicit_conversion with INTEGER_CST representing first byte instead
of the whole RAW_DATA_CST.  If it is an optimizable trivial
conversion, just save that to subconvs, otherwise allocate an
artificial ck_list for all the RAW_DATA_CST bytes and create
subsubconv for each of them.
(convert_like_internal): For ck_list with RAW_DATA_CST, instead of
doing all the checks for optimizable conversion just check kind and
assert everything else, otherwise use subsubconversions instead of
the subconversion for each element.

* g++.dg/cpp/embed-25.C: New test.
* g++.dg/cpp0x/pr118671.C: New test.

Diff:
---
 gcc/cp/call.cc| 89 ++-
 gcc/testsuite/g++.dg/cpp/embed-25.C   | 56 ++
 gcc/testsuite/g++.dg/cpp0x/pr118671.C | 61 
 3 files changed, 193 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 3a56a82632d9..c08bd0c8634a 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -868,6 +868,67 @@ build_list_conv (tree type, tree ctor, int flags, 
tsubst_flags_t complain)
 
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
 {
+  if (TREE_CODE (val) == RAW_DATA_CST)
+   {
+ tree elt
+   = build_int_cst (TREE_TYPE (val), RAW_DATA_UCHAR_ELT (val, 0));
+ conversion *sub
+   = implicit_conversion (elttype, TREE_TYPE (val), elt,
+  false, flags, complain);
+ conversion *next;
+ if (sub == NULL)
+   return NULL;
+ /* For conversion to initializer_list or
+initializer_list or initializer_list
+we can optimize and keep RAW_DATA_CST with adjusted
+type if we report narrowing errors if needed.
+Use just one subconversion for that case.  */
+ if (sub->kind == ck_std
+ && sub->type
+ && (TREE_CODE (sub->type) == INTEGER_TYPE
+ || is_byte_access_type (sub->type))
+ && TYPE_PRECISION (sub->type) == CHAR_BIT
+ && (next = next_conversion (sub))
+ && next->kind == ck_identity)
+   {
+ subconvs[i] = sub;
+ continue;
+   }
+ /* Otherwise. build separate subconv for each RAW_DATA_CST
+byte.  Wrap those into an artificial ck_list which convert_like
+will then handle.  */
+ conversion **subsubconvs = alloc_conversions (RAW_DATA_LENGTH (val));
+ unsigned int j;
+ subsubconvs[0] = sub;
+ for (j = 1; j < (unsigned) RAW_DATA_LENGTH (val); ++j)
+   {
+ elt = build_int_cst (TREE_TYPE (val),
+  RAW_DATA_UCHAR_ELT (val, j));
+ sub = implicit_conversion (elttype, TREE_TYPE (val), elt,
+false, flags, complain);
+ if (sub == NULL)
+   return NULL;
+ subsubconvs[j] = sub;
+   }
+
+ t = alloc_conversion (ck_list);
+ t->type = type;
+ t->u.list = subsubconvs;
+ t->rank = cr_exact;
+ 

[gcc r15-7350] c++: Fix overeager Woverloaded-virtual with conversion operators [PR109918]

2025-02-04 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:d346af2af88caf1e21a5cc1f0afa33596198fb60

commit r15-7350-gd346af2af88caf1e21a5cc1f0afa33596198fb60
Author: Simon Martin 
Date:   Tue Feb 4 10:58:17 2025 +0100

c++: Fix overeager Woverloaded-virtual with conversion operators [PR109918]

We currently emit an incorrect -Woverloaded-virtual warning upon the
following test case

=== cut here ===
struct A {
  virtual operator int() { return 42; }
  virtual operator char() = 0;
};
struct B : public A {
  operator char() { return 'A'; }
};
=== cut here ===

The problem is that when iterating over ovl_range (fns), warn_hidden
gets confused by the conversion operator marker, concludes that
seen_non_override is true and therefore emits a warning for all
conversion operators in A that do not convert to char, even if
-Woverloaded-virtual is 1 (e.g. with -Wall, the case reported).

A second set of problems is highlighted when -Woverloaded-virtual is 2.

First, with the same test case, since base_fndecls contains all
conversion operators in A (except the one to char, that's been removed
when iterating over ovl_range (fns)), we emit a spurious warning for
the conversion operator to int, even though it's unrelated.

Second, in case there are several conversion operators with different
cv-qualifiers to the same type in A, we rightfully emit a warning,
however the note uses the location of the conversion operator marker
instead of the right one; location_of should go over conv_op_marker.

This patch fixes all these by explicitly keeping track of (1) base
methods that are overriden, as well as (2) base methods that are hidden
but not overriden (and by what), and warning about methods that are in
(2) but not (1). It also ignores non virtual base methods, per
"definition" of -Woverloaded-virtual.

Co-authored-by: Jason Merrill 

PR c++/117114
PR c++/109918

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Keep track of overloaded and of hidden
base methods.
* error.cc (location_of): Skip over conv_op_marker.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt1.C: Check that no warning is
emitted for non virtual base methods.
* g++.dg/warn/Woverloaded-virt10.C: New test.
* g++.dg/warn/Woverloaded-virt11.C: New test.
* g++.dg/warn/Woverloaded-virt12.C: New test.
* g++.dg/warn/Woverloaded-virt13.C: New test.
* g++.dg/warn/Woverloaded-virt5.C: New test.
* g++.dg/warn/Woverloaded-virt6.C: New test.
* g++.dg/warn/Woverloaded-virt7.C: New test.
* g++.dg/warn/Woverloaded-virt8.C: New test.
* g++.dg/warn/Woverloaded-virt9.C: New test.

Diff:
---
 gcc/cp/class.cc| 92 --
 gcc/cp/error.cc|  3 +-
 gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C  |  2 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt10.C | 11 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt11.C | 25 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt12.C | 23 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt13.C | 28 
 gcc/testsuite/g++.dg/warn/Woverloaded-virt5.C  | 12 
 gcc/testsuite/g++.dg/warn/Woverloaded-virt6.C  | 12 
 gcc/testsuite/g++.dg/warn/Woverloaded-virt7.C  | 37 +++
 gcc/testsuite/g++.dg/warn/Woverloaded-virt8.C  | 15 +
 gcc/testsuite/g++.dg/warn/Woverloaded-virt9.C  | 14 
 12 files changed, 239 insertions(+), 35 deletions(-)

diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 130fbc9a9724..d5ae69b0fdfa 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -3243,10 +3243,16 @@ warn_hidden (tree t)
  continue;
 
tree name = OVL_NAME (fns);
+   size_t num_fns = 0; /* The number of fndecls in fns.  */
auto_vec base_fndecls;
tree base_binfo;
tree binfo;
unsigned j;
+   size_t num_overriders = 0;
+   hash_set overriden_base_fndecls;
+   /* base_fndecls that are hidden but not overriden. The "value"
+  contains the last fndecl we saw that hides the "key".  */
+   hash_map hidden_base_fndecls;
 
if (IDENTIFIER_CDTOR_P (name))
  continue;
@@ -3264,47 +3270,65 @@ warn_hidden (tree t)
if (base_fndecls.is_empty ())
  continue;
 
-   /* Remove any overridden functions.  */
-   bool seen_non_override = false;
+   /* Find all the base_fndecls that are overridden, as well as those
+  that are hidden, in T.  */
for (tree fndecl : ovl_range (fns))
  {
-   bool any_override = false;
-   if (TREE_CODE (fndecl) == FUNCTION_DECL
-   && DECL_VINDEX (fndecl))
+   bool template_p = TREE_CODE (fndecl) == TEMPLATE_DECL;
+   bool fndecl_ove

[gcc r15-7351] IBM zSystems: Do not use @PLT with larl

2025-02-04 Thread Ilya Leoshkevich via Gcc-cvs
https://gcc.gnu.org/g:a2e0a30c52faa022421f5d2cc55abc487c86ab01

commit r15-7351-ga2e0a30c52faa022421f5d2cc55abc487c86ab01
Author: Ilya Leoshkevich 
Date:   Thu Oct 13 02:54:52 2022 +0200

IBM zSystems: Do not use @PLT with larl

Commit 0990d93dd8a4 ("IBM Z: Use @PLT symbols for local functions in
64-bit mode") made GCC call both static and non-static functions and
load both static and non-static function addresses with the @PLT
suffix.  This made it difficult for linkers to distinguish calling and
address taking instructions [1].  It is currently assumed that the
R_390_PLT32DBL relocation, corresponding to the @PLT suffix, is used
only for calling, and the R_390_PC32DBL relocation, corresponding to
the empty suffix, is used only for address taking.

Linkers needs to make this distinction in order to decide whether to
ask ld.so to use canonical PLT entries.  Normally GOT entries in shared
objects contain addresses of the respective functions, with one notable
exception: when a no-pie executable calls the respective function and
also takes its address.  Such executables assume that all addresses are
known in advance, so they use addresses of the respective PLT entries.
For consistency reasons, all respective GOT entries in the process must
also use them.

When a linker sees that a no-pie executable both calls a function and
also takes its address, it creates a PLT entry and asks ld.so to
consider it canonical by setting the respective undefined symbol's
address, which is normally 0, to the address of this PLT entry.

Improve the situation by not using @PLT with larl.

Now that @PLT is not used with larl, also drop the 31-bit handling,
which was required because 31-bit PLT entries require %r12 to point to
the respective object's GOT, and this requirement is not satisfied when
calling them by pointer from another object.

Also drop the weak symbol handling, which was required because it is
not possible to load an undefined weak symbol address (0) using larl.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29655

gcc/ChangeLog:

* config/s390/s390.cc (print_operand): Remove the no longer
necessary 31-bit and weak symbol handling.
* config/s390/s390.md (*movdi_64): Do not use @PLT with larl.
(*movsi_larl): Likewise.
(main_base_64): Likewise.
(reload_base_64): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/s390/call-z10-pic-nodatarel.c: Adjust
expectations.
* gcc.target/s390/call-z10-pic.c: Likewise.
* gcc.target/s390/call-z10.c: Likewise.
* gcc.target/s390/call-z9-pic-nodatarel.c: Likewise.
* gcc.target/s390/call-z9-pic.c: Likewise.
* gcc.target/s390/call-z9.c: Likewise.

Diff:
---
 gcc/config/s390/s390.cc| 16 +++-
 gcc/config/s390/s390.md|  8 
 gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c |  6 ++
 gcc/testsuite/gcc.target/s390/call-z10-pic.c   |  6 ++
 gcc/testsuite/gcc.target/s390/call-z10.c   | 14 +-
 gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c  |  6 ++
 gcc/testsuite/gcc.target/s390/call-z9-pic.c|  6 ++
 gcc/testsuite/gcc.target/s390/call-z9.c| 14 +-
 8 files changed, 25 insertions(+), 51 deletions(-)

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 86a5f059b85d..1d96df49feac 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -8585,7 +8585,7 @@ print_operand_address (FILE *file, rtx addr)
 'E': print opcode suffix for branch on index instruction.
 'G': print the size of the operand in bytes.
 'J': print tls_load/tls_gdcall/tls_ldcall suffix
-'K': print @PLT suffix for call targets and load address values.
+'K': print @PLT suffix for branch targets; do not use with larl.
 'M': print the second word of a TImode operand.
 'N': print the second word of a DImode operand.
 'O': print only the displacement of a memory reference or address.
@@ -8854,19 +8854,9 @@ print_operand (FILE *file, rtx x, int code)
 call even static functions via PLT.  ld will optimize @PLT away for
 normal code, and keep it for patches.
 
-Do not indiscriminately add @PLT in 31-bit mode due to the %r12
-restriction, use UNSPEC_PLT31 instead.
-
 @PLT only makes sense for functions, data is taken care of by
--mno-pic-data-is-text-relative.
-
-Adding @PLT interferes with handling of weak symbols in non-PIC code,
-since their addresses are loaded with larl, which then always produces
-a non-NULL result, so skip them here as well.  */
-  if (TARGET_64BIT
- && GET_CODE (x) == SYM

[gcc r15-7354] c++: bogus -Wvexing-parse with trailing-return-type [PR118718]

2025-02-04 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:53d1f6cdb5a82e859176e854636400faba0bf0bf

commit r15-7354-g53d1f6cdb5a82e859176e854636400faba0bf0bf
Author: Marek Polacek 
Date:   Fri Jan 31 14:52:36 2025 -0500

c++: bogus -Wvexing-parse with trailing-return-type [PR118718]

This warning should not warn for

  auto f1 () -> auto;

because that cannot be confused with initializing a variable.

PR c++/118718

gcc/cp/ChangeLog:

* parser.cc (warn_about_ambiguous_parse): Don't warn when a trailing
return type is present.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wvexing-parse10.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/parser.cc| 4 
 gcc/testsuite/g++.dg/warn/Wvexing-parse10.C | 9 +
 2 files changed, 13 insertions(+)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 44515bb9074a..1da881e295b4 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -23617,6 +23617,10 @@ warn_about_ambiguous_parse (const 
cp_decl_specifier_seq *decl_specifiers,
(const_cast(declarator
 return;
 
+  /* Don't warn for auto f () -> auto.  */
+  if (declarator->u.function.late_return_type)
+return;
+
   /* Don't warn when the whole declarator (not just the declarator-id!)
  was parenthesized.  That is, don't warn for int(n()) but do warn
  for int(f)().  */
diff --git a/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C 
b/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C
new file mode 100644
index ..3fbe88b7d00b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wvexing-parse10.C
@@ -0,0 +1,9 @@
+// PR c++/118718
+// { dg-do compile { target c++14 } }
+
+void
+fn ()
+{
+  auto f1 () -> auto;
+  auto f2 (); // { dg-warning "empty parentheses" }
+}


[gcc r15-7355] c++: auto in trailing-return-type in parameter [PR117778]

2025-02-04 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:e6e40cb7459c9b21b291fe28e46cd4ebcd924dff

commit r15-7355-ge6e40cb7459c9b21b291fe28e46cd4ebcd924dff
Author: Marek Polacek 
Date:   Wed Jan 29 15:58:38 2025 -0500

c++: auto in trailing-return-type in parameter [PR117778]

This PR describes a few issues, both ICE and rejects-valid, but
ultimately the problem is that we don't properly synthesize the
second auto in:

  int
  g (auto fp() -> auto)
  {
return fp ();
  }

since r12-5860, which disabled auto_is_implicit_function_template_parm_p
in cp_parser_parameter_declaration after parsing the decl-specifier-seq.

If there is no trailing auto, there is no problem.

So we have to make sure auto_is_implicit_function_template_parm_p is
properly set when parsing the trailing auto.  A complication is that
one can write:

  auto f (auto fp(auto fp2() -> auto) -> auto) -> auto;
  ~~~

where only the underlined auto should be synthesized.  So when we
parse a parameter-declaration-clause inside another
parameter-declaration-clause, we should not enable the flag.  We
have no flags to keep track of such nesting, but I think I can walk
current_binding_level to see if we find ourselves in such an unlikely
scenario.

PR c++/117778

gcc/cp/ChangeLog:

* parser.cc (cp_parser_late_return_type_opt): Maybe override
auto_is_implicit_function_template_parm_p.
(cp_parser_parameter_declaration): Move a make_temp_override below.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/lambda-generic-117778.C: New test.
* g++.dg/cpp2a/abbrev-fn2.C: New test.
* g++.dg/cpp2a/abbrev-fn3.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/parser.cc   | 39 +
 gcc/testsuite/g++.dg/cpp1y/lambda-generic-117778.C | 12 ++
 gcc/testsuite/g++.dg/cpp2a/abbrev-fn2.C| 49 ++
 gcc/testsuite/g++.dg/cpp2a/abbrev-fn3.C| 15 +++
 4 files changed, 106 insertions(+), 9 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 1da881e295b4..9b8be084452e 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -25518,6 +25518,26 @@ cp_parser_late_return_type_opt (cp_parser *parser, 
cp_declarator *declarator,
   /* Consume the ->.  */
   cp_lexer_consume_token (parser->lexer);
 
+  /* We may be in the context of parsing a parameter declaration,
+namely, its declarator.  auto_is_implicit_function_template_parm_p
+will be disabled in that case.  But for code like
+
+  int g (auto fp() -> auto);
+
+we have to re-enable the flag for the trailing auto.  However, that
+only applies for the outermost trailing auto in a parameter clause; in
+
+  int f2 (auto fp(auto fp2() -> auto) -> auto);
+
+the inner -> auto should not be synthesized.  */
+  int i = 0;
+  for (cp_binding_level *b = current_binding_level;
+  b->kind == sk_function_parms; b = b->level_chain)
+   ++i;
+  auto cleanup = make_temp_override
+   (parser->auto_is_implicit_function_template_parm_p,
+(i == 2 && !current_function_decl));
+
   type = cp_parser_trailing_type_id (parser);
 }
 
@@ -26283,15 +26303,6 @@ cp_parser_parameter_declaration (cp_parser *parser,
&decl_specifiers,
&declares_class_or_enum);
 
-  /* [dcl.spec.auto.general]: "A placeholder-type-specifier of the form
- type-constraint opt auto can be used as a decl-specifier of the
- decl-specifier-seq of a parameter-declaration of a function declaration
- or lambda-expression..." but we must not synthesize an implicit template
- type parameter in its declarator.  That is, in "void f(auto[auto{10}]);"
- we want to synthesize only the first auto.  */
-  auto cleanup = make_temp_override
-(parser->auto_is_implicit_function_template_parm_p, false);
-
   /* Complain about missing 'typename' or other invalid type names.  */
   if (!decl_specifiers.any_type_specifiers_p
   && cp_parser_parse_and_diagnose_invalid_type_name (parser))
@@ -26305,6 +26316,16 @@ cp_parser_parameter_declaration (cp_parser *parser,
   return NULL;
 }
 
+  /* [dcl.spec.auto.general]: "A placeholder-type-specifier of the form
+ type-constraint opt auto can be used as a decl-specifier of the
+ decl-specifier-seq of a parameter-declaration of a function declaration
+ or lambda-expression..." but we must not synthesize an implicit template
+ type parameter in its declarator (except the trailing-return-type).
+ That is, in "void f(auto[auto{10}]);" we want to synthesize only the
+ first auto.  */
+  auto cleanup = make_temp_override
+(parser->auto_is_implicit_function_template_parm_p, false);