[gcc r15-5705] selftest: invoke "diff" when ASSERT_STREQ fails

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:746629e22888b376f95c45779db40bfbfe2ab282

commit r15-5705-g746629e22888b376f95c45779db40bfbfe2ab282
Author: David Malcolm 
Date:   Tue Nov 26 16:09:37 2024 -0500

selftest: invoke "diff" when ASSERT_STREQ fails

Currently when ASSERT_STREQ or ASSERT_STREQ_AT fail we print
both strings to stderr.  However it can be hard to figure out
the problem (e.g. for 1-character differences in long strings).

Extend the output by writing out the strings to tempfiles and
invoking "diff -up" on them when we have such a selftest failure,
to (I hope) simplify debugging.

gcc/ChangeLog:
* selftest.cc (selftest::print_diff): New function.
(selftest::assert_streq): Call it when we have non-equal
non-null strings.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/selftest.cc | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/gcc/selftest.cc b/gcc/selftest.cc
index 15284c3359c4..7ab7889cf8c5 100644
--- a/gcc/selftest.cc
+++ b/gcc/selftest.cc
@@ -63,6 +63,26 @@ fail_formatted (const location &loc, const char *fmt, ...)
   abort ();
 }
 
+/* Invoke "diff" to print the difference between VAL1 and VAL2
+   on stdout.  */
+
+static void
+print_diff (const location &loc, const char *val1, const char *val2)
+{
+  temp_source_file tmpfile1 (loc, ".txt", val1);
+  temp_source_file tmpfile2 (loc, ".txt", val2);
+  const char *args[] = {"diff",
+   "-up",
+   tmpfile1.get_filename (),
+   tmpfile2.get_filename (),
+   NULL};
+  int exit_status = 0;
+  int err = 0;
+  pex_one (PEX_SEARCH | PEX_LAST,
+  args[0], CONST_CAST (char **, args),
+  NULL, NULL, NULL, &exit_status, &err);
+}
+
 /* Implementation detail of ASSERT_STREQ.
Compare val1 and val2 with strcmp.  They ought
to be non-NULL; fail gracefully if either or both are NULL.  */
@@ -89,8 +109,12 @@ assert_streq (const location &loc,
if (strcmp (val1, val2) == 0)
  pass (loc, "ASSERT_STREQ");
else
- fail_formatted (loc, "ASSERT_STREQ (%s, %s)\n val1=\"%s\"\n 
val2=\"%s\"\n",
- desc_val1, desc_val2, val1, val2);
+ {
+   print_diff (loc, val1, val2);
+   fail_formatted
+ (loc, "ASSERT_STREQ (%s, %s)\n val1=\"%s\"\n val2=\"%s\"\n",
+  desc_val1, desc_val2, val1, val2);
+ }
   }
 }


[gcc r15-5706] aarch64: Fix fp8_scalar_1.c's stacktest1

2024-11-26 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:1a0d48060d6b0b7783adabb321f0a96ead16080b

commit r15-5706-g1a0d48060d6b0b7783adabb321f0a96ead16080b
Author: Andrew Pinski 
Date:   Tue Nov 26 13:05:00 2024 -0800

aarch64: Fix fp8_scalar_1.c's stacktest1

The function body test was expecting:
umovw0, v0.b[0]
strbw0, [sp, 15]

But the code generation was improved after r15-5375-gbeec291225be to just:
str b0, [sp, 15]

which is correct and better because no longer need to move between SIMD 
registers
and the GPRs.
This changes the function body test to new better code generation.

Pushed as obvious after a test of the testcase to make sure it now passes.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/fp8_scalar_1.c (stacktest1): Fix for new
improved code generation.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/gcc.target/aarch64/fp8_scalar_1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/fp8_scalar_1.c 
b/gcc/testsuite/gcc.target/aarch64/fp8_scalar_1.c
index 61edf06401b8..6632c77e0c63 100644
--- a/gcc/testsuite/gcc.target/aarch64/fp8_scalar_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/fp8_scalar_1.c
@@ -7,9 +7,8 @@
 
 /*
 **stacktest1:
-** umovw0, v0.b\[0\]
 ** sub sp, sp, #16
-** strbw0, \[sp, 15\]
+** str b0, \[sp, 15\]
 ** ldr b0, \[sp, 15\]
 ** add sp, sp, 16
 ** ret


[gcc r15-5707] aarch64: Update error message check for __builtin_launder check of sve-sizeless-2.C

2024-11-26 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:4a2352828ec4fdfb70dda5405b5a907b46248eec

commit r15-5707-g4a2352828ec4fdfb70dda5405b5a907b46248eec
Author: Andrew Pinski 
Date:   Tue Nov 26 13:38:15 2024 -0800

aarch64: Update error message check for __builtin_launder check of 
sve-sizeless-2.C

r15-3614-g9fe57e4879de93 changed the error message for __builtin_launder 
but this testcase
was not updated for the new format of the error message since it is an 
aarch64 specific
testcase.

This patch updates the expected error message.

Pushed as obvious after testing to see the testcase now works.

gcc/testsuite/ChangeLog:

* g++.dg/ext/sve-sizeless-2.C: Update the expected error message
for __builtin_launder.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/g++.dg/ext/sve-sizeless-2.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/ext/sve-sizeless-2.C 
b/gcc/testsuite/g++.dg/ext/sve-sizeless-2.C
index 0b86d9e82176..394ac1e45795 100644
--- a/gcc/testsuite/g++.dg/ext/sve-sizeless-2.C
+++ b/gcc/testsuite/g++.dg/ext/sve-sizeless-2.C
@@ -301,7 +301,7 @@ statements (int n)
 
   // Other built-ins
 
-  __builtin_launder (sve_sc1); // { dg-error {non-pointer argument to 
'__builtin_launder'} }
+  __builtin_launder (sve_sc1); // { dg-error {'svint8_t' of argument to 
'__builtin_launder' is not a pointer to object type} }
   __builtin_memcpy (&sve_sc1, &sve_sc2, 2);
 
   // Lambdas


[gcc r15-5697] gdbhooks: Handle references to vec* in VecPrinter

2024-11-26 Thread Alex Coplan via Gcc-cvs
https://gcc.gnu.org/g:098a41cb972d3711ebcb518a72a1addfdb6c70cf

commit r15-5697-g098a41cb972d3711ebcb518a72a1addfdb6c70cf
Author: Alex Coplan 
Date:   Tue Nov 26 15:10:29 2024 +

gdbhooks: Handle references to vec* in VecPrinter

vec.h has this method:

  template
  inline T *
  vec_safe_push (vec *&v, const T &obj CXX_MEM_STAT_INFO)

where v is a reference to a pointer to vec.  This matches the regex for
VecPrinter, so gdbhooks.py attempts to print it but chokes on the reference.
I see the following:

  #1  0x02b84b7b in vec_safe_push (v=Traceback 
(most
  recent call last):
File "$SRC/gcc/gcc/gdbhooks.py", line 486, in to_string
  return '0x%x' % intptr(self.gdbval)
File "$SRC/gcc/gcc/gdbhooks.py", line 168, in intptr
  return long(gdbval) if sys.version_info.major == 2 else int(gdbval)
  gdb.error: Cannot convert value to long.

This patch makes VecPrinter handle such references by stripping them
(dereferencing) at the top of the relevant functions.

gcc/ChangeLog:

* gdbhooks.py (strip_ref): New. Use it ...
(VecPrinter.to_string): ... here,
(VecPrinter.children): ... and here.

Diff:
---
 gcc/gdbhooks.py | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 904ee28423a9..a91e5fd2a834 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -472,6 +472,11 @@ def get_vec_kind(val):
 else:
 assert False, f"unexpected vec kind {kind}"
 
+def strip_ref(gdbval):
+if gdbval.type.code == gdb.TYPE_CODE_REF:
+return gdbval.referenced_value ()
+return gdbval
+
 class VecPrinter:
 #-ex "up" -ex "p bb->preds"
 def __init__(self, gdbval):
@@ -483,10 +488,10 @@ class VecPrinter:
 def to_string (self):
 # A trivial implementation; prettyprinting the contents is done
 # by gdb calling the "children" method below.
-return '0x%x' % intptr(self.gdbval)
+return '0x%x' % intptr(strip_ref(self.gdbval))
 
 def children (self):
-val = self.gdbval
+val = strip_ref(self.gdbval)
 if intptr(val) != 0 and get_vec_kind(val) == VEC_KIND_PTR:
 val = val['m_vec']


[gcc r15-5708] Fortran: fix minor front-end memleaks

2024-11-26 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:94f98f67f7271f6f962d1c562559aa8a4839f505

commit r15-5708-g94f98f67f7271f6f962d1c562559aa8a4839f505
Author: Harald Anlauf 
Date:   Tue Nov 26 20:37:35 2024 +0100

Fortran: fix minor front-end memleaks

gcc/fortran/ChangeLog:

* expr.cc (find_inquiry_ref): Fix memleak introduced by scanning
the reference chain to find and simplify inquiry references.
* symbol.cc (gfc_copy_formal_args_intr): Free formal namespace
when not needed to avoid a front-end memleak.

Diff:
---
 gcc/fortran/expr.cc   | 6 +-
 gcc/fortran/symbol.cc | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 6b40e8e0aa5b..a997bdae726a 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1833,6 +1833,7 @@ find_inquiry_ref (gfc_expr *p, gfc_expr **newp)
 {
   gfc_ref *ref;
   gfc_ref *inquiry = NULL;
+  gfc_ref *inquiry_head;
   gfc_expr *tmp;
 
   tmp = gfc_copy_expr (p);
@@ -1858,6 +1859,7 @@ find_inquiry_ref (gfc_expr *p, gfc_expr **newp)
   return false;
 }
 
+  inquiry_head = inquiry;
   gfc_resolve_expr (tmp);
 
   /* Leave these to the backend since the type and kind is not confirmed until
@@ -1930,7 +1932,7 @@ find_inquiry_ref (gfc_expr *p, gfc_expr **newp)
mpc_imagref (tmp->value.complex), GFC_RND_MODE);
  break;
}
-  // TODO: Fix leaking expr tmp, when simplify is done twice.
+
   if (inquiry->next)
gfc_replace_expr (tmp, *newp);
 }
@@ -1944,10 +1946,12 @@ find_inquiry_ref (gfc_expr *p, gfc_expr **newp)
 }
 
   gfc_free_expr (tmp);
+  gfc_free_ref_list (inquiry_head);
   return true;
 
 cleanup:
   gfc_free_expr (tmp);
+  gfc_free_ref_list (inquiry_head);
   return false;
 }
 
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index e803cdd93c9a..f13cb1883ead 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -4910,6 +4910,8 @@ gfc_copy_formal_args_intr (gfc_symbol *dest, 
gfc_intrinsic_sym *src,
   if (dest->formal != NULL)
 /* The current ns should be that for the dest proc.  */
 dest->formal_ns = gfc_current_ns;
+  else
+gfc_free_namespace (gfc_current_ns);
   /* Restore the current namespace to what it was on entry.  */
   gfc_current_ns = parent_ns;
 }


[gcc r15-5709] libstdc++: Add -fno-assume-sane-operators-new-delete to test [PR117751]

2024-11-26 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:44e71c84f0795c1f6e7d40f5a3eb66e9835244c2

commit r15-5709-g44e71c84f0795c1f6e7d40f5a3eb66e9835244c2
Author: Jonathan Wakely 
Date:   Mon Nov 25 22:40:43 2024 +

libstdc++: Add -fno-assume-sane-operators-new-delete to test [PR117751]

libstdc++-v3/ChangeLog:

PR libstdc++/117751
* testsuite/18_support/50594.cc: Edit dg-options to include the
-fno-assume-sane-operators-new-delete option.

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

diff --git a/libstdc++-v3/testsuite/18_support/50594.cc 
b/libstdc++-v3/testsuite/18_support/50594.cc
index ce45789e16aa..7b736eb1deca 100644
--- a/libstdc++-v3/testsuite/18_support/50594.cc
+++ b/libstdc++-v3/testsuite/18_support/50594.cc
@@ -1,4 +1,4 @@
-// { dg-options "-fwhole-program" }
+// { dg-options "-fwhole-program -fno-assume-sane-operators-new-delete" }
 // { dg-additional-options "-static-libstdc++" { target *-*-mingw* } }
 // { dg-require-effective-target std_allocator_new }
 // { dg-xfail-run-if "AIX operator new" { powerpc-ibm-aix* } }


[gcc r15-5703] csky: use quotes when referring to cpus and archs [PR90160]

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:e2db825f857da195e93fd8e4ac5228311fd37775

commit r15-5703-ge2db825f857da195e93fd8e4ac5228311fd37775
Author: David Malcolm 
Date:   Tue Nov 26 15:58:25 2024 -0500

csky: use quotes when referring to cpus and archs [PR90160]

gcc/ChangeLog:
PR translation/90160
* config/csky/csky.cc (csky_configure_build_target): Use %qs when
referring to cpu and arch names.
(csky_option_override): Likewise.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/config/csky/csky.cc | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config/csky/csky.cc b/gcc/config/csky/csky.cc
index 72619ea30312..5d295238ba58 100644
--- a/gcc/config/csky/csky.cc
+++ b/gcc/config/csky/csky.cc
@@ -2541,7 +2541,7 @@ csky_configure_build_target (struct csky_build_target 
*target,
 between different cpu & arch, should based on arch.  */
   if (csky_selected_arch
  && (csky_selected_cpu->base_arch != csky_selected_arch->base_arch))
-   warning (0, "cpu %s is not based on arch %s, ignoring the arch",
+   warning (0, "cpu %qs is not based on arch %qs, ignoring the arch",
 csky_selected_cpu->name, csky_selected_arch->name);
   if (!csky_selected_arch)
csky_selected_arch = &all_architectures[csky_selected_cpu->base_arch];
@@ -2607,7 +2607,7 @@ csky_option_override (void)
   || CSKY_TARGET_ARCH (CK860)))
 {
   flag_pic = 0;
-  warning (0, "%qs is not supported by arch %s",
+  warning (0, "%qs is not supported by arch %qs",
   "-fPIC", csky_active_target.arch_pp_name);
 }
 
@@ -2645,7 +2645,7 @@ csky_option_override (void)
}
 
   if (CSKY_TARGET_ARCH (CK801) || CSKY_TARGET_ARCH (CK802))
