[gcc r15-4053] doc: Drop GCC 2.6 ABI change note for H8/h8300-hms

2024-10-03 Thread Gerald Pfeifer via Gcc-cvs
https://gcc.gnu.org/g:186be7f37aed3b141af6367e05d28c5bcb0d9330

commit r15-4053-g186be7f37aed3b141af6367e05d28c5bcb0d9330
Author: Gerald Pfeifer 
Date:   Fri Oct 4 12:53:15 2024 +0800

doc: Drop GCC 2.6 ABI change note for H8/h8300-hms

gcc:
PR target/69374
* doc/install.texi (Specific) : Drop GCC 2.6
ABI change note.

Diff:
---
 gcc/doc/install.texi | 5 -
 1 file changed, 5 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index e035061a23e1..09559615bbf6 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -4118,11 +4118,6 @@ This configuration is intended for embedded systems.
 @heading h8300-hms
 Renesas H8/300 series of processors.
 
-The calling convention and structure layout has changed in release 2.6.
-All code must be recompiled.  The calling convention now passes the
-first three arguments in function calls in registers.  Structures are no
-longer a multiple of 2 bytes.
-
 @html
 
 @end html


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

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:09f789660e9bedc8ecdc5add9afdfced4d68dcd0

commit r14-10740-g09f789660e9bedc8ecdc5add9afdfced4d68dcd0
Author: Kim Gräsman 
Date:   Tue Aug 27 17:11:29 2024 +0100

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

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

libstdc++-v3/ChangeLog:

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

(cherry picked from commit c2ad7b2d5247cf2ddee98d7f46274775a3fa1268)

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

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


[gcc r14-10742] libstdc++: Make debug sequence members mutable [PR116369]

2024-10-03 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:4ef6b95d5dabba0a907d9545f901c77f0a5cb42d

commit r14-10742-g4ef6b95d5dabba0a907d9545f901c77f0a5cb42d
Author: Jonathan Wakely 
Date:   Wed Aug 21 12:29:32 2024 +0100

libstdc++: Make debug sequence members mutable [PR116369]

We need to be able to attach debug mode iterators to const containers,
so the safe iterator constructor uses const_cast to get a modifiable
pointer to the container. If the container was defined as const, that
const_cast to access its members results in undefined behaviour.  PR
116369 shows a case where it results in a segfault because the container
is in a rodata section (which shouldn't have happened, but the undefined
behaviour in the library still exists in any case).

This makes the _M_iterators and _M_const_iterators data members mutable,
so that it's safe to modify them even if the declared type of the
container is a const type.

Ideally we would not need the const_cast at all. Instead, the _M_attach
member (and everything it calls) should be const-qualified. That would
work fine now, because the members that it ends up modifying are
mutable. Making that change would require a number of new exports from
the shared library, and would require retaining the old non-const member
functions (maybe as symbol aliases) for backwards compatibility. That
might be worth changing at some point, but isn't done here.

libstdc++-v3/ChangeLog:

PR c++/116369
* include/debug/safe_base.h (_Safe_sequence_base::_M_iterators):
Add mutable specifier.
(_Safe_sequence_base::_M_const_iterators): Likewise.

(cherry picked from commit a35dd276cbf6236e08bcf6e56e62c2be41cf6e3c)

Diff:
---
 libstdc++-v3/include/debug/safe_base.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/debug/safe_base.h 
b/libstdc++-v3/include/debug/safe_base.h
index d5fbe4b1320b..88d7f0b05c8b 100644
--- a/libstdc++-v3/include/debug/safe_base.h
+++ b/libstdc++-v3/include/debug/safe_base.h
@@ -205,10 +205,10 @@ namespace __gnu_debug
 
   public:
 /// The list of mutable iterators that reference this container
-_Safe_iterator_base* _M_iterators;
+mutable _Safe_iterator_base* _M_iterators;
 
 /// The list of constant iterators that reference this container
-_Safe_iterator_base* _M_const_iterators;
+mutable _Safe_iterator_base* _M_const_iterators;
 
 /// The container version number. This number may never be 0.
 mutable unsigned int _M_version;


[gcc r14-10739] libstdc++: Fix autoconf check for O_NONBLOCK in

2024-10-03 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:1982bd34cf63beef4d86a048bc16aab11a1ad71b

commit r14-10739-g1982bd34cf63beef4d86a048bc16aab11a1ad71b
Author: Jonathan Wakely 
Date:   Wed Aug 28 12:38:18 2024 +0100

libstdc++: Fix autoconf check for O_NONBLOCK in 

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

libstdc++-v3/ChangeLog:

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

(cherry picked from commit b68561dd7925dfee1836f75d3fa8d33fff5c2498)

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

diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 906e0143099e..9cba3d9c8ee4 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -302,6 +302,9 @@
 /* Define if openat is available in . */
 #undef HAVE_OPENAT
 
+/* Define if O_NONBLOCK is defined in  */
+#undef HAVE_O_NONBLOCK
+
 /* Define if poll is available in . */
 #undef HAVE_POLL
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb07788..18053ab7eae6 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -54085,6 +54085,8 @@ if test 
"$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
 "
 if test "x$ac_cv_have_decl_O_NONBLOCK" = xyes; then :
 