-   error ("%qs is not supported by arch %s",
+   error ("%qs is not supported by arch %qs",
   "-mhard-float", csky_active_target.arch_pp_name);
   else if (csky_fpu_index == TARGET_FPU_auto)
error ("%<-mhard-float%> is not supported by the selected CPU");
@@ -2710,7 +2710,7 @@ csky_option_override (void)
  pools are placed.  */
   if ((CSKY_TARGET_ARCH (CK801) || CSKY_TARGET_ARCH (CK802))
   && !TARGET_CONSTANT_POOL)
-error ("%qs is not supported by arch %s",
+error ("%qs is not supported by arch %qs",
   "-mno-constpool", csky_active_target.arch_pp_name);
   else if (TARGET_CONSTANT_POOL == -1)
 TARGET_CONSTANT_POOL = (CSKY_TARGET_ARCH (CK801)
@@ -2733,7 +2733,7 @@ csky_option_override (void)
   else if (TARGET_MINI_REGISTERS == -1)
TARGET_MINI_REGISTERS = 0;
   if (TARGET_HIGH_REGISTERS > 0)
-   warning (0, "%qs is not supported by arch %s",
+   warning (0, "%qs is not supported by arch %qs",
 "-mhigh-registers", csky_active_target.arch_pp_name);
   TARGET_HIGH_REGISTERS = 0;
 }
@@ -2750,7 +2750,7 @@ csky_option_override (void)
   if (CSKY_TARGET_ARCH (CK801))
 {
   if (TARGET_MULTIPLE_STLD > 0)
-   warning (0, "%qs is not supported by arch %s",
+   warning (0, "%qs is not supported by arch %qs",
 "-mmultiple-stld", csky_active_target.arch_pp_name);
   TARGET_MULTIPLE_STLD = 0;
 }


[gcc r15-5704] testsuite: rename plugins from .c to .cc

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:b4d4e22a6232999e1a8bc11db9641fb71d118c0b

commit r15-5704-gb4d4e22a6232999e1a8bc11db9641fb71d118c0b
Author: David Malcolm 
Date:   Tue Nov 26 16:01:35 2024 -0500

testsuite: rename plugins from .c to .cc

In r12-6650-g5c69acb32329d4 we updated our sources from .c to .cc
since for some time GCC has been implemented in C++, not C.

GCC plugins are also implemented in C++, not C, but the plugins
in our testsuite still have .c extensions.

Rename the plugin implementation files in the testsuite from .c to .cc,
for consistency with GCC's implementation files (as opposed to .C,
which is used in C++ parts of the testsuite).

Don't rename the files that the plugins are tested *on*.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/plugin.exp (plugin_test_list): Update for renaming
of all plugin implementation files from .c to .cc.
* g++.dg/plugin/attribute_plugin.c: Rename to...
* g++.dg/plugin/attribute_plugin.cc: ...this.
* g++.dg/plugin/comment_plugin.c: Rename to...
* g++.dg/plugin/comment_plugin.cc: ...this.
* g++.dg/plugin/decl_plugin.c: Rename to...
* g++.dg/plugin/decl_plugin.cc: ...this.
* g++.dg/plugin/def_plugin.c: Rename to...
* g++.dg/plugin/def_plugin.cc: ...this.
* g++.dg/plugin/dumb_plugin.c: Rename to...
* g++.dg/plugin/dumb_plugin.cc: ...this.
* g++.dg/plugin/header_plugin.c: Rename to...
* g++.dg/plugin/header_plugin.cc: ...this.
* g++.dg/plugin/pragma_plugin.c: Rename to...
* g++.dg/plugin/pragma_plugin.cc: ...this.
* g++.dg/plugin/selfassign.c: Rename to...
* g++.dg/plugin/selfassign.cc: ...this.
* g++.dg/plugin/show_template_tree_color_plugin.c: Rename to...
* g++.dg/plugin/show_template_tree_color_plugin.cc: ...this.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Update for renaming
of all plugin implementation files from .c to .cc.
* gcc.dg/plugin/analyzer_cpython_plugin.c: Rename to...
* gcc.dg/plugin/analyzer_cpython_plugin.cc: ...this.
* gcc.dg/plugin/analyzer_gil_plugin.c: Rename to...
* gcc.dg/plugin/analyzer_gil_plugin.cc: ...this.
* gcc.dg/plugin/analyzer_kernel_plugin.c: Rename to...
* gcc.dg/plugin/analyzer_kernel_plugin.cc: ...this.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Rename to...
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: ...this.
* gcc.dg/plugin/crash_test_plugin.c: Rename to...
* gcc.dg/plugin/crash_test_plugin.cc: ...this.
* gcc.dg/plugin/diagnostic_group_plugin.c: Rename to...
* gcc.dg/plugin/diagnostic_group_plugin.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_show_trees.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_show_trees.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_inlining.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_metadata.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_nesting.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_nesting.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Rename
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc: ..to
this.
* gcc.dg/plugin/diagnostic_plugin_test_text_art.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_text_art.cc: ...this.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c:
Rename to...
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc:
...this.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Rename to...
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: ...this.
* gcc.dg/plugin/dump_plugin.c: Rename to...
* gcc.dg/plugin/dump_plugin.cc: ...this.
* gcc.dg/plugin/expensive_selftests_plugin.c: Rename to...
* gcc.dg/plugin/expensive_selftests_plugin.cc: ...this.
* gcc.dg/plugin/finish_unit_plugin.c: Rename to...
* gcc.dg/plugin/finish_unit_plugin.cc: ...this.
* gcc.dg/plugin/ggcplug.c: Rename to...
* gcc.dg/plugin/ggcplug.cc: ...this.
* gcc.dg/plugin/location_overflow_plugin.c: Rename to...

[gcc r15-5701] Fortran: passing inquiry ref of complex array to assumed rank dummy [PR117774]

2024-11-26 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:eff7e72815ada5c70c974d42f6a419e29a03eb27

commit r15-5701-geff7e72815ada5c70c974d42f6a419e29a03eb27
Author: Harald Anlauf 
Date:   Mon Nov 25 22:55:10 2024 +0100

Fortran: passing inquiry ref of complex array to assumed rank dummy 
[PR117774]

PR fortran/117774

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): When passing an array
to an assumed-rank dummy, terminate search for array reference of
actual argument before an inquiry reference (e.g. INQUIRY_RE,
INQUIRY_IM) so that bounds update works properly.

gcc/testsuite/ChangeLog:

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

Diff:
---
 gcc/fortran/trans-expr.cc |  5 ++-
 gcc/testsuite/gfortran.dg/assumed_rank_25.f90 | 51 +++
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index bc1d5a87307d..41d06a99f757 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7398,7 +7398,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
  /* Change AR_FULL to a (:,:,:) ref to force bounds update. */
  gfc_ref *ref;
  for (ref = e->ref; ref->next; ref = ref->next)
-   ;
+   {
+ if (ref->next->type == REF_INQUIRY)
+   break;
+   };
  if (ref->u.ar.type == AR_FULL
  && ref->u.ar.as->type != AS_ASSUMED_SIZE)
ref->u.ar.type = AR_SECTION;
diff --git a/gcc/testsuite/gfortran.dg/assumed_rank_25.f90 
b/gcc/testsuite/gfortran.dg/assumed_rank_25.f90
new file mode 100644
index ..fce75aa519f3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/assumed_rank_25.f90
@@ -0,0 +1,51 @@
+! { dg-do run }
+! { dg-additional-options "-fcheck=bounds" }
+!
+! PR fortran/117774 - passing imaginary part of complex array to assumed rank 
dummy
+
+module mod
+  implicit none
+contains
+  subroutine foo(r, s1, s2)
+real, intent(in) :: r(..) ! ASSUMED-RANK DUMMY
+real, intent(in), optional :: s1(:)
+real, intent(in), optional :: s2(:,:)
+select rank (r)
+rank (1)
+! print *, r
+  if (present (s1)) then
+ if (any (r /= s1)) stop 1
+  end if
+rank (2)
+! print *, r
+  if (present (s2)) then
+ if (any (r /= s2)) stop 2
+  end if
+end select
+  end subroutine
+end module
+
+program p
+  use mod
+  implicit none
+  real:: re1(3),   im1(3)
+  real:: re2(3,7), im2(3,7)
+  complex :: z1(3),z2 (3,7)
+  integer :: i, j
+
+  re1 = [(2*i-1,i=1,size(re1))]
+  im1 = [(2*i  ,i=1,size(im1))]
+  z1  = cmplx (re1,im1)
+  call foo (z1% re, re1)
+  call foo (z1% im, im1)
+  call foo (z1(2:)% re, re1(2:))
+  call foo (z1(2:)% im, im1(2:))
+
+  re2 = reshape ([ (re1+10*j, j=1,7)], shape (re2))
+  im2 = reshape ([ (im1+10*j, j=1,7)], shape (im2))
+  z2  = cmplx (re2,im2)
+  call foo (z2   % re, s2=re2)
+  call foo (z2   % im, s2=im2)
+  call foo (z2(2:,3:)% re, s2=re2(2:,3:))
+  call foo (z2(2:,3:)% im, s2=im2(2:,3:))
+end


[gcc r14-10989] [PATCH] PR modula2/116378 m2 bootstrap fails on x86_64-darwin

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:5a809d4196577bb9f0c18d6f569acade6d1541f9

commit r14-10989-g5a809d4196577bb9f0c18d6f569acade6d1541f9
Author: Gaius Mulley 
Date:   Tue Nov 26 15:56:48 2024 +

[PATCH] PR modula2/116378 m2 bootstrap fails on x86_64-darwin

This patch fixes m2 bootstrap failure on x86_64-darwin.  libc_open
is defined with three parameters the last of which is an int for
portability (rather than a vararg).  This avoids portability
problems by promoting mode_t to an int.  In the future it could
be tidied up by using the m2 optarg extension.

gcc/m2/ChangeLog:

PR modula2/116378
* gm2-libs-iso/TermFile.mod (termOpen): Add third argument
for open.
* gm2-libs/libc.def (open): Remove vararg and use INTEGER for
mode parameter three.
* mc-boot-ch/Glibc.c (tracedb_open): Replace mode_t with int.
(libc_open): Rewrite without varargs.
* mc-boot/Glibc.h (libc_open): Replace varargs with int mode.
* pge-boot/Glibc.cc (libc_open): Rewrite.
* pge-boot/Glibc.h (libc_open): Replace varargs with int mode.

gcc/testsuite/ChangeLog:

PR modula2/116378
* gm2/extensions/run/pass/testopen.mod: Add third argument
for open.
* gm2/isolib/run/pass/openlibc.mod: Ditto.
* gm2/pim/run/pass/testaddr3.mod: Ditto.

(cherry picked from commit 9cdde72d1cefdf252ad2eec1ff465dccb3ab)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-libs-iso/TermFile.mod   | 2 +-
 gcc/m2/gm2-libs/libc.def   | 2 +-
 gcc/m2/mc-boot-ch/Glibc.c  | 8 ++--
 gcc/m2/mc-boot/Glibc.h | 2 +-
 gcc/m2/pge-boot/Glibc.cc   | 9 ++---
 gcc/m2/pge-boot/Glibc.h| 2 +-
 gcc/testsuite/gm2/extensions/run/pass/testopen.mod | 2 +-
 gcc/testsuite/gm2/isolib/run/pass/openlibc.mod | 2 +-
 gcc/testsuite/gm2/pim/run/pass/testaddr3.mod   | 2 +-
 9 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/gcc/m2/gm2-libs-iso/TermFile.mod b/gcc/m2/gm2-libs-iso/TermFile.mod
index a3ad58ceba01..3347bdd4e869 100644
--- a/gcc/m2/gm2-libs-iso/TermFile.mod
+++ b/gcc/m2/gm2-libs-iso/TermFile.mod
@@ -503,7 +503,7 @@ BEGIN
   THEN
  fd := libc.open(ADR("/dev/tty"), O_WRONLY, 0600B)
   ELSE
- fd := libc.open(ADR("/dev/tty"), O_RDONLY)
+ fd := libc.open(ADR("/dev/tty"), O_RDONLY, 0)
   END ;
   IF tcgetattr(fd, new)=0
   THEN
diff --git a/gcc/m2/gm2-libs/libc.def b/gcc/m2/gm2-libs/libc.def
index f28f8b5f2bca..a314b59e43f1 100644
--- a/gcc/m2/gm2-libs/libc.def
+++ b/gcc/m2/gm2-libs/libc.def
@@ -211,7 +211,7 @@ PROCEDURE close (d: INTEGER) : [ INTEGER ] ;
open - open the file, filename with flag and mode.
 *)
 
-PROCEDURE open (filename: ADDRESS; oflag: INTEGER; ...) : INTEGER ;
+PROCEDURE open (filename: ADDRESS; oflag: INTEGER; mode: INTEGER) : INTEGER ;
 
 
 (*
diff --git a/gcc/m2/mc-boot-ch/Glibc.c b/gcc/m2/mc-boot-ch/Glibc.c
index 492f17f6bdc7..5ad1711bc643 100644
--- a/gcc/m2/mc-boot-ch/Glibc.c
+++ b/gcc/m2/mc-boot-ch/Glibc.c
@@ -67,7 +67,7 @@ tracedb (const char *format, ...)
 
 static
 void
-tracedb_open (const void *p, int flags, mode_t mode)
+tracedb_open (const void *p, int flags, int mode)
 {
 #if defined(BUILD_MC_LIBC_TRACE)
   bool item_written = false;
@@ -343,15 +343,11 @@ libc_creat (char *p, mode_t mode)
 
 EXTERN
 int
-libc_open (void *p, int oflag, ...)
+libc_open (void *p, int oflag, int mode)
 {
-  va_list arg;
-  va_start (arg, oflag);
-  mode_t mode = va_arg (arg, mode_t);
   tracedb_open (p, oflag, mode);
   int result = open (reinterpret_cast  (p), oflag, mode);
   tracedb_result (result);
-  va_end (arg);
   return result;
 }
 
diff --git a/gcc/m2/mc-boot/Glibc.h b/gcc/m2/mc-boot/Glibc.h
index 2f7fac46d771..957232345f56 100644
--- a/gcc/m2/mc-boot/Glibc.h
+++ b/gcc/m2/mc-boot/Glibc.h
@@ -178,7 +178,7 @@ EXTERN int libc_close (int d);
open - open the file, filename with flag and mode.
 */
 
-EXTERN int libc_open (void * filename, int oflag, ...);
+EXTERN int libc_open (void * filename, int oflag, int mode);
 
 /*
creat - creates a new file
diff --git a/gcc/m2/pge-boot/Glibc.cc b/gcc/m2/pge-boot/Glibc.cc
index a63b328ed608..7ea40d0f0c11 100644
--- a/gcc/m2/pge-boot/Glibc.cc
+++ b/gcc/m2/pge-boot/Glibc.cc
@@ -224,14 +224,9 @@ libc_creat (char *p, mode_t mode)
 
 EXTERN
 int
-libc_open (void *p, int oflag, ...)
+libc_open (void *p, int oflag, int mode)
 {
-  va_list arg;
-  va_start (arg, oflag);
-  mode_t mode = va_arg (arg, mode_t);
-  int result = open (reinterpret_cast  (p), oflag, mode);
-  va_end (arg);
-  return result;
+  return open (reinterpret_cast  (p), oflag, mode);
 }
 
 EXTERN
diff --git a/gcc/m2/pge-boot/Glibc.h b/gcc/m2/pge-boot/Glibc.h
index a5558932348b..0a5481ef5239 100644
--- a/gcc/m2/pge

[gcc r14-10990] [PATCH] modula2: change identifier names to avoid build warnings

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:3851751ab968aa49c3db014ec064debbe31cef58

commit r14-10990-g3851751ab968aa49c3db014ec064debbe31cef58
Author: Gaius Mulley 
Date:   Tue Nov 26 16:05:03 2024 +

[PATCH] modula2: change identifier names to avoid build warnings

This fix avoids the following warnings: In implementation module
‘StdChans’: either the identifier has the same name as a keyword or
alternatively a keyword has the wrong case (‘IN’ and ‘in’)
   54 |stdnull: ChanId ;

the symbol name ‘in’ is legal as an identifier, however as such it
might cause confusion and is considered bad programming practice.

gcc/m2/ChangeLog:

* gm2-libs-iso/StdChans.mod (in): Rename to ...
(inch): ... this.
(out): Rename to ...
(outch): ... this.
(err): Rename to ...
(errch): ... this.

(cherry picked from commit b584f387bf74df9ba2cbbc07d00a05a105757329)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-libs-iso/StdChans.mod | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gcc/m2/gm2-libs-iso/StdChans.mod b/gcc/m2/gm2-libs-iso/StdChans.mod
index fbefbde4b101..e15d4ef95805 100644
--- a/gcc/m2/gm2-libs-iso/StdChans.mod
+++ b/gcc/m2/gm2-libs-iso/StdChans.mod
@@ -45,9 +45,9 @@ FROM RTgen IMPORT ChanDev, DeviceType,
 
 
 VAR
-   in,
-   out,
-   err,
+   inch,
+   outch,
+   errch,
stdin,
stdout,
stderr,
@@ -169,21 +169,21 @@ END NullChan ;
 PROCEDURE InChan () : ChanId ;
   (* Returns the identity of the current default input channel. *)
 BEGIN
-   RETURN( in )
+   RETURN( inch )
 END InChan ;
 
 
 PROCEDURE OutChan () : ChanId ;
   (* Returns the identity of the current default output channel. *)
 BEGIN
-   RETURN( out )
+   RETURN( outch )
 END OutChan ;
 
 
 PROCEDURE ErrChan () : ChanId ;
   (* Returns the identity of the current default error message channel. *)
 BEGIN
-   RETURN( err )
+   RETURN( errch )
 END ErrChan ;
 
   (* The following procedures allow for redirection of the default channels *)
@@ -191,21 +191,21 @@ END ErrChan ;
 PROCEDURE SetInChan (cid: ChanId) ;
   (* Sets the current default input channel to that identified by cid. *)
 BEGIN
-   in := cid
+   inch := cid
 END SetInChan ;
 
 
 PROCEDURE SetOutChan (cid: ChanId) ;
   (* Sets the current default output channel to that identified by cid. *)
 BEGIN
-   out := cid
+   outch := cid
 END SetOutChan ;
 
 
 PROCEDURE SetErrChan (cid: ChanId) ;
   (* Sets the current default error channel to that identified by cid. *)
 BEGIN
-   err := cid
+   errch := cid
 END SetErrChan ;
 
 
@@ -303,9 +303,9 @@ END Init ;
 BEGIN
Init
 FINALLY
-   SafeClose(in) ;
-   SafeClose(out) ;
-   SafeClose(err) ;
+   SafeClose(inch) ;
+   SafeClose(outch) ;
+   SafeClose(errch) ;
SafeClose(stdin) ;
SafeClose(stdout) ;
SafeClose(stderr)


[gcc r13-9217] gnat: fix lto-type-mismatch between C_Version_String and gnat_version_string [PR115917]

2024-11-26 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:e236e9edbe78f2be5224a0f188ae3bb74d6b3c1b

commit r13-9217-ge236e9edbe78f2be5224a0f188ae3bb74d6b3c1b
Author: Arsen Arsenović 
Date:   Thu Aug 15 19:17:41 2024 +0200

gnat: fix lto-type-mismatch between C_Version_String and 
gnat_version_string [PR115917]

gcc/ada/ChangeLog:

PR ada/115917
* gnatvsn.ads: Add note about the duplication of this value in
version.c.
* version.c (VER_LEN_MAX): Define to the same value as
Gnatvsn.Ver_Len_Max.
(gnat_version_string): Use VER_LEN_MAX as bound.

(cherry picked from commit 9cbcf8d1de159e6113fafb5dc2feb4a7e467a302)

Diff:
---
 gcc/ada/gnatvsn.ads | 3 ++-
 gcc/ada/version.c   | 5 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gnatvsn.ads b/gcc/ada/gnatvsn.ads
index b6edc9dabed9..308986afc182 100644
--- a/gcc/ada/gnatvsn.ads
+++ b/gcc/ada/gnatvsn.ads
@@ -83,7 +83,8 @@ package Gnatvsn is
--  space to store any possible version string value for checks. This
--  value should never be decreased in the future, but it would be
--  OK to increase it if absolutely necessary. If it is increased,
-   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max as well.
+   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max, and to update
+   --  the VER_LEN_MAX define in version.c as well.
 
Ver_Prefix : constant String := "GNAT Version: ";
--  Prefix generated by binder. If it is changed, be sure to change
diff --git a/gcc/ada/version.c b/gcc/ada/version.c
index 5e64edd0b17d..2fa9b8c2c859 100644
--- a/gcc/ada/version.c
+++ b/gcc/ada/version.c
@@ -31,4 +31,7 @@
 
 #include "version.h"
 
-char gnat_version_string[] = version_string;
+/* Logically a reference to Gnatvsn.Ver_Len_Max.  Please keep in sync.  */
+#define VER_LEN_MAX 256
+
+char gnat_version_string[VER_LEN_MAX] = version_string;


[gcc r14-10991] gnat: fix lto-type-mismatch between C_Version_String and gnat_version_string [PR115917]

2024-11-26 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:29c9213c3759f7ba24cdd498a5bc379cb9d16e5e

commit r14-10991-g29c9213c3759f7ba24cdd498a5bc379cb9d16e5e
Author: Arsen Arsenović 
Date:   Thu Aug 15 19:17:41 2024 +0200

gnat: fix lto-type-mismatch between C_Version_String and 
gnat_version_string [PR115917]

gcc/ada/ChangeLog:

PR ada/115917
* gnatvsn.ads: Add note about the duplication of this value in
version.c.
* version.c (VER_LEN_MAX): Define to the same value as
Gnatvsn.Ver_Len_Max.
(gnat_version_string): Use VER_LEN_MAX as bound.

(cherry picked from commit 9cbcf8d1de159e6113fafb5dc2feb4a7e467a302)

Diff:
---
 gcc/ada/gnatvsn.ads | 3 ++-
 gcc/ada/version.c   | 5 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gnatvsn.ads b/gcc/ada/gnatvsn.ads
index 29238362cc04..f2082ece0965 100644
--- a/gcc/ada/gnatvsn.ads
+++ b/gcc/ada/gnatvsn.ads
@@ -83,7 +83,8 @@ package Gnatvsn is
--  space to store any possible version string value for checks. This
--  value should never be decreased in the future, but it would be
--  OK to increase it if absolutely necessary. If it is increased,
-   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max as well.
+   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max, and to update
+   --  the VER_LEN_MAX define in version.c as well.
 
Ver_Prefix : constant String := "GNAT Version: ";
--  Prefix generated by binder. If it is changed, be sure to change
diff --git a/gcc/ada/version.c b/gcc/ada/version.c
index 5e64edd0b17d..2fa9b8c2c859 100644
--- a/gcc/ada/version.c
+++ b/gcc/ada/version.c
@@ -31,4 +31,7 @@
 
 #include "version.h"
 
-char gnat_version_string[] = version_string;
+/* Logically a reference to Gnatvsn.Ver_Len_Max.  Please keep in sync.  */
+#define VER_LEN_MAX 256
+
+char gnat_version_string[VER_LEN_MAX] = version_string;


[gcc r12-10833] gnat: fix lto-type-mismatch between C_Version_String and gnat_version_string [PR115917]

2024-11-26 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:2897bfe8f9efdf58a61e955b51821cc49d2a9cfc

commit r12-10833-g2897bfe8f9efdf58a61e955b51821cc49d2a9cfc
Author: Arsen Arsenović 
Date:   Thu Aug 15 19:17:41 2024 +0200

gnat: fix lto-type-mismatch between C_Version_String and 
gnat_version_string [PR115917]

gcc/ada/ChangeLog:

PR ada/115917
* gnatvsn.ads: Add note about the duplication of this value in
version.c.
* version.c (VER_LEN_MAX): Define to the same value as
Gnatvsn.Ver_Len_Max.
(gnat_version_string): Use VER_LEN_MAX as bound.

(cherry picked from commit 9cbcf8d1de159e6113fafb5dc2feb4a7e467a302)

Diff:
---
 gcc/ada/gnatvsn.ads | 3 ++-
 gcc/ada/version.c   | 5 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gnatvsn.ads b/gcc/ada/gnatvsn.ads
index 47a06b96c3cf..99d06c7e5aa4 100644
--- a/gcc/ada/gnatvsn.ads
+++ b/gcc/ada/gnatvsn.ads
@@ -83,7 +83,8 @@ package Gnatvsn is
--  space to store any possible version string value for checks. This
--  value should never be decreased in the future, but it would be
--  OK to increase it if absolutely necessary. If it is increased,
-   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max as well.
+   --  be sure to increase GNAT.Compiler.Version.Ver_Len_Max, and to update
+   --  the VER_LEN_MAX define in version.c as well.
 
Ver_Prefix : constant String := "GNAT Version: ";
--  Prefix generated by binder. If it is changed, be sure to change
diff --git a/gcc/ada/version.c b/gcc/ada/version.c
index 5e64edd0b17d..2fa9b8c2c859 100644
--- a/gcc/ada/version.c
+++ b/gcc/ada/version.c
@@ -31,4 +31,7 @@
 
 #include "version.h"
 
-char gnat_version_string[] = version_string;
+/* Logically a reference to Gnatvsn.Ver_Len_Max.  Please keep in sync.  */
+#define VER_LEN_MAX 256
+
+char gnat_version_string[VER_LEN_MAX] = version_string;


[gcc r15-5698] plugin: add missing colon in error message [PR93746]

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:08bb92d642757f1d4374b947f45f871cc04b8c65

commit r15-5698-g08bb92d642757f1d4374b947f45f871cc04b8c65
Author: David Malcolm 
Date:   Tue Nov 26 10:39:12 2024 -0500

plugin: add missing colon in error message [PR93746]

gcc/ChangeLog:
PR plugins/93746
* plugin.cc (try_init_one_plugin): Add missing colon in error
message.

Signed-off-by: David Malcolm 

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

diff --git a/gcc/plugin.cc b/gcc/plugin.cc
index cd7776a0a9ec..652892796b5b 100644
--- a/gcc/plugin.cc
+++ b/gcc/plugin.cc
@@ -714,7 +714,7 @@ try_init_one_plugin (struct plugin_name_args *plugin)
   /* Check the plugin license.  */
   if (dlsym (dl_handle, str_license) == NULL)
 fatal_error (input_location,
-"plugin %s is not licensed under a GPL-compatible license"
+"plugin %s is not licensed under a GPL-compatible license:"
 " %s", plugin->full_name, dlerror ());
 
   PTR_UNION_AS_VOID_PTR (plugin_init_union)


[gcc r15-5699] loop-prefetch: fix wording of warning [PR80760]

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:67458ea13895bae3965274e7f03701fb14f8b1e6

commit r15-5699-g67458ea13895bae3965274e7f03701fb14f8b1e6
Author: David Malcolm 
Date:   Tue Nov 26 10:39:18 2024 -0500

loop-prefetch: fix wording of warning [PR80760]

gcc/ChangeLog:
PR translation/80760
* tree-ssa-loop-prefetch.cc (pass_loop_prefetch::execute): Add
missing colon to not-a-power-of-two param warning.

gcc/testsuite/ChangeLog:
PR translation/80760
* gcc.dg/tree-ssa/pr79803.c: Add ':' to expected warning.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr79803.c | 2 +-
 gcc/tree-ssa-loop-prefetch.cc   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
index 3b475fa67494..102fb76e2737 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
@@ -13,7 +13,7 @@ void raise0(void)
   __builtin_longjmp (buf, 1);
 }
 
-int execute(int cmd) /* { dg-warning "'l1-cache-size' parameter is not a power 
of two 3" } */
+int execute(int cmd) /* { dg-warning "'l1-cache-size' parameter is not a power 
of two: 3" } */
 {
   int last = 0;
 
diff --git a/gcc/tree-ssa-loop-prefetch.cc b/gcc/tree-ssa-loop-prefetch.cc
index 971bbae95815..a191eaf75f58 100644
--- a/gcc/tree-ssa-loop-prefetch.cc
+++ b/gcc/tree-ssa-loop-prefetch.cc
@@ -2103,7 +2103,7 @@ pass_loop_prefetch::execute (function *fun)
   if (!warned)
{
  warning (OPT_Wdisabled_optimization,
-  "% parameter is not a power of two %d",
+  "% parameter is not a power of two: %d",
   PREFETCH_BLOCK);
  warned = true;
}


[gcc r15-5700] c: avoid double-negative in warning message [PR94370]

2024-11-26 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:5134bad11b9a71f869abbb7f3d37b669c6ba138b

commit r15-5700-g5134bad11b9a71f869abbb7f3d37b669c6ba138b
Author: David Malcolm 
Date:   Tue Nov 26 10:39:48 2024 -0500

c: avoid double-negative in warning message [PR94370]

gcc/c/ChangeLog:
PR c/94370
* c-typeck.cc (c_build_functype_attribute_variant): Reword
warning message to avoid double-negative.

gcc/testsuite/ChangeLog:
PR c/94370
* gcc.dg/format/proto.c: Update wording of message.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/c/c-typeck.cc   | 4 ++--
 gcc/testsuite/gcc.dg/format/proto.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index a23d83bf41fe..f465123bfab0 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -567,8 +567,8 @@ c_build_functype_attribute_variant (tree ntype, tree otype, 
tree attrs)
   && lookup_attribute ("format", attrs))
 {
   warning_at (input_location, OPT_Wattributes,
- "%qs attribute cannot be applied to a function that "
- "does not take variable arguments", "format");
+ "%qs attribute can only be applied to variadic functions",
+ "format");
   attrs = remove_attribute ("format", attrs);
 }
   return c_build_type_attribute_variant (ntype, attrs);
diff --git a/gcc/testsuite/gcc.dg/format/proto.c 
b/gcc/testsuite/gcc.dg/format/proto.c
index 2556400b10c4..f29e331c8144 100644
--- a/gcc/testsuite/gcc.dg/format/proto.c
+++ b/gcc/testsuite/gcc.dg/format/proto.c
@@ -18,7 +18,7 @@ FMT (3, 4) void print3 ();
 FMT (3, 4) void print3 ();
 
 FMT (1, 2) void print4 ();
-   void print4 (void);  // { dg-warning "'format' 
attribute cannot be applied to a function that does not take variable 
arguments" }
+   void print4 (void);  // { dg-warning "'format' 
attribute can only be applied to variadic functions" }
 
void print5 ();
 FMT (1, 2) void print5 (void);  // { dg-warning "\\\[-Wattributes" 
}
@@ -59,7 +59,7 @@ FMT (3, 4) void (*pfprint3)();
 FMT (3, 4) void (*pfprint3)();
 
 FMT (1, 2) void (*pfprint4)();
-   void (*pfprint4)(void);  // { dg-warning "'format' 
attribute cannot be applied to a function that does not take variable 
arguments" }
+   void (*pfprint4)(void);  // { dg-warning "'format' 
attribute can only be applied to variadic functions" }
 
void (*pfprint5)();
 FMT (1, 2) void (*pfprint5)(void);  // { dg-warning 
"\\\[-Wattributes" }


[gcc r14-10987] testsuite: arm: Use correct the expected asm in epilog-1.c test

2024-11-26 Thread Torbjorn Svensson via Gcc-cvs
https://gcc.gnu.org/g:407970fdd3f5fefb2d2a2e6419a03e22025ebdd9

commit r14-10987-g407970fdd3f5fefb2d2a2e6419a03e22025ebdd9
Author: Torbjörn SVENSSON 
Date:   Tue Nov 26 10:31:49 2024 +0100

testsuite: arm: Use correct the expected asm in epilog-1.c test

In r14.2.0-376-g724446556e5, I accidentally introduced a regression in
the expected assembler as the csinc instruction was not used for
armv8.1-m.main.

The generated assembler for armv8.1-m.main is:
push{r3, r4, r5, lr}
ldr r4, .L5
ldr r5, [r4]
addsr4, r2, #1
tst r5, #4
it  ne
movne   r2, r4
bl  bar
movsr0, #0
pop {r3, r4, r5, pc}

gcc/testsuite/ChangeLog:

* gcc.target/arm/epilog-1.c: Corrected armv8.1.m-main asm.

Signed-off-by: Torbjörn SVENSSON 

Diff:
---
 gcc/testsuite/gcc.target/arm/epilog-1.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/arm/epilog-1.c 
b/gcc/testsuite/gcc.target/arm/epilog-1.c
index a15164564606..d765dc42b82d 100644
--- a/gcc/testsuite/gcc.target/arm/epilog-1.c
+++ b/gcc/testsuite/gcc.target/arm/epilog-1.c
@@ -20,8 +20,10 @@ Below block is for non-armv8.1-m.main
 ** |
 
 Below block is for armv8.1-m.main
+** adds(r[0-9]+), r2, #1
 ** tst r[0-9]+, #4
-** csinc   r2, r2, r2, eq
+** it  ne
+** movne   r2, \1
 
 ** )
 ** bl  bar


[gcc r15-5702] [PATCH] testsuite:RISC-V:Modify the char string.

2024-11-26 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:3e2a1b268cf1f8994a63c85412154f01e1a8c7d8

commit r15-5702-g3e2a1b268cf1f8994a63c85412154f01e1a8c7d8
Author: yulong 
Date:   Tue Nov 26 10:36:44 2024 -0700

[PATCH] testsuite:RISC-V:Modify the char string.

From: yulong 

This patch modifies the char string from __riscv_xsfvcp to __riscv_xsfcease.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/predef-sf-2.c: Modify the char string.

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

diff --git a/gcc/testsuite/gcc.target/riscv/predef-sf-2.c 
b/gcc/testsuite/gcc.target/riscv/predef-sf-2.c
index dcb746bcd260..aaf73a6d8c56 100644
--- a/gcc/testsuite/gcc.target/riscv/predef-sf-2.c
+++ b/gcc/testsuite/gcc.target/riscv/predef-sf-2.c
@@ -7,7 +7,7 @@ int main () {
 #endif
 
 #if !defined(__riscv_xsfcease)
-#error "__riscv_xsfvcp"
+#error "__riscv_xsfcease"
 #endif
 
   return 0;


[gcc r14-10993] Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:da1305a9fee3b2efbb4702bb2d9b2f740d2e538a

commit r14-10993-gda1305a9fee3b2efbb4702bb2d9b2f740d2e538a
Author: Paul Thomas 
Date:   Tue Nov 26 08:58:21 2024 +

Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26  Paul Thomas  

gcc/fortran
PR fortran/117763
* trans-array.cc (gfc_get_array_span): Guard against derefences
of 'expr'. Clean up some typos. Use 'gfc_get_vptr_from_expr'
for clarity and apply a functional reversion of last section
that deals with class dummies.

gcc/testsuite/
PR fortran/117763
* gfortran.dg/pr117763.f90: New test.

(cherry picked from commit 8278d9551df610179fca114808a7e6e62bab3d82)

Diff:
---
 gcc/fortran/trans-array.cc |  16 +-
 gcc/testsuite/gfortran.dg/pr117763.f90 | 279 +
 2 files changed, 289 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 3994f4f71f0f..fe69b694e0da 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -961,8 +961,8 @@ tree
 gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   tree tmp;
-  gfc_symbol *sym = expr->expr_type == EXPR_VARIABLE
-   ? expr->symtree->n.sym : NULL;
+  gfc_symbol *sym = (expr && expr->expr_type == EXPR_VARIABLE) ?
+   expr->symtree->n.sym : NULL;
 
   if (is_pointer_array (desc)
   || (get_CFI_desc (NULL, expr, &desc, NULL)
@@ -989,7 +989,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   /* Treat unlimited polymorphic expressions separately because
 the element size need not be the same as the span.  Obtain
-the class container, which is simplified here by their being
+the class container, which is simplified here by there being
 no component references.  */
   if (sym && sym->attr.dummy)
{
@@ -1013,12 +1013,16 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
   /* The descriptor is a class _data field. Use the vtable size
 since it is guaranteed to have been set and is always OK for
 class array descriptors that are not unlimited.  */
-  tmp = gfc_class_vptr_get (TREE_OPERAND (desc, 0));
+  tmp = gfc_get_vptr_from_expr (desc);
   tmp = gfc_vptr_size_get (tmp);
 }
-  else if (sym && sym->ts.type == BT_CLASS && sym->attr.dummy)
+  else if (sym && sym->ts.type == BT_CLASS
+  && expr->ref->type == REF_COMPONENT
+  && expr->ref->next->type == REF_ARRAY
+  && expr->ref->next->next == NULL
+  && CLASS_DATA (sym)->attr.dimension)
 {
-  /* Class dummys usually requires extraction from the saved
+  /* Class dummys usually require extraction from the saved
 descriptor, which gfc_class_vptr_get does for us.  */
   tmp = gfc_class_vptr_get (sym->backend_decl);
   tmp = gfc_vptr_size_get (tmp);
diff --git a/gcc/testsuite/gfortran.dg/pr117763.f90 
b/gcc/testsuite/gfortran.dg/pr117763.f90
new file mode 100644
index ..5f7b36c02694
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117763.f90
@@ -0,0 +1,279 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR117763, which was a regression caused by the patch for
+! PR109345.
+!
+! Contributed by Juergen Reuter  
+!
+module iso_varying_string
+  implicit none
+  integer, parameter, private :: GET_BUFFER_LEN = 1
+
+  type, public :: varying_string
+ private
+ character(LEN=1), dimension(:), allocatable :: chars
+  end type varying_string
+
+  interface assignment(=)
+ module procedure op_assign_CH_VS
+ module procedure op_assign_VS_CH
+  end interface assignment(=)
+
+  interface char
+ module procedure char_auto
+ module procedure char_fixed
+  end interface char
+
+  interface len
+ module procedure len_
+  end interface len
+
+  interface var_str
+ module procedure var_str_
+  end interface var_str
+
+  public :: assignment(=)
+  public :: char
+  public :: len
+  public :: var_str
+
+  private :: op_assign_CH_VS
+  private :: op_assign_VS_CH
+  private :: char_auto
+  private :: char_fixed
+  private :: len_
+  private :: var_str_
+
+contains
+
+  elemental function len_ (string) result (length)
+type(varying_string), intent(in) :: string
+integer  :: length
+if(ALLOCATED(string%chars)) then
+   length = SIZE(string%chars)
+else
+   length = 0
+endif
+  end function len_
+
+  elemental subroutine op_assign_CH_VS (var, exp)
+character(LEN=*), intent(out):: var
+type(varying_string), intent(in) :: exp
+var = char(exp)
+  end subroutine op_assign_CH_VS
+
+  elemental subroutine op_assign_VS_CH (var, exp)
+type(varying_string), intent(out) :: var
+character(LEN=*), intent(in)  :: exp
+var = var_str(exp)
+  end subroutine op_assign_VS_CH
+
+  pure function char_auto (string) resul

[gcc r13-9219] Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:8d81d6b2f9b72a41f23b07214d88cfcb176a

commit r13-9219-g8d81d6b2f9b72a41f23b07214d88cfcb176a
Author: Paul Thomas 
Date:   Tue Nov 26 08:58:21 2024 +

Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26  Paul Thomas  

gcc/fortran
PR fortran/117763
* trans-array.cc (gfc_get_array_span): Guard against derefences
of 'expr'. Clean up some typos. Use 'gfc_get_vptr_from_expr'
for clarity and apply a functional reversion of last section
that deals with class dummies.

gcc/testsuite/
PR fortran/117763
* gfortran.dg/pr117763.f90: New test.

(cherry picked from commit 8278d9551df610179fca114808a7e6e62bab3d82)

Diff:
---
 gcc/fortran/trans-array.cc |  16 +-
 gcc/testsuite/gfortran.dg/pr117763.f90 | 279 +
 2 files changed, 289 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 79963befd52f..76e397b2a0ed 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -943,8 +943,8 @@ tree
 gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   tree tmp;
-  gfc_symbol *sym = expr->expr_type == EXPR_VARIABLE
-   ? expr->symtree->n.sym : NULL;
+  gfc_symbol *sym = (expr && expr->expr_type == EXPR_VARIABLE) ?
+   expr->symtree->n.sym : NULL;
 
   if (is_pointer_array (desc)
   || (get_CFI_desc (NULL, expr, &desc, NULL)
@@ -971,7 +971,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   /* Treat unlimited polymorphic expressions separately because
 the element size need not be the same as the span.  Obtain
-the class container, which is simplified here by their being
+the class container, which is simplified here by there being
 no component references.  */
   if (sym && sym->attr.dummy)
{
@@ -995,12 +995,16 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
   /* The descriptor is a class _data field. Use the vtable size
 since it is guaranteed to have been set and is always OK for
 class array descriptors that are not unlimited.  */
-  tmp = gfc_class_vptr_get (TREE_OPERAND (desc, 0));
+  tmp = gfc_get_vptr_from_expr (desc);
   tmp = gfc_vptr_size_get (tmp);
 }
-  else if (sym && sym->ts.type == BT_CLASS && sym->attr.dummy)
+  else if (sym && sym->ts.type == BT_CLASS
+  && expr->ref->type == REF_COMPONENT
+  && expr->ref->next->type == REF_ARRAY
+  && expr->ref->next->next == NULL
+  && CLASS_DATA (sym)->attr.dimension)
 {
-  /* Class dummys usually requires extraction from the saved
+  /* Class dummys usually require extraction from the saved
 descriptor, which gfc_class_vptr_get does for us.  */
   tmp = gfc_class_vptr_get (sym->backend_decl);
   tmp = gfc_vptr_size_get (tmp);
diff --git a/gcc/testsuite/gfortran.dg/pr117763.f90 
b/gcc/testsuite/gfortran.dg/pr117763.f90
new file mode 100644
index ..5f7b36c02694
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117763.f90
@@ -0,0 +1,279 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR117763, which was a regression caused by the patch for
+! PR109345.
+!
+! Contributed by Juergen Reuter  
+!
+module iso_varying_string
+  implicit none
+  integer, parameter, private :: GET_BUFFER_LEN = 1
+
+  type, public :: varying_string
+ private
+ character(LEN=1), dimension(:), allocatable :: chars
+  end type varying_string
+
+  interface assignment(=)
+ module procedure op_assign_CH_VS
+ module procedure op_assign_VS_CH
+  end interface assignment(=)
+
+  interface char
+ module procedure char_auto
+ module procedure char_fixed
+  end interface char
+
+  interface len
+ module procedure len_
+  end interface len
+
+  interface var_str
+ module procedure var_str_
+  end interface var_str
+
+  public :: assignment(=)
+  public :: char
+  public :: len
+  public :: var_str
+
+  private :: op_assign_CH_VS
+  private :: op_assign_VS_CH
+  private :: char_auto
+  private :: char_fixed
+  private :: len_
+  private :: var_str_
+
+contains
+
+  elemental function len_ (string) result (length)
+type(varying_string), intent(in) :: string
+integer  :: length
+if(ALLOCATED(string%chars)) then
+   length = SIZE(string%chars)
+else
+   length = 0
+endif
+  end function len_
+
+  elemental subroutine op_assign_CH_VS (var, exp)
+character(LEN=*), intent(out):: var
+type(varying_string), intent(in) :: exp
+var = char(exp)
+  end subroutine op_assign_CH_VS
+
+  elemental subroutine op_assign_VS_CH (var, exp)
+type(varying_string), intent(out) :: var
+character(LEN=*), intent(in)  :: exp
+var = var_str(exp)
+  end subroutine op_assign_VS_CH
+
+  pure function char_auto (string) result (

[gcc r12-10835] Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:2ae871b71512f77cc6857bf0ecbf80dd1253e18c

commit r12-10835-g2ae871b71512f77cc6857bf0ecbf80dd1253e18c
Author: Paul Thomas 
Date:   Tue Nov 26 08:58:21 2024 +

Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26  Paul Thomas  

gcc/fortran
PR fortran/117763
* trans-array.cc (gfc_get_array_span): Guard against derefences
of 'expr'. Clean up some typos. Use 'gfc_get_vptr_from_expr'
for clarity and apply a functional reversion of last section
that deals with class dummies.

gcc/testsuite/
PR fortran/117763
* gfortran.dg/pr117763.f90: New test.

(cherry picked from commit 8278d9551df610179fca114808a7e6e62bab3d82)

Diff:
---
 gcc/fortran/trans-array.cc |  16 +-
 gcc/testsuite/gfortran.dg/pr117763.f90 | 279 +
 2 files changed, 289 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 504b1bb07f06..ddaedf9604e9 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -943,8 +943,8 @@ tree
 gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   tree tmp;
-  gfc_symbol *sym = expr->expr_type == EXPR_VARIABLE
-   ? expr->symtree->n.sym : NULL;
+  gfc_symbol *sym = (expr && expr->expr_type == EXPR_VARIABLE) ?
+   expr->symtree->n.sym : NULL;
 
   if (is_pointer_array (desc)
   || (get_CFI_desc (NULL, expr, &desc, NULL)
@@ -971,7 +971,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   /* Treat unlimited polymorphic expressions separately because
 the element size need not be the same as the span.  Obtain
-the class container, which is simplified here by their being
+the class container, which is simplified here by there being
 no component references.  */
   if (sym && sym->attr.dummy)
{
@@ -995,12 +995,16 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
   /* The descriptor is a class _data field. Use the vtable size
 since it is guaranteed to have been set and is always OK for
 class array descriptors that are not unlimited.  */
-  tmp = gfc_class_vptr_get (TREE_OPERAND (desc, 0));
+  tmp = gfc_get_vptr_from_expr (desc);
   tmp = gfc_vptr_size_get (tmp);
 }
-  else if (sym && sym->ts.type == BT_CLASS && sym->attr.dummy)
+  else if (sym && sym->ts.type == BT_CLASS
+  && expr->ref->type == REF_COMPONENT
+  && expr->ref->next->type == REF_ARRAY
+  && expr->ref->next->next == NULL
+  && CLASS_DATA (sym)->attr.dimension)
 {
-  /* Class dummys usually requires extraction from the saved
+  /* Class dummys usually require extraction from the saved
 descriptor, which gfc_class_vptr_get does for us.  */
   tmp = gfc_class_vptr_get (sym->backend_decl);
   tmp = gfc_vptr_size_get (tmp);
diff --git a/gcc/testsuite/gfortran.dg/pr117763.f90 
b/gcc/testsuite/gfortran.dg/pr117763.f90
new file mode 100644
index ..5f7b36c02694
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117763.f90
@@ -0,0 +1,279 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR117763, which was a regression caused by the patch for
+! PR109345.
+!
+! Contributed by Juergen Reuter  
+!
+module iso_varying_string
+  implicit none
+  integer, parameter, private :: GET_BUFFER_LEN = 1
+
+  type, public :: varying_string
+ private
+ character(LEN=1), dimension(:), allocatable :: chars
+  end type varying_string
+
+  interface assignment(=)
+ module procedure op_assign_CH_VS
+ module procedure op_assign_VS_CH
+  end interface assignment(=)
+
+  interface char
+ module procedure char_auto
+ module procedure char_fixed
+  end interface char
+
+  interface len
+ module procedure len_
+  end interface len
+
+  interface var_str
+ module procedure var_str_
+  end interface var_str
+
+  public :: assignment(=)
+  public :: char
+  public :: len
+  public :: var_str
+
+  private :: op_assign_CH_VS
+  private :: op_assign_VS_CH
+  private :: char_auto
+  private :: char_fixed
+  private :: len_
+  private :: var_str_
+
+contains
+
+  elemental function len_ (string) result (length)
+type(varying_string), intent(in) :: string
+integer  :: length
+if(ALLOCATED(string%chars)) then
+   length = SIZE(string%chars)
+else
+   length = 0
+endif
+  end function len_
+
+  elemental subroutine op_assign_CH_VS (var, exp)
+character(LEN=*), intent(out):: var
+type(varying_string), intent(in) :: exp
+var = char(exp)
+  end subroutine op_assign_CH_VS
+
+  elemental subroutine op_assign_VS_CH (var, exp)
+type(varying_string), intent(out) :: var
+character(LEN=*), intent(in)  :: exp
+var = var_str(exp)
+  end subroutine op_assign_VS_CH
+
+  pure function char_auto (string) result 

[gcc r15-5711] PR117350: Keep assembler name for abstract decls for autofdo

2024-11-26 Thread Andi Kleen via Gcc-cvs
https://gcc.gnu.org/g:5e718a7a789b39ef877e0d66c7a6a85b54eb112f

commit r15-5711-g5e718a7a789b39ef877e0d66c7a6a85b54eb112f
Author: Andi Kleen 
Date:   Thu Oct 31 10:26:16 2024 -0700

PR117350: Keep assembler name for abstract decls for autofdo

autofdo looks up inline stacks and tries to match them with the profile
data using their symbol name. Make sure all decls that can be in a inline 
stack
have a valid assembler name.

This fixes a bootstrap problem with autoprofiledbootstrap and LTO.

2024-10-30  Jason Merrill  
Andrew Pinski  
Andi Kleen  
gcc/ChangeLog:

PR bootstrap/117350
* tree.cc (need_assembler_name_p): Keep assembler name
for abstract declarations when autofdo is used.

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

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 125f38b1cfab..833c3a9cc89d 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -798,8 +798,9 @@ need_assembler_name_p (tree decl)
   || DECL_ASSEMBLER_NAME_SET_P (decl))
 return false;
 
-  /* Abstract decls do not need an assembler name.  */
-  if (DECL_ABSTRACT_P (decl))
+  /* Abstract decls do not need an assembler name, except they
+ can be looked up by autofdo.  */
+  if (DECL_ABSTRACT_P (decl) && !flag_auto_profile)
 return false;
 
   /* For VAR_DECLs, only static, public and external symbols need an


[gcc r15-5712] libcpp: modules and -include again

2024-11-26 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:134dc932e1ceb13519846795c895319f77df3235

commit r15-5712-g134dc932e1ceb13519846795c895319f77df3235
Author: Jason Merrill 
Date:   Tue Nov 26 16:19:05 2024 -0500

libcpp: modules and -include again

I enabled include translation to header units in r15-1104-ga29f481bbcaf2b,
but it seems that patch wasn't sufficient, as any diagnostics in the main
source file would show up as coming from the header instead.

Fixed by setting buffer->file for leaving the file transition that my
previous patch made us enter.  And don't push a buffer of newlines, in this
case that messes up line numbers instead of aligning them.

libcpp/ChangeLog:

* files.cc (_cpp_stack_file): Handle -include of header unit more
specially.

gcc/testsuite/ChangeLog:

* g++.dg/modules/dashinclude-1_b.C: Add an #error.
* g++.dg/modules/dashinclude-1_a.H: Remove dg-module-do run.

Diff:
---
 gcc/testsuite/g++.dg/modules/dashinclude-1_b.C |  2 ++
 libcpp/files.cc| 10 --
 gcc/testsuite/g++.dg/modules/dashinclude-1_a.H |  1 -
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C 
b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C
index 6e6a33407a46..f257a1d658e3 100644
--- a/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C
+++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C
@@ -6,4 +6,6 @@ int main ()
   return f();
 }
 
+#error foo // { dg-error "foo" }
+
 // { dg-final { scan-lang-dump {Translating include to import} module } }
diff --git a/libcpp/files.cc b/libcpp/files.cc
index 1cbce4947ee1..a60fe1fb6eac 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -977,8 +977,11 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, 
include_type type,
 that.  (We also need an extra newline, so this looks like a regular
 file, which we do that to to make sure we don't fall off the end in the
 middle of a line.  */
-  static uchar newlines[] = "\n\n\n";
-  cpp_push_buffer (pfile, newlines, 2, true);
+  if (type != IT_CMDLINE)
+   {
+ static uchar newlines[] = "\n\n\n";
+ cpp_push_buffer (pfile, newlines, 2, true);
+   }
 
   size_t len = strlen (buf);
   buf[len] = '\n'; /* See above  */
@@ -986,6 +989,9 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, 
include_type type,
= cpp_push_buffer (pfile, reinterpret_cast (buf),
   len, true);
   buffer->to_free = buffer->buf;
+  if (type == IT_CMDLINE)
+   /* Tell _cpp_pop_buffer to change files.  */
+   buffer->file = file;
 
   file->header_unit = +1;
   _cpp_mark_file_once_only (pfile, file);
diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H 
b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H
index c1b40a539243..82ee340798f6 100644
--- a/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H
+++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H
@@ -1,4 +1,3 @@
-// { dg-module-do run }
 // { dg-additional-options "-fmodule-header" }
 // { dg-module-cmi {} }


[gcc r15-5714] c++: modules and local static

2024-11-26 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:2fd9aef1db1a4260ee823bc3a3d4cfc22e95c543

commit r15-5714-g2fd9aef1db1a4260ee823bc3a3d4cfc22e95c543
Author: Jason Merrill 
Date:   Tue Nov 26 07:50:49 2024 -0500

c++: modules and local static

Here we weren't emitting the guard variable for 'a'  when we emitted 'afn'
in the importer, because we only treated inline variables as needing that.
Fixed by generalizing to vague_linkage_p.

But we need to specifically exempt vtables, because the rest of the module
code handles them specially and expects them to be DECL_EXTERNAL.

gcc/cp/ChangeLog:

* module.cc (trees_out::core_bools): Check vague_linkage_p.
(has_definition): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/static-3_b.C: New test.
* g++.dg/modules/static-3_a.H: New test.

Diff:
---
 gcc/cp/module.cc  | 23 ---
 gcc/testsuite/g++.dg/modules/static-3_b.C |  8 
 gcc/testsuite/g++.dg/modules/static-3_a.H | 13 +
 3 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index e5955081d4d3..ddede0fdd437 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -5521,16 +5521,13 @@ trees_out::core_bools (tree t, bits_out& bits)
 
case VAR_DECL:
  if (TREE_PUBLIC (t)
- && !(TREE_STATIC (t)
-  && DECL_FUNCTION_SCOPE_P (t)
-  && DECL_DECLARED_INLINE_P (DECL_CONTEXT (t)))
- && !DECL_VAR_DECLARED_INLINE_P (t))
+ && DECL_VTABLE_OR_VTT_P (t))
+   /* We handle vtable linkage specially.  */
is_external = true;
- break;
-
+ gcc_fallthrough ();
case FUNCTION_DECL:
  if (TREE_PUBLIC (t)
- && !DECL_DECLARED_INLINE_P (t))
+ && !vague_linkage_p (t))
is_external = true;
  break;
}
@@ -11950,11 +11947,15 @@ has_definition (tree decl)
   since there's no TU to emit them in otherwise.  */
return true;
 
- if (!decl_maybe_constant_var_p (decl)
- && !DECL_INLINE_VAR_P (decl))
-   return false;
+ if (decl_maybe_constant_var_p (decl))
+   /* We might need its constant value.  */
+   return true;
 
- return true;
+ if (vague_linkage_p (decl))
+   /* These are emitted as needed.  */
+   return true;
+
+ return false;
}
   break;
 
diff --git a/gcc/testsuite/g++.dg/modules/static-3_b.C 
b/gcc/testsuite/g++.dg/modules/static-3_b.C
new file mode 100644
index ..70180f8eb323
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/static-3_b.C
@@ -0,0 +1,8 @@
+// { dg-additional-options -fmodules }
+
+import "static-3_a.H";
+
+int main()
+{
+  afn();
+}
diff --git a/gcc/testsuite/g++.dg/modules/static-3_a.H 
b/gcc/testsuite/g++.dg/modules/static-3_a.H
new file mode 100644
index ..e5a014e93732
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/static-3_a.H
@@ -0,0 +1,13 @@
+// { dg-additional-options -fmodules }
+// { dg-module-do link }
+
+inline int i;
+
+struct A {
+  A() { ++i; }
+};
+
+inline A& afn() {
+  static A a;
+  return a;
+}


[gcc r15-5713] c++: enable -Warray-compare by default

2024-11-26 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:d89d033e2731a53bf71a0db5259380504357d2f5

commit r15-5713-gd89d033e2731a53bf71a0db5259380504357d2f5
Author: Jason Merrill 
Date:   Fri Nov 22 08:47:56 2024 +0100

c++: enable -Warray-compare by default

Discussion of P2865R5 mentioned that we only enabled this warning with
-Wall; we should handle it like other deprecations.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Enable -Warray-compare
in C++20.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr15791-1.C: Add -Wno-array-compare.

Diff:
---
 gcc/c-family/c-opts.cc| 5 +
 gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C | 1 +
 2 files changed, 6 insertions(+)

diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index a0029294d400..a02d011abc1f 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1051,6 +1051,11 @@ c_common_post_options (const char **pfilename)
   warn_deprecated_literal_operator,
   deprecated_in (cxx23));
 
+  /* -Warray-compare is enabled by default in C++20.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+  warn_array_compare,
+  warn_array_compare || deprecated_in (cxx20));
+
   /* -Wtemplate-id-cdtor is enabled by default in C++20.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
   warn_template_id_cdtor,
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C 
b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C
index 68f14adad00a..9905851ee7c4 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr15791-1.C
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-additional-options -Wno-array-compare } */
 
 void link_error ();


[gcc r15-5669] libstdc++: Add conditional noexcept to range access functions

2024-11-26 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:8692cb10e82e72af70b690c23be5e5096bb999d2

commit r15-5669-g8692cb10e82e72af70b690c23be5e5096bb999d2
Author: Jonathan Wakely 
Date:   Mon Nov 25 21:22:12 2024 +

libstdc++: Add conditional noexcept to range access functions

As an extension, this adds conditional noexcept to std::begin, std::end,
and std::ssize.

libstdc++-v3/ChangeLog:

* include/bits/range_access.h (begin, end, ssize): Add
conditional noexcept.
* testsuite/18_support/initializer_list/range_access.cc: Check
results and noexcept-specifier for std::begin and std::end.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc:
Check for conditional noexcept on std::begin and std::end.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc:
Likewise.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
Likewise.
* testsuite/24_iterators/range_access/range_access.cc: Check
conditional noexcept is correct.
* testsuite/24_iterators/range_access/range_access_cpp17.cc:
Check std::size, std::empty and std::data.
* testsuite/24_iterators/range_access/range_access_cpp20.cc:
Check conditional noexcept on std::ssize.

Diff:
---
 libstdc++-v3/include/bits/range_access.h   | 15 +++---
 .../18_support/initializer_list/range_access.cc| 10 
 .../headers/iterator/range_access_c++11.cc | 15 --
 .../headers/iterator/range_access_c++14.cc | 15 --
 .../headers/iterator/range_access_c++17.cc | 15 --
 .../24_iterators/range_access/range_access.cc  | 18 +++
 .../range_access/range_access_cpp17.cc | 57 ++
 .../range_access/range_access_cpp20.cc |  8 ++-
 8 files changed, 134 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/include/bits/range_access.h 
b/libstdc++-v3/include/bits/range_access.h
index 2dacbedfa533..ae58710e4a24 100644
--- a/libstdc++-v3/include/bits/range_access.h
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -51,7 +51,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 [[__nodiscard__, __gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR auto
-begin(_Container& __cont) -> decltype(__cont.begin())
+begin(_Container& __cont) noexcept(noexcept(__cont.begin()))
+-> decltype(__cont.begin())
 { return __cont.begin(); }
 
   /**
@@ -62,7 +63,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 [[__nodiscard__, __gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR auto
-begin(const _Container& __cont) -> decltype(__cont.begin())
+begin(const _Container& __cont) noexcept(noexcept(__cont.begin()))
+-> decltype(__cont.begin())
 { return __cont.begin(); }
 
   /**
@@ -73,7 +75,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 [[__nodiscard__, __gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR auto
-end(_Container& __cont) -> decltype(__cont.end())
+end(_Container& __cont) noexcept(noexcept(__cont.end()))
+-> decltype(__cont.end())
 { return __cont.end(); }
 
   /**
@@ -84,7 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 [[__nodiscard__, __gnu__::__always_inline__]]
 inline _GLIBCXX17_CONSTEXPR auto
-end(const _Container& __cont) -> decltype(__cont.end())
+end(const _Container& __cont) noexcept(noexcept(__cont.end()))
+-> decltype(__cont.end())
 { return __cont.end(); }
 
   /**
@@ -351,8 +355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 [[nodiscard, __gnu__::__always_inline__]]
 constexpr auto
-ssize(const _Container& __cont)
-noexcept(noexcept(__cont.size()))
+ssize(const _Container& __cont) noexcept(noexcept(__cont.size()))
 -> common_type_t>
 {
   using type = make_signed_t;
diff --git a/libstdc++-v3/testsuite/18_support/initializer_list/range_access.cc 
b/libstdc++-v3/testsuite/18_support/initializer_list/range_access.cc
index ca572dc25dfe..3d4e2fefd395 100644
--- a/libstdc++-v3/testsuite/18_support/initializer_list/range_access.cc
+++ b/libstdc++-v3/testsuite/18_support/initializer_list/range_access.cc
@@ -27,3 +27,13 @@ test01()
   std::begin({1, 2, 3});
   std::end({1, 2, 3});
 }
+
+void
+test02()
+{
+  static constexpr std::initializer_list il{1};
+  static_assert( std::begin(il) == il.begin() );
+  static_assert( std::end(il) == il.end() );
+  static_assert( noexcept(std::begin(il)) );
+  static_assert( noexcept(std::end(il)) );
+}
diff --git 
a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc 
b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc
index 448e86bce2ff..89143d5dfa0b 100644
--- a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc
+++ b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc
@@ -20,13 +20,20 @@
 
 #i

[gcc r15-5668] libstdc++: Improve Doxygen comments in

2024-11-26 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:828287eac4ff2b6da18e3a53c1e83adfa1e06180

commit r15-5668-g828287eac4ff2b6da18e3a53c1e83adfa1e06180
Author: Jonathan Wakely 
Date:   Mon Nov 25 16:21:01 2024 +

libstdc++: Improve Doxygen comments in 

Use Markdown backticks to format comments, instead of Doxygen @c and @a
commands.

libstdc++-v3/ChangeLog:

* include/bits/forward_list.h: Use Markdown in Doxygen comments.

Diff:
---
 libstdc++-v3/include/bits/forward_list.h | 123 ---
 1 file changed, 62 insertions(+), 61 deletions(-)

diff --git a/libstdc++-v3/include/bits/forward_list.h 
b/libstdc++-v3/include/bits/forward_list.h
index c9238cef96fa..663ed0c46aff 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -421,14 +421,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  Meets the requirements of a container, a
*  sequence, including the
*  optional sequence requirements with the
-   *  %exception of @c at and @c operator[].
+   *  %exception of `at` and `operator[]`.
*
*  This is a @e singly @e linked %list.  Traversal up the
*  %list requires linear time, but adding and removing elements (or
*  @e nodes) is done in constant time, regardless of where the
*  change takes place.  Unlike std::vector and std::deque,
-   *  random-access iterators are not provided, so subscripting ( @c
-   *  [] ) access is not allowed.  For algorithms which only need
+   *  random-access iterators are not provided, so subscripting (`[]`)
+   *  access is not allowed.  For algorithms which only need
*  sequential access, this lack makes no difference.
*
*  Also unlike the other standard containers, std::forward_list provides
@@ -529,7 +529,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __n   The number of elements to initially create.
*  @param  __al  An allocator object.
*
-   *  This constructor creates the %forward_list with @a __n default
+   *  This constructor creates the %forward_list with `__n` default
*  constructed elements.
*/
   explicit
@@ -543,8 +543,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __value  An element to copy.
*  @param  __al An allocator object.
*
-   *  This constructor fills the %forward_list with @a __n copies of
-   *  @a __value.
+   *  This constructor fills the %forward_list with `__n` copies of
+   *  `__value`.
*/
   forward_list(size_type __n, const _Tp& __value,
   const _Alloc& __al = _Alloc())
@@ -558,8 +558,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __al An allocator object.
*
*  Create a %forward_list consisting of copies of the elements from
-   *  [@a __first,@a __last).  This is linear in N (where N is
-   *  distance(@a __first,@a __last)).
+   *  `[__first,__last)`.  This is linear in N (where N is
+   *  `distance(__first,__last)`).
*/
   template>
@@ -619,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __al  An allocator object.
*
*  Create a %forward_list consisting of copies of the elements
-   *  in the initializer_list @a __il.  This is linear in __il.size().
+   *  in the initializer_list `__il`.  This is linear in `__il.size()`.
*/
   forward_list(std::initializer_list<_Tp> __il,
   const _Alloc& __al = _Alloc())
@@ -637,7 +637,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __list  A %forward_list of identical element and allocator
*types.
*
-   *  All the elements of @a __list are copied.
+   *  All the elements of `__list` are copied.
*
*  Whether the allocator is copied depends on the allocator traits.
*/
@@ -649,7 +649,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __list  A %forward_list of identical element and allocator
*types.
*
-   *  The contents of @a __list are moved into this %forward_list
+   *  The contents of `__list` are moved into this %forward_list
*  (without copying, if the allocators permit it).
*
*  Afterwards @a __list is a valid, but unspecified %forward_list
@@ -672,8 +672,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __il  An initializer_list of value_type.
*
*  Replace the contents of the %forward_list with copies of the
-   *  elements in the initializer_list @a __il.  This is linear in
-   *  __il.size().
+   *  elements in the initializer_list `__il`.  This is linear in
+   *  `__il.size()`.
*/
   forward_list&
   operator=(std::initializer_list<_Tp> __il)
@@ -688,7 +688,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @param  __last   An input iterator.
*
*  This function fills a %forward_list with copies of the ele

[gcc r15-5667] libstdc++: Move std::error_category symbol to separate file [PR117630]

2024-11-26 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:1f4f3683457512cbeb722c6e6458454c21c419d1

commit r15-5667-g1f4f3683457512cbeb722c6e6458454c21c419d1
Author: Jonathan Wakely 
Date:   Sun Nov 17 20:46:07 2024 +

libstdc++: Move std::error_category symbol to separate file [PR117630]

As described in PR 117630 the cow-stdexcept.cc file pulls in symbols
from system_error.cc, which are not actually needed there. Moving the
definition of error_category::_M_message to a separate file should solve
it.

libstdc++-v3/ChangeLog:

PR libstdc++/117630
* src/c++11/Makefile.am: Add new file.
* src/c++11/Makefile.in: Regnerate.
* src/c++11/cow-stdexcept.cc (error_category::_M_message): Move
member function definition to ...
* src/c++11/cow-system_error.cc: New file.

Diff:
---
 libstdc++-v3/src/c++11/Makefile.am |  1 +
 libstdc++-v3/src/c++11/Makefile.in | 13 
 libstdc++-v3/src/c++11/cow-stdexcept.cc|  9 --
 libstdc++-v3/src/c++11/cow-system_error.cc | 48 ++
 4 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/libstdc++-v3/src/c++11/Makefile.am 
b/libstdc++-v3/src/c++11/Makefile.am
index 89e20ca3b06b..a501607c474b 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -69,6 +69,7 @@ sources = \
codecvt.cc \
condition_variable.cc \
cow-stdexcept.cc \
+   cow-system_error.cc \
ctype.cc \
debug.cc \
functexcept.cc \
diff --git a/libstdc++-v3/src/c++11/Makefile.in 
b/libstdc++-v3/src/c++11/Makefile.in
index 4be021e80259..770e948a98af 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -129,12 +129,12 @@ am__objects_1 = limits.lo placeholders.lo
 am__objects_3 = ctype_configure_char.lo ctype_members.lo
 am__objects_4 = basic_file.lo
 am__objects_5 = assert_fail.lo chrono.lo codecvt.lo \
-   condition_variable.lo cow-stdexcept.lo ctype.lo debug.lo \
-   functexcept.lo functional.lo futex.lo future.lo hash_c++0x.lo \
-   hashtable_c++0x.lo ios.lo ios_errcat.lo locale_init.lo \
-   localename.lo mutex.lo random.lo regex.lo shared_ptr.lo \
-   snprintf_lite.lo system_error.lo thread.lo $(am__objects_2) \
-   $(am__objects_3) $(am__objects_4)
+   condition_variable.lo cow-stdexcept.lo cow-system_error.lo \
+   ctype.lo debug.lo functexcept.lo functional.lo futex.lo \
+   future.lo hash_c++0x.lo hashtable_c++0x.lo ios.lo \
+   ios_errcat.lo locale_init.lo localename.lo mutex.lo random.lo \
+   regex.lo shared_ptr.lo snprintf_lite.lo system_error.lo \
+   thread.lo $(am__objects_2) $(am__objects_3) $(am__objects_4)
 @ENABLE_DUAL_ABI_TRUE@am__objects_6 = cow-fstream-inst.lo \
 @ENABLE_DUAL_ABI_TRUE@ cow-sstream-inst.lo cow-string-inst.lo \
 @ENABLE_DUAL_ABI_TRUE@ cow-string-io-inst.lo \
@@ -488,6 +488,7 @@ sources = \
codecvt.cc \
condition_variable.cc \
cow-stdexcept.cc \
+   cow-system_error.cc \
ctype.cc \
debug.cc \
functexcept.cc \
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc 
b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 6af88f23fca0..ada16eb8e9e5 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -46,7 +46,6 @@ _txnal_runtime_error_get_msg(void* e);
 #define _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS 1
 #define __cow_string __cow_stringxxx
 #include 
-#include 
 #undef __cow_string
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -169,14 +168,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 "alignof(std::string) has changed");
 #endif
 
-  // Return error_category::message() as an SSO string
-  __sso_string
-  error_category::_M_message(int i) const
-  {
-string msg = this->message(i);
-return {msg.c_str(), msg.length()};
-  }
-
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/src/c++11/cow-system_error.cc 
b/libstdc++-v3/src/c++11/cow-system_error.cc
new file mode 100644
index ..56824c190e7e
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-system_error.cc
@@ -0,0 +1,48 @@
+// Dual ABI Support for  -*- C++ -*-
+
+// Copyright (C) 2014-2024 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+//

[gcc r15-5674] Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:8278d9551df610179fca114808a7e6e62bab3d82

commit r15-5674-g8278d9551df610179fca114808a7e6e62bab3d82
Author: Paul Thomas 
Date:   Tue Nov 26 08:58:21 2024 +

Fortran: Partial reversion of r15-5083 [PR117763]

2024-11-26  Paul Thomas  

gcc/fortran
PR fortran/117763
* trans-array.cc (gfc_get_array_span): Guard against derefences
of 'expr'. Clean up some typos. Use 'gfc_get_vptr_from_expr'
for clarity and apply a functional reversion of last section
that deals with class dummies.

gcc/testsuite/
PR fortran/117763
* gfortran.dg/pr117763.f90: New test.

Diff:
---
 gcc/fortran/trans-array.cc |  16 +-
 gcc/testsuite/gfortran.dg/pr117763.f90 | 279 +
 2 files changed, 289 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 32dcd4cb0c7d..a458af322ce8 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -961,8 +961,8 @@ tree
 gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   tree tmp;
-  gfc_symbol *sym = expr->expr_type == EXPR_VARIABLE
-   ? expr->symtree->n.sym : NULL;
+  gfc_symbol *sym = (expr && expr->expr_type == EXPR_VARIABLE) ?
+   expr->symtree->n.sym : NULL;
 
   if (is_pointer_array (desc)
   || (get_CFI_desc (NULL, expr, &desc, NULL)
@@ -989,7 +989,7 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
 {
   /* Treat unlimited polymorphic expressions separately because
 the element size need not be the same as the span.  Obtain
-the class container, which is simplified here by their being
+the class container, which is simplified here by there being
 no component references.  */
   if (sym && sym->attr.dummy)
{
@@ -1013,12 +1013,16 @@ gfc_get_array_span (tree desc, gfc_expr *expr)
   /* The descriptor is a class _data field. Use the vtable size
 since it is guaranteed to have been set and is always OK for
 class array descriptors that are not unlimited.  */
-  tmp = gfc_class_vptr_get (TREE_OPERAND (desc, 0));
+  tmp = gfc_get_vptr_from_expr (desc);
   tmp = gfc_vptr_size_get (tmp);
 }
-  else if (sym && sym->ts.type == BT_CLASS && sym->attr.dummy)
+  else if (sym && sym->ts.type == BT_CLASS
+  && expr->ref->type == REF_COMPONENT
+  && expr->ref->next->type == REF_ARRAY
+  && expr->ref->next->next == NULL
+  && CLASS_DATA (sym)->attr.dimension)
 {
-  /* Class dummys usually requires extraction from the saved
+  /* Class dummys usually require extraction from the saved
 descriptor, which gfc_class_vptr_get does for us.  */
   tmp = gfc_class_vptr_get (sym->backend_decl);
   tmp = gfc_vptr_size_get (tmp);
diff --git a/gcc/testsuite/gfortran.dg/pr117763.f90 
b/gcc/testsuite/gfortran.dg/pr117763.f90
new file mode 100644
index ..5f7b36c02694
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117763.f90
@@ -0,0 +1,279 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR117763, which was a regression caused by the patch for
+! PR109345.
+!
+! Contributed by Juergen Reuter  
+!
+module iso_varying_string
+  implicit none
+  integer, parameter, private :: GET_BUFFER_LEN = 1
+
+  type, public :: varying_string
+ private
+ character(LEN=1), dimension(:), allocatable :: chars
+  end type varying_string
+
+  interface assignment(=)
+ module procedure op_assign_CH_VS
+ module procedure op_assign_VS_CH
+  end interface assignment(=)
+
+  interface char
+ module procedure char_auto
+ module procedure char_fixed
+  end interface char
+
+  interface len
+ module procedure len_
+  end interface len
+
+  interface var_str
+ module procedure var_str_
+  end interface var_str
+
+  public :: assignment(=)
+  public :: char
+  public :: len
+  public :: var_str
+
+  private :: op_assign_CH_VS
+  private :: op_assign_VS_CH
+  private :: char_auto
+  private :: char_fixed
+  private :: len_
+  private :: var_str_
+
+contains
+
+  elemental function len_ (string) result (length)
+type(varying_string), intent(in) :: string
+integer  :: length
+if(ALLOCATED(string%chars)) then
+   length = SIZE(string%chars)
+else
+   length = 0
+endif
+  end function len_
+
+  elemental subroutine op_assign_CH_VS (var, exp)
+character(LEN=*), intent(out):: var
+type(varying_string), intent(in) :: exp
+var = char(exp)
+  end subroutine op_assign_CH_VS
+
+  elemental subroutine op_assign_VS_CH (var, exp)
+type(varying_string), intent(out) :: var
+character(LEN=*), intent(in)  :: exp
+var = var_str(exp)
+  end subroutine op_assign_VS_CH
+
+  pure function char_auto (string) result (char_string)
+type(varying_string), intent(in) :: string
+character(

[gcc r15-5671] builtins: Fix up DFP ICEs on __builtin_is{inf, finite, normal} [PR43374]

2024-11-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f39e6b4f5cd4e5362cf4b1004a591df2c8b00304

commit r15-5671-gf39e6b4f5cd4e5362cf4b1004a591df2c8b00304
Author: Jakub Jelinek 
Date:   Tue Nov 26 09:45:21 2024 +0100

builtins: Fix up DFP ICEs on __builtin_is{inf,finite,normal} [PR43374]

__builtin_is{inf,finite,normal} builtins ICE on _Decimal{32,64,128,64x}
operands unless those operands are constant.

The problem is that we fold the builtins to comparisons with the largest
finite number, but
a) get_max_float was only handling binary floats
b) real_from_string again assumes binary float
and so we were ICEing in the build_real called after the two calls.

This patch adds decimal handling into get_max_float (well, moves it
from c-cppbuiltin.cc which was printing those for __DEC{32,64,128}_MAX__
macros) and uses real_from_string3 (perhaps it is time to rename it
to just real_from_string now that we can use function overloading)
so that it handles both binary and decimal floats.

2024-11-26  Jakub Jelinek  

PR middle-end/43374
gcc/
* real.cc (get_max_float): Handle decimal float.
* builtins.cc (fold_builtin_interclass_mathfn): Use
real_from_string3 rather than real_from_string.  Use
"1E%d" format string rather than "0x1p%d" for decimal
float minimum.
gcc/c-family/
* c-cppbuiltin.cc (builtin_define_decimal_float_constants): Use
get_max_float.
gcc/testsuite/
* gcc.dg/dfp/pr43374.c: New test.

Diff:
---
 gcc/builtins.cc| 13 +
 gcc/c-family/c-cppbuiltin.cc   | 13 ++---
 gcc/real.cc| 16 +++
 gcc/testsuite/gcc.dg/dfp/pr43374.c | 56 ++
 4 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 029c561d4665..055b31d264ca 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -9580,7 +9580,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree 
fndecl, tree arg)
arg = fold_build1_loc (loc, NOP_EXPR, type, arg);
  }
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
-   real_from_string (&r, buf);
+   real_from_string3 (&r, buf, mode);
result = build_call_expr (isgr_fn, 2,
  fold_build1_loc (loc, ABS_EXPR, type, arg),
  build_real (type, r));
@@ -9604,7 +9604,7 @@ fold_builtin_interclass_mathfn (location_t loc, tree 
fndecl, tree arg)
arg = fold_build1_loc (loc, NOP_EXPR, type, arg);
  }
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
-   real_from_string (&r, buf);
+   real_from_string3 (&r, buf, mode);
result = build_call_expr (isle_fn, 2,
  fold_build1_loc (loc, ABS_EXPR, type, arg),
  build_real (type, r));
@@ -9643,9 +9643,12 @@ fold_builtin_interclass_mathfn (location_t loc, tree 
fndecl, tree arg)
arg = fold_build1_loc (loc, ABS_EXPR, type, arg);
 
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false);
-   real_from_string (&rmax, buf);
-   sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
-   real_from_string (&rmin, buf);
+   real_from_string3 (&rmax, buf, mode);
+   if (DECIMAL_FLOAT_MODE_P (mode))
+ sprintf (buf, "1E%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
+   else
+ sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (orig_mode)->emin - 1);
+   real_from_string3 (&rmin, buf, orig_mode);
max_exp = build_real (type, rmax);
min_exp = build_real (type, rmin);
 
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 349918c325cd..8fbfef561e8a 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -357,17 +357,8 @@ builtin_define_decimal_float_constants (const char 
*name_prefix,
 
   /* Compute the maximum representable value.  */
   sprintf (name, "__%s_MAX__", name_prefix);
-  p = buf;
-  for (digits = fmt->p; digits; digits--)
-{
-  *p++ = '9';
-  if (digits == fmt->p)
-   *p++ = '.';
-}
-  *p = 0;
-  /* fmt->p plus 1, to account for the decimal point and fmt->emax
- minus 1 because the digits are nines, not 1.0.  */
-  sprintf (&buf[fmt->p + 1], "E%d%s", fmt->emax - 1, suffix);
+  get_max_float (fmt, buf, sizeof (buf) - strlen (suffix), false);
+  strcat (buf, suffix);
   builtin_define_with_value (name, buf, 0);
 
   /* Compute epsilon (the difference between 1 and least value greater
diff --git a/gcc/real.cc b/gcc/real.cc
index 1392595a72f1..b89ff8334091 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -5438,6 +5438,22 @@ void
 get_max_float (const struct real_format *fmt, char *buf, size_t len,
   bool norm_max)
 {
+  if (fmt->b == 10)
+{
+  char *p = buf;
+  

[gcc r15-5670] affine: Remove unused variable rem from wide_int_constant_multiple_p

2024-11-26 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:014b135672717d23706d5e2554d49d7cf2200fa5

commit r15-5670-g014b135672717d23706d5e2554d49d7cf2200fa5
Author: Andrew Pinski 
Date:   Tue Nov 26 00:37:33 2024 -0800

affine: Remove unused variable rem from wide_int_constant_multiple_p

This might fix the current bootstrap failure on aarch64, I only tested it
on x86_64. But the rem variable is unused and the for poly_widest_int, there
could be loop if NUM_POLY_INT_COEFFS is 2 or more. In the case of aarch64,
NUM_POLY_INT_COEFFS is 2.
Note the reason why there is warning for the unused variable is due to the 
deconstructor.

Pushed as obvious after a build for x86_64-linux-gnu.

gcc/ChangeLog:

* tree-affine.cc (wide_int_constant_multiple_p): Remove unused rem 
variable.

Signed-off-by: Andrew Pinski 

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

diff --git a/gcc/tree-affine.cc b/gcc/tree-affine.cc
index 76117aa4fd6d..bb99176eabba 100644
--- a/gcc/tree-affine.cc
+++ b/gcc/tree-affine.cc
@@ -891,7 +891,7 @@ wide_int_constant_multiple_p (const poly_widest_int &val,
  const poly_widest_int &div,
  bool *mult_set, poly_widest_int *mult)
 {
-  poly_widest_int rem, cst;
+  poly_widest_int cst;
 
   if (known_eq (val, 0))
 {


[gcc r15-5672] builtins: Fix up DFP ICEs on __builtin_fpclassify [PR102674]

2024-11-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:5bb36d832c955e575bd458a02f3c6c5b28564aed

commit r15-5672-g5bb36d832c955e575bd458a02f3c6c5b28564aed
Author: Jakub Jelinek 
Date:   Tue Nov 26 09:46:51 2024 +0100

builtins: Fix up DFP ICEs on __builtin_fpclassify [PR102674]

This patch is similar to the one I've just posted, __builtin_fpclassify also
needs to print decimal float minimum differently and use real_from_string3.
Plus I've done some formatting fixes.

2024-11-26  Jakub Jelinek  

PR middle-end/102674
* builtins.cc (fold_builtin_fpclassify): Use real_from_string3 
rather
than real_from_string.  Use "1E%d" format string rather than 
"0x1p%d"
for decimal float minimum.  Formatting fixes.

* gcc.dg/dfp/pr102674.c: New test.

Diff:
---
 gcc/builtins.cc | 23 -
 gcc/testsuite/gcc.dg/dfp/pr102674.c | 65 +
 2 files changed, 79 insertions(+), 9 deletions(-)

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 055b31d264ca..6271cdc1debb 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -9837,28 +9837,33 @@ fold_builtin_fpclassify (location_t loc, tree *args, 
int nargs)
 (x == 0 ? FP_ZERO : FP_SUBNORMAL))).  */
 
   tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
-build_real (type, dconst0));
+build_real (type, dconst0));
   res = fold_build3_loc (loc, COND_EXPR, integer_type_node,
-tmp, fp_zero, fp_subnormal);
+tmp, fp_zero, fp_subnormal);
 
-  sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
-  real_from_string (&r, buf);
+  if (DECIMAL_FLOAT_MODE_P (mode))
+sprintf (buf, "1E%d", REAL_MODE_FORMAT (mode)->emin - 1);
+  else
+sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
+  real_from_string3 (&r, buf, mode);
   tmp = fold_build2_loc (loc, GE_EXPR, integer_type_node,
-arg, build_real (type, r));
-  res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, fp_normal, 
res);
+arg, build_real (type, r));
+  res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
+fp_normal, res);
 
   if (tree_expr_maybe_infinite_p (arg))
 {
   tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
-build_real (type, dconstinf));
+build_real (type, dconstinf));
   res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