+$as_echo "#define HAVE_O_NONBLOCK 1" >>confdefs.h
+
 fi
 
 fi
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 37396bd6ebbe..a6525a9d3e46 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -539,7 +539,10 @@ AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/socket.h 
sys/uio.h poll.h netdb.h arpa
 AC_CHECK_DECL(F_GETFL,,,[#include ])
 AC_CHECK_DECL(F_SETFL,,,[#include ])
 if test "$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
-  AC_CHECK_DECL(O_NONBLOCK,,,[#include ])
+  AC_CHECK_DECL(O_NONBLOCK,
+AC_DEFINE(HAVE_O_NONBLOCK,1,[Define if O_NONBLOCK is defined in 
]),
+[],
+[#include ])
 fi
 
 # For Transactional Memory TS


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

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

commit r14-10741-gab9ab537b11a6a82f283b08898b67f83f4a19e57
Author: Kim Gräsman 
Date:   Tue Aug 27 17:08:47 2024 +0100

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

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

libstdc++-v3/ChangeLog:

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

(cherry picked from commit f6ed7a61a7c906f8fb7f8059132225c9bc41f3b2)

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

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


[gcc r14-10737] libstdc++: Fix std::codecvt for empty dest [PR37475]

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

commit r14-10737-gc4253d6a170f40725ce3a11ce7a3e236b6e4842f
Author: Jonathan Wakely 
Date:   Tue Jun 11 16:45:43 2024 +0100

libstdc++: Fix std::codecvt for empty dest 
[PR37475]

For the GNU locale model, codecvt::do_out and codecvt::do_in incorrectly
return 'ok' when the destination range is empty. That happens because
detecting incomplete output is done in the loop body, and the loop is
never even entered if to == to_end.

By restructuring the loop condition so that we check the output range
separately, we can ensure that for a non-empty source range, we always
enter the loop at least once, and detect if the destination range is too
small.

The loops also seem easier to reason about if we return immediately on
any error, instead of checking the result twice on every iteration. We
can use an RAII type to restore the locale before returning, which also
simplifies all the other member functions.

libstdc++-v3/ChangeLog:

PR libstdc++/37475
* config/locale/gnu/codecvt_members.cc (Guard): New RAII type.
(do_out, do_in): Return partial if the destination is empty but
the source is not. Use Guard to restore locale on scope exit.
Return immediately on any conversion error.
(do_encoding, do_max_length, do_length): Use Guard.
* testsuite/22_locale/codecvt/in/char/37475.cc: New test.
* testsuite/22_locale/codecvt/in/wchar_t/37475.cc: New test.
* testsuite/22_locale/codecvt/out/char/37475.cc: New test.
* testsuite/22_locale/codecvt/out/wchar_t/37475.cc: New test.

(cherry picked from commit 73ad57c244c283bf6da0c16630212f11b945eda5)

Diff:
---
 libstdc++-v3/config/locale/gnu/codecvt_members.cc  | 117 +
 .../testsuite/22_locale/codecvt/in/char/37475.cc   |  23 
 .../22_locale/codecvt/in/wchar_t/37475.cc  |  23 
 .../testsuite/22_locale/codecvt/out/char/37475.cc  |  23 
 .../22_locale/codecvt/out/wchar_t/37475.cc |  23 
 5 files changed, 142 insertions(+), 67 deletions(-)

diff --git a/libstdc++-v3/config/locale/gnu/codecvt_members.cc 
b/libstdc++-v3/config/locale/gnu/codecvt_members.cc
index 034713d236ef..794f25a5f356 100644
--- a/libstdc++-v3/config/locale/gnu/codecvt_members.cc
+++ b/libstdc++-v3/config/locale/gnu/codecvt_members.cc
@@ -37,8 +37,23 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  // Specializations.
 #ifdef _GLIBCXX_USE_WCHAR_T
+namespace
+{
+  // RAII type for changing and restoring the current thread's locale.
+  struct Guard
+  {
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+explicit Guard(__c_locale loc) : old(__uselocale(loc)) { }
+~Guard() { __uselocale(old); }
+#else
+explicit Guard(__c_locale) { }
+#endif
+__c_locale old;
+  };
+}
+
+  // Specializations.
   codecvt_base::result
   codecvt::
   do_out(state_type& __state, const intern_type* __from,
@@ -46,22 +61,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 extern_type* __to, extern_type* __to_end,
 extern_type*& __to_next) const
   {
-result __ret = ok;
 state_type __tmp_state(__state);
-
-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-__c_locale __old = __uselocale(_M_c_locale_codecvt);
-#endif
+Guard g(_M_c_locale_codecvt);
 
 // wcsnrtombs is *very* fast but stops if encounters NUL characters:
 // in case we fall back to wcrtomb and then continue, in a loop.
 // NB: wcsnrtombs is a GNU extension
-for (__from_next = __from, __to_next = __to;
-__from_next < __from_end && __to_next < __to_end
-&& __ret == ok;)
+__from_next = __from;
+__to_next = __to;
+while (__from_next < __from_end)
   {
-   const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
- __from_end - __from_next);
+   if (__to_next >= __to_end)
+ return partial;
+
+   const intern_type* __from_chunk_end
+ = wmemchr(__from_next, L'\0', __from_end - __from_next);
if (!__from_chunk_end)
  __from_chunk_end = __from_end;
 
@@ -77,12 +91,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
for (; __from < __from_next; ++__from)
  __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
__state = __tmp_state;
-   __ret = error;
+   return error;
  }
else if (__from_next && __from_next < __from_chunk_end)
  {
__to_next += __conv;
-   __ret = partial;
+   return partial;
  }
else
  {
@@ -90,13 +104,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__to_next += __conv;
  }
 
-   if (__from_next < __from_end && __ret == ok)
+   if (__from_next < __from_end)
  {
exte

[gcc r14-10733] libstdc++: Disable std::formatter specialization

2024-10-03 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:98ae5227a3e475e2c7d54d01fb5ee06cf0885ccc

commit r14-10733-g98ae5227a3e475e2c7d54d01fb5ee06cf0885ccc
Author: Jonathan Wakely 
Date:   Fri Sep 20 17:26:35 2024 +0100

libstdc++: Disable std::formatter specialization

I noticed that char8_t was missing from the list of types that were
prevented from using the std::formatter partial specialization for
integer types. That partial specialization was also matching
cv-qualified integer types, because std::integral is true.

This change simplifies the constraints by introducing a new variable
template which is only true for cv-unqualified integer types, with
explicit specializations to exclude the character types. This should be
slightly more efficient than the previous constraints that checked
std::integral and (!__is_one_of). It also
avoids the need for a separate std::formatter specialization for 128-bit
integers, as they can be handled by the new variable template too.

libstdc++-v3/ChangeLog:

* include/std/format (__format::__is_formattable_integer): New
variable template and specializations.
(template struct formatter): Replace
constraints on first arg with __is_formattable_integer.
* testsuite/std/format/formatter/requirements.cc: Check that
std::formatter specializations for char8_t and const int are
disabled.

(cherry picked from commit 0f52a92ab249bde64b7570d4cf549437a3283520)

Diff:
---
 libstdc++-v3/include/std/format| 53 --
 .../testsuite/std/format/formatter/requirements.cc | 17 +++
 2 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 8f6a82a1fd41..95c2991765c3 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1394,8 +1394,9 @@ namespace __format
 
   // We can format a floating-point type iff it is usable with to_chars.
   template
-concept __formattable_float = requires (_Tp __t, char* __p)
-{ __format::to_chars(__p, __p, __t, chars_format::scientific, 6); };
+concept __formattable_float
+  = is_same_v, _Tp> && requires (_Tp __t, char* __p)
+  { __format::to_chars(__p, __p, __t, chars_format::scientific, 6); };
 
   template<__char _CharT>
 struct __formatter_fp
@@ -2103,32 +2104,33 @@ namespace __format
 #endif // USE_WCHAR_T
   /// @}
 
-  /// Format an integer.
-  template
-requires (!__is_one_of<_Tp, char, wchar_t, char16_t, char32_t>::value)
-struct formatter<_Tp, _CharT>
-{
-  formatter() = default;
-
-  [[__gnu__::__always_inline__]]
-  constexpr typename basic_format_parse_context<_CharT>::iterator
-  parse(basic_format_parse_context<_CharT>& __pc)
-  {
-   return _M_f.template _M_parse<_Tp>(__pc);
-  }
+/// @cond undocumented
+namespace __format
+{
+  // each cv-unqualified arithmetic type ArithmeticT other than
+  // char, wchar_t, char8_t, char16_t, or char32_t
+  template
+constexpr bool __is_formattable_integer = __is_integer<_Tp>::__value;
 
-  template
-   typename basic_format_context<_Out, _CharT>::iterator
-   format(_Tp __u, basic_format_context<_Out, _CharT>& __fc) const
-   { return _M_f.format(__u, __fc); }
+#if defined __SIZEOF_INT128__
+  template<> inline constexpr bool __is_formattable_integer<__int128>  = true;
+  template<> inline constexpr bool __is_formattable_integer
+  = true;
+#endif
 
-private:
-  __format::__formatter_int<_CharT> _M_f;
-};
+  template<> inline constexpr bool __is_formattable_integer = false;
+  template<> inline constexpr bool __is_formattable_integer = false;
+#ifdef _GLIBCXX_USE_CHAR8_T
+  template<> inline constexpr bool __is_formattable_integer = false;
+#endif
+  template<> inline constexpr bool __is_formattable_integer = false;
+  template<> inline constexpr bool __is_formattable_integer = false;
+}
+/// ~endcond
 
-#if defined __SIZEOF_INT128__ && defined __STRICT_ANSI__
+  /// Format an integer.
   template
-requires (__is_one_of<_Tp, __int128, unsigned __int128>::value)
+requires __format::__is_formattable_integer<_Tp>
 struct formatter<_Tp, _CharT>
 {
   formatter() = default;
@@ -2148,7 +2150,6 @@ namespace __format
 private:
   __format::__formatter_int<_CharT> _M_f;
 };
-#endif
 
 #if defined __glibcxx_to_chars
   /// Format a floating-point value.
@@ -2541,6 +2542,8 @@ namespace __format
 } // namespace __format
 /// @endcond
 
+// Concept std::formattable was introduced by P2286R8 "Formatting Ranges",
+// but we can't guard it with __cpp_lib_format_ranges until we define that!
 #if __cplusplus > 202002L
   // [format.formattable], concept formattable
   template
diff --git a/libstdc++-v3/testsuite/std/format/formatter/requirements.cc 
b/libstdc++-v3/testsuite/std/format/formatter/requirements.cc
index bde67e586

[gcc r14-10732] libstdc++: Fix formatting of most negative chrono::duration [PR116755]

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

commit r14-10732-gaeb54d0f3a9eb9363157a040beaddd4939bd4774
Author: Jonathan Wakely 
Date:   Wed Sep 18 17:20:29 2024 +0100

libstdc++: Fix formatting of most negative chrono::duration [PR116755]

When formatting chrono::duration::min() we were
causing undefined behaviour by trying to form the negative of the most
negative value. If we convert negative durations with integer rep to the
corresponding unsigned integer rep then we can safely represent all
values.

libstdc++-v3/ChangeLog:

PR libstdc++/116755
* include/bits/chrono_io.h (formatter>::format):
Cast negative integral durations to unsigned rep.
* testsuite/20_util/duration/io.cc: Test the most negative
integer durations.

(cherry picked from commit 482e651f5750e4648ade90e32ed45b094538e7f8)

Diff:
---
 libstdc++-v3/include/bits/chrono_io.h | 16 ++--
 libstdc++-v3/testsuite/20_util/duration/io.cc |  8 
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/chrono_io.h 
b/libstdc++-v3/include/bits/chrono_io.h
index 72c66a0fef0d..f8b78daedc65 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -1608,8 +1608,20 @@ namespace __format
   basic_format_context<_Out, _CharT>& __fc) const
{
  if constexpr (numeric_limits<_Rep>::is_signed)
-   if (__d < __d.zero())
- return _M_f._M_format(-__d, __fc, true);
+   if (__d < __d.zero()) [[unlikely]]
+ {
+   if constexpr (is_integral_v<_Rep>)
+ {
+   // -d is undefined for the most negative integer.
+   // Convert duration to corresponding unsigned rep.
+   using _URep = make_unsigned_t<_Rep>;
+   auto __ucnt = -static_cast<_URep>(__d.count());
+   auto __ud = chrono::duration<_URep, _Period>(__ucnt);
+   return _M_f._M_format(__ud, __fc, true);
+ }
+   else
+ return _M_f._M_format(-__d, __fc, true);
+ }
  return _M_f._M_format(__d, __fc, false);
}
 
diff --git a/libstdc++-v3/testsuite/20_util/duration/io.cc 
b/libstdc++-v3/testsuite/20_util/duration/io.cc
index 6b00689672c8..57020f4f9537 100644
--- a/libstdc++-v3/testsuite/20_util/duration/io.cc
+++ b/libstdc++-v3/testsuite/20_util/duration/io.cc
@@ -106,6 +106,14 @@ test_format()
   VERIFY( s == "500ms" );
   s = std::format("{:%Q %q}", u);
   VERIFY( s == "500 ms" );
+
+  // PR libstdc++/116755 extra minus sign for most negative value
+  auto minsec = std::chrono::seconds::min();
+  s = std::format("{}", minsec);
+  auto expected = std::format("{}s", minsec.count());
+  VERIFY( s == expected );
+  s = std::format("{:%Q%q}", minsec);
+  VERIFY( s == expected );
 }
 
 void


[gcc r14-10738] libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]

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

commit r14-10738-g1b09baab8c751c6d14c1028dcaf9497a5c39b695
Author: Jonathan Wakely 
Date:   Thu Sep 26 12:12:13 2024 +0100

libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]

This function definition should not be marked as non-throwing, because
the declaration in  is potentially throwing.

Also fix whitespace.

libstdc++-v3/ChangeLog:

PR libstdc++/116857
* libsupc++/guard.cc (__cxa_guard_acquire): Remove
_GLIBCXX_NOTHROW to match declaration in .

(cherry picked from commit efdda203f52b9b55ef9acc8ad668bbd0570a8de6)

Diff:
---
 libstdc++-v3/libsupc++/guard.cc | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
index 364797817f72..707083e09d06 100644
--- a/libstdc++-v3/libsupc++/guard.cc
+++ b/libstdc++-v3/libsupc++/guard.cc
@@ -36,22 +36,22 @@
 namespace __cxxabiv1 {
 
 extern "C" int
-__cxa_guard_acquire (__guard* g) _GLIBCXX_NOTHROW
-  {
-return __MCF_cxa_guard_acquire(g);
-  }
+__cxa_guard_acquire (__guard* g)
+{
+  return __MCF_cxa_guard_acquire(g);
+}
 
 extern "C" void
 __cxa_guard_release (__guard* g) _GLIBCXX_NOTHROW
-  {
-__MCF_cxa_guard_release(g);
-  }
+{
+  __MCF_cxa_guard_release(g);
+}
 
 extern "C" void
 __cxa_guard_abort (__guard* g) _GLIBCXX_NOTHROW
-  {
-__MCF_cxa_guard_abort(g);
-  }
+{
+  __MCF_cxa_guard_abort(g);
+}
 
 }  // namespace __cxxabiv1


[gcc r14-10736] libstdc++: Populate std::time_get::get's %c format for C locale

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

commit r14-10736-gc5bdd24abac34382c6d503c1265649f65e750b54
Author: Jonathan Wakely 
Date:   Tue Sep 24 23:20:56 2024 +0100

libstdc++: Populate std::time_get::get's %c format for C locale

We were using the empty string "" for D_T_FMT and ERA_D_T_FMT in the C
locale, instead of "%a %b %e %T %Y" as the C standard requires. Set it
correctly for each locale implementation that defines time_members.cc.

We can also explicitly set the _M_era_xxx pointers to the same values as
the corresponding _M_xxx ones, rather than setting them to point to
identical string literals. This doesn't rely on the compiler merging
string literals, and makes it more explicit that they're the same in the
C locale.

libstdc++-v3/ChangeLog:

* config/locale/dragonfly/time_members.cc
(__timepunct::_M_initialize_timepunc)
(__timepunct::_M_initialize_timepunc): Set
_M_date_time_format for C locale. Set %Ex formats to the same
values as the %x formats.
* config/locale/generic/time_members.cc: Likewise.
* config/locale/gnu/time_members.cc: Likewise.
* testsuite/22_locale/time_get/get/char/5.cc: New test.
* testsuite/22_locale/time_get/get/wchar_t/5.cc: New test.

(cherry picked from commit c534e37faccf481afa9bc28f0605ca0ec3846c89)

Diff:
---
 .../config/locale/dragonfly/time_members.cc| 16 +-
 libstdc++-v3/config/locale/generic/time_members.cc |  8 ++---
 libstdc++-v3/config/locale/gnu/time_members.cc | 16 +-
 .../testsuite/22_locale/time_get/get/char/5.cc | 37 ++
 .../testsuite/22_locale/time_get/get/wchar_t/5.cc  | 37 ++
 5 files changed, 94 insertions(+), 20 deletions(-)

diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc 
b/libstdc++-v3/config/locale/dragonfly/time_members.cc
index 0c96928135eb..069b2ddd26bb 100644
--- a/libstdc++-v3/config/locale/dragonfly/time_members.cc
+++ b/libstdc++-v3/config/locale/dragonfly/time_members.cc
@@ -67,11 +67,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  _M_c_locale_timepunct = _S_get_c_locale();
 
  _M_data->_M_date_format = "%m/%d/%y";
- _M_data->_M_date_era_format = "%m/%d/%y";
+ _M_data->_M_date_era_format = _M_data->_M_date_format;
  _M_data->_M_time_format = "%H:%M:%S";
- _M_data->_M_time_era_format = "%H:%M:%S";
- _M_data->_M_date_time_format = "";
- _M_data->_M_date_time_era_format = "";
+ _M_data->_M_time_era_format = _M_data->_M_time_format;
+ _M_data->_M_date_time_format = "%a %b %e %T %Y";
+ _M_data->_M_date_time_era_format = _M_data->_M_date_time_format;
  _M_data->_M_am = "AM";
  _M_data->_M_pm = "PM";
  _M_data->_M_am_pm_format = "%I:%M:%S %p";
@@ -224,11 +224,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  _M_c_locale_timepunct = _S_get_c_locale();
 
  _M_data->_M_date_format = L"%m/%d/%y";
- _M_data->_M_date_era_format = L"%m/%d/%y";
+ _M_data->_M_date_era_format = _M_data->_M_date_format;
  _M_data->_M_time_format = L"%H:%M:%S";
- _M_data->_M_time_era_format = L"%H:%M:%S";
- _M_data->_M_date_time_format = L"";
- _M_data->_M_date_time_era_format = L"";
+ _M_data->_M_time_era_format = _M_data->_M_time_format;
+ _M_data->_M_date_time_format = L"%a %b %e %T %Y";
+ _M_data->_M_date_time_era_format = _M_data->_M_date_time_format;
  _M_data->_M_am = L"AM";
  _M_data->_M_pm = L"PM";
  _M_data->_M_am_pm_format = L"%I:%M:%S %p";
diff --git a/libstdc++-v3/config/locale/generic/time_members.cc 
b/libstdc++-v3/config/locale/generic/time_members.cc
index 68395820fefa..6619f0ca881a 100644
--- a/libstdc++-v3/config/locale/generic/time_members.cc
+++ b/libstdc++-v3/config/locale/generic/time_members.cc
@@ -65,11 +65,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_data = new __timepunct_cache;
 
   _M_data->_M_date_format = "%m/%d/%y";
-  _M_data->_M_date_era_format = "%m/%d/%y";
+  _M_data->_M_date_era_format = _M_data->_M_date_format;
   _M_data->_M_time_format = "%H:%M:%S";
-  _M_data->_M_time_era_format = "%H:%M:%S";
-  _M_data->_M_date_time_format = "";
-  _M_data->_M_date_time_era_format = "";
+  _M_data->_M_time_era_format = _M_data->_M_time_format;
+  _M_data->_M_date_time_format = "%a %b %e %T %Y";
+  _M_data->_M_date_time_era_format = _M_data->_M_date_time_format;
   _M_data->_M_am = "AM";
   _M_data->_M_pm = "PM";
   _M_data->_M_am_pm_format = "%I:%M:%S %p";
diff --git a/libstdc++-v3/config/locale/gnu/time_members.cc 
b/libstdc++-v3/config/locale/gnu/time_members.cc
index 1e3b87488fae..88c8ab700809 100644
--- a/libstdc++-v3/config/locale/gnu/time_members.cc
+++ b/libstdc++-v3/config/locale/gnu/time_members.cc
@@ 

[gcc r14-10735] libstdc++: Add missing 'inline' to always_inline function

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:2f9585392da2f8c570fe879adbd08a6b0bfdc496

commit r14-10735-g2f9585392da2f8c570fe879adbd08a6b0bfdc496
Author: Jonathan Wakely 
Date:   Thu Sep 26 23:36:46 2024 +0100

libstdc++: Add missing 'inline' to always_inline function

This fixes a -Wattributes warning for the COW std::string which was
previously suppressed due to being in a system header.

libstdc++-v3/ChangeLog:

* include/bits/cow_string.h (__resize_for_overwrite): Add
inline keyword to function with always_inline attribute.

(cherry picked from commit 48e1b89f14f5eab9eb3f61830f608d92c4ee54b6)

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

diff --git a/libstdc++-v3/include/bits/cow_string.h 
b/libstdc++-v3/include/bits/cow_string.h
index 5d81bfc1230e..36599a204235 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -3755,7 +3755,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
   template
 [[__gnu__::__always_inline__]]
-void
+inline void
 basic_string<_CharT, _Traits, _Alloc>::
 __resize_and_overwrite(const size_type __n, _Operation __op)
 { resize_and_overwrite<_Operation&>(__n, __op); }


[gcc r14-10734] libstdc++: Work around some PSTL test failures for debug mode [PR90276]

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:61584f377ceee868c73a994e4d9d7b7bee5fb443

commit r14-10734-g61584f377ceee868c73a994e4d9d7b7bee5fb443
Author: Jonathan Wakely 
Date:   Thu Jun 6 11:50:06 2024 +0100

libstdc++: Work around some PSTL test failures for debug mode [PR90276]

This addresses one known failure due to a bug in the upstream tests, and
a number of timeouts due to the algorithms running much more slowly with
debug mode checks enabled.

libstdc++-v3/ChangeLog:

PR libstdc++/90276
* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
[_GLIBCXX_DEBUG]: Add xfail-run-if for debug mode.
* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
[_GLIBCXX_DEBUG]: Reduce size of test data.
* testsuite/25_algorithms/pstl/alg_sorting/includes.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_sorting/set_util.h:
Likewise.

(cherry picked from commit 003ce8a6c4c28f8d285134afa9a423d0e234cf2e)

Diff:
---
 .../testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc  | 4 
 libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/includes.cc | 4 
 libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc | 1 +
 libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/set_util.h  | 4 
 4 files changed, 13 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc 
b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
index 61bbca758b4f..63e6abe2ea46 100644
--- a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
@@ -133,7 +133,11 @@ void
 test_by_type(Generator1 generator1, Generator2 generator2, Compare comp)
 {
 using namespace std;
+#ifdef _GLIBCXX_DEBUG
+size_t max_size = 1000;
+#else
 size_t max_size = 1;
+#endif
 Sequence in1(max_size, [](size_t v) { return T(v); });
 Sequence exp(max_size, [](size_t v) { return T(v); });
 size_t m;
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/includes.cc 
b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/includes.cc
index ed07810618d6..1567c369c4cd 100644
--- a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/includes.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/includes.cc
@@ -77,7 +77,11 @@ void
 test_includes(Compare compare)
 {
 
+#ifdef _GLIBCXX_DEBUG
+const std::size_t n_max = 1;
+#else
 const std::size_t n_max = 100;
+#endif
 
 // The rand()%(2*n+1) encourages generation of some duplicates.
 std::srand(42);
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc 
b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
index 6d441cc3ae9d..797d0ee9340c 100644
--- a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
@@ -3,6 +3,7 @@
 // { dg-do run { target c++17 } }
 // { dg-timeout-factor 3 }
 // { dg-require-effective-target tbb_backend }
+// { dg-xfail-run-if "see PR 90276" { debug_mode } }
 
 //===-- partial_sort.pass.cpp 
-===//
 //
diff --git a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/set_util.h 
b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/set_util.h
index ecf5cd1c89db..214e3452aa75 100644
--- a/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/set_util.h
+++ b/libstdc++-v3/testsuite/25_algorithms/pstl/alg_sorting/set_util.h
@@ -51,7 +51,11 @@ namespace TestUtils
 void
 test_set_op(Compare compare)
 {
+#ifdef _GLIBCXX_DEBUG
+const std::size_t n_max = 1000;
+#else
 const std::size_t n_max = 10;
+#endif
 
 // The rand()%(2*n+1) encourages generation of some duplicates.
 std::srand(4200);


[gcc r15-4050] c++: record template specialization hash

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:5dad738c1dd1649a85d04a56f93d0ea229c9590f

commit r15-4050-g5dad738c1dd1649a85d04a56f93d0ea229c9590f
Author: Jason Merrill 
Date:   Thu Oct 3 16:29:20 2024 -0400

c++: record template specialization hash

A lot of compile time of template-heavy code is spent in re-hashing
hashtable elements upon expansion.  The following records the hash in the
hash element.  This speeds up C++20 compilation of stdc++.h by about 25% for
about a 0.1% increase in memory usage.

With the hash value in the entry, we don't need to pass it separately to the
find functions.

Adding default arguments to the spec and hash fields simplifies spec_entry
initialization and avoids problems from hash starting with an indeterminate
value.

gcc/cp/ChangeLog:

* cp-tree.h (spec_entry::hash): New member.
* pt.cc (spec_hasher::hash): Set it and return it.
(maybe_process_partial_specialization): Clear it when
changing tmpl/args.
(lookup_template_class): Likewise, don't pass hash to find.
(retrieve_specialization): Set it, don't pass hash to find.
(register_specialization): Don't pass hash to find.
(reregister_specialization): Likewise.
(match_mergeable_specialization): Likewise.
(add_mergeable_specialization): Likewise.

Co-authored-by: Richard Biener 

Diff:
---
 gcc/cp/cp-tree.h | 11 ---
 gcc/cp/pt.cc | 35 +++
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index c5d02567cb4b..dc153a97dc46 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5840,9 +5840,14 @@ public:
 /* Entry in the specialization hash table.  */
 struct GTY((for_user)) spec_entry
 {
-  tree tmpl;  /* The general template this is a specialization of.  */
-  tree args;  /* The args for this (maybe-partial) specialization.  */
-  tree spec;  /* The specialization itself.  */
+  /* The general template this is a specialization of.  */
+  tree tmpl;
+  /* The args for this (maybe-partial) specialization.  */
+  tree args;
+  /* The specialization itself.  */
+  tree spec = NULL_TREE;
+  /* The cached result of hash_tmpl_and_args (tmpl, args).  */
+  hashval_t hash = 0;
 };
 
 /* in class.cc */
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4ceae1d38de1..03a1144765b2 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -1161,6 +1161,7 @@ maybe_process_partial_specialization (tree type)
  elt.tmpl = tmpl;
  CLASSTYPE_TI_ARGS (inst)
= elt.args = INNERMOST_TEMPLATE_ARGS (elt.args);
+ elt.hash = 0; /* Recalculate after changing tmpl/args.  */
 
  spec_entry **slot
= type_specializations->find_slot (&elt, INSERT);
@@ -1282,7 +1283,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t 
hash)
   spec_entry elt;
   elt.tmpl = tmpl;
   elt.args = args;
-  elt.spec = NULL_TREE;
+  elt.hash = hash;
 
   spec_hash_table *specializations;
   if (DECL_CLASS_TEMPLATE_P (tmpl))
@@ -1290,9 +1291,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t 
hash)
   else
 specializations = decl_specializations;
 
-  if (hash == 0)
-hash = spec_hasher::hash (&elt);
-  if (spec_entry *found = specializations->find_with_hash (&elt, hash))
+  if (spec_entry *found = specializations->find (&elt))
 return found->spec;
 
   return NULL_TREE;
@@ -1551,7 +1550,7 @@ register_specialization (tree spec, tree tmpl, tree args, 
bool is_friend,
   if (hash == 0)
 hash = spec_hasher::hash (&elt);
 
-  spec_entry **slot = decl_specializations->find_slot_with_hash (&elt, hash, 
INSERT);
+  spec_entry **slot = decl_specializations->find_slot (&elt, INSERT);
   if (*slot)
 fn = (*slot)->spec;
   else
@@ -1739,7 +1738,9 @@ spec_hasher::hash (tree tmpl, tree args)
 hashval_t
 spec_hasher::hash (spec_entry *e)
 {
-  return spec_hasher::hash (e->tmpl, e->args);
+  if (e->hash == 0)
+e->hash = hash (e->tmpl, e->args);
+  return e->hash;
 }
 
 /* Recursively calculate a hash value for a template argument ARG, for use
@@ -1973,7 +1974,6 @@ reregister_specialization (tree spec, tree tinfo, tree 
new_spec)
 
   elt.tmpl = most_general_template (TI_TEMPLATE (tinfo));
   elt.args = TI_ARGS (tinfo);
-  elt.spec = NULL_TREE;
 
   entry = decl_specializations->find (&elt);
   if (entry != NULL)
@@ -10019,8 +10019,6 @@ lookup_template_class (tree d1, tree arglist, tree 
in_decl, tree context,
   tree t;
   spec_entry **slot;
   spec_entry *entry;
-  spec_entry elt;
-  hashval_t hash;
 
   if (identifier_p (d1))
 {
@@ -10236,11 +10234,10 @@ lookup_template_class (tree d1, tree arglist, tree 
in_decl, tree context,
}
 
   /* If we already have this specialization, return it.  */
+  spec_entry elt;
   elt.tmpl = gen_tmpl;
   elt.args = arglist;
-  elt.spec = NULL

[gcc r15-4051] testsuite: gnat.dg: fix dg-do directive syntax

2024-10-03 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:68d88d9b68f5b8a952ded65607af32f9244c8d87

commit r15-4051-g68d88d9b68f5b8a952ded65607af32f9244c8d87
Author: Sam James 
Date:   Fri Oct 4 03:15:28 2024 +0100

testsuite: gnat.dg: fix dg-do directive syntax

Fix incorrect use of '[' rather than '{' in 'dg-...' directives.

gcc/testsuite/ChangeLog:

* gnat.dg/pack13.adb: Fix 'dg-...' directive syntax.
* gnat.dg/size_attribute.adb: Ditto.
* gnat.dg/subp_elim_errors.adb: Ditto.

Diff:
---
 gcc/testsuite/gnat.dg/pack13.adb   | 2 +-
 gcc/testsuite/gnat.dg/size_attribute.adb   | 2 +-
 gcc/testsuite/gnat.dg/subp_elim_errors.adb | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gnat.dg/pack13.adb b/gcc/testsuite/gnat.dg/pack13.adb
index dd9cb09cf7b6..6581a53f9987 100644
--- a/gcc/testsuite/gnat.dg/pack13.adb
+++ b/gcc/testsuite/gnat.dg/pack13.adb
@@ -1,4 +1,4 @@
--- [ dg-do compile }
+-- { dg-do compile }
 
 package body Pack13 is
 
diff --git a/gcc/testsuite/gnat.dg/size_attribute.adb 
b/gcc/testsuite/gnat.dg/size_attribute.adb
index 25642e0b0aad..ec655f67a868 100644
--- a/gcc/testsuite/gnat.dg/size_attribute.adb
+++ b/gcc/testsuite/gnat.dg/size_attribute.adb
@@ -1,5 +1,5 @@
 -- PR middle-end/35823
--- { dg-do compile ]
+-- { dg-do compile }
 
 procedure Size_Attribute (Arg : in String) is
Size : constant Natural := Arg'Size;
diff --git a/gcc/testsuite/gnat.dg/subp_elim_errors.adb 
b/gcc/testsuite/gnat.dg/subp_elim_errors.adb
index 669e8772117e..1b8c3f23054d 100644
--- a/gcc/testsuite/gnat.dg/subp_elim_errors.adb
+++ b/gcc/testsuite/gnat.dg/subp_elim_errors.adb
@@ -1,4 +1,4 @@
--- [ dg-do compile }
+-- { dg-do compile }
 
 with System;


[gcc r15-4052] gcc: fix typo in gimplify

2024-10-03 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:4f0026c26fe0a24a44187cb376a819c6fd976c97

commit r15-4052-g4f0026c26fe0a24a44187cb376a819c6fd976c97
Author: Sam James 
Date:   Thu Oct 3 02:47:55 2024 +0100

gcc: fix typo in gimplify

gcc/ChangeLog:

* gimplify.cc (gimple_add_init_for_auto_var): Fix 'variable' typo.

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

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index ceb53e5d5bb7..dd7efa71b742 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -2019,7 +2019,7 @@ gimple_add_init_for_auto_var (tree decl,
   gimplify_assign (decl, call, seq_p);
 }
 
-/* Generate padding initialization for automatic vairable DECL.
+/* Generate padding initialization for automatic variable DECL.
C guarantees that brace-init with fewer initializers than members
aggregate will initialize the rest of the aggregate as-if it were
static initialization.  In turn static initialization guarantees


[gcc r13-9075] libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:24e2b4cf7902fbdc6c921cfaf9674f844146b3e1

commit r13-9075-g24e2b4cf7902fbdc6c921cfaf9674f844146b3e1
Author: Jonathan Wakely 
Date:   Thu Sep 26 12:12:13 2024 +0100

libstdc++: Remove noexcept-specifier from MCF __cxa_guard_acquire [PR116857]

This function definition should not be marked as non-throwing, because
the declaration in  is potentially throwing.

Also fix whitespace.

libstdc++-v3/ChangeLog:

PR libstdc++/116857
* libsupc++/guard.cc (__cxa_guard_acquire): Remove
_GLIBCXX_NOTHROW to match declaration in .

(cherry picked from commit efdda203f52b9b55ef9acc8ad668bbd0570a8de6)

Diff:
---
 libstdc++-v3/libsupc++/guard.cc | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
index 55305ad0ff66..54b3c6480ac8 100644
--- a/libstdc++-v3/libsupc++/guard.cc
+++ b/libstdc++-v3/libsupc++/guard.cc
@@ -36,22 +36,22 @@
 namespace __cxxabiv1 {
 
 extern "C" int
-__cxa_guard_acquire (__guard* g) _GLIBCXX_NOTHROW
-  {
-return __MCF_cxa_guard_acquire(g);
-  }
+__cxa_guard_acquire (__guard* g)
+{
+  return __MCF_cxa_guard_acquire(g);
+}
 
 extern "C" void
 __cxa_guard_release (__guard* g) _GLIBCXX_NOTHROW
-  {
-__MCF_cxa_guard_release(g);
-  }
+{
+  __MCF_cxa_guard_release(g);
+}
 
 extern "C" void
 __cxa_guard_abort (__guard* g) _GLIBCXX_NOTHROW
-  {
-__MCF_cxa_guard_abort(g);
-  }
+{
+  __MCF_cxa_guard_abort(g);
+}
 
 }  // namespace __cxxabiv1


[gcc r13-9074] libstdc++: Fix formatting of most negative chrono::duration [PR116755]

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:7ea30d4a5b211cc8ddda8f7f33bb2308b681be74

commit r13-9074-g7ea30d4a5b211cc8ddda8f7f33bb2308b681be74
Author: Jonathan Wakely 
Date:   Wed Sep 18 17:20:29 2024 +0100

libstdc++: Fix formatting of most negative chrono::duration [PR116755]

When formatting chrono::duration::min() we were
causing undefined behaviour by trying to form the negative of the most
negative value. If we convert negative durations with integer rep to the
corresponding unsigned integer rep then we can safely represent all
values.

libstdc++-v3/ChangeLog:

PR libstdc++/116755
* include/bits/chrono_io.h (formatter>::format):
Cast negative integral durations to unsigned rep.
* testsuite/20_util/duration/io.cc: Test the most negative
integer durations.

(cherry picked from commit 482e651f5750e4648ade90e32ed45b094538e7f8)

Diff:
---
 libstdc++-v3/include/bits/chrono_io.h | 16 ++--
 libstdc++-v3/testsuite/20_util/duration/io.cc |  8 
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/chrono_io.h 
b/libstdc++-v3/include/bits/chrono_io.h
index d63f7c40d838..37ede63a53eb 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -1609,8 +1609,20 @@ namespace __format
   basic_format_context<_Out, _CharT>& __fc) const
{
  if constexpr (numeric_limits<_Rep>::is_signed)
-   if (__d < __d.zero())
- return _M_f._M_format(-__d, __fc, true);
+   if (__d < __d.zero()) [[unlikely]]
+ {
+   if constexpr (is_integral_v<_Rep>)
+ {
+   // -d is undefined for the most negative integer.
+   // Convert duration to corresponding unsigned rep.
+   using _URep = make_unsigned_t<_Rep>;
+   auto __ucnt = -static_cast<_URep>(__d.count());
+   auto __ud = chrono::duration<_URep, _Period>(__ucnt);
+   return _M_f._M_format(__ud, __fc, true);
+ }
+   else
+ return _M_f._M_format(-__d, __fc, true);
+ }
  return _M_f._M_format(__d, __fc, false);
}
 
diff --git a/libstdc++-v3/testsuite/20_util/duration/io.cc 
b/libstdc++-v3/testsuite/20_util/duration/io.cc
index b7028a4e6c62..6a5e12a85971 100644
--- a/libstdc++-v3/testsuite/20_util/duration/io.cc
+++ b/libstdc++-v3/testsuite/20_util/duration/io.cc
@@ -107,6 +107,14 @@ test_format()
   VERIFY( s == "500ms" );
   s = std::format("{:%Q %q}", u);
   VERIFY( s == "500 ms" );
+
+  // PR libstdc++/116755 extra minus sign for most negative value
+  auto minsec = std::chrono::seconds::min();
+  s = std::format("{}", minsec);
+  auto expected = std::format("{}s", minsec.count());
+  VERIFY( s == expected );
+  s = std::format("{:%Q%q}", minsec);
+  VERIFY( s == expected );
 }
 
 int main()


[gcc r15-4048] c++: free garbage vec in coerce_template_parms

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:d77f073ce66cedbcbb22357c49b9ef19e1b61a43

commit r15-4048-gd77f073ce66cedbcbb22357c49b9ef19e1b61a43
Author: Jason Merrill 
Date:   Thu Oct 3 16:31:00 2024 -0400

c++: free garbage vec in coerce_template_parms

coerce_template_parms can create two different vecs for the inner template
arguments, new_inner_args and (potentially) the result of
expand_template_argument_pack.  One or the other, or possibly both, end up
being garbage: in the typical case, the expanded vec is garbage because it's
only used as the source for convert_template_argument.  In some dependent
cases, the new vec is garbage because we decide to return the original args
instead.  In these cases, ggc_free the garbage vec to reduce the memory
overhead of overload resolution.

gcc/cp/ChangeLog:

* pt.cc (coerce_template_parms): Free garbage vecs.

Co-authored-by: Richard Biener 

Diff:
---
 gcc/cp/pt.cc | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 20affcd65a27..4ceae1d38de1 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -9275,6 +9275,7 @@ coerce_template_parms (tree parms,
{
  /* We don't know how many args we have yet, just use the
 unconverted (and still packed) ones for now.  */
+ ggc_free (new_inner_args);
  new_inner_args = orig_inner_args;
  arg_idx = nargs;
  break;
@@ -9329,7 +9330,8 @@ coerce_template_parms (tree parms,
  = make_pack_expansion (conv, complain);
 
   /* We don't know how many args we have yet, just
- use the unconverted ones for now.  */
+use the unconverted (but unpacked) ones for now.  */
+ ggc_free (new_inner_args);
   new_inner_args = inner_args;
  arg_idx = nargs;
   break;
@@ -9442,6 +9444,12 @@ coerce_template_parms (tree parms,
 SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args,
 TREE_VEC_LENGTH (new_inner_args));
 
+  /* If we expanded packs in inner_args and aren't returning it now, the
+ expanded vec is garbage.  */
+  if (inner_args != new_inner_args
+  && inner_args != orig_inner_args)
+ggc_free (inner_args);
+
   return return_full_args ? new_args : new_inner_args;
 }


[gcc r15-4038] Restore aarch64 bootstrap

2024-10-03 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:34670dee56a6bd030094801b3da900b1d214b454

commit r15-4038-g34670dee56a6bd030094801b3da900b1d214b454
Author: Richard Biener 
Date:   Thu Oct 3 13:26:21 2024 +0200

Restore aarch64 bootstrap

This zero-initializes vec_init to avoid a bogus maybe-uninitialized
diagnostic.

* tree-vect-loop.cc (vectorizable_induction): Initialize
vec_init.

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

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index f5ecf0bdb805..730888f62755 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -10278,7 +10278,7 @@ vectorizable_induction (loop_vec_info loop_vinfo,
   tree vec_def;
   edge pe = loop_preheader_edge (loop);
   basic_block new_bb;
-  tree new_vec, vec_init, vec_step, t;
+  tree new_vec, vec_init = NULL_TREE, vec_step, t;
   tree new_name;
   gimple *new_stmt;
   gphi *induction_phi;


[gcc r15-4040] libstdc++: Fix -Wdeprecated-declarations warning for Parallel Mode [PR116944]

2024-10-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:7754a8b7b4978ad82aef3ad456c5f60460b47393

commit r15-4040-g7754a8b7b4978ad82aef3ad456c5f60460b47393
Author: Jonathan Wakely 
Date:   Thu Oct 3 11:03:41 2024 +0100

libstdc++: Fix -Wdeprecated-declarations warning for Parallel Mode 
[PR116944]

The pragmas to disable warnings need to be moved before the first use of
the deprecated classes.

libstdc++-v3/ChangeLog:

PR libstdc++/116944
* include/parallel/base.h: Move diagnostic pragmas earlier.

Diff:
---
 libstdc++-v3/include/parallel/base.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/parallel/base.h 
b/libstdc++-v3/include/parallel/base.h
index fcbcc1e0b996..4341e26baf0b 100644
--- a/libstdc++-v3/include/parallel/base.h
+++ b/libstdc++-v3/include/parallel/base.h
@@ -150,6 +150,9 @@ namespace __gnu_parallel
 max(const _Tp& __a, const _Tp& __b)
 { return (__a > __b) ? __a : __b; }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // *nary_function
+
   /** @brief Constructs predicate for equality from strict weak
*  ordering predicate
*/
@@ -166,9 +169,6 @@ namespace __gnu_parallel
   { return !_M_comp(__a, __b) && !_M_comp(__b, __a); }
 };
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // *nary_function
-
   /** @brief Similar to std::unary_negate,
*  but giving the argument types explicitly. */
   template


[gcc r15-4039] libstdc++: Fix some warnings seen during bootstrap

2024-10-03 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:28911f626864e73c579ea2ad5f5308d2e8c3fcd9

commit r15-4039-g28911f626864e73c579ea2ad5f5308d2e8c3fcd9
Author: Jonathan Wakely 
Date:   Wed Oct 2 20:27:55 2024 +0100

libstdc++: Fix some warnings seen during bootstrap

libstdc++-v3/ChangeLog:

* include/bits/locale_facets_nonio.tcc (money_put::__do_get):
Ignore -Wformat warning for __ibm128 arguments.
* include/tr1/tuple (ignore): Ignore -Wunused warning.

Diff:
---
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 3 +++
 libstdc++-v3/include/tr1/tuple| 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc 
b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 5fddc1e3b269..53553d113b23 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -637,6 +637,8 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
 
 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
   && defined __LONG_DOUBLE_IEEE128__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat" // '%Lf' expects 'long double'
 extern "C"
 __typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__("snprintf");
 
@@ -671,6 +673,7 @@ __typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 
__asm__("snprintf");
   return __intl ? _M_insert(__s, __io, __fill, __digits)
: _M_insert(__s, __io, __fill, __digits);
 }
+#pragma GCC diagnostic pop
 #endif
 
 _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
diff --git a/libstdc++-v3/include/tr1/tuple b/libstdc++-v3/include/tr1/tuple
index b5c62b585a9a..f66090d36317 100644
--- a/libstdc++-v3/include/tr1/tuple
+++ b/libstdc++-v3/include/tr1/tuple
@@ -423,7 +423,7 @@ namespace tr1
   // TODO: Put this in some kind of shared file.
   namespace
   {
-_Swallow_assign ignore;
+_Swallow_assign ignore  __attribute__((__unused__));
   } // anonymous namespace
 }


[gcc r15-4041] libstdc++: Make Unicode utils work with Parallel Mode

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

commit r15-4041-g0d9d6872089b212c0bf3768a32de9bfbde9e5a17
Author: Jonathan Wakely 
Date:   Thu Oct 3 11:17:36 2024 +0100

libstdc++: Make Unicode utils work with Parallel Mode

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (__unicode::__is_incb_linker): Use
_GLIBCXX_STD_A namespace for std::find.

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

diff --git a/libstdc++-v3/include/bits/unicode.h 
b/libstdc++-v3/include/bits/unicode.h
index a14a17c5dfcf..1232f60037c8 100644
--- a/libstdc++-v3/include/bits/unicode.h
+++ b/libstdc++-v3/include/bits/unicode.h
@@ -625,7 +625,7 @@ inline namespace __v15_1_0
   {
 const auto __end = std::end(__incb_linkers);
 // Array is small enough that linear search is faster than binary search.
-return std::find(__incb_linkers, __end, __c) != __end;
+return _GLIBCXX_STD_A::find(__incb_linkers, __end, __c) != __end;
   }
 
   // @pre c <= 0x10


[gcc r15-4042] AVR: Make gcc.dg/c23-stdarg-9.c work.

2024-10-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:8d63d87c6d45bf8feecdaf54b1743c94938ce7ff

commit r15-4042-g8d63d87c6d45bf8feecdaf54b1743c94938ce7ff
Author: Georg-Johann Lay 
Date:   Thu Oct 3 15:19:21 2024 +0200

AVR: Make gcc.dg/c23-stdarg-9.c work.

gcc/testsuite/
* gcc.dg/c23-stdarg-9.c (struct S) [AVR]: Only use int a[500].

Diff:
---
 gcc/testsuite/gcc.dg/c23-stdarg-9.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/c23-stdarg-9.c 
b/gcc/testsuite/gcc.dg/c23-stdarg-9.c
index e2839e7e2cd0..068fe3d4c7a5 100644
--- a/gcc/testsuite/gcc.dg/c23-stdarg-9.c
+++ b/gcc/testsuite/gcc.dg/c23-stdarg-9.c
@@ -5,7 +5,12 @@
 
 #include 
 
+#ifdef __AVR__
+/* AVR doesn't have that much stack... */
+struct S { int a[500]; };
+#else
 struct S { int a[1024]; };
+#endif
 
 int
 f1 (...)


[gcc(refs/users/meissner/heads/work179-vpair)] Add support for restricting asm to fpr registers.

2024-10-03 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:58c9ff276f5fad46546494ec6394f040c1d6189e

commit 58c9ff276f5fad46546494ec6394f040c1d6189e
Author: Michael Meissner 
Date:   Thu Oct 3 12:31:37 2024 -0400

Add support for restricting asm to fpr registers.

2024-10-03  Michael Meissner  

* config/rs6000/vector-pair.h (__VPAIR_SPLAT): Add support for
restricting asm usage to traditional FPR registers.
(__VPAIR_UNARY): Likewise.
(__VPAIR_BINARY): Likewise.
(__VPAIR_RMA): Likewise.

Diff:
---
 gcc/config/rs6000/vector-pair.h | 50 +
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/vector-pair.h b/gcc/config/rs6000/vector-pair.h
index c36952003551..e146f6ca17cb 100644
--- a/gcc/config/rs6000/vector-pair.h
+++ b/gcc/config/rs6000/vector-pair.h
@@ -88,10 +88,51 @@ typedef union __vpair_union vector_pair_f32_t;
 /* Operations using a vector pair and __asm__operations.  */
 #elif __MMA__ && !__VPAIR_NOP10__
 
+/* When using __asm__, we need to access the second register.  Due to the way
+   VSX registers were formed by combining the traditional floating point
+   registers and Altivec registers, we can't use the output modifier %L to
+   refer to the second register if the VSX register was a traditional Altivec
+   register.  If the value is in VSX registers 34 & 35, %x0 would give 34, but
+   %L0 would give 1, since 'Altivec' registers start at 0.
+
+   If we are using GAS under Linux, we can use %x0+1 to access the second
+   register and use the full VSX register set.
+
+   If this include file is used on non-Linux systems, or with a non-GCC
+   compiler, limit the registers used to the traditional FPR registers so that
+   we can use %L0.  */
+
+#if __VPAIR__USE_FPR__ || !__GNUC__ || (!__linux__ && !__ELF__)
+
+/* Use %0 and %L0 on traditional FPR registers.  */
+#define __VPAIR_SPLAT(R, X, VP_FUNC, VEC)  \
+  __asm__ ("xxlor %L0,%0,%0"   \
+   : "=d" ((R)->__vpair)   \
+   : "0" (__builtin_vec_splats ((X
+
+#define __VPAIR_UNARY(R, A, VP_FUNC, OPCODE, VEC, VEC_FUNC)\
+  __asm__ (OPCODE " %0,%1\n\t" OPCODE " %L0,%L1"   \
+   : "=d" ((R)->__vpair)   \
+   : "d" ((A)->__vpair))
+
+#define __VPAIR_BINARY(R, A, B, VP_FUNC, OPCODE, VEC, VEC_FUNC)
\
+  __asm__ (OPCODE " %0,%1\n\t" OPCODE " %L0,%L1"   \
+   : "=d" ((R)->__vpair)   \
+   : "d" ((A)->__vpair), "d" ((B)->__vpair))
+
+/* Note the 'a' form of the fma instructions must be used.  */
+#define __VPAIR_FMA(R, A, B, C, VP_FUNC, OPCODE, VEC, VEC_FUNC)
\
+  __asm__ (OPCODE " %0,%1,%2\n\t" OPCODE " %L0,%L1,%L2"
\
+   : "=d" ((R)->__vpair)   \
+   : "d" ((A)->__vpair), "d" ((B)->__vpair), "0" ((C)->__vpair))
+
+#else
+
+/* Use %x0 and %x0+1 on VSX reigsters.  */
 #define __VPAIR_SPLAT(R, X, VP_FUNC, VEC)  \
   __asm__ ("xxlor %x0+1,%x0,%x0"   \
-  : "=wa" ((R)->__vpair)   \
-  : "0" (__builtin_vec_splats ((X
+   : "=wa" ((R)->__vpair)  \
+   : "0" (__builtin_vec_splats ((X
 
 #define __VPAIR_UNARY(R, A, VP_FUNC, OPCODE, VEC, VEC_FUNC)\
   __asm__ (OPCODE " %x0,%x1\n\t" OPCODE " %x0+1,%x1+1" \
@@ -101,13 +142,14 @@ typedef union __vpair_union   vector_pair_f32_t;
 #define __VPAIR_BINARY(R, A, B, VP_FUNC, OPCODE, VEC, VEC_FUNC)
\
   __asm__ (OPCODE " %x0,%x1\n\t" OPCODE " %x0+1,%x1+1" \
: "=wa" ((R)->__vpair)  \
-  : "wa" ((A)->__vpair), "wa" ((B)->__vpair))
+   : "wa" ((A)->__vpair), "wa" ((B)->__vpair))
 
 /* Note the 'a' form of the fma instructions must be used.  */
 #define __VPAIR_FMA(R, A, B, C, VP_FUNC, OPCODE, VEC, VEC_FUNC)
\
   __asm__ (OPCODE " %x0,%x1,%x2\n\t" OPCODE " %x0+1,%x1+1,%x2+1"   \
: "=wa" ((R)->__vpair)  \
-  : "wa" ((A)->__vpair), "wa" ((B)->__vpair), "0" ((C)->__vpair))
+   : "wa" ((A)->__vpair), "wa" ((B)->__vpair), "0" ((C)->__vpair))
+#endif /* Select whether to use %0/%L0 or %x0/%x0+1.  */
 
 #else  /* vpair support on power8/power9.  */


[gcc(refs/users/meissner/heads/work179-vpair)] Update ChangeLog.*

2024-10-03 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7260eba33dfd0ed6be3ac20d148dfa5efff295cd

commit 7260eba33dfd0ed6be3ac20d148dfa5efff295cd
Author: Michael Meissner 
Date:   Thu Oct 3 12:32:57 2024 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.vpair | 12 
 1 file changed, 12 insertions(+)

diff --git a/gcc/ChangeLog.vpair b/gcc/ChangeLog.vpair
index 58e4b1d07a7b..2176ac0d0348 100644
--- a/gcc/ChangeLog.vpair
+++ b/gcc/ChangeLog.vpair
@@ -1,5 +1,17 @@
  Branch work179-vpair, patch #311 
 
+Add support for restricting asm to fpr registers.
+
+2024-10-03  Michael Meissner  
+
+   * config/rs6000/vector-pair.h (__VPAIR_SPLAT): Add support for
+   restricting asm usage to traditional FPR registers.
+   (__VPAIR_UNARY): Likewise.
+   (__VPAIR_BINARY): Likewise.
+   (__VPAIR_RMA): Likewise.
+
+ Branch work179-vpair, patch #311 
+
 Add vector-pair.h runtime tests.
 
 2024-10-03  Michael Meissner  


[gcc r15-4043] c++: free garbage vec in coerce_template_parms

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:5b08ae503dd4aef2789a667daaf1984e7cc94aaa

commit r15-4043-g5b08ae503dd4aef2789a667daaf1984e7cc94aaa
Author: Jason Merrill 
Date:   Wed Oct 2 08:05:28 2024 -0400

c++: free garbage vec in coerce_template_parms

coerce_template_parms can create two different vecs for the inner template
arguments, new_inner_args and (potentially) the result of
expand_template_argument_pack.  One or the other, or possibly both, end up
being garbage: in the typical case, the expanded vec is garbage because it's
only used as the source for convert_template_argument.  In some dependent
cases, the new vec is garbage because we decide to return the original args
instead.  In these cases, ggc_free the garbage vec to reduce the memory
overhead of overload resolution.

gcc/cp/ChangeLog:

* pt.cc (struct free_if_changed_proxy): New.
(coerce_template_parms): Use it.

Co-authored-by: Richard Biener  

Diff:
---
 gcc/cp/pt.cc | 36 ++--
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 20affcd65a27..6d488128d689 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -9079,6 +9079,30 @@ pack_expansion_args_count (tree args)
   return count;
 }
 
+/* Used for a variable of pointer type T (typically 'tree') that starts out
+   pointing to exposed data, but might get changed to point to internal data
+   that can be safely discarded at scope exit.  Use .release when exposing the
+   internal data to prevent ggc_free.  */
+
+template 
+struct free_if_changed_proxy
+{
+  T val;
+  T orig;
+
+  free_if_changed_proxy (T t): val(t), orig(t) { }
+  ~free_if_changed_proxy ()
+  {
+if (val != orig)
+  ggc_free (val);
+  }
+
+  T release () { return orig = val; }
+
+  operator T () { return val; }
+  free_if_changed_proxy& operator= (const T& t) { val = t; return *this; }
+};
+
 /* Convert all template arguments to their appropriate types, and
return a vector containing the innermost resulting template
arguments.  If any error occurs, return error_mark_node. Error and
@@ -9105,8 +9129,6 @@ coerce_template_parms (tree parms,
   bool require_all_args /* = true */)
 {
   int nparms, nargs, parm_idx, arg_idx, lost = 0;
-  tree orig_inner_args;
-  tree inner_args;
 
   /* When used as a boolean value, indicates whether this is a
  variadic template parameter list. Since it's an int, we can also
@@ -9152,7 +9174,6 @@ coerce_template_parms (tree parms,
++default_p;
 }
 
-  inner_args = orig_inner_args = INNERMOST_TEMPLATE_ARGS (args);
   /* If there are no parameters that follow a parameter pack, we need to
  expand any argument packs so that we can deduce a parameter pack from
  some non-packed args followed by an argument pack, as in variadic85.C.
@@ -9161,6 +9182,7 @@ coerce_template_parms (tree parms,
  with a nested class inside a partial specialization of a class
  template, as in variadic92.C, or when deducing a template parameter pack
  from a sub-declarator, as in variadic114.C.  */
+  free_if_changed_proxy inner_args = INNERMOST_TEMPLATE_ARGS (args);
   if (!post_variadic_parms)
 inner_args = expand_template_argument_pack (inner_args);
 
@@ -9275,7 +9297,8 @@ coerce_template_parms (tree parms,
{
  /* We don't know how many args we have yet, just use the
 unconverted (and still packed) ones for now.  */
- new_inner_args = orig_inner_args;
+ ggc_free (new_inner_args);
+ new_inner_args = inner_args.orig;
  arg_idx = nargs;
  break;
}
@@ -9329,8 +9352,9 @@ coerce_template_parms (tree parms,
  = make_pack_expansion (conv, complain);
 
   /* We don't know how many args we have yet, just
- use the unconverted ones for now.  */
-  new_inner_args = inner_args;
+use the unconverted (but unpacked) ones for now.  */
+ ggc_free (new_inner_args);
+ new_inner_args = inner_args.release ();
  arg_idx = nargs;
   break;
 }


[gcc r15-4045] c++: -Wdeprecated enables later standard deprecations

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:dca2b47916c6646dc8bc1cfc0d07e70b05d36a78

commit r15-4045-gdca2b47916c6646dc8bc1cfc0d07e70b05d36a78
Author: Jason Merrill 
Date:   Wed Oct 2 13:23:53 2024 -0400

c++: -Wdeprecated enables later standard deprecations

By default -Wdeprecated warns about deprecations in the active standard.
When specified explicitly, let's also warn about deprecations in later
standards.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Explicit -Wdeprecated enables
deprecations from later standards.

gcc/ChangeLog:

* doc/invoke.texi: Explicit -Wdeprecated enables more warnings.

Diff:
---
 gcc/doc/invoke.texi| 22 --
 gcc/c-family/c-opts.cc | 17 -
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c90f5b4d58ef..d38c1feb86f7 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3864,8 +3864,10 @@ for code that is not valid in C++23 but used to be valid 
but deprecated
 in C++20 with a pedantic warning that can be disabled with
 @option{-Wno-comma-subscript}.
 
-Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
-and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
+Enabled by default with @option{-std=c++20} unless
+@option{-Wno-deprecated}, and after @option{-std=c++23} regardless of
+@option{-Wno-deprecated}.  Before @option{-std=c++20}, enabled with
+explicit @option{-Wdeprecated}.
 
 This warning is upgraded to an error by @option{-pedantic-errors} in
 C++23 mode or later.
@@ -4012,7 +4014,7 @@ int k = f - e;
 
 @option{-Wdeprecated-enum-enum-conversion} is enabled by default with
 @option{-std=c++20}.  In pre-C++20 dialects, this warning can be enabled
-by @option{-Wenum-conversion}.
+by @option{-Wenum-conversion} or @option{-Wdeprecated}.
 
 @opindex Wdeprecated-enum-float-conversion
 @opindex Wno-deprecated-enum-float-conversion
@@ -4030,14 +4032,14 @@ bool b = e <= 3.7;
 
 @option{-Wdeprecated-enum-float-conversion} is enabled by default with
 @option{-std=c++20}.  In pre-C++20 dialects, this warning can be enabled
-by @option{-Wenum-conversion}.
+by @option{-Wenum-conversion} or @option{-Wdeprecated}.
 
 @opindex Wdeprecated-literal-operator
 @opindex Wno-deprecated-literal-operator
 @item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)}
 Warn that the declaration of a user-defined literal operator with a
 space before the suffix is deprecated.  This warning is enabled by
-default in C++23.
+default in C++23, or with explicit @option{-Wdeprecated}.
 
 @smallexample
 string operator "" _i18n(const char*, std::size_t); // deprecated
@@ -4740,7 +4742,8 @@ non-class type, @code{volatile}-qualified function return 
type,
 @code{volatile}-qualified parameter type, and structured bindings of a
 @code{volatile}-qualified type.  This usage was deprecated in C++20.
 
-Enabled by default with @option{-std=c++20}.
+Enabled by default with @option{-std=c++20}.  Before
+@option{-std=c++20}, enabled with explicit @option{-Wdeprecated}.
 
 @opindex Wzero-as-null-pointer-constant
 @opindex Wno-zero-as-null-pointer-constant
@@ -10389,6 +10392,13 @@ disable the error when compiled with @option{-Werror} 
flag.
 @item -Wno-deprecated
 Do not warn about usage of deprecated features.  @xref{Deprecated Features}.
 
+In C++, explicitly specifying @option{-Wdeprecated} also enables
+warnings about some features that are deprecated in later language
+standards, specifically @option{-Wcomma-subscript},
+@option{-Wvolatile}, @option{-Wdeprecated-enum-float-conversion},
+@option{-Wdeprecated-enum-enum-conversion}, and
+@option{-Wdeprecated-literal-operator}.
+
 @opindex Wno-deprecated-declarations
 @opindex Wdeprecated-declarations
 @item -Wno-deprecated-declarations
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 8ff3d966bb6c..510e0870140e 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -996,30 +996,37 @@ c_common_post_options (const char **pfilename)
   SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_register,
   cxx_dialect >= cxx17);
 
+  /* Explicit -Wdeprecated turns on warnings from later standards.  */
+  auto deprecated_in = [&](enum cxx_dialect d)
+  {
+if (OPTION_SET_P (warn_deprecated)) return !!warn_deprecated;
+return (warn_deprecated && cxx_dialect >= d);
+  };
+
   /* -Wcomma-subscript is enabled by default in C++20.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
   warn_comma_subscript,
   cxx_dialect >= cxx23
-  || (cxx_dialect == cxx20 && warn_deprecated));
+  || deprecated_in (cxx20));
 
   /* -Wvolatile is enabled by default in C++20.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set, warn_volatile,
-  cxx_dialect >= cxx20 && warn_dep

[gcc r15-4044] c++: add -Wdeprecated-literal-operator [CWG2521]

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:b6ff52a9957c05834351a39517dd49966cb1092c

commit r15-4044-gb6ff52a9957c05834351a39517dd49966cb1092c
Author: Jason Merrill 
Date:   Wed Oct 2 11:21:14 2024 -0400

c++: add -Wdeprecated-literal-operator [CWG2521]

C++23 CWG issue 2521 (https://wg21.link/cwg2521) deprecates user-defined
literal operators declared with the optional space between "" and the
suffix.

Many testcases used that syntax; I removed the space from most of them, and
added C++23 warning tests to a few.

CWG 2521

gcc/ChangeLog:

* doc/invoke.texi: Document -Wdeprecated-literal-operator.

gcc/c-family/ChangeLog:

* c.opt: Add -Wdeprecated-literal-operator.
* c-opts.cc (c_common_post_options): Default on in C++23.
* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

* parser.cc (location_between): New.
(cp_parser_operator): Handle -Wdeprecated-literal-operator.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/udlit-string-literal.h
* g++.dg/cpp0x/Wliteral-suffix2.C
* g++.dg/cpp0x/constexpr-55708.C
* g++.dg/cpp0x/gnu_fext-numeric-literals.C
* g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C
* g++.dg/cpp0x/pr51420.C
* g++.dg/cpp0x/pr60209-neg.C
* g++.dg/cpp0x/pr60209.C
* g++.dg/cpp0x/pr61038.C
* g++.dg/cpp0x/std_fext-numeric-literals.C
* g++.dg/cpp0x/std_fno-ext-numeric-literals.C
* g++.dg/cpp0x/udlit-addr.C
* g++.dg/cpp0x/udlit-args-neg.C
* g++.dg/cpp0x/udlit-args.C
* g++.dg/cpp0x/udlit-args2.C
* g++.dg/cpp0x/udlit-clink-neg.C
* g++.dg/cpp0x/udlit-concat-neg.C
* g++.dg/cpp0x/udlit-concat.C
* g++.dg/cpp0x/udlit-constexpr.C
* g++.dg/cpp0x/udlit-cpp98-neg.C
* g++.dg/cpp0x/udlit-declare-neg.C
* g++.dg/cpp0x/udlit-embed-quote.C
* g++.dg/cpp0x/udlit-extended-id-1.C
* g++.dg/cpp0x/udlit-extended-id-3.C
* g++.dg/cpp0x/udlit-extern-c.C
* g++.dg/cpp0x/udlit-friend.C
* g++.dg/cpp0x/udlit-general.C
* g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C
* g++.dg/cpp0x/udlit-implicit-conv-neg.C
* g++.dg/cpp0x/udlit-inline.C
* g++.dg/cpp0x/udlit-mangle.C
* g++.dg/cpp0x/udlit-member-neg.C
* g++.dg/cpp0x/udlit-namespace.C
* g++.dg/cpp0x/udlit-nofunc-neg.C
* g++.dg/cpp0x/udlit-nonempty-str-neg.C
* g++.dg/cpp0x/udlit-nosuffix-neg.C
* g++.dg/cpp0x/udlit-nounder-neg.C
* g++.dg/cpp0x/udlit-operator-neg.C
* g++.dg/cpp0x/udlit-overflow-neg.C
* g++.dg/cpp0x/udlit-overflow.C
* g++.dg/cpp0x/udlit-preproc-neg.C
* g++.dg/cpp0x/udlit-raw-length.C
* g++.dg/cpp0x/udlit-raw-op-string-neg.C
* g++.dg/cpp0x/udlit-raw-op.C
* g++.dg/cpp0x/udlit-raw-str.C
* g++.dg/cpp0x/udlit-resolve-char8_t.C
* g++.dg/cpp0x/udlit-resolve.C
* g++.dg/cpp0x/udlit-shadow-neg.C
* g++.dg/cpp0x/udlit-string-length.C
* g++.dg/cpp0x/udlit-suffix-neg.C
* g++.dg/cpp0x/udlit-template.C
* g++.dg/cpp0x/udlit-tmpl-arg-neg.C
* g++.dg/cpp0x/udlit-tmpl-arg-neg2.C
* g++.dg/cpp0x/udlit-tmpl-arg.C
* g++.dg/cpp0x/udlit-tmpl-parms-neg.C
* g++.dg/cpp0x/udlit-tmpl-parms.C
* g++.dg/cpp1y/pr57640.C
* g++.dg/cpp1y/pr88872.C
* g++.dg/cpp26/unevalstr1.C
* g++.dg/cpp2a/concepts-pr60391.C
* g++.dg/cpp2a/consteval-prop21.C
* g++.dg/cpp2a/nontype-class6.C
* g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C
* g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C
* g++.dg/cpp2a/udlit-class-nttp-ctad.C
* g++.dg/cpp2a/udlit-class-nttp-neg.C
* g++.dg/cpp2a/udlit-class-nttp-neg2.C
* g++.dg/cpp2a/udlit-class-nttp.C
* g++.dg/ext/is_convertible2.C
* g++.dg/lookup/pr87269.C
* g++.dg/cpp0x/udlit_system_header: Adjust for C++23 deprecated
operator "" _suffix.
* g++.dg/DRs/dr2521.C: New test.

Diff:
---
 gcc/doc/invoke.texi| 12 +++
 gcc/c-family/c.opt |  4 +++
 gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h  | 10 +++---
 gcc/c-family/c-opts.cc |  5 +++
 gcc/cp/parser.cc   | 33 +++---
 gcc/testsuite/g++.dg/DRs/dr2521.C  |  5 +++
 gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix2.C  |  5 +--
 gcc/testsuite/g++.dg/cpp0x/constexpr-55708.C   |  2 +-
 .../g++.dg/cpp0x/gnu_fext-numeric-lit

[gcc r15-4046] Revert "c++: free garbage vec in coerce_template_parms"

2024-10-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:fe33530e6241712c42feeb2a649c1e8b2f2cb406

commit r15-4046-gfe33530e6241712c42feeb2a649c1e8b2f2cb406
Author: Jason Merrill 
Date:   Thu Oct 3 13:25:14 2024 -0400

Revert "c++: free garbage vec in coerce_template_parms"

This broke bootstrap, improving.

This reverts commit 5b08ae503dd4aef2789a667daaf1984e7cc94aaa.

Diff:
---
 gcc/cp/pt.cc | 36 ++--
 1 file changed, 6 insertions(+), 30 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 6d488128d689..20affcd65a27 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -9079,30 +9079,6 @@ pack_expansion_args_count (tree args)
   return count;
 }
 
-/* Used for a variable of pointer type T (typically 'tree') that starts out
-   pointing to exposed data, but might get changed to point to internal data
-   that can be safely discarded at scope exit.  Use .release when exposing the
-   internal data to prevent ggc_free.  */
-
-template 
-struct free_if_changed_proxy
-{
-  T val;
-  T orig;
-
-  free_if_changed_proxy (T t): val(t), orig(t) { }
-  ~free_if_changed_proxy ()
-  {
-if (val != orig)
-  ggc_free (val);
-  }
-
-  T release () { return orig = val; }
-
-  operator T () { return val; }
-  free_if_changed_proxy& operator= (const T& t) { val = t; return *this; }
-};
-
 /* Convert all template arguments to their appropriate types, and
return a vector containing the innermost resulting template
arguments.  If any error occurs, return error_mark_node. Error and
@@ -9129,6 +9105,8 @@ coerce_template_parms (tree parms,
   bool require_all_args /* = true */)
 {
   int nparms, nargs, parm_idx, arg_idx, lost = 0;
+  tree orig_inner_args;
+  tree inner_args;
 
   /* When used as a boolean value, indicates whether this is a
  variadic template parameter list. Since it's an int, we can also
@@ -9174,6 +9152,7 @@ coerce_template_parms (tree parms,
++default_p;
 }
 
+  inner_args = orig_inner_args = INNERMOST_TEMPLATE_ARGS (args);
   /* If there are no parameters that follow a parameter pack, we need to
  expand any argument packs so that we can deduce a parameter pack from
  some non-packed args followed by an argument pack, as in variadic85.C.
@@ -9182,7 +9161,6 @@ coerce_template_parms (tree parms,
  with a nested class inside a partial specialization of a class
  template, as in variadic92.C, or when deducing a template parameter pack
  from a sub-declarator, as in variadic114.C.  */
-  free_if_changed_proxy inner_args = INNERMOST_TEMPLATE_ARGS (args);
   if (!post_variadic_parms)
 inner_args = expand_template_argument_pack (inner_args);
 
@@ -9297,8 +9275,7 @@ coerce_template_parms (tree parms,
{
  /* We don't know how many args we have yet, just use the
 unconverted (and still packed) ones for now.  */
- ggc_free (new_inner_args);
- new_inner_args = inner_args.orig;
+ new_inner_args = orig_inner_args;
  arg_idx = nargs;
  break;
}
@@ -9352,9 +9329,8 @@ coerce_template_parms (tree parms,
  = make_pack_expansion (conv, complain);
 
   /* We don't know how many args we have yet, just
-use the unconverted (but unpacked) ones for now.  */
- ggc_free (new_inner_args);
- new_inner_args = inner_args.release ();
+ use the unconverted ones for now.  */
+  new_inner_args = inner_args;
  arg_idx = nargs;
   break;
 }


[gcc r15-4047] Aarch64: Define WIDEST_HARDWARE_FP_SIZE

2024-10-03 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:547219f41f049083cda55929ae1c900195993504

commit r15-4047-g547219f41f049083cda55929ae1c900195993504
Author: Eric Botcazou 
Date:   Thu Oct 3 19:46:59 2024 +0200

Aarch64: Define WIDEST_HARDWARE_FP_SIZE

The macro is documented like this in the internal manual:

 -- Macro: WIDEST_HARDWARE_FP_SIZE
 A C expression for the size in bits of the widest floating-point
 format supported by the hardware.  If you define this macro, you
 must specify a value less than or equal to mode precision of the
 mode used for C type 'long double' (from hook
 'targetm.c.mode_for_floating_type' with argument
 'TI_LONG_DOUBLE_TYPE').  If you do not define this macro, mode
 precision of the mode used for C type 'long double' is the default.

AArch64 uses 128-bit TFmode for long double but, as far as I know, no FPU
implemented in hardware supports it.

gcc/
* config/aarch64/aarch64.h (WIDEST_HARDWARE_FP_SIZE): Define to 64.

gcc/testsuite/
* gnat.dg/specs/size_clause6.ads: New test.

Diff:
---
 gcc/config/aarch64/aarch64.h |  2 ++
 gcc/testsuite/gnat.dg/specs/size_clause6.ads | 12 
 2 files changed, 14 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index ec8fde783b35..030cffb17606 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -96,6 +96,8 @@
 
 #define LONG_LONG_TYPE_SIZE64
 
+#define WIDEST_HARDWARE_FP_SIZE64
+
 /* This value is the amount of bytes a caller is allowed to drop the stack
before probing has to be done for stack clash protection.  */
 #define STACK_CLASH_CALLER_GUARD 1024
diff --git a/gcc/testsuite/gnat.dg/specs/size_clause6.ads 
b/gcc/testsuite/gnat.dg/specs/size_clause6.ads
new file mode 100644
index ..6015bcd76f6a
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/size_clause6.ads
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+
+with Interfaces;
+
+package Size_Clause6 is
+
+  type Long_Double is new Interfaces.IEEE_Extended_Float;
+  for Long_Double'Size use 128; -- { dg-warning "unused" "" { target { ! { { 
i?86-*-* x86_64-*-* } && lp64 } } } }
+
+  function Int (X : in Long_Double) return Integer is (0);
+
+end Size_Clause6;


[gcc r15-4037] aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

2024-10-03 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:edec4bfc99744b48da3ffde1e4f39c9aceecfd42

commit r15-4037-gedec4bfc99744b48da3ffde1e4f39c9aceecfd42
Author: Andrew Pinski 
Date:   Wed Oct 2 14:21:24 2024 -0700

aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

Early-RA was considering throwing instructions as being dead and removing
them even if -fno-delete-dead-exceptions was in use. This fixes that 
oversight.

Built and tested for aarch64-linux-gnu.

PR target/116927

gcc/ChangeLog:

* config/aarch64/aarch64-early-ra.cc (early_ra::is_dead_insn): Insns
that throw are not dead with -fno-delete-dead-exceptions.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr116927-1.C: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/config/aarch64/aarch64-early-ra.cc|  6 ++
 gcc/testsuite/g++.dg/torture/pr116927-1.C | 15 +++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-early-ra.cc 
b/gcc/config/aarch64/aarch64-early-ra.cc
index 5f269d029b45..6e544dd61915 100644
--- a/gcc/config/aarch64/aarch64-early-ra.cc
+++ b/gcc/config/aarch64/aarch64-early-ra.cc
@@ -3389,6 +3389,12 @@ early_ra::is_dead_insn (rtx_insn *insn)
   if (side_effects_p (set))
 return false;
 
+  /* If we can't delete dead exceptions and the insn throws,
+ then the instruction is not dead.  */
+  if (!cfun->can_delete_dead_exceptions
+  && !insn_nothrow_p (insn))
+return false;
+
   return true;
 }
 
diff --git a/gcc/testsuite/g++.dg/torture/pr116927-1.C 
b/gcc/testsuite/g++.dg/torture/pr116927-1.C
new file mode 100644
index ..22fa1dbd7e1a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116927-1.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fnon-call-exceptions -fno-delete-dead-exceptions" 
}
+
+// PR target/116927
+// aarch64's Early ra was removing possiblely trapping
+// floating point insn
+
+void
+foo (float f)
+{
+  try {
+f ++;
+  }catch(...)
+  {}
+}