-fp_infinite, res);
+fp_infinite, res);
 }
 
   if (tree_expr_maybe_nan_p (arg))
 {
   tmp = fold_build2_loc (loc, ORDERED_EXPR, integer_type_node, arg, arg);
-  res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, res, 
fp_nan);
+  res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
+res, fp_nan);
 }
 
   return res;
diff --git a/gcc/testsuite/gcc.dg/dfp/pr102674.c 
b/gcc/testsuite/gcc.dg/dfp/pr102674.c
new file mode 100644
index ..c67ecf5ce71b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/pr102674.c
@@ -0,0 +1,65 @@
+/* PR middle-end/102674 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#define FP_NAN 0
+#define FP_INFINITE 1
+#define FP_ZERO 2
+#define FP_SUBNORMAL 3
+#define FP_NORMAL 4
+
+__attribute__((noipa)) int
+foo (_Decimal32 x)
+{
+  return __builtin_fpclassify (FP_NAN, FP_INFINITE, FP_NORMAL,
+  FP_SUBNORMAL, FP_ZERO, x);
+}
+
+__attribute__((noipa)) int
+bar (_Decimal64 x)
+{
+  return __builtin_fpclassify (FP_NAN, FP_INFINITE, FP_NORMAL,
+  FP_SUBNORMAL, FP_ZERO, x);
+}
+
+__attribute__((noipa)) int
+baz (_Decimal128 x)
+{
+  return __builtin_fpclassify (FP_NAN, FP_INFINITE, FP_NORMAL,
+  FP_SUBNORMAL, FP_ZERO, x);
+}
+
+int
+main ()
+{
+  if (foo (__builtin_infd32 ()) != FP_INFINITE
+  || foo (-__builtin_infd32 ()) != FP_INFINITE
+  || foo (__builtin_nand32 ("")) != FP_NAN
+  || foo (9.99E96DF) != FP_NORMAL
+  || foo (-1E-95DF) != FP_NORMAL
+  || foo (0.99E-95DF) != FP_SUBNORMAL
+  || foo (-0.01E-95DF) != FP_SUBNORMAL
+  || foo (0.000DF) != FP_ZERO
+  || foo (-0.0DF) != FP_ZERO)
+__builtin_abort ();
+  if (bar (__builtin_infd64 ()) != FP_INFINITE
+  || bar (-__builtin_infd64 ()) != FP_INFINITE
+  || bar (__builtin_nand64 ("")) != FP_NAN
+  || bar (9.999E384DD) != FP_NORMAL
+  || bar (-1E-383DD) != FP_NORMAL
+  || bar (0.999E-383DD) != FP_SUBNORMAL
+  || bar (-0.001E-383DD) != FP_SUBNORMAL
+  || bar (0.000DD) != FP_ZERO
+  || bar (-0.00DD) != FP_ZERO)
+__builtin_abort ();
+  if (baz (__builtin_infd128 ()) != FP_INFINITE
+  || baz (-__builtin_infd128 ()) != FP_INFINITE
+  || baz (__builtin_nand128 ("")

[gcc r15-5673] RISC-V: avlprop: Do not propagate VL from slidedown.

2024-11-26 Thread Robin Dapp via Gcc-cvs
https://gcc.gnu.org/g:9c82afd42e7b5c3bdb849c66879138e59d8eb866

commit r15-5673-g9c82afd42e7b5c3bdb849c66879138e59d8eb866
Author: Robin Dapp 
Date:   Mon Nov 25 12:40:53 2024 +0100

RISC-V: avlprop: Do not propagate VL from slidedown.

In the following situation (found in the
rvv/autovec/vls-vlmax/shuffle-slide.c test which is not yet pushed)

vsetivlizero,4,e8,mf4,ta,ma
vle8.v  v2,0(a1)# (1)
vle8.v  v1,0(a2)# (2)
vsetivlizero,2,e8,mf4,tu,ma
vslidedown.vi   v1,v2,2
vsetivlizero,4,e8,mf4,ta,ma
vse8.v  v1,0(a2)

we wrongly "propagate" VL=2 from vslidedown into the load.

Although we check whether the "target" instruction has a merge operand
the check only handles cases where the merge operand itself is
loaded, like (2) in the snippet above.  For (1) we load the non-merged
operand, assume propagation is valid and continue despite (2).

This patch just re-uses avl_can_be_propagated_p in order to disable
slides altogether in such situations.

gcc/ChangeLog:

* config/riscv/riscv-avlprop.cc 
(pass_avlprop::get_vlmax_ta_preferred_avl):
Check whether the use insn is valid for propagation.

Diff:
---
 gcc/config/riscv/riscv-avlprop.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv-avlprop.cc 
b/gcc/config/riscv/riscv-avlprop.cc
index 91d80aa00d62..62491f9be2d4 100644
--- a/gcc/config/riscv/riscv-avlprop.cc
+++ b/gcc/config/riscv/riscv-avlprop.cc
@@ -351,7 +351,8 @@ pass_avlprop::get_vlmax_ta_preferred_avl (insn_info *insn) 
const
  if (!use_insn->can_be_optimized () || use_insn->is_asm ()
  || use_insn->is_call () || use_insn->has_volatile_refs ()
  || use_insn->has_pre_post_modify ()
- || !has_vl_op (use_insn->rtl ()))
+ || !has_vl_op (use_insn->rtl ())
+ || !avl_can_be_propagated_p (use_insn->rtl ()))
return NULL_RTX;
 
  /* We should only propagate non-VLMAX AVL into VLMAX insn when


[gcc r15-5682] ada: Store error message kind as an enum

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:9a0914232665c3215f5274f52ea6ddf654df4976

commit r15-5682-g9a0914232665c3215f5274f52ea6ddf654df4976
Author: Viljar Indus 
Date:   Thu Oct 31 15:50:46 2024 +0200

ada: Store error message kind as an enum

Simplify the storage for the kind of error message under a single
enumerator. This replaces the existing attributes with the following
enumeration values.
* Is_Warning_Msg => Warning
* Is_Style_Msg => Style
* Is_Info_Msg => Info
* Is_Check_Msg => Low_Check, Medium_Check, High_Check
* Is_Serious_Error => Error, if the attribute was false then
  Non_Serious_Error.

gcc/ada/ChangeLog:

* diagnostics-converter.adb: Use new enum values instead
of the old attributes.
* diagnostics-switch_repository.adb: Same as above.
* diagnostics-utils.adb: Same as above.
* diagnostics.adb: Same as above.
* diagnostics.ads: Same as above.
* errout.adb: Same as above.
* erroutc.adb: Same as above.
* erroutc.ads: Remove old attriubtes and replace them
with Error_Msg_Kind.
* errutil.adb: Same as others.

Diff:
---
 gcc/ada/diagnostics-converter.adb |  11 +-
 gcc/ada/diagnostics-switch_repository.adb |  16 ++-
 gcc/ada/diagnostics-utils.adb |   2 +-
 gcc/ada/diagnostics.adb   |  38 +++---
 gcc/ada/diagnostics.ads   |  11 +-
 gcc/ada/errout.adb| 208 +-
 gcc/ada/erroutc.adb   | 176 ++---
 gcc/ada/erroutc.ads   |  84 +---
 gcc/ada/errutil.adb   |  63 ++---
 9 files changed, 279 insertions(+), 330 deletions(-)

diff --git a/gcc/ada/diagnostics-converter.adb 
b/gcc/ada/diagnostics-converter.adb
index e1613f674c68..f02c2130d7ee 100644
--- a/gcc/ada/diagnostics-converter.adb
+++ b/gcc/ada/diagnostics-converter.adb
@@ -51,9 +51,10 @@ package body Diagnostics.Converter is
 
function Get_Diagnostics_Kind (E_Msg : Error_Msg_Object)
   return Diagnostic_Kind
-   is (if E_Msg.Warn then Get_Warning_Kind (E_Msg)
-  elsif E_Msg.Style then Style
-  elsif E_Msg.Info then Info
+   is (if E_Msg.Kind = Erroutc.Warning then Get_Warning_Kind (E_Msg)
+  elsif E_Msg.Kind = Erroutc.Style then Style
+  elsif E_Msg.Kind = Erroutc.Info then Info
+  elsif E_Msg.Kind = Erroutc.Non_Serious_Error then Non_Serious_Error
   else Error);
 
---
@@ -126,14 +127,12 @@ package body Diagnostics.Converter is
 
   D.Kind := Get_Diagnostics_Kind (E_Msg);
 
-  if E_Msg.Warn or E_Msg.Style or E_Msg.Info then
+  if E_Msg.Kind in Erroutc.Warning | Erroutc.Style | Erroutc.Info then
  D.Switch := Get_Switch_Id (E_Msg);
   end if;
 
   D.Warn_Err := E_Msg.Warn_Err;
 
-  D.Serious := E_Msg.Serious;
-
   --  Convert the primary location
 
   Add_Location (D, Primary_Labeled_Span (E_Msg.Sptr));
diff --git a/gcc/ada/diagnostics-switch_repository.adb 
b/gcc/ada/diagnostics-switch_repository.adb
index d60990192f2f..1795663e615d 100644
--- a/gcc/ada/diagnostics-switch_repository.adb
+++ b/gcc/ada/diagnostics-switch_repository.adb
@@ -582,14 +582,16 @@ package body Diagnostics.Switch_Repository is
---
 
function Get_Switch_Id (E : Error_Msg_Object) return Switch_Id is
-
+  Switch_Name : constant String :=
+(if E.Warn_Chr = "$ " then "gnatel"
+ elsif E.Warn_Chr in "? " | "  " then ""
+ elsif E.Kind in Erroutc.Warning | Erroutc.Info
+ then "gnatw" & E.Warn_Chr
+ elsif E.Kind in Erroutc.Style then "gnatw" & E.Warn_Chr
+ else "");
begin
-  if E.Warn_Chr = "$ " then
- return Get_Switch_Id ("gnatel");
-  elsif E.Warn or E.Info then
- return Get_Switch_Id ("gnatw" & E.Warn_Chr);
-  elsif E.Style then
- return Get_Switch_Id ("gnaty" & E.Warn_Chr);
+  if Switch_Name /= "" then
+ return Get_Switch_Id (Switch_Name);
   else
  return No_Switch_Id;
   end if;
diff --git a/gcc/ada/diagnostics-utils.adb b/gcc/ada/diagnostics-utils.adb
index a590536d917b..11649ccf40ec 100644
--- a/gcc/ada/diagnostics-utils.adb
+++ b/gcc/ada/diagnostics-utils.adb
@@ -219,7 +219,7 @@ package body Diagnostics.Utils is
  (if D.Warn_Err then "error"
   else
(case D.Kind is
-when Diagnostics.Error => "error",
+when Diagnostics.Error | Non_Serious_Error => "error",
 when Warning | Restriction_Warning | Default_Warning |
  Tagless_Warning => "warning",
 when Style => "style",
diff --git a/gcc/ada/diagnostics.adb b/gcc/ada/diagnostics.adb
index c9c5483693c9..d45279f51073 100644
--- a/gcc/ada/diagnostics.adb
+++ b/gcc/ada/diagnostics.adb
@@ -197,21 +197,29 @@ package body Diagnostics is
   proce

[gcc r15-5688] ada: Relocate implementation of Write_Error_Summary

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:fed7c5cd733b593c9aee5898f36726efd3fa811c

commit r15-5688-gfed7c5cd733b593c9aee5898f36726efd3fa811c
Author: Viljar Indus 
Date:   Tue Nov 12 13:11:00 2024 +0200

ada: Relocate implementation of Write_Error_Summary

Reuse the same implementation in Errout and Errutil.

gcc/ada/ChangeLog:

* errout.adb: Remove implmentation of Write_Error_Summary.
* erroutc.adb: Add implemenetation of Write_Error_Summary.
* erroutc.ads: Add spec of Write_Error_Summary.
* errutil.adb: Remove implementation for writing the error summary.

Diff:
---
 gcc/ada/errout.adb  | 141 
 gcc/ada/erroutc.adb | 138 ++
 gcc/ada/erroutc.ads |   3 ++
 gcc/ada/errutil.adb |  73 +--
 4 files changed, 142 insertions(+), 213 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 4070d92992d5..7e24970f1879 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -2495,9 +2495,6 @@ package body Errout is
   --  Emit all error messages in the table use the pretty printed format if
   --  -gnatdF is used otherwise use the brief format.
 
-  procedure Write_Error_Summary;
-  --  Write error summary
-
   procedure Write_Header (Sfile : Source_File_Index);
   --  Write header line (compiling or checking given file)
 
@@ -2615,144 +2612,6 @@ package body Errout is
  Set_Standard_Output;
   end Emit_Error_Msgs;
 
-  -
-  -- Write_Error_Summary --
-  -
-
-  procedure Write_Error_Summary is
-  begin
- --  Extra blank line if error messages or source listing were output
-
- if Total_Errors_Detected + Warnings_Detected > 0 or else Full_List
- then
-Write_Eol;
- end if;
-
- --  Message giving number of lines read and number of errors detected.
- --  This normally goes to Standard_Output. The exception is when brief
- --  mode is not set, verbose mode (or full list mode) is set, and
- --  there are errors. In this case we send the message to standard
- --  error to make sure that *something* appears on standard error
- --  in an error situation.
-
- if Total_Errors_Detected + Warnings_Detected /= 0
-   and then not Brief_Output
-   and then (Verbose_Mode or Full_List)
- then
-Set_Standard_Error;
- end if;
-
- --  Message giving total number of lines. Don't give this message if
- --  the Main_Source line is unknown (this happens in error situations,
- --  e.g. when integrated preprocessing fails).
-
- if Main_Source_File > No_Source_File then
-Write_Str (" ");
-Write_Int (Num_Source_Lines (Main_Source_File));
-
-if Num_Source_Lines (Main_Source_File) = 1 then
-   Write_Str (" line: ");
-else
-   Write_Str (" lines: ");
-end if;
- end if;
-
- if Total_Errors_Detected = 0 then
-Write_Str ("No errors");
-
- elsif Total_Errors_Detected = 1 then
-Write_Str ("1 error");
-
- else
-Write_Int (Total_Errors_Detected);
-Write_Str (" errors");
- end if;
-
- --  We now need to output warnings. When using -gnatwe, all warnings
- --  should be treated as errors, except for warnings originating from
- --  the use of the Compile_Time_Warning pragma. Another situation
- --  where a warning might be treated as an error is when the source
- --  code contains a Warning_As_Error pragma.
- --  When warnings are treated as errors, we still log them as
- --  warnings, but we add a message denoting how many of these warnings
- --  are also errors.
-
- declare
-Warnings_Count : constant Int := Warnings_Detected;
-
-Compile_Time_Warnings : Int;
---  Number of warnings that come from a Compile_Time_Warning
---  pragma.
-
-Non_Compile_Time_Warnings : Int;
---  Number of warnings that do not come from a Compile_Time_Warning
---  pragmas.
-
- begin
-if Warnings_Count > 0 then
-   Write_Str (", ");
-   Write_Int (Warnings_Count);
-   Write_Str (" warning");
-
-   if Warnings_Count > 1 then
-  Write_Char ('s');
-   end if;
-
-   Compile_Time_Warnings := Count_Compile_Time_Pragma_Warnings;
-   Non_Compile_Time_Warnings :=
-  Warnings_Count - Compile_Time_Warnings;
-
-   if Warning_Mode = Treat_As_Error
- and then Non_Compile_Time_Warnings > 0
-   then
-  Write_Str (" (");
-
-  

[gcc r15-5689] ada: Refactor code of Check_Ambiguous_Call and Valid_Conversion

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:38b977cc077d055be9730b6476043d666864c832

commit r15-5689-g38b977cc077d055be9730b6476043d666864c832
Author: Javier Miranda 
Date:   Tue Oct 29 08:31:28 2024 +

ada: Refactor code of Check_Ambiguous_Call and Valid_Conversion

Code cleanup; factorizing code.

gcc/ada/ChangeLog:

* sem_ch2.adb (Check_Ambiguous_Call): Replace code factorized
code by call to the new subprogram Is_Ambiguous_Operand.
* sem_res.ads (Is_Ambiguous_Operand): New subprogram that
factorizes previous code in Check_Ambiguous_Call and
Valid_Conversion.
* sem_res.adb (Is_Ambiguous_Operand): New subprogram.
(Valid_Tagged_Conversion): Replace factorized code by call to
the new subprogram Is_Ambiguous_Operand.
(Report_Error_N): New subprogram.
(Report_Error_NE): New subprogram.
(Report_Interpretation): New subprogram.
(Conversion_Error_N): Removed; replaced by Report_Error_N.
(Conversion_Error_NE): Removed; replaced by Report_Error_NE.
(Valid_Conversion): Update Opnd_Type after the call to
Is_Ambiguous_Operand in the overloaded case.

Diff:
---
 gcc/ada/sem_ch2.adb | 102 +-
 gcc/ada/sem_res.adb | 544 ++--
 gcc/ada/sem_res.ads |  11 ++
 3 files changed, 336 insertions(+), 321 deletions(-)

diff --git a/gcc/ada/sem_ch2.adb b/gcc/ada/sem_ch2.adb
index 6d11b71b95fe..f76f08b93564 100644
--- a/gcc/ada/sem_ch2.adb
+++ b/gcc/ada/sem_ch2.adb
@@ -39,7 +39,6 @@ with Sem;use Sem;
 with Sem_Ch8;use Sem_Ch8;
 with Sem_Dim;use Sem_Dim;
 with Sem_Res;use Sem_Res;
-with Sem_Type;   use Sem_Type;
 with Sinfo;  use Sinfo;
 with Sinfo.Nodes;use Sinfo.Nodes;
 with Sinfo.Utils;use Sinfo.Utils;
@@ -147,102 +146,21 @@ package body Sem_Ch2 is
   --
 
   procedure Check_Ambiguous_Call (Func_Call : Node_Id) is
-
- procedure Report_Interpretation (Nam : Entity_Id; Typ : Entity_Id);
- --  Report an interpretation of the function call. When calling a
- --  standard operator, use the location of the type, which may be
- --  user-defined.
-
- ---
- -- Report_Interpretation --
- ---
-
- procedure Report_Interpretation (Nam : Entity_Id; Typ : Entity_Id) is
- begin
-if Sloc (Nam) = Standard_Location then
-   Error_Msg_Sloc := Sloc (Typ);
-else
-   Error_Msg_Sloc := Sloc (Nam);
-end if;
-
-if Nkind (Parent (Nam)) = N_Full_Type_Declaration then
-   Error_Msg_N
- ("\\possible interpretation (inherited)#!", Func_Call);
-else
-   Error_Msg_N ("\\possible interpretation#!", Func_Call);
-end if;
- end Report_Interpretation;
-
-  --  Start of processing for Check_Ambiguous_Call
+ Result : Boolean;
+ pragma Unreferenced (Result);
 
   begin
  Check_Parameterless_Call (Func_Call);
 
  if Is_Overloaded (Func_Call) then
-declare
-   I   : Interp_Index;
-   I1  : Interp_Index;
-   It  : Interp;
-   It1 : Interp;
-   N1  : Entity_Id;
-   T1  : Entity_Id;
-
-begin
-   --  Remove procedure calls, as they cannot syntactically appear
-   --  in interpolated expressions. These calls were not removed by
-   --  type checking because interpolated expressions do not impose
-   --  a context type.
-
-   Get_First_Interp (Func_Call, I, It);
-   while Present (It.Nam) loop
-  if It.Typ = Standard_Void_Type then
- Remove_Interp (I);
-  end if;
-
-  Get_Next_Interp (I, It);
-   end loop;
-
-   Get_First_Interp (Func_Call, I, It);
-
-   if No (It.Nam) then
-  Error_Msg_N ("illegal expression", Func_Call);
-  return;
-   end if;
-
-   I1  := I;
-   It1 := It;
-
-   --  The node may be labeled overloaded, but still contain only
-   --  one interpretation because others were discarded earlier. If
-   --  this is the case, retain the single interpretation.
-
-   Get_Next_Interp (I, It);
-
-   if Present (It.Typ) then
-  N1  := It1.Nam;
-  T1  := It1.Typ;
-
-  It1 := Disambiguate
-   (N   => Func_Call,
-I1  => I1,
-I2  => I,
-Typ => Any_Type);
-
-  if It1 = No_Interp then
-  

[gcc r15-5684] ada: Remove Current_Node from Errout

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:ba0c6d0e4ea01afa3ad8740fce6d77e009b1ccbf

commit r15-5684-gba0c6d0e4ea01afa3ad8740fce6d77e009b1ccbf
Author: Viljar Indus 
Date:   Tue Nov 5 10:42:55 2024 +0200

ada: Remove Current_Node from Errout

This variable was used for Opt.Include_Subprogram_In_Messages
activated by -gnatdJ. This switch has been removed so this variable
is no longer used.

gcc/ada/ChangeLog:

* errout.ads: Remove Current_Node.
* errout.adb: Remove uses of Current_Node.
* par-ch6.adb: Same as above.
* par-ch7.adb: Same as above.
* par-ch9.adb: Same as above.

Diff:
---
 gcc/ada/errout.adb  | 4 ++--
 gcc/ada/errout.ads  | 4 
 gcc/ada/par-ch6.adb | 1 -
 gcc/ada/par-ch7.adb | 2 --
 gcc/ada/par-ch9.adb | 9 +
 5 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 84958a743119..7991f781e423 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -301,12 +301,12 @@ package body Errout is
 
procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is
begin
-  Error_Msg (Msg, To_Span (Flag_Location), Current_Node);
+  Error_Msg (Msg, To_Span (Flag_Location), Empty);
end Error_Msg;
 
procedure Error_Msg (Msg : String; Flag_Span : Source_Span) is
begin
-  Error_Msg (Msg, Flag_Span, Current_Node);
+  Error_Msg (Msg, Flag_Span, Empty);
end Error_Msg;
 
procedure Error_Msg
diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
index 3c0c2cecf68d..38b979f61f0c 100644
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -48,10 +48,6 @@ package Errout is
--  Source_Reference line, then this is initialized to No_Source_File, to
--  force an initial reference to the real source file name.
 
-   Current_Node : Node_Id := Empty;
-   --  Used by Error_Msg as a default Node_Id.
-   --  Relevant only when Opt.Include_Subprogram_In_Messages is set.
-
---
-- Suppression of Error Messages --
---
diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
index c3cc57256164..4fe002202228 100644
--- a/gcc/ada/par-ch6.adb
+++ b/gcc/ada/par-ch6.adb
@@ -344,7 +344,6 @@ package body Ch6 is
   end if;
 
   Scopes (Scope.Last).Labl := Name_Node;
-  Current_Node := Name_Node;
   Ignore (Tok_Colon);
 
   --  Deal with generic instantiation, the one case in which we do not
diff --git a/gcc/ada/par-ch7.adb b/gcc/ada/par-ch7.adb
index c71e25770f35..2682df47c53a 100644
--- a/gcc/ada/par-ch7.adb
+++ b/gcc/ada/par-ch7.adb
@@ -127,7 +127,6 @@ package body Ch7 is
  Scopes (Scope.Last).Sloc := Token_Ptr;
  Name_Node := P_Defining_Program_Unit_Name;
  Scopes (Scope.Last).Labl := Name_Node;
- Current_Node := Name_Node;
 
  if Aspect_Specifications_Present then
 Aspect_Sloc := Token_Ptr;
@@ -173,7 +172,6 @@ package body Ch7 is
  Scopes (Scope.Last).Sloc := Token_Ptr;
  Name_Node := P_Defining_Program_Unit_Name;
  Scopes (Scope.Last).Labl := Name_Node;
- Current_Node := Name_Node;
 
  --  Case of renaming declaration
 
diff --git a/gcc/ada/par-ch9.adb b/gcc/ada/par-ch9.adb
index 4d07a3a1f1f5..9f5273b3e37e 100644
--- a/gcc/ada/par-ch9.adb
+++ b/gcc/ada/par-ch9.adb
@@ -101,7 +101,6 @@ package body Ch9 is
  Scan; -- past BODY
  Name_Node := P_Defining_Identifier (C_Is);
  Scopes (Scope.Last).Labl := Name_Node;
- Current_Node := Name_Node;
 
  if Token = Tok_Left_Paren then
 Error_Msg_SC ("discriminant part not allowed in task body");
@@ -167,7 +166,7 @@ package body Ch9 is
 Name_Node := P_Defining_Identifier;
 Set_Defining_Identifier (Task_Node, Name_Node);
 Scopes (Scope.Last).Labl := Name_Node;
-Current_Node := Name_Node;
+
 Set_Discriminant_Specifications
   (Task_Node, P_Known_Discriminant_Part_Opt);
 
@@ -176,7 +175,6 @@ package body Ch9 is
 Name_Node := P_Defining_Identifier (C_Is);
 Set_Defining_Identifier (Task_Node, Name_Node);
 Scopes (Scope.Last).Labl := Name_Node;
-Current_Node := Name_Node;
 
 if Token = Tok_Left_Paren then
Error_Msg_SC ("discriminant part not allowed for single task");
@@ -442,7 +440,6 @@ package body Ch9 is
  Scan; -- past BODY
  Name_Node := P_Defining_Identifier (C_Is);
  Scopes (Scope.Last).Labl := Name_Node;
- Current_Node := Name_Node;
 
  if Token = Tok_Left_Paren then
 Error_Msg_SC ("discriminant part not allowed in protected body");
@@ -497,7 +494,6 @@ package body Ch9 is
 Name_Node := P_Defining_Identifier (C_Is);
 Set_Defining_Identifier (Protected_Node, Name_Node);
 Scopes (Scope.Last).Labl := Name_Node;
-Current_Node := Name_Node;
 

[gcc r15-5692] ada: Add minimal support for address clause/aspect on controlled objects

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:84d8a383c9fe80bd9c4e364505247ef025e1c2b6

commit r15-5692-g84d8a383c9fe80bd9c4e364505247ef025e1c2b6
Author: Eric Botcazou 
Date:   Tue Nov 12 19:46:12 2024 +0100

ada: Add minimal support for address clause/aspect on controlled objects

The clause and aspect have been accepted by the compiler for a few years,
but the result is generally an internal compiler error or an incorrect
finalization at run time.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Do not insert the tag
assignment there if the object has the Address aspect.
* exp_ch7.adb: Add clauses for Aspect package.
(Build_Finalizer.Process_Object_Declaration): Deal with an object
with delayed freezing.
(Insert_Actions_In_Scope_Around): If the target is the declaration
of an object with address clause or aspect, move all the statements
that have been inserted after it into the Initialization_Statements
list of the object.
* freeze.adb (Check_Address_Clause): Do not reassign the tag here,
instead set the appropriate flag on the assignment statement.

Diff:
---
 gcc/ada/exp_ch3.adb |  4 +++-
 gcc/ada/exp_ch7.adb | 52 ++--
 gcc/ada/freeze.adb  | 46 +++---
 3 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 7d8a7fd4fedc..e60a5f6ddafa 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -8155,7 +8155,9 @@ package body Exp_Ch3 is
 Tag_Assign := Make_Tag_Assignment (N);
 
 if Present (Tag_Assign) then
-   if Present (Following_Address_Clause (N)) then
+   if Present (Following_Address_Clause (N))
+ or else Has_Aspect (Def_Id, Aspect_Address)
+   then
   Ensure_Freeze_Node (Def_Id);
elsif not Special_Ret_Obj then
   Insert_Action_After (Init_After, Tag_Assign);
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index e7bf0bd7f11b..aed6bcf356f1 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -27,6 +27,7 @@
 --- controlled types
 --- transient scopes
 
+with Aspects;use Aspects;
 with Atree;  use Atree;
 with Debug;  use Debug;
 with Einfo;  use Einfo;
@@ -2799,10 +2800,16 @@ package body Exp_Ch7 is
 
  if Ekind (Obj_Id) in E_Constant | E_Variable then
 
+--  The object has delayed freezing. The Master_Node insertion
+--  point is after the freeze node.
+
+if Has_Delayed_Freeze (Obj_Id) then
+   Master_Node_Ins := Freeze_Node (Obj_Id);
+
 --  The object is initialized by an aggregate. The Master_Node
 --  insertion point is after the last aggregate assignment.
 
-if Present (Last_Aggregate_Assignment (Obj_Id)) then
+elsif Present (Last_Aggregate_Assignment (Obj_Id)) then
Master_Node_Ins := Last_Aggregate_Assignment (Obj_Id);
 
 --  The object is initialized by a build-in-place function call.
@@ -5371,6 +5378,7 @@ package body Exp_Ch7 is
   First_Obj: Node_Id;
   Last_Obj : Node_Id;
   Mark_Id  : Entity_Id;
+  Marker   : Node_Id;
   Target   : Node_Id;
 
--  Start of processing for Insert_Actions_In_Scope_Around
@@ -5402,9 +5410,6 @@ package body Exp_Ch7 is
  Target := N;
   end if;
 
-  First_Obj := Target;
-  Last_Obj  := Target;
-
   --  Add all actions associated with a transient scope into the main tree.
   --  There are several scenarios here:
 
@@ -5415,18 +5420,26 @@ package body Exp_Ch7 is
 
   --3)   Target  Last_Obj
 
-  --  Flag declarations are inserted before the first object
+  --  Declarations are inserted before the target
 
   if Present (Act_Before) then
  First_Obj := First (Act_Before);
  Insert_List_Before (Target, Act_Before);
+  else
+ First_Obj := Target;
   end if;
 
-  --  Finalization calls are inserted after the last object
+  --  Set a marker on the next statement
+
+  Marker := Next (Target);
+
+  --  Finalization calls are inserted after the target
 
   if Present (Act_After) then
  Last_Obj := Last (Act_After);
  Insert_List_After (Target, Act_After);
+  else
+ Last_Obj := Target;
   end if;
 
   --  Mark and release the secondary stack when the context warrants it
@@ -5457,6 +5470,33 @@ package body Exp_Ch7 is
 Related_Node => Target);
   end if;
 
+  --  If the target is the declaration of an object with an address clause
+  --  or aspect, move all the statements that have been inserted after it
+  --  into its Initialization_Statemen

[gcc r15-5679] ada: Fix the file documenting the ali format

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:92e782e7758b068a6399c97f8b8e1972d67b0739

commit r15-5679-g92e782e7758b068a6399c97f8b8e1972d67b0739
Author: Jose Ruiz 
Date:   Tue Nov 12 12:22:55 2024 +0100

ada: Fix the file documenting the ali format

gcc/ada/ChangeLog:

* doc/gnat_ugn/the_gnat_compilation_model.rst: The format of
the ali file is documented in lib-writ.ads.
* gnat_ugn.texi: Regenerate.

Diff:
---
 gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst | 4 ++--
 gcc/ada/gnat_ugn.texi   | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst 
b/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst
index 4c87b732be73..64a363132c71 100644
--- a/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst
+++ b/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst
@@ -1751,8 +1751,8 @@ The following information is contained in that file:
   in the unit. Used by some tools to provide cross-reference information.
 
 For a full detailed description of the format of the :file:`ALI` file,
-see the source of the body of unit ``Lib.Writ``, contained in file
-:file:`lib-writ.adb` in the GNAT compiler sources.
+see the source of the spec of unit ``Lib.Writ``, contained in file
+:file:`lib-writ.ads` in the GNAT compiler sources.
 
 
 .. _Binding_an_Ada_Program:
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 0414a2170cdf..a03dc7cae4bb 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-GNAT User's Guide for Native Platforms , Nov 18, 2024
+GNAT User's Guide for Native Platforms , Nov 26, 2024
 
 AdaCore
 
@@ -3228,8 +3228,8 @@ in the unit. Used by some tools to provide 
cross-reference information.
 @end itemize
 
 For a full detailed description of the format of the @code{ALI} file,
-see the source of the body of unit @code{Lib.Writ}, contained in file
-@code{lib-writ.adb} in the GNAT compiler sources.
+see the source of the spec of unit @code{Lib.Writ}, contained in file
+@code{lib-writ.ads} in the GNAT compiler sources.
 
 @node Binding an Ada Program,GNAT and Libraries,The Ada Library Information 
Files,The GNAT Compilation Model
 @anchor{gnat_ugn/the_gnat_compilation_model 
binding-an-ada-program}@anchor{2a}@anchor{gnat_ugn/the_gnat_compilation_model 
id34}@anchor{68}
@@ -29839,8 +29839,8 @@ to permit their use in free software.
 
 @printindex ge
 
-@anchor{d2}@w{  }
 @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
   }
+@anchor{d2}@w{  }
 
 @c %**end of body
 @bye


[gcc r15-5680] ada: Simplify code

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:7cdb07a77bac31dc39f8eea2e7eaabf99bbd00ab

commit r15-5680-g7cdb07a77bac31dc39f8eea2e7eaabf99bbd00ab
Author: Viljar Indus 
Date:   Mon Sep 16 12:14:00 2024 +0300

ada: Simplify code

gcc/ada/ChangeLog:

* diagnostics-converter.adb: Remove uses of Info_Warning type. Use
common constructors to simplify implementation.
* diagnostics-pretty_emitter.adb: Remove Info_Warning type.
* diagnostics-utils.adb: Remove uses of Info_Warning.
* diagnostics.adb: Simplify implementation of Primary_Location.
* diagnostics.ads: Remove Info_Warning type.

Diff:
---
 gcc/ada/diagnostics-converter.adb  | 64 ++
 gcc/ada/diagnostics-pretty_emitter.adb | 14 +++-
 gcc/ada/diagnostics-utils.adb  |  5 ++-
 gcc/ada/diagnostics.adb| 13 +--
 gcc/ada/diagnostics.ads|  6 +---
 5 files changed, 27 insertions(+), 75 deletions(-)

diff --git a/gcc/ada/diagnostics-converter.adb 
b/gcc/ada/diagnostics-converter.adb
index 45bb19c0a840..e1613f674c68 100644
--- a/gcc/ada/diagnostics-converter.adb
+++ b/gcc/ada/diagnostics-converter.adb
@@ -41,8 +41,7 @@ package body Diagnostics.Converter is
  (E_Id : Error_Msg_Id) return Sub_Diagnostic_Type;
 
function Get_Warning_Kind (E_Msg : Error_Msg_Object) return Diagnostic_Kind
-   is (if E_Msg.Info then Info_Warning
-   elsif E_Msg.Warn_Chr = "* " then Restriction_Warning
+   is (if E_Msg.Warn_Chr = "* " then Restriction_Warning
elsif E_Msg.Warn_Chr = "? " then Default_Warning
elsif E_Msg.Warn_Chr = "  " then Tagless_Warning
else Warning);
@@ -50,6 +49,13 @@ package body Diagnostics.Converter is
--  printer added the warning switch label but treated the message as
--  an info message.
 
+   function Get_Diagnostics_Kind (E_Msg : Error_Msg_Object)
+  return Diagnostic_Kind
+   is (if E_Msg.Warn then Get_Warning_Kind (E_Msg)
+  elsif E_Msg.Style then Style
+  elsif E_Msg.Info then Info
+  else Error);
+
---
-- Convert_Errors_To_Diagnostics --
---
@@ -92,27 +98,14 @@ package body Diagnostics.Converter is
   --  shall be printed with the same kind token as the main diagnostic.
   D.Kind := Continuation;
 
-  declare
- L : Labeled_Span_Type;
-  begin
- if E_Msg.Insertion_Sloc /= No_Location then
-L.Span := To_Span (E_Msg.Insertion_Sloc);
- else
-L.Span := E_Msg.Sptr;
- end if;
-
- L.Is_Primary := True;
- Add_Location (D, L);
-  end;
+  Add_Location (D,
+Primary_Labeled_Span
+  (if E_Msg.Insertion_Sloc /= No_Location
+   then To_Span (E_Msg.Insertion_Sloc)
+   else E_Msg.Sptr));
 
   if E_Msg.Optr.Ptr /= E_Msg.Sptr.Ptr then
- declare
-L : Labeled_Span_Type;
- begin
-L.Span   := E_Msg.Optr;
-L.Is_Primary := False;
-Add_Location (D, L);
- end;
+ Add_Location (D, Secondary_Labeled_Span (E_Msg.Optr));
   end if;
 
   return D;
@@ -131,17 +124,10 @@ package body Diagnostics.Converter is
begin
   D.Message := E_Msg.Text;
 
-  if E_Msg.Warn then
- D.Kind   := Get_Warning_Kind (E_Msg);
- D.Switch := Get_Switch_Id (E_Msg);
-  elsif E_Msg.Style then
- D.Kind   := Style;
- D.Switch := Get_Switch_Id (E_Msg);
-  elsif E_Msg.Info then
- D.Kind := Info;
+  D.Kind := Get_Diagnostics_Kind (E_Msg);
+
+  if E_Msg.Warn or E_Msg.Style or E_Msg.Info then
  D.Switch := Get_Switch_Id (E_Msg);
-  else
- D.Kind := Error;
   end if;
 
   D.Warn_Err := E_Msg.Warn_Err;
@@ -150,24 +136,12 @@ package body Diagnostics.Converter is
 
   --  Convert the primary location
 
-  declare
- L : Labeled_Span_Type;
-  begin
- L.Span   := E_Msg.Sptr;
- L.Is_Primary := True;
- Add_Location (D, L);
-  end;
+  Add_Location (D, Primary_Labeled_Span (E_Msg.Sptr));
 
   --  Convert the secondary location if it is different from the primary
 
   if E_Msg.Optr.Ptr /= E_Msg.Sptr.Ptr then
- declare
-L : Labeled_Span_Type;
- begin
-L.Span   := E_Msg.Optr;
-L.Is_Primary := False;
-Add_Location (D, L);
- end;
+ Add_Location (D, Secondary_Labeled_Span (E_Msg.Optr));
   end if;
 
   E_Next_Id := Errors.Table (E_Id).Next;
diff --git a/gcc/ada/diagnostics-pretty_emitter.adb 
b/gcc/ada/diagnostics-pretty_emitter.adb
index 389be8a6533d..df27a5c6fde4 100644
--- a/gcc/ada/diagnostics-pretty_emitter.adb
+++ b/gcc/ada/diagnostics-pretty_emitter.adb
@@ -1075,11 +1075,8 @@ package body Diagnostics.Pretty_Emitter is
 Diag : Di

[gcc r15-5675] ada: Fix latent issue exposed by recent change in aggregate expansion

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:95bb4ef5cbe1fa0bc05802debcb25a9422e080a5

commit r15-5675-g95bb4ef5cbe1fa0bc05802debcb25a9422e080a5
Author: Eric Botcazou 
Date:   Tue Nov 12 00:18:00 2024 +0100

ada: Fix latent issue exposed by recent change in aggregate expansion

The tag is not assigned when a compile-time known aggregate initializes an
object declared with an address clause/aspect.

gcc/ada/ChangeLog:

* freeze.adb: Remove clauses for Exp_Ch3.
(Check_Address_Clause): Always reassign the tag for an object of a
tagged type if there is an initialization expression.

Diff:
---
 gcc/ada/freeze.adb | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index b52898f42121..9486d02f6818 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -33,7 +33,6 @@ with Einfo.Entities; use Einfo.Entities;
 with Einfo.Utils;use Einfo.Utils;
 with Elists; use Elists;
 with Errout; use Errout;
-with Exp_Ch3;use Exp_Ch3;
 with Exp_Ch7;use Exp_Ch7;
 with Exp_Disp;   use Exp_Disp;
 with Exp_Pakd;   use Exp_Pakd;
@@ -767,16 +766,23 @@ package body Freeze is
 Append_Freeze_Action (E,
   Make_Assignment_Statement (Sloc (Decl),
 Name   => Lhs,
-Expression => Expression (Decl)));
+Expression => Init));
 
 Set_No_Initialization (Decl);
 
 --  If the object is tagged, check whether the tag must be
 --  reassigned explicitly.
 
-Tag_Assign := Make_Tag_Assignment (Decl);
-if Present (Tag_Assign) then
-   Append_Freeze_Action (E, Tag_Assign);
+if Is_Tagged_Type (Typ) and then Tagged_Type_Expansion then
+   Tag_Assign :=
+ Make_Tag_Assignment_From_Type
+   (Sloc (Decl),
+New_Occurrence_Of (E, Sloc (Decl)),
+Underlying_Type (Typ));
+
+   if Present (Tag_Assign) then
+  Append_Freeze_Action (E, Tag_Assign);
+   end if;
 end if;
  end if;
   end if;


[gcc r15-5677] ada: Remove use of global name buffer

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:222da6bd24838c700ef72648da2956bade588b47

commit r15-5677-g222da6bd24838c700ef72648da2956bade588b47
Author: Ronan Desplanques 
Date:   Tue Nov 12 13:35:17 2024 +0100

ada: Remove use of global name buffer

Before this patch, the body of Fname.UF.Get_File_Name did a lot of
juggling with the global name buffer, which made it hard to understand.
This patch makes the body use local buffers instead.

gcc/ada/ChangeLog:

* fname-uf.adb (Get_File_Name): Use local name buffers.

Diff:
---
 gcc/ada/fname-uf.adb | 58 +++-
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/gcc/ada/fname-uf.adb b/gcc/ada/fname-uf.adb
index cb9363416a62..4afb3b01b343 100644
--- a/gcc/ada/fname-uf.adb
+++ b/gcc/ada/fname-uf.adb
@@ -218,6 +218,8 @@ package body Fname.UF is
   Fname : File_Name_Type := No_File;
   --  Path name and File name for mapping
 
+  Unit_Buf : Bounded_String;
+
begin
   --  Null or error name means that some previous error occurred. This is
   --  an unrecoverable error, so signal it.
@@ -247,7 +249,7 @@ package body Fname.UF is
 
   --  Here for the case where the name was not found in the table
 
-  Get_Decoded_Name_String (Uname);
+  Append_Decoded (Unit_Buf, Uname);
 
   --  A special fudge, normally we don't have operator symbols present,
   --  since it is always an error to do so. However, if we do, at this
@@ -266,21 +268,27 @@ package body Fname.UF is
   --  avoid bombs due to writing a bad file name, and we get expected error
   --  processing downstream, e.g. a compilation following gnatchop.
 
-  if Name_Buffer (1) = '"' then
- Get_Name_String (Uname);
- Name_Len := Name_Len + 1;
- Name_Buffer (Name_Len) := Name_Buffer (Name_Len - 1);
- Name_Buffer (Name_Len - 1) := Name_Buffer (Name_Len - 2);
- Name_Buffer (Name_Len - 2) := '_';
- Name_Buffer (1):= '_';
+  if Unit_Buf.Chars (1) = '"' then
+ Unit_Buf.Length := 0;
+ Append (Unit_Buf, Uname);
+ Unit_Buf.Length := Unit_Buf.Length + 1;
+ Unit_Buf.Chars (Unit_Buf.Length) :=
+   Unit_Buf.Chars (Unit_Buf.Length - 1);
+ Unit_Buf.Chars (Unit_Buf.Length - 1) :=
+   Unit_Buf.Chars (Unit_Buf.Length - 2);
+ Unit_Buf.Chars (Unit_Buf.Length - 2) := '_';
+ Unit_Buf.Chars (1) := '_';
   end if;
 
   --  Deal with spec or body suffix
 
-  Unit_Char := Name_Buffer (Name_Len);
+  Unit_Char := Unit_Buf.Chars (Unit_Buf.Length);
   pragma Assert (Unit_Char = 'b' or else Unit_Char = 's');
-  pragma Assert (Name_Len >= 3 and then Name_Buffer (Name_Len - 1) = '%');
-  Name_Len := Name_Len - 2;
+  pragma
+Assert
+  (Unit_Buf.Length >= 3
+ and then Unit_Buf.Chars (Unit_Buf.Length - 1) = '%');
+  Unit_Buf.Length := Unit_Buf.Length - 2;
 
   if Subunit then
  Unit_Char := 'u';
@@ -289,15 +297,9 @@ package body Fname.UF is
   --  Now we need to find the proper translation of the name
 
   declare
- Uname : constant String (1 .. Name_Len) :=
-   Name_Buffer (1 .. Name_Len);
-
  Pent : Nat;
  Fnam : File_Name_Type := No_File;
 
- Is_Predef : Boolean;
- --  Set True for predefined file
-
   --  Start of search through pattern table
 
   begin
@@ -318,21 +320,21 @@ package body Fname.UF is
 Pent := SFN_Patterns.First;
 while Pent <= SFN_Patterns.Last loop
if SFN_Patterns.Table (Pent).Typ = Unit_Char_Search then
-  --  Determine if we have a predefined file name
-
-  Is_Predef :=
-Is_Predefined_Unit_Name
-  (Uname, Renamings_Included => True);
-
   --  Found a match, execute the pattern
+  declare
+ Is_Predef : constant Boolean :=
+   Is_Predefined_Unit_Name
+ (+Unit_Buf, Renamings_Included => True);
 
-  Name_Len := Uname'Length;
-  Name_Buffer (1 .. Name_Len) := Uname;
+ Buf : Bounded_String;
+  begin
+ Append (Buf, Unit_Buf);
 
-  Instantiate_SFN_Pattern
-(SFN_Patterns.Table (Pent), Global_Name_Buffer, Is_Predef);
+ Instantiate_SFN_Pattern
+   (SFN_Patterns.Table (Pent), Buf, Is_Predef);
 
-  Fnam := Name_Find;
+ Fnam := Name_Find (Buf);
+  end;
 
   --  If we are in the second search of the table, we accept
   --  the file name without checking, because we know that the


[gcc r15-5676] ada: Clean up utility function

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:22bd31334267d40435c353632fae86f648a20ace

commit r15-5676-g22bd31334267d40435c353632fae86f648a20ace
Author: Ronan Desplanques 
Date:   Tue Nov 12 09:31:35 2024 +0100

ada: Clean up utility function

This patch makes Sem_Util.Get_Library_Unit_Name use Uname more 
idiomatically.

gcc/ada/ChangeLog:

* sem_util.adb (Get_Library_Unit_Name): Improve use of Uname.

Diff:
---
 gcc/ada/sem_util.adb | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index a7869397bfcd..30c1a5236ae7 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -10656,15 +10656,9 @@ package body Sem_Util is
 
function Get_Library_Unit_Name (Decl_Node : Node_Id) return String_Id is
   Unit_Name_Id : constant Unit_Name_Type := Get_Unit_Name (Decl_Node);
-  Buf : Bounded_String;
+  Buf  : Bounded_String;
begin
-  Get_Unit_Name_String (Buf, Unit_Name_Id);
-
-  --  Remove the last seven characters (" (spec)" or " (body)")
-
-  Buf.Length := Buf.Length - 7;
-  pragma Assert (Buf.Chars (Buf.Length + 1) = ' ');
-
+  Get_Unit_Name_String (Buf, Unit_Name_Id, Suffix => False);
   return String_From_Name_Buffer (Buf);
end Get_Library_Unit_Name;


[gcc r15-5690] ada: Minor adjustments to error message for RM B.1(24)

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:e14ec5681e780626f59ef7b37d0648c2d6992a14

commit r15-5690-ge14ec5681e780626f59ef7b37d0648c2d6992a14
Author: Eric Botcazou 
Date:   Wed Nov 13 09:42:01 2024 +0100

ada: Minor adjustments to error message for RM B.1(24)

The RM B.1(24) sub-clause says that imported entities cannot be initialized
and it is checked in three contexts, aspect Import, pragma Import and pragma
Import_Object, with slightly different error messages.  Moreover, for the
aspect, the error is given twice because that of the pragma is also given.

In addition, if the initialization expression is an aggregate that is not
static, the error is given only for the aspect and not for the two pragmas.

This change aligns the error messages on that of pragma Import and plugs the
aforementioned loophole for the two pragmas.

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Aspect_Export_Import): Add explicit mention
of the declaration in the error message for the Import.
* sem_prag.adb (Process_Extended_Import_Export_Object_Pragma): Also
test Has_Init_Expression on the declaration node for Import_Object
and use the same wording as that of Import.
(Process_Import_Or_Interface): Also test Has_Init_Expression on the
declaration node for Import.

Diff:
---
 gcc/ada/sem_ch13.adb |  4 
 gcc/ada/sem_prag.adb | 21 -
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 3597bceb3cce..2d13ecc2f983 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -1903,6 +1903,10 @@ package body Sem_Ch13 is
  if Nkind (N) = N_Object_Declaration
and then Present (Expression (N))
  then
+Error_Msg_Sloc := Sloc (Defining_Identifier (N));
+Error_Msg_N
+  ("no initialization allowed for declaration of& #",
+   Defining_Identifier (N));
 Error_Msg_N
   ("imported entities cannot be initialized "
& "(RM B.1(24))", Expression (N));
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 484c7538bbf8..cc94b02e43ce 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -9169,15 +9169,17 @@ package body Sem_Prag is
 --  initialization generated by the code generator, e.g. for an
 --  access type, does not count here.
 
-elsif Present (Expression (Parent (Def_Id)))
-   and then
- Comes_From_Source
-   (Original_Node (Expression (Parent (Def_Id
+elsif (Present (Expression (Parent (Def_Id)))
+and then
+  Comes_From_Source
+(Original_Node (Expression (Parent (Def_Id)
+  or else Has_Init_Expression (Parent (Def_Id))
 then
Error_Msg_Sloc := Sloc (Def_Id);
Error_Pragma_Arg
- ("imported entities cannot be initialized (RM B.1(24))",
-  "\no initialization allowed for & declared#", Arg1);
+ ("no initialization allowed for declaration of& #",
+  "\imported entities cannot be initialized (RM B.1(24))",
+  Arg1);
 else
Set_Imported (Def_Id);
Note_Possible_Modification (Arg_Internal, Sure => False);
@@ -9740,9 +9742,10 @@ package body Sem_Prag is
 --  only counts if it comes from source, otherwise it is simply
 --  the code generator making an implicit initialization explicit.
 
-elsif Present (Expression (Parent (Def_Id)))
-  and then Comes_From_Source
- (Original_Node (Expression (Parent (Def_Id
+elsif (Present (Expression (Parent (Def_Id)))
+and then Comes_From_Source
+   (Original_Node (Expression (Parent (Def_Id)
+   or else Has_Init_Expression (Parent (Def_Id))
 then
--  Set imported flag to prevent cascaded errors


[gcc r15-5678] ada: Change specifications of Uname subprograms

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:bd0b9886f17d9dc13de8f533f1239016d1198ea8

commit r15-5678-gbd0b9886f17d9dc13de8f533f1239016d1198ea8
Author: Ronan Desplanques 
Date:   Tue Nov 12 16:09:13 2024 +0100

ada: Change specifications of Uname subprograms

The old specifications were ambiguous as to whether they expected
actuals to have %s/%b suffixes. The new specifications also increases
modularity across the board.

gcc/ada/ChangeLog:

* uname.ads (Is_Internal_Unit_Name, Is_Predefined_Unit_Name): Change
specifications to take a Unit_Name_Type as input.
(Encoded_Library_Unit_Name): New subprogram.
(Is_Predefined_Unit_Name): New overloaded subprogram.
(Get_External_Unit_Name_String): Make use of new
Encoded_Library_Unit_Name subprogram.
* uname.adb (Is_Internal_Unit_Name, Is_Predefined_Unit_Name): Adapt
bodies to specification changes.
* fname-uf.adb (Get_File_Name): Adapt to Uname interface changes.

Diff:
---
 gcc/ada/fname-uf.adb |  2 +-
 gcc/ada/uname.adb| 67 
 gcc/ada/uname.ads|  8 +++
 3 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/gcc/ada/fname-uf.adb b/gcc/ada/fname-uf.adb
index 4afb3b01b343..3f65957a6a27 100644
--- a/gcc/ada/fname-uf.adb
+++ b/gcc/ada/fname-uf.adb
@@ -324,7 +324,7 @@ package body Fname.UF is
   declare
  Is_Predef : constant Boolean :=
Is_Predefined_Unit_Name
- (+Unit_Buf, Renamings_Included => True);
+ (Uname, Renamings_Included => True);
 
  Buf : Bounded_String;
   begin
diff --git a/gcc/ada/uname.adb b/gcc/ada/uname.adb
index 5a7dac53b3d4..598b55467e94 100644
--- a/gcc/ada/uname.adb
+++ b/gcc/ada/uname.adb
@@ -42,6 +42,15 @@ package body Uname is
--  True if Prefix is at the beginning of X. For example,
--  Has_Prefix("a-filename.ads", Prefix => "a-") is True.
 
+   function Encoded_Library_Unit_Name (N : Unit_Name_Type) return String;
+   --  Returns the name of the library unit N as a string without a %s or %b
+   --  suffix.
+
+   function Is_Predefined_Unit_Name
+ (Name : String; Renamings_Included : Boolean := True) return Boolean;
+   --  Same as Fname.Is_Predefined_File_Name, except it works with the name of
+   --  the unit, rather than the file name.
+
---
-- Get_Body_Name --
---
@@ -55,6 +64,16 @@ package body Uname is
   return Name_Find (Buffer);
end Get_Body_Name;
 
+   ---
+   -- Encoded_Library_Unit_Name --
+   ---
+
+   function Encoded_Library_Unit_Name (N : Unit_Name_Type) return String is
+  S : constant String := Get_Name_String (N);
+   begin
+  return S (S'First .. S'Last - 2);
+   end Encoded_Library_Unit_Name;
+
---
-- Get_External_Unit_Name_String --
---
@@ -64,10 +83,8 @@ package body Uname is
   Newlen : Natural;
 
begin
-  --  Get unit name and eliminate trailing %s or %b
-
-  Get_Name_String (N);
-  Name_Len := Name_Len - 2;
+  Name_Len := 0;
+  Add_Str_To_Name_Buffer (Encoded_Library_Unit_Name (N));
 
   --  Find number of components
 
@@ -489,21 +506,22 @@ package body Uname is
---
 
function Is_Internal_Unit_Name
- (Name   : String;
-  Renamings_Included : Boolean := True) return Boolean
+ (Name : Unit_Name_Type; Renamings_Included : Boolean := True)
+  return Boolean
is
   Gnat : constant String := "gnat";
 
+  Lib_Unit_Name : constant String := Encoded_Library_Unit_Name (Name);
begin
-  if Name = Gnat then
+  if Lib_Unit_Name = Gnat then
  return True;
   end if;
 
-  if Has_Prefix (Name, Prefix => Gnat & ".") then
+  if Has_Prefix (Lib_Unit_Name, Prefix => Gnat & ".") then
  return True;
   end if;
 
-  return Is_Predefined_Unit_Name (Name, Renamings_Included);
+  return Is_Predefined_Unit_Name (Lib_Unit_Name, Renamings_Included);
end Is_Internal_Unit_Name;
 
-
@@ -511,13 +529,20 @@ package body Uname is
-
 
function Is_Predefined_Unit_Name
- (Name   : String;
-  Renamings_Included : Boolean := True) return Boolean
+ (Name : Unit_Name_Type; Renamings_Included : Boolean := True)
+  return Boolean is
+   begin
+  return
+Is_Predefined_Unit_Name
+  (Encoded_Library_Unit_Name (Name), Renamings_Included);
+   end Is_Predefined_Unit_Name;
+
+   function Is_Predefined_Unit_Name
+ (Name : String; Renamings_Included : Boolean := True) return Boolean
is
   Ada: constant String := "ada";
   Interfaces : constant Strin

[gcc r15-5685] ada: Refactor checking redundant messages

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:8d0bb808f632eea52548df59e36c1b479c64c45b

commit r15-5685-g8d0bb808f632eea52548df59e36c1b479c64c45b
Author: Viljar Indus 
Date:   Mon Nov 11 10:19:21 2024 +0200

ada: Refactor checking redundant messages

Move common code between errout and errutil into a single function.

gcc/ada/ChangeLog:

* errout.adb: Use Is_Redundant_Error_Message.
* erroutc.adb: Move the common code for checking if a message
can be removed to Is_Redundant_Error_Message.
* erroutc.ads: Add definition of Is_Redundant_Error_Message.
* errutil.adb: Use Is_Redundant_Error_Message.

Diff:
---
 gcc/ada/errout.adb  | 33 +
 gcc/ada/erroutc.adb | 37 +
 gcc/ada/erroutc.ads |  5 +
 gcc/ada/errutil.adb | 32 
 4 files changed, 51 insertions(+), 56 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 7991f781e423..644fd1fad37d 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -1340,37 +1340,14 @@ package body Errout is
  --  from the parser recovering. In full errors mode, we don't do this
  --  deletion, but otherwise such messages are discarded at this stage.
 
- if Prev_Msg /= No_Error_Msg
-   and then Errors.Table (Prev_Msg).Line = Errors.Table (Cur_Msg).Line
-   and then Errors.Table (Prev_Msg).Sfile
-= Errors.Table (Cur_Msg).Sfile
-   and then Compiler_State = Parsing
+ if Compiler_State = Parsing
and then not All_Errors_Mode
+   and then Is_Redundant_Error_Message (Prev_Msg, Cur_Msg)
  then
---  Don't delete unconditional messages and at this stage, don't
---  delete continuation lines; we attempted to delete those earlier
---  if the parent message was deleted.
-
-if not Errors.Table (Cur_Msg).Uncond and then not Continuation then
-   --  Don't delete if prev msg is warning and new msg is an error.
-   --  This is because we don't want a real error masked by a
-   --  warning. In all other cases (that is parse errors for the
-   --  same line that are not unconditional) we do delete the
-   --  message. This helps to avoid junk extra messages from
-   --  cascaded parsing errors
-
-   if Errors.Table (Prev_Msg).Kind not in Warning | Style
- or else Errors.Table (Cur_Msg).Kind in Warning | Style
-   then
-  --  All tests passed, delete the message by simply returning
-  --  without any further processing.
-
-  pragma Assert (not Continuation);
+pragma Assert (not Continuation);
 
-  Last_Killed := True;
-  return;
-   end if;
-end if;
+Last_Killed := True;
+return;
  end if;
 
  --  Come here if message is to be inserted in the error chain
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index 32197ad78843..c57205418de7 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -441,6 +441,43 @@ package body Erroutc is
   end case;
end Increase_Error_Msg_Count;
 
+   
+   -- Is_Redundant_Error_Message --
+   
+
+   function Is_Redundant_Error_Message
+ (Prev_Msg : Error_Msg_Id; Cur_Msg : Error_Msg_Id) return Boolean is
+
+   begin
+  return
+Prev_Msg /= No_Error_Msg
+
+--  Error messages are posted on the same line
+
+and then Errors.Table (Prev_Msg).Line = Errors.Table (Cur_Msg).Line
+and then Errors.Table (Prev_Msg).Sfile = Errors.Table (Cur_Msg).Sfile
+
+--  Do not consider unconditional messages to be redundant right now
+--  They may be removed later.
+
+and then not Errors.Table (Cur_Msg).Uncond
+
+--  Do not consider continuation messages as they are removed with
+--  their parent later on.
+
+and then not Errors.Table (Cur_Msg).Msg_Cont
+
+--  Don't delete if prev msg is warning and new msg is an error.
+--  This is because we don't want a real error masked by a
+--  warning. In all other cases (that is parse errors for the
+--  same line that are not unconditional) we do delete the
+--  message. This helps to avoid junk extra messages from
+--  cascaded parsing errors
+
+and then (Errors.Table (Prev_Msg).Kind not in Warning | Style
+  or else Errors.Table (Cur_Msg).Kind in Warning | Style);
+   end Is_Redundant_Error_Message;
+

-- Has_Switch_Tag --

diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index dac47725aaef..9a70cfa62444 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@

[gcc r15-5683] ada: Remove Raise_Exception_On_Error

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:2364e96f011d33698a6366f414aa813c5f9adc8b

commit r15-5683-g2364e96f011d33698a6366f414aa813c5f9adc8b
Author: Viljar Indus 
Date:   Mon Nov 4 14:16:02 2024 +0200

ada: Remove Raise_Exception_On_Error

Raise_Exception_On_Error is never modified so it can be removed.

gcc/ada/ChangeLog:

* err_vars.ads: Remove Raise_Exception_On_Error and
Error_Msg_Exception.
* errout.ads: Same as above.
* errout.adb: Remove uses of Raise_Exception_On_Error and
Error_Msg_Exception.
* errutil.adb: Same as above.

Diff:
---
 gcc/ada/err_vars.ads | 11 ---
 gcc/ada/errout.adb   |  4 
 gcc/ada/errout.ads   | 11 ---
 gcc/ada/errutil.adb  |  4 
 4 files changed, 30 deletions(-)

diff --git a/gcc/ada/err_vars.ads b/gcc/ada/err_vars.ads
index 838217b95f43..13b68be4b596 100644
--- a/gcc/ada/err_vars.ads
+++ b/gcc/ada/err_vars.ads
@@ -55,17 +55,6 @@ package Err_Vars is
--  not get reset by any Error_Msg call, so the caller is responsible
--  for resetting it.
 
-   Raise_Exception_On_Error : Nat := 0;
-   --  If this value is non-zero, then any attempt to generate an error
-   --  message raises the exception Error_Msg_Exception, and the error
-   --  message is not output. This is used for defending against junk
-   --  resulting from illegalities, and also for substitution of more
-   --  appropriate error messages from higher semantic levels. It is
-   --  a counter so that the increment/decrement protocol nests neatly.
-
-   Error_Msg_Exception : exception;
-   --  Exception raised if Raise_Exception_On_Error is true
-
Current_Error_Source_File : Source_File_Index := No_Source_File;
--  Id of current messages. Used to post file name when unit changes. This
--  is initialized to Main_Source_File at the start of a compilation, which
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index a569b61c43f9..84958a743119 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -996,10 +996,6 @@ package body Errout is
 
   pragma Assert (Msg (Msg'First) /= ' ' and then Msg (Msg'Last) /= ' ');
 
-  if Raise_Exception_On_Error /= 0 then
- raise Error_Msg_Exception;
-  end if;
-
   Continuation := Msg_Cont;
   Continuation_New_Line := False;
   Suppress_Message := False;
diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
index fce7d9b502ad..3c0c2cecf68d 100644
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -48,17 +48,6 @@ package Errout is
--  Source_Reference line, then this is initialized to No_Source_File, to
--  force an initial reference to the real source file name.
 
-   Raise_Exception_On_Error : Nat renames Err_Vars.Raise_Exception_On_Error;
-   --  If this value is non-zero, then any attempt to generate an error
-   --  message raises the exception Error_Msg_Exception, and the error message
-   --  is not output. This is used for defending against junk resulting from
-   --  illegalities, and also for substitution of more appropriate error
-   --  messages from higher semantic levels. It is a counter so that the
-   --  increment/decrement protocol nests neatly.
-
-   Error_Msg_Exception : exception renames Err_Vars.Error_Msg_Exception;
-   --  Exception raised if Raise_Exception_On_Error is true
-
Current_Node : Node_Id := Empty;
--  Used by Error_Msg as a default Node_Id.
--  Relevant only when Opt.Include_Subprogram_In_Messages is set.
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 450be6b93026..ab320be33904 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -172,10 +172,6 @@ package body Errutil is
  return;
   end if;
 
-  if Raise_Exception_On_Error /= 0 then
- raise Error_Msg_Exception;
-  end if;
-
   Prescan_Message (Msg);
   Set_Msg_Text (Msg, Sptr);


[gcc r15-5681] ada: Refactor code for printing the error location

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0

commit r15-5681-g20e7dfa9fb7db0cd45ad80d8e0592bd1fc7caad0
Author: Viljar Indus 
Date:   Fri Nov 1 13:15:21 2024 +0200

ada: Refactor code for printing the error location

gcc/ada/ChangeLog:

* errout.adb: Use Output_Msg_Location
* erroutc.adb: add common implementation for printing the
error message line.
* erroutc.ads: Add new method Output_Msg_Location
* errutil.adb: use Output_Msg_Location

Diff:
---
 gcc/ada/errout.adb  | 23 +--
 gcc/ada/erroutc.adb | 29 +
 gcc/ada/erroutc.ads |  7 +++
 gcc/ada/errutil.adb | 19 +--
 4 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 21c8adf5e4f3..de2413a8f158 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -2635,28 +2635,7 @@ package body Errout is
end if;
 
if Use_Prefix then
-  Write_Str (SGR_Locus);
-
-  if Full_Path_Name_For_Brief_Errors then
- Write_Name (Full_Ref_Name (Errors.Table (E).Sfile));
-  else
- Write_Name (Reference_Name (Errors.Table (E).Sfile));
-  end if;
-
-  Write_Char (':');
-  Write_Int (Int (Physical_To_Logical
-   (Errors.Table (E).Line,
-  Errors.Table (E).Sfile)));
-  Write_Char (':');
-
-  if Errors.Table (E).Col < 10 then
- Write_Char ('0');
-  end if;
-
-  Write_Int (Int (Errors.Table (E).Col));
-  Write_Str (": ");
-
-  Write_Str (SGR_Reset);
+  Output_Msg_Location (E);
end if;
 
Output_Msg_Text (E);
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index db1c0923e907..606600c613b7 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -774,6 +774,35 @@ package body Erroutc is
   end loop;
end Output_Text_Within;
 
+   -
+   -- Output_Msg_Location --
+   -
+
+   procedure Output_Msg_Location (E : Error_Msg_Id) is
+  E_Obj : constant Error_Msg_Object := Errors.Table (E);
+   begin
+  Write_Str (SGR_Locus);
+
+  if Full_Path_Name_For_Brief_Errors then
+ Write_Name (Full_Ref_Name (E_Obj.Sfile));
+  else
+ Write_Name (Reference_Name (E_Obj.Sfile));
+  end if;
+
+  Write_Char (':');
+  Write_Int (Int (Physical_To_Logical (E_Obj.Line, E_Obj.Sfile)));
+  Write_Char (':');
+
+  if E_Obj.Col < 10 then
+ Write_Char ('0');
+  end if;
+
+  Write_Int (Int (E_Obj.Col));
+  Write_Str (": ");
+
+  Write_Str (SGR_Reset);
+   end Output_Msg_Location;
+
-
-- Output_Msg_Text --
-
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index 0a52af5033c2..6c3b9daef34d 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -512,6 +512,13 @@ package Erroutc is
--  that match or are less than the last Source_Reference pragma are listed
--  as all blanks, avoiding output of junk line numbers.
 
+   procedure Output_Msg_Location (E : Error_Msg_Id);
+   --  Write the location of the error message in the following format:
+   --
+   --  :::
+   --
+   --  If Full_Path_Name_For_Brief_Errors then full path of the file is used.
+
procedure Output_Msg_Text (E : Error_Msg_Id);
--  Outputs characters of text in the text of the error message E. Note that
--  no end of line is output, the caller is responsible for adding the end
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 6747fe59d24b..795b2f21962d 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -411,24 +411,7 @@ package body Errutil is
 
  while E /= No_Error_Msg loop
 if not Errors.Table (E).Deleted then
-   if Full_Path_Name_For_Brief_Errors then
-  Write_Name (Full_Ref_Name (Errors.Table (E).Sfile));
-   else
-  Write_Name (Reference_Name (Errors.Table (E).Sfile));
-   end if;
-
-   Write_Char (':');
-   Write_Int (Int (Physical_To_Logical
-(Errors.Table (E).Line,
- Errors.Table (E).Sfile)));
-   Write_Char (':');
-
-   if Errors.Table (E).Col < 10 then
-  Write_Char ('0');
-   end if;
-
-   Write_Int (Int (Errors.Table (E).Col));
-   Write_Str (": ");
+   Output_Msg_Location (E);
Output_Msg_Text (E);
Write_Eol;
 end if;


[gcc r15-5686] ada: Remove Warn_Runtime_Raise attribute from Error_Msg_Object

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:9fb54f47d0f5c149c94e86def16e538460ce3636

commit r15-5686-g9fb54f47d0f5c149c94e86def16e538460ce3636
Author: Viljar Indus 
Date:   Mon Nov 11 11:01:12 2024 +0200

ada: Remove Warn_Runtime_Raise attribute from Error_Msg_Object

The goal of this attribute is to raise a warning to an error when
the -gnatwE flag is used. This is similar to the existing warnings
as error behavior under the Warn_Err flag so it can be merged.

gcc/ada/ChangeLog:

* errout.adb: Set Warn_Err as true if Is_Runtime_Error was
set in the error message.
* erroutc.adb: Remove instances of Warn_Runtime_Raise.
* erroutc.ads: Likewise.
* errutil.adb: Likewise.

Diff:
---
 gcc/ada/errout.adb  | 31 ---
 gcc/ada/erroutc.adb |  1 -
 gcc/ada/erroutc.ads |  4 
 gcc/ada/errutil.adb |  1 -
 4 files changed, 4 insertions(+), 33 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 644fd1fad37d..8858df117374 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -1246,7 +1246,6 @@ package body Errout is
   Compile_Time_Pragma => Is_Compile_Time_Msg,
   Warn_Err=> False, -- reset below
   Warn_Chr=> Warning_Msg_Char,
-  Warn_Runtime_Raise  => Is_Runtime_Raise,
   Uncond  => Is_Unconditional_Msg,
   Msg_Cont=> Continuation,
   Deleted => False,
@@ -1258,20 +1257,14 @@ package body Errout is
   Warn_Err :=
 Error_Msg_Kind in Warning | Style
 and then (Warning_Treated_As_Error (Msg_Buffer (1 .. Msglen))
-  or else Warning_Treated_As_Error
-(Get_Warning_Tag (Cur_Msg)));
+  or else Warning_Treated_As_Error (Get_Warning_Tag (Cur_Msg))
+  or else Is_Runtime_Raise);
 
   --  Propagate Warn_Err to this message and preceding continuations.
-  --  Likewise, propagate Error_Msg_Kind and Is_Runtime_Raise, because the
-  --  current continued message could have been escalated from warning to
-  --  error.
 
   for J in reverse 1 .. Errors.Last loop
  Errors.Table (J).Warn_Err := Warn_Err;
 
- Errors.Table (J).Kind := Error_Msg_Kind;
- Errors.Table (J).Warn_Runtime_Raise := Is_Runtime_Raise;
-
  exit when not Errors.Table (J).Msg_Cont;
   end loop;
 
@@ -3587,28 +3580,13 @@ package body Errout is
--  not remove style messages here. They are warning messages
--  but not ones we want removed in this context.
 
-   and then (Errors.Table (E).Kind = Warning
-   or else
- Errors.Table (E).Warn_Runtime_Raise)
+   and then Errors.Table (E).Kind = Warning
 
--  Don't remove unconditional messages
 
and then not Errors.Table (E).Uncond
 then
-   if Errors.Table (E).Kind = Warning then
-  Warnings_Detected := Warnings_Detected - 1;
-   end if;
-
-   --  When warning about a runtime exception has been escalated
-   --  into error, the starting message has increased the total
-   --  errors counter, so here we decrease this counter.
-
-   if Errors.Table (E).Warn_Runtime_Raise
- and then not Errors.Table (E).Msg_Cont
- and then Warning_Mode = Treat_Run_Time_Warnings_As_Errors
-   then
-  Total_Errors_Detected := Total_Errors_Detected - 1;
-   end if;
+   Warnings_Detected := Warnings_Detected - 1;
 
return True;
 
@@ -4361,7 +4339,6 @@ package body Errout is
   if Error_Msg_Kind = Warning
 and then Warning_Mode = Treat_Run_Time_Warnings_As_Errors
   then
- Error_Msg_Kind := Non_Serious_Error;
  Is_Runtime_Raise := True;
   end if;
 
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index c57205418de7..9d22996204c1 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -340,7 +340,6 @@ package body Erroutc is
   w ("  Col= ", Int (E.Col));
   w ("  Kind   = ", E.Kind'Img);
   w ("  Warn_Err   = ", E.Warn_Err);
-  w ("  Warn_Runtime_Raise = ", E.Warn_Runtime_Raise);
   w ("  Warn_Chr   = '" & E.Warn_Chr & ''');
   w ("  Uncond = ", E.Uncond);
   w ("  Msg_Cont   = ", E.Msg_Cont);
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index 9a70cfa62444..76cd0205fa84 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -228,10 +228,6 @@ package Erroutc is
   --  True if this is a warning message which is to be treated as an error
   --  as a result of a match with a Warning_As_Error pragma.
 
-

[gcc r15-5687] ada: Relocate implementation of Set_Msg_Insertion_Column

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:9b33f74c84ef5681ccb735209d95479a5ece7377

commit r15-5687-g9b33f74c84ef5681ccb735209d95479a5ece7377
Author: Viljar Indus 
Date:   Tue Nov 12 12:32:05 2024 +0200

ada: Relocate implementation of Set_Msg_Insertion_Column

The implementation was duplicated in errout and errutil. Move
the implementation to erroutc where other similar commonly used
functions are.

gcc/ada/ChangeLog:

* errout.adb: Remove implemntation of Set_Msg_Insertion_Column.
* erroutc.adb: Add implementation of Set_Msg_Insertion_Column.
* erroutc.ads: Add spec of Set_Msg_Insertion_Column.
* errutil.adb: Remove implementation of Set_Msg_Insertion_Column.

Diff:
---
 gcc/ada/errout.adb  | 16 
 gcc/ada/erroutc.adb | 13 +
 gcc/ada/erroutc.ads |  3 +++
 gcc/ada/errutil.adb | 17 +
 4 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 8858df117374..4070d92992d5 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -52,7 +52,6 @@ with Sinfo.Utils;use Sinfo.Utils;
 with Snames; use Snames;
 with Stand;  use Stand;
 with Stringt;use Stringt;
-with Stylesw;use Stylesw;
 with System.OS_Lib;
 with Uname;  use Uname;
 with Warnsw;
@@ -143,9 +142,6 @@ package body Errout is
--  around node N are required by the Ada syntax, e.g. when N is an
--  expression of a qualified expression.
 
-   procedure Set_Msg_Insertion_Column;
-   --  Handle column number insertion (@ insertion character)
-
procedure Set_Msg_Insertion_Node;
--  Handle node (name from node) insertion (& insertion character)
 
@@ -3776,18 +3772,6 @@ package body Errout is
   Errors_Must_Be_Ignored := To;
end Set_Ignore_Errors;
 
-   --
-   -- Set_Msg_Insertion_Column --
-   --
-
-   procedure Set_Msg_Insertion_Column is
-   begin
-  if RM_Column_Check then
- Set_Msg_Str (" in column ");
- Set_Msg_Int (Int (Error_Msg_Col) + 1);
-  end if;
-   end Set_Msg_Insertion_Column;
-

-- Set_Msg_Insertion_Node --

diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index 9d22996204c1..209159e1765b 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -42,6 +42,7 @@ with Sinfo.Nodes;
 with Sinput;   use Sinput;
 with Snames;   use Snames;
 with Stringt;  use Stringt;
+with Stylesw;  use Stylesw;
 with Targparm;
 with Uintp;use Uintp;
 with Widechar; use Widechar;
@@ -1330,6 +1331,18 @@ package body Erroutc is
   end loop;
end Set_Msg_Insertion_Code;
 
+   --
+   -- Set_Msg_Insertion_Column --
+   --
+
+   procedure Set_Msg_Insertion_Column is
+   begin
+  if RM_Column_Check then
+ Set_Msg_Str (" in column ");
+ Set_Msg_Int (Int (Error_Msg_Col) + 1);
+  end if;
+   end Set_Msg_Insertion_Column;
+
-
-- Set_Msg_Insertion_File_Name --
-
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index 76cd0205fa84..0853bdbeab6f 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -576,6 +576,9 @@ package Erroutc is
procedure Set_Msg_Insertion_Code;
--  Handle error code insertion ([] insertion character)
 
+   procedure Set_Msg_Insertion_Column;
+   --  Handle column number insertion (@ insertion character)
+
procedure Set_Msg_Insertion_File_Name;
--  Handle file name insertion (left brace insertion character)
 
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 1094e8ac3179..0891d4618aa7 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -32,7 +32,6 @@ with Output;   use Output;
 with Scans;use Scans;
 with Sinput;   use Sinput;
 with Stringt;  use Stringt;
-with Stylesw;  use Stylesw;
 
 package body Errutil is
 
@@ -58,9 +57,6 @@ package body Errutil is
--  indicates if there are errors attached to the line, which forces
--  listing on, even in the presence of pragma List (Off).
 
-   procedure Set_Msg_Insertion_Column;
-   --  Handle column number insertion (@ insertion character)
-
procedure Set_Msg_Text (Text : String; Flag : Source_Ptr);
--  Add a sequence of characters to the current message. The characters may
--  be one of the special insertion characters (see documentation in spec).
@@ -495,6 +491,7 @@ package body Errutil is
  if Warnings_Detected >= Maximum_Messages then
 Set_Standard_Error;
 Write_Line ("maximum number of warnings detected");
+
 Warning_Mode := Suppress;
  end if;
 
@@ -605,18 +602,6 @@ package body Errutil is
   Errors_Must_Be_Ignored := To;
end Set_Ignore_Errors;
 
-   --
-   -- Set_Msg_Insertion_Column --
-   ---

[gcc r15-5691] ada: Clean up previous change

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:936f9f1d159bd6ef3b1e25e72a6abd1c0fff10b1

commit r15-5691-g936f9f1d159bd6ef3b1e25e72a6abd1c0fff10b1
Author: Eric Botcazou 
Date:   Wed Nov 13 16:37:32 2024 +0100

ada: Clean up previous change

gcc/ada/ChangeLog:

* sem_res.adb (Valid_Conversion): Do not initialize Opnd_Type before
calling Get_Corresponding_Mutably_Tagged_Type_If_Present.

Diff:
---
 gcc/ada/sem_res.adb | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 9cd1db1a9aa6..5ca206135295 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -13803,7 +13803,7 @@ package body Sem_Res is
   Report_Errs : Boolean := True) return Boolean
is
   Target_Type  : constant Entity_Id := Base_Type (Target);
-  Opnd_Type: Entity_Id  := Etype (Operand);
+  Opnd_Type: Entity_Id;
   Inc_Ancestor : Entity_Id;
 
   function Conversion_Check
@@ -14270,14 +14270,10 @@ package body Sem_Res is
begin
   Check_Parameterless_Call (Operand);
 
-  if Is_Overloaded (Operand) then
- if Is_Ambiguous_Operand (Operand) then
-return False;
- end if;
-
- --  The Etype may have been updated by Is_Ambiguous_Operand
-
- Opnd_Type := Etype (Operand);
+  if Is_Overloaded (Operand)
+and then Is_Ambiguous_Operand (Operand)
+  then
+ return False;
   end if;
 
   --  When we encounter a class-wide equivalent type used to represent
@@ -14285,7 +14281,7 @@ package body Sem_Res is
   --  at the class-wide mutably tagged type instead.
 
   Opnd_Type :=
-Get_Corresponding_Mutably_Tagged_Type_If_Present (Opnd_Type);
+Get_Corresponding_Mutably_Tagged_Type_If_Present (Etype (Operand));
 
   --  Deal with conversion of integer type to address if the pragma
   --  Allow_Integer_Address is in effect. We convert the conversion to


[gcc r15-5693] ada: Do not use ATTR_ADDR_EXPR for 'Unrestricted_Access

2024-11-26 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:ae7c0475f108f14cabcc1613df449670b1e9d1a2

commit r15-5693-gae7c0475f108f14cabcc1613df449670b1e9d1a2
Author: Eric Botcazou 
Date:   Mon Nov 11 11:16:26 2024 +0100

ada: Do not use ATTR_ADDR_EXPR for 'Unrestricted_Access

Unlike for 'Access or 'Unchecked_Access, the Attribute_to_gnu routine passes
ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access, which causes the
processing done in build_unary_op to flatten the reference, in particular to
remove all intermediate (view) conversions, which may be problematic for the
SUBSTITUTE_PLACEHOLDER_IN_EXPR machinery.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Attribute_to_gnu) : Do not
pass ATTR_ADDR_EXPR to build_unary_op for 'Unrestricted_Access.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 5d971c1681d6..3aa41253d74c 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -1840,10 +1840,15 @@ Attribute_to_gnu (Node_Id gnat_node, tree 
*gnu_result_type_p,
   gcc_assert (TREE_CODE (gnu_prefix) != TYPE_DECL);
 
   gnu_result_type = get_unpadded_type (Etype (gnat_node));
+
+  /* We used to pass ATTR_ADDR_EXPR for Attr_Unrestricted_Access too, but
+the processing done in build_unary_op for it flattens the reference,
+in particular removes all intermediate (view) conversions, which may
+cause SUBSTITUTE_PLACEHOLDER_IN_EXPR to fail to substitute in the
+bounds of a fat pointer returned for Attr_Unrestricted_Access.  */
   gnu_result
-   = build_unary_op (((attribute == Attr_Address
-   || attribute == Attr_Unrestricted_Access)
-  && !Must_Be_Byte_Aligned (gnat_node))
+   = build_unary_op (attribute == Attr_Address
+ && !Must_Be_Byte_Aligned (gnat_node)
  ? ATTR_ADDR_EXPR : ADDR_EXPR,
  gnu_result_type, gnu_prefix);


[gcc r15-5694] improve std::deque::_M_reallocate_map

2024-11-26 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:1729147f2b1a05ad2a4e8e2d91d1d2ba914039d6

commit r15-5694-g1729147f2b1a05ad2a4e8e2d91d1d2ba914039d6
Author: Jan Hubicka 
Date:   Tue Nov 26 13:52:09 2024 +0100

improve std::deque::_M_reallocate_map

Looking into reason why we still do throw_bad_alloc in clang binary I 
noticed
that quite few calls come from deque::_M_reallocate_map.  This patch adds
unreachable to limit the size of realloc_map.  _M_reallocate_map is called 
only
if new size is smaller then max_size.  map is an array holding pointers to
entries of fixed size.

Since rellocation is done by doubling the map size, I think the maximal 
size of
map allocated is max_size / deque_buf_size rounded up times two.  This 
should
be also safe for overflows since we have extra bit.

map size is always at least 8. Theoretically this computation may be wrong 
for
very large T, but in that case callers should never reallocate.

On the testcase I get:
jh@shroud:~> ~/trunk-install-new4/bin/g++ -O2 dq.C -c ; size -A dq.o | grep 
text
.text  284  0
.text._ZNSt5dequeIiSaIiEE17_M_reallocate_mapEmb485  0
.text.unlikely  10  0
jh@shroud:~> ~/trunk-install-new5/bin/g++ -O2 dq.C -c ; size -A dq.o | grep 
text
.text  284  0
.text._ZNSt5dequeIiSaIiEE17_M_reallocate_mapEmb465  0
.text.unlikely  10  0

so this saves about 20 bytes of rellocate_map, which I think is worthwhile.
Curiously enough gcc14 does:

jh@shroud:~> g++ -O2 dq.C -c ; size -A dq.o | grep text
.text 604  0
.text.unlikely 10  0

which is 145 bytes smaller. Obvoius difference is that _M_reallocate_map 
gets inlined.
Compiling gcc14 preprocessed file with trunk gives:

jh@shroud:~> g++ -O2 dq.C -S ; size -A dq.o | grep text
.text 762  0
.text.unlikely 10  0

So inlining is due to changes at libstdc++ side, but code size growth is 
due to
something else.

For clang this reduced number of thris_bad_new_array_length from 121 to 61.

libstdc++-v3/ChangeLog:

* include/bits/deque.tcc (std::deque::_M_reallocate_map): Add
__builtin_unreachable check to declare that maps are not very large.
* include/bits/stl_deque.h (std::deque::size): Add 
__builtin_unreachable
to check for maximal size of map.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/deque-1.C: New test.
* g++.dg/tree-ssa/deque-2.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/tree-ssa/deque-1.C |  9 +
 gcc/testsuite/g++.dg/tree-ssa/deque-2.C | 10 ++
 libstdc++-v3/include/bits/deque.tcc |  4 
 libstdc++-v3/include/bits/stl_deque.h   |  7 ++-
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/deque-1.C 
b/gcc/testsuite/g++.dg/tree-ssa/deque-1.C
new file mode 100644
index ..c639ebb1a5f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/deque-1.C
@@ -0,0 +1,9 @@
+// { dg-do compile } 
+// { dg-options "-O1 -fdump-tree-optimized" }
+#include 
+void
+test(std::deque &q, int v)
+{
+  q.push_back (v);
+}
+// { dg-final { scan-tree-dump-not "throw_bad_alloc" "optimized" } }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/deque-2.C 
b/gcc/testsuite/g++.dg/tree-ssa/deque-2.C
new file mode 100644
index ..7e268b3f018d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/deque-2.C
@@ -0,0 +1,10 @@
+// { dg-do compile }
+// { dg-options "-O3 -fdump-tree-optimized" }
+#include 
+std::deque
+test2(std::deque &q)
+{
+  return q;
+}
+// rethrow is OK, but throw is not.
+// { dg-final { scan-tree-dump-not {[^e]throw} "optimized" } }
diff --git a/libstdc++-v3/include/bits/deque.tcc 
b/libstdc++-v3/include/bits/deque.tcc
index deb010a0ebb5..ee03c917a295 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -956,6 +956,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 + std::max(this->_M_impl._M_map_size,
__nodes_to_add) + 2;
 
+ const size_t __bufsz = __deque_buf_size(sizeof(_Tp));
+ if (__new_map_size > ((max_size() + __bufsz - 1) / __bufsz) * 2)
+   __builtin_unreachable();
+
  _Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
  __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
 + (__add_at_front ? __nodes_to_add : 0);
diff --git a/libstdc++-v3/include/bits/stl_deque.h 
b/libstdc++-v3/include/bits/stl_deque.h
index c617933bd81c..dd1212793ded 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -1266,7 +126

[gcc r14-10982] [PATCH] PR modula2/115957 ICE on procedure local const declaration

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:99d537558ebffb52cb8f784ab550b962958fedef

commit r14-10982-g99d537558ebffb52cb8f784ab550b962958fedef
Author: Gaius Mulley 
Date:   Tue Nov 26 12:57:12 2024 +

[PATCH] PR modula2/115957 ICE on procedure local const declaration

An ICE would occur if a constant was declared using a variable term.
This fix catches variable terms in constant expressions and generates
an unrecoverable error.

gcc/m2/ChangeLog:

PR modula2/115957
* gm2-compiler/M2StackAddress.mod (PopAddress): Detect tail=NIL
and generate an internal error.
* gm2-compiler/PCBuild.bnf (InConstParameter): New variable.
(InConstBlock): New variable.
(ErrorString): Rewrite using MetaErrorStringT0.
(ErrorArrayAt): Rewrite using MetaErrorStringT0.
(WarnMissingToken): Use MetaErrorStringT0.
(CompilationUnit): Set seenError FALSE.
(init): Initialize InConstParameter and InConstBlock.
(ConstantDeclaration): Set InConstBlock.
(ConstSetOrQualidentOrFunction): Call CheckNotVar if not
InConstParameter and InConstBlock.
(ConstActualParameters): Set InConstParameter TRUE and restore
value at the end.
* gm2-compiler/PCSymBuild.def (CheckNotVar): New procedure.
Remove all unnecessary export qualified list.
* gm2-compiler/PCSymBuild.mod (CheckNotVar): New procedure.

gcc/testsuite/ChangeLog:

PR modula2/115957
* gm2/errors/fail/badconst.mod: New test.
* gm2/pim/fail/tinyadr.mod: New test.

(cherry picked from commit d9709fafb2c498ba2f4c920f953c9b78fa3bf114)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2StackAddress.mod | 11 +---
 gcc/m2/gm2-compiler/PCBuild.bnf| 40 +-
 gcc/m2/gm2-compiler/PCSymBuild.def | 38 +---
 gcc/m2/gm2-compiler/PCSymBuild.mod | 18 +-
 gcc/testsuite/gm2/errors/fail/badconst.mod | 19 ++
 gcc/testsuite/gm2/pim/fail/tinyadr.mod | 12 +
 6 files changed, 90 insertions(+), 48 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2StackAddress.mod 
b/gcc/m2/gm2-compiler/M2StackAddress.mod
index c7262dce3b38..ff65b42059c4 100644
--- a/gcc/m2/gm2-compiler/M2StackAddress.mod
+++ b/gcc/m2/gm2-compiler/M2StackAddress.mod
@@ -157,9 +157,14 @@ BEGIN
 END ;
 DISPOSE(b)
  END ;
- WITH s^.tail^ DO
-DEC(items) ;
-RETURN( bucket[items] )
+ IF s^.tail = NIL
+ THEN
+InternalError ('stack underflow')
+ ELSE
+WITH s^.tail^ DO
+   DEC(items) ;
+   RETURN( bucket[items] )
+END
  END
   END
END
diff --git a/gcc/m2/gm2-compiler/PCBuild.bnf b/gcc/m2/gm2-compiler/PCBuild.bnf
index 46f46af73ffe..0e45b2e889cc 100644
--- a/gcc/m2/gm2-compiler/PCBuild.bnf
+++ b/gcc/m2/gm2-compiler/PCBuild.bnf
@@ -47,7 +47,7 @@ IMPLEMENTATION MODULE PCBuild ;
 FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken,
  InsertTokenAndRewind, GetTokenNo, MakeVirtualTok ;
 
-FROM M2Error IMPORT ErrorStringAt, WriteFormat1, WriteFormat2 ;
+FROM M2MetaError IMPORT MetaErrorStringT0 ;
 FROM NameKey IMPORT NulName, Name, makekey ;
 FROM DynamicStrings IMPORT String, InitString, KillString, Mark, ConCat, 
ConCatChar ;
 FROM M2Printf IMPORT printf0 ;
@@ -102,7 +102,8 @@ FROM PCSymBuild IMPORT PCStartBuildProgModule,
PushConstType,
PushConstAttributeType,
PushConstAttributePairType,
-   PushRType ;
+   PushRType,
+   CheckNotVar ;
 
 FROM SymbolTable IMPORT MakeGnuAsm, PutGnuAsmVolatile, PutGnuAsm, 
PutGnuAsmInput,
 PutGnuAsmOutput, PutGnuAsmTrash, PutGnuAsmVolatile,
@@ -127,13 +128,15 @@ CONST
Pass1 = FALSE ;
 
 VAR
-   WasNoError  : BOOLEAN ;
+   InConstParameter,
+   InConstBlock,
+   seenError   : BOOLEAN ;
 
 
 PROCEDURE ErrorString (s: String) ;
 BEGIN
-   ErrorStringAt (s, GetTokenNo ()) ;
-   WasNoError := FALSE
+   MetaErrorStringT0 (GetTokenNo (), s) ;
+   seenError := TRUE
 END ErrorString ;
 
 
@@ -145,7 +148,7 @@ END ErrorArray ;
 
 PROCEDURE ErrorArrayAt (a: ARRAY OF CHAR; tok: CARDINAL) ;
 BEGIN
-   ErrorStringAt (InitString(a), tok)
+   MetaErrorStringT0 (tok, InitString (a))
 END ErrorArrayAt ;
 
 
@@ -220,7 +223,7 @@ BEGIN
str := DescribeStop(s0, s1, s2) ;
 
str := ConCat(InitString('syntax error,'), Mark(str)) ;
-   ErrorStringAt(str, GetTokenNo())
+   MetaErrorStringT0 (GetTokenNo (), str)
 END WarnMissingToken ;
 
 
@@ -338,9 +341,9 @@ END Expect ;
 
 PROCEDURE CompilationUnit () : BOOLEAN ;
 BEGIN
-   WasNoError := TRUE ;
+   seenError := FALSE ;

[gcc r15-5696] RISC-V: Refactor the testcases for RVV gather/scatter

2024-11-26 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:a22dfe208d94105a6e587a3b25e8fe8d62444d8a

commit r15-5696-ga22dfe208d94105a6e587a3b25e8fe8d62444d8a
Author: Pan Li 
Date:   Mon Nov 25 11:45:30 2024 +0800

RISC-V: Refactor the testcases for RVV gather/scatter

This patch would like to refactor the testcases of gather/scatter
after sorts of optimization option passing to testcase.  Includes:

* Remove unnecessary optimization options.
* Adjust dg-final by any-opts and/or no-opts if the rtl dump changes
  on different optimization options (like O2, O3).

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* 
gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c:
Adjust the dump check times.
* gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-1.c:
Remove unnecessary option and add target no-opts/any-tops.
* gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-2.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/gather-scatter/strided_store-1.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/gather-scatter/strided_store-2.c: 
Ditto.

Signed-off-by: Pan Li 

Diff:
---
 .../rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c  |  2 +-
 .../riscv/rvv/autovec/gather-scatter/strided_load-1.c|  9 +++--
 .../riscv/rvv/autovec/gather-scatter/strided_load-2.c| 16 ++--
 .../riscv/rvv/autovec/gather-scatter/strided_store-1.c   |  9 +++--
 .../riscv/rvv/autovec/gather-scatter/strided_store-2.c   |  2 +-
 5 files changed, 30 insertions(+), 8 deletions(-)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
index 11a4031f47bb..1fd3644886ac 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c
@@ -106,7 +106,7 @@ TEST_LOOP (_Float16, uint64_t)
 TEST_LOOP (float, uint64_t)
 TEST_LOOP (double, uint64_t)
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 88 
"vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 80 
"vect" } } */
 /* { dg-final { scan-tree-dump " \.MASK_LEN_GATHER_LOAD" "vect" } } */
 /* { dg-final { scan-tree-dump-not " \.GATHER_LOAD" "vect" } } */
 /* { dg-final { scan-tree-dump-not " \.MASK_GATHER_LOAD" "vect" } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-1.c
index 79b39f102bf2..b8c9669fa541 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-1.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O3 
-mrvv-vector-bits=scalable -fno-vect-cost-model -ffast-math 
-fdump-tree-optimized-details" } */
+/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -mrvv-vector-bits=scalable 
-fno-vect-cost-model -ffast-math -fdump-tree-optimized-details" } */
 
 #include 
 
@@ -40,6 +40,11 @@
 
 TEST_ALL (TEST_LOOP)
 
-/* { dg-final { scan-tree-dump-times " \.MASK_LEN_STRIDED_LOAD " 66 
"optimized" } } */
+/* { dg-final { scan-tree-dump-times " \.MASK_LEN_STRIDED_LOAD " 66 
"optimized" { target { any-opts
+ "-O3"
+   } } } } */
+/* { dg-final { scan-tree-dump-times " \.MASK_LEN_STRIDED_LOAD " 44 
"optimized" { target { any-opts
+ "-O2"
+   } } } } */
 /* { dg-final { scan-tree-dump-not " \.GATHER_LOAD" "optimized" } } */
 /* { dg-final { scan-tree-dump-not " \.MASK_GATHER_LOAD" "optimized" } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-2.c
index 8a452e547a39..dab9658b12b8 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-2.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O3 
-mrvv-vector-bits=scalable -fno-vect-cost-model -ffast-math 
-fdump-tree-optimized-details" } */
+/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -mrvv-vector-bits=scalable 
-fno-vect-cost-model -ffast-math -fdump-tree-optimized-details" } */
 
 #include 
 
@@ -40,6 +40,18 @@
 
 TEST_ALL (TEST_LOOP)
 
-/* { dg-final { scan-tree-dump-times " \.MASK_LEN_STRIDED_LOAD " 33 
"optimized" } } */
+/* { dg-final { scan-tree-dump-times " \.MASK_LEN_STRIDED_LOAD " 64 
"optimized" { target { any-opts {
+ "-mrvv-max-lmul=m8"
+ "-mrvv-max-lmul=dynamic"
+   } } } } */
+

[gcc r15-5695] RISC-V: Fix incorrect optimization options passing to gather/scatter

2024-11-26 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:1802669b76cd53f3d016f1892bbd7c2c3dac1857

commit r15-5695-g1802669b76cd53f3d016f1892bbd7c2c3dac1857
Author: Pan Li 
Date:   Mon Nov 25 11:45:29 2024 +0800

RISC-V: Fix incorrect optimization options passing to gather/scatter

Like the strided load/store, the testcases of vector gather/scatter are
designed to pick up different sorts of optimization options but actually
these option are ignored according to the Execution log of gcc.log.  This 
patch
would like to make it correct almost the same as what we fixed for
strided load/store.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp: Fix the incorrect optimization
options passing to testcases.

Signed-off-by: Pan Li 

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

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp 
b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
index 71251737be2b..448374d49db5 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
+++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
@@ -119,7 +119,7 @@ set AUTOVEC_TEST_OPTS [list \
   {-ftree-vectorize -O2 -mrvv-vector-bits=scalable -mrvv-max-lmul=dynamic 
-ffast-math} ]
 foreach op $AUTOVEC_TEST_OPTS {
   dg-runtest [lsort [glob -nocomplain 
$srcdir/$subdir/autovec/gather-scatter/*.\[cS\]]] \
-"" "$op"
+"$op" ""
   dg-runtest [lsort [glob -nocomplain 
$srcdir/$subdir/autovec/strided/*.\[cS\]]] \
 "$op" ""
   dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/sat/*.\[cS\]]] \


[gcc r14-10983] [PATCH] PR modula2/116048 ICE when encountering wrong kind of qualident

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:bcb8f401101455e1e6098bb9808d2059f4425de7

commit r14-10983-gbcb8f401101455e1e6098bb9808d2059f4425de7
Author: Gaius Mulley 
Date:   Tue Nov 26 13:04:05 2024 +

[PATCH] PR modula2/116048 ICE when encountering wrong kind of qualident

Following on from PR-115957 further ICEs can be generated by using the
wrong kind of qualident symbol.  For example using a variable instead of
a type or using a type instead of a const.  This fix tracks the expected
qualident kind state when parsing const, type and variable declarations.
If the error is unrecoverable then a detailed message explaining the
context of the qualident (and why the seen qualident is wrong) is
generated.

gcc/m2/ChangeLog:

PR modula2/116048
* Make-lang.in (GM2-COMP-BOOT-DEFS): Add M2StateCheck.def.
(GM2-COMP-BOOT-MODS): Add M2StateCheck.mod.
(GM2-COMP-DEFS): Add M2StateCheck.def.
(GM2-COMP-MODS): Add M2StateCheck.mod.
* gm2-compiler/M2Quads.mod (StartBuildWith): Generate
unrecoverable error is the qualident type is NulSym.
Replace MetaError1 with MetaErrorT1 and position the error
to the qualident.
* gm2-compiler/P3Build.bnf (M2StateCheck): Import procedures.
(seenError): New variable.
(WasNoError): Remove variable.
(BlockState): New variable.
(ErrorString): Rewrite using seenError.
(CompilationUnit): Ditto.
(QualidentCheck): New rule.
(ConstantDeclaration): Bookend with InclConst and ExclConst.
(Constructor): Add InclConstructor, ExclConstructor and call
CheckQualident.
(ConstActualParameters): Call PushState, PopState, InclConstFunc
and CheckQualident.
(TypeDeclaration): Bookend with InclType and ExclType.
(SimpleType): Call QualidentCheck.
(CaseTag): Ditto.
(OptReturnType): Ditto.
(VariableDeclaration): Bookend with InclVar and ExclVar.
(Designator): Call QualidentCheck.
(Formal;Type): Ditto.
* gm2-compiler/PCBuild.bnf (M2StateCheck): Import procedures.
(ConstantDeclaration): Rewrite using InclConst and ExclConst.
(Constructor): Bookend with InclConstructor and ExclConstructor.
Call CheckQualident.
(ConstructorOrConstActualParameters): Rewrite and cal
l CheckQualident.
(ConstActualParameters): Bookend with PushState PopState.
Call InclConstFunc and CheckQualident.
* gm2-gcc/init.cc (_M2_M2StateCheck_init): New declaration.
(_M2_P3Build_init): New declaration.
(init_PerCompilationInit): Call _M2_M2StateCheck_init and
_M2_P3Build_init.
* gm2-compiler/M2StateCheck.def: New file.
* gm2-compiler/M2StateCheck.mod: New file.

gcc/testsuite/ChangeLog:

PR modula2/116048
* gm2/errors/fail/errors-fail.exp: Remove -Wstudents
and add -Wuninit-variable-checking=all.
Replace gm2_init_pim with gm2_init_iso.
* gm2/errors/fail/testfio.mod: Modify test code to
provoke an error in the first basic block.
* gm2/errors/fail/testparam.mod: Ditto.
* gm2/errors/fail/array1.mod: Ditto.
* gm2/errors/fail/badtype.mod: New test.
* gm2/errors/fail/badvar.mod: New test.

(cherry picked from commit 7f8064ff0e2ac90c5bb6c30cc61acc5a28ebbe4c)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/Make-lang.in   |   4 +
 gcc/m2/gm2-compiler/M2Quads.mod   |  45 ++--
 gcc/m2/gm2-compiler/M2StateCheck.def  | 154 
 gcc/m2/gm2-compiler/M2StateCheck.mod  | 344 ++
 gcc/m2/gm2-compiler/P3Build.bnf   |  65 +++--
 gcc/m2/gm2-compiler/PCBuild.bnf   |  45 ++--
 gcc/m2/gm2-gcc/init.cc|   4 +
 gcc/testsuite/gm2/errors/fail/array1.mod  |   5 +
 gcc/testsuite/gm2/errors/fail/badtype.mod |  10 +
 gcc/testsuite/gm2/errors/fail/badvar.mod  |  10 +
 gcc/testsuite/gm2/errors/fail/errors-fail.exp |   2 +-
 gcc/testsuite/gm2/errors/fail/testfio.mod |   8 +
 gcc/testsuite/gm2/errors/fail/testparam.mod   |   5 +
 13 files changed, 645 insertions(+), 56 deletions(-)

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index daa7ef6747a5..2bd60ca29393 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -808,6 +808,7 @@ GM2-COMP-BOOT-DEFS = \
M2Size.def \
M2StackAddress.def \
M2StackWord.def \
+   M2StateCheck.def \
M2Students.def \
M2Swig.def \
M2SymInit.def \
@@ -882,6 +883,7 @@ GM2-COMP-BOOT-MODS = \
M2Size.mod \
M2StackAddress.mod \
M2StackWord.mod \
+   M2StateCheck.mod \
M2Students.mod \
M2Swi

[gcc r14-10984] [PATCH] modula2: Add GNU flex as a build and install prerequisite.

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:0891093e65c343ee4e4434c357ca915ee56e37b7

commit r14-10984-g0891093e65c343ee4e4434c357ca915ee56e37b7
Author: Gaius Mulley 
Date:   Tue Nov 26 13:11:31 2024 +

[PATCH] modula2: Add GNU flex as a build and install prerequisite.

gcc/ChangeLog:

* doc/install.texi (GM2-prerequisite): Add GNU flex.

(cherry picked from commit 52f3473e375b1bb57d08c97291a82c04070036c3)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/doc/install.texi | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index f20336c2062f..814db3ea5ec3 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -336,6 +336,10 @@ environment to your ``good'' shell prior to running
 @command{zsh} is not a fully compliant POSIX shell and will not
 work when configuring GCC@.
 
+@item GNU flex
+
+Necessary to build the lexical analysis module.
+
 @item A POSIX or SVR4 awk
 
 Necessary for creating some of the generated source files for GCC@.


[gcc r14-10985] [PATCH] modula2: Improve error message to include symbol name.

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:2665f3e027d835a8a64652a4792792fddd83dd8b

commit r14-10985-g2665f3e027d835a8a64652a4792792fddd83dd8b
Author: Gaius Mulley 
Date:   Tue Nov 26 13:15:56 2024 +

[PATCH] modula2: Improve error message to include symbol name.

gcc/m2/ChangeLog:

* gm2-compiler/M2StateCheck.mod (GenerateError): Add
symbol name to the error message.

(cherry picked from commit 6a99f3ae962542165fdfc077f1040ea4d936691b)

Signed-off-by: Gaius Mulley 

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

diff --git a/gcc/m2/gm2-compiler/M2StateCheck.mod 
b/gcc/m2/gm2-compiler/M2StateCheck.mod
index e53cb174474c..940c433bcc14 100644
--- a/gcc/m2/gm2-compiler/M2StateCheck.mod
+++ b/gcc/m2/gm2-compiler/M2StateCheck.mod
@@ -306,7 +306,7 @@ PROCEDURE GenerateError (tok: CARDINAL; s: StateCheck; sym: 
CARDINAL) ;
 VAR
str: String ;
 BEGIN
-   str := InitString ('not expecting a {%1Ad} {%1a: }in a ') ;
+   str := InitString ('not expecting the {%1Ad} {%1a} in a ') ;
IF const IN s^.state
THEN
   str := ConCat (str, Mark (InitString ('{%kCONST} block')))


[gcc r14-10986] [PATCH] PR modula2/115823 Wrong expansion of isnormal optab

2024-11-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:056448490e4ddb03263d9566b8aaee2340cba3ac

commit r14-10986-g056448490e4ddb03263d9566b8aaee2340cba3ac
Author: Gaius Mulley 
Date:   Tue Nov 26 13:18:27 2024 +

[PATCH] PR modula2/115823 Wrong expansion of isnormal optab

This patch corrects the function declaration of a builtin
(using the libname rather than the source name).

gcc/m2/ChangeLog:

PR modula2/115823
* gm2-gcc/m2builtins.cc (define_builtin): Build
the function decl using the libname.

gcc/testsuite/ChangeLog:

PR modula2/115823
* gm2/builtins/run/pass/testisnormal.mod: Change to an
implementation module.
* gm2/builtins/run/pass/testisnormal.def: New test.
* gm2/builtins/run/pass/testsinl.def: New test.
* gm2/builtins/run/pass/testsinl.mod: New test.

(cherry picked from commit 79e029a41825f533bb87b4bee5427b90b62175ae)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-gcc/m2builtins.cc   |  4 ++--
 .../gm2/builtins/run/pass/testisnormal.def |  5 +
 .../gm2/builtins/run/pass/testisnormal.mod |  2 +-
 gcc/testsuite/gm2/builtins/run/pass/testsinl.def   |  5 +
 gcc/testsuite/gm2/builtins/run/pass/testsinl.mod   | 23 ++
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc
index e3e55a699917..44f48fc01ba8 100644
--- a/gcc/m2/gm2-gcc/m2builtins.cc
+++ b/gcc/m2/gm2-gcc/m2builtins.cc
@@ -1431,8 +1431,8 @@ define_builtin (enum built_in_function val, const char 
*name, tree prototype,
   tree decl;
   builtin_macro_definition bmd;
 
-  decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name),
- prototype);
+  decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
+get_identifier (libname), prototype);
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def 
b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def
new file mode 100644
index ..df01cc353eb5
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.def
@@ -0,0 +1,5 @@
+DEFINITION MODULE testisnormal ;
+
+PROCEDURE test ;
+
+END testisnormal.
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod 
b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
index 6b65a7b9b122..1349d80e8e8e 100644
--- a/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
+++ b/gcc/testsuite/gm2/builtins/run/pass/testisnormal.mod
@@ -1,4 +1,4 @@
-MODULE testisnormal ;
+IMPLEMENTATION MODULE testisnormal ;
 
 FROM libc IMPORT printf, exit ;
 FROM Builtins IMPORT isnormal ;
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testsinl.def 
b/gcc/testsuite/gm2/builtins/run/pass/testsinl.def
new file mode 100644
index ..7afd3cc86235
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testsinl.def
@@ -0,0 +1,5 @@
+DEFINITION MODULE testsinl ;
+
+PROCEDURE test ;
+
+END testsinl.
diff --git a/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod 
b/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod
new file mode 100644
index ..7f669f89c8e2
--- /dev/null
+++ b/gcc/testsuite/gm2/builtins/run/pass/testsinl.mod
@@ -0,0 +1,23 @@
+IMPLEMENTATION MODULE testsinl ;
+
+FROM libc IMPORT printf ;
+FROM Builtins IMPORT sinl ;
+
+
+(*
+   test -
+*)
+
+PROCEDURE test ;
+VAR
+   result: LONGREAL ;
+BEGIN
+   result := sinl (3.14) ;
+   printf ("sinl (3.14) = %lg\n", result) ;
+END test ;
+
+
+BEGIN
+   test ;
+   printf ("all tests pass\n")
+END testsinl.