[gcc r14-9651] RISC-V: Allow RVV intrinsic when function target("arch=+v")

2024-03-25 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:5cab64a9cfb93fb0e246a25e3fdc7b664afb774e

commit r14-9651-g5cab64a9cfb93fb0e246a25e3fdc7b664afb774e
Author: Pan Li 
Date:   Mon Mar 25 14:22:31 2024 +0800

RISC-V: Allow RVV intrinsic when function target("arch=+v")

This patch would like to allow the RVV intrinsic when function is
attributed as target("arch=+v") and build with rv64gc.  For example:

vint32m1_t
__attribute__((target("arch=+v")))
test_1 (vint32m1_t a, vint32m1_t b, size_t vl)
{
  return __riscv_vadd_vv_i32m1 (a, b, vl);
}

build with -march=rv64gc -mabi=lp64d -O3, we will have asm like below:
test_1:
  .option push
  .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_\

zifencei2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0
  vsetvli zero,a0,e32,m1,ta,ma
  vadd.vv v8,v8,v9
  ret

The riscv_vector.h must be included when leverage intrinisc type(s) and
API(s).  And the scope of this attribute should not excced the function
body.  Meanwhile, to make rvv types and API(s) available for this attribute,
include riscv_vector.h will not report error for now if v is not present
in march.

Below test are passed for this patch:
* The riscv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-c.cc (riscv_pragma_intrinsic): Remove error
when V is disabled and init the RVV types and intrinic APIs.
* config/riscv/riscv-vector-builtins.cc (expand_builtin): Report
error if V ext is disabled.
* config/riscv/riscv.cc (riscv_return_value_is_vector_type_p):
Ditto.
(riscv_arguments_is_vector_type_p): Ditto.
(riscv_vector_cc_function_p): Ditto.
* config/riscv/riscv_vector.h: Remove error if V is disable.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pragma-1.c: Remove.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-1.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-2.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-3.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-4.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-5.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-6.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c: 
New test.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c: 
New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/config/riscv/riscv-c.cc| 18 -
 gcc/config/riscv/riscv-vector-builtins.cc  |  5 
 gcc/config/riscv/riscv.cc  | 30 +++---
 gcc/config/riscv/riscv_vector.h|  4 ---
 gcc/testsuite/gcc.target/riscv/rvv/base/pragma-1.c |  4 ---
 .../rvv/base/target_attribute_v_with_intrinsic-1.c |  5 
 .../rvv/base/target_attribute_v_with_intrinsic-2.c | 18 +
 .../rvv/base/target_attribute_v_with_intrinsic-3.c | 13 ++
 .../rvv/base/target_attribute_v_with_intrinsic-4.c | 10 
 .../rvv/base/target_attribute_v_with_intrinsic-5.c | 12 +
 .../rvv/base/target_attribute_v_with_intrinsic-6.c | 12 +
 .../rvv/base/target_attribute_v_with_intrinsic-7.c |  9 +++
 .../rvv/base/target_attribute_v_with_intrinsic-8.c | 23 +
 13 files changed, 145 insertions(+), 18 deletions(-)

diff --git a/gcc/config/riscv/riscv-c.cc b/gcc/config/riscv/riscv-c.cc
index edb866d51e4..01314037461 100644
--- a/gcc/config/riscv/riscv-c.cc
+++ b/gcc/config/riscv/riscv-c.cc
@@ -201,14 +201,20 @@ riscv_pragma_intrinsic (cpp_reader *)
   if (strcmp (name, "vector") == 0
   || strcmp (name, "xtheadvector") == 0)
 {
-  if (!TARGET_VECTOR)
+  if (TARGET_VECTOR)
+   riscv_vector::handle_pragma_vector ();
+  else /* Indicates riscv_vector.h is included but v is missing in arch  */
{
- error ("%<#pragma riscv intrinsic%> option %qs needs 'V' or "
-"'XTHEADVECTOR' extension enabled",
-name);
- return;
+ /* To make the the rvv types and intrinsic API available for the
+target("arch=+v") attribute,  we need to temporally enable the
+TARGET_VECTOR, and disable it after all initialized.  */
+ target_flags |= MASK_VECTOR;
+
+ riscv_vector::init_builtins ();
+ riscv_vector::handle_pragma_vector ();
+
+ target_flags &= ~MASK_VECTOR;
}
-  riscv_vector::handle_pragma_vector ();
 }
   else
 error ("unknown %<#pragma riscv intrinsic%> option %qs", name);
diff --git a/gcc/config/riscv/riscv-vector-builtins.cc 
b/gcc/config/riscv/riscv-vector-builtins.cc

[gcc r14-9652] libstdc++: Fix incorrect macro used in #undef in test

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

commit r14-9652-gcf3fc6f414f52a99f2dfc71c2e72e96fe60d2b6f
Author: Jonathan Wakely 
Date:   Sat Mar 23 00:19:55 2024 +

libstdc++: Fix incorrect macro used in #undef in test

This was a copy & paste error.

libstdc++-v3/ChangeLog:

* testsuite/std/text_encoding/requirements.cc: #undef the
correct macro.

Diff:
---
 libstdc++-v3/testsuite/std/text_encoding/requirements.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc 
b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
index a1d5d6baee1..6cd71b68225 100644
--- a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
+++ b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
@@ -8,7 +8,7 @@
 # error "Feature-test macro for text_encoding has wrong value in 
"
 #endif
 
-#undef __cpp_lib_expected
+#undef __cpp_lib_text_encoding
 #include 
 #ifndef __cpp_lib_text_encoding
 # error "Feature-test macro for text_encoding missing in "


[gcc r14-9653] modula2: Rebuild documentation sections for target independent libs

2024-03-25 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:44863af22d2c3168fb73d00cc58f393a35d3070d

commit r14-9653-g44863af22d2c3168fb73d00cc58f393a35d3070d
Author: Gaius Mulley 
Date:   Mon Mar 25 14:33:54 2024 +

modula2: Rebuild documentation sections for target independent libs

This patch rebuilds the documentation for the target independent
library sections.

gcc/m2/ChangeLog:

* Make-lang.in (doc/m2.pdf): Add line break.
* target-independent/m2/Builtins.texi: Rebuilt.
* target-independent/m2/gm2-libs.texi: Rebuilt.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/Make-lang.in|   3 +-
 gcc/m2/target-independent/m2/Builtins.texi |  11 +-
 gcc/m2/target-independent/m2/gm2-libs.texi | 599 +++--
 3 files changed, 574 insertions(+), 39 deletions(-)

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 49ec168b205..ef6990ce617 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -168,7 +168,8 @@ doc/m2.ps: doc/m2.dvi
 m2.pdf: doc/m2.pdf
 
 doc/m2.pdf: $(TEXISRC) $(objdir)/m2/images/gnu.eps
-   $(TEXI2PDF) -I $(objdir)/m2 -I $(srcdir)/doc/include 
$(srcdir)/doc/gm2.texi -o $@
+   $(TEXI2PDF) -I $(objdir)/m2 -I $(srcdir)/doc/include \
+  $(srcdir)/doc/gm2.texi -o $@
 
 M2_PDFFILES = doc/m2.pdf
 
diff --git a/gcc/m2/target-independent/m2/Builtins.texi 
b/gcc/m2/target-independent/m2/Builtins.texi
index 6f50bfa338e..b6903215293 100644
--- a/gcc/m2/target-independent/m2/Builtins.texi
+++ b/gcc/m2/target-independent/m2/Builtins.texi
@@ -6,6 +6,13 @@ FROM SYSTEM IMPORT ADDRESS ;
 
 (* floating point intrinsic procedure functions *)
 
+@findex isnanf
+PROCEDURE __BUILTIN__ isnanf (x: SHORTREAL) : INTEGER ;
+@findex isnan
+PROCEDURE __BUILTIN__ isnan (x: REAL) : INTEGER ;
+@findex isnanl
+PROCEDURE __BUILTIN__ isnanl (x: LONGREAL) : INTEGER ;
+
 @findex isfinitef
 PROCEDURE __BUILTIN__ isfinitef (x: SHORTREAL) : INTEGER ;
 @findex isfinite
@@ -113,9 +120,9 @@ PROCEDURE __BUILTIN__ nextafterf (x, y: SHORTREAL) : 
SHORTREAL ;
 PROCEDURE __BUILTIN__ nextafterl (x, y: LONGREAL) : LONGREAL ;
 
 @findex nexttoward
-PROCEDURE __BUILTIN__ nexttoward (x, y: REAL) : LONGREAL ;
+PROCEDURE __BUILTIN__ nexttoward (x: REAL; y: LONGREAL) : REAL ;
 @findex nexttowardf
-PROCEDURE __BUILTIN__ nexttowardf (x, y: SHORTREAL) : LONGREAL ;
+PROCEDURE __BUILTIN__ nexttowardf (x: SHORTREAL; y: LONGREAL) : SHORTREAL ;
 @findex nexttowardl
 PROCEDURE __BUILTIN__ nexttowardl (x, y: LONGREAL) : LONGREAL ;
 
diff --git a/gcc/m2/target-independent/m2/gm2-libs.texi 
b/gcc/m2/target-independent/m2/gm2-libs.texi
index 0531a4a1753..db8189f4059 100644
--- a/gcc/m2/target-independent/m2/gm2-libs.texi
+++ b/gcc/m2/target-independent/m2/gm2-libs.texi
@@ -242,6 +242,13 @@ FROM SYSTEM IMPORT ADDRESS ;
 
 (* floating point intrinsic procedure functions *)
 
+@findex isnanf
+PROCEDURE __BUILTIN__ isnanf (x: SHORTREAL) : INTEGER ;
+@findex isnan
+PROCEDURE __BUILTIN__ isnan (x: REAL) : INTEGER ;
+@findex isnanl
+PROCEDURE __BUILTIN__ isnanl (x: LONGREAL) : INTEGER ;
+
 @findex isfinitef
 PROCEDURE __BUILTIN__ isfinitef (x: SHORTREAL) : INTEGER ;
 @findex isfinite
@@ -349,9 +356,9 @@ PROCEDURE __BUILTIN__ nextafterf (x, y: SHORTREAL) : 
SHORTREAL ;
 PROCEDURE __BUILTIN__ nextafterl (x, y: LONGREAL) : LONGREAL ;
 
 @findex nexttoward
-PROCEDURE __BUILTIN__ nexttoward (x, y: REAL) : LONGREAL ;
+PROCEDURE __BUILTIN__ nexttoward (x: REAL; y: LONGREAL) : REAL ;
 @findex nexttowardf
-PROCEDURE __BUILTIN__ nexttowardf (x, y: SHORTREAL) : LONGREAL ;
+PROCEDURE __BUILTIN__ nexttowardf (x: SHORTREAL; y: LONGREAL) : SHORTREAL ;
 @findex nexttowardl
 PROCEDURE __BUILTIN__ nexttowardl (x, y: LONGREAL) : LONGREAL ;
 
@@ -662,10 +669,10 @@ DEFINITION MODULE DynamicStrings ;
 FROM SYSTEM IMPORT ADDRESS ;
 EXPORT QUALIFIED String,
  InitString, KillString, Fin, InitStringCharStar,
- InitStringChar, Index, RIndex,
+ InitStringChar, Index, RIndex, ReverseIndex,
  Mark, Length, ConCat, ConCatChar, Assign, Dup, Add,
  Equal, EqualCharStar, EqualArray, ToUpper, ToLower,
- CopyOut, Mult, Slice,
+ CopyOut, Mult, Slice, ReplaceChar,
  RemoveWhitePrefix, RemoveWhitePostfix, RemoveComment,
  char, string,
  InitStringDB, InitStringCharStarDB, InitStringCharDB,
@@ -766,6 +773,15 @@ PROCEDURE ConCatChar (a: String; ch: CHAR) : String ;
 PROCEDURE Assign (a, b: String) : String ;
 
 
+(*
+   ReplaceChar - returns string s after it has changed all
+ occurances of from to to.
+*)
+
+@findex ReplaceChar
+PROCEDURE ReplaceChar (s: String; from, to: CHAR) : String ;
+
+
 (*
Dup - duplicate a String, s, returning the copy of s.
 *)
@@ -845,14 +861,29 @@ PROCEDURE Index (s: String; ch: CHAR; o: CARDINAL) : 
INTEGER ;
 
 (*
RIndex - returns the indice of the last occurance of, ch,
-in

[gcc r14-9654] amdgcn: Add gfx1036 target

2024-03-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:78b56a12dd028b9b4051422c6bad6260055e4465

commit r14-9654-g78b56a12dd028b9b4051422c6bad6260055e4465
Author: Richard Biener 
Date:   Mon Mar 25 11:24:08 2024 +0100

amdgcn: Add gfx1036 target

Add support for the gfx1036 RDNA2 APU integrated graphics devices.  The ROCm
documentation warns that these may not be supported, but it seems to work
at least partially.

gcc/ChangeLog:

* config.gcc (amdgcn): Add gfx1036 entries.
* config/gcn/gcn-hsa.h (NO_XNACK): Likewise.
(gcn_local_sym_hash): Likewise.
* config/gcn/gcn-opts.h (enum processor_type): Likewise.
(TARGET_GFX1036): New macro.
* config/gcn/gcn.cc (gcn_option_override): Handle gfx1036.
(gcn_omp_device_kind_arch_isa): Likewise.
(output_file_start): Likewise.
* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __gfx1036__.
(TARGET_CPU_CPP_BUILTINS): Rename __gfx1030 to __gfx1030__.
* config/gcn/gcn.opt: Add gfx1036.
* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1036): New.
(main): Handle gfx1036.
* config/gcn/t-omp-device: Add gfx1036 isa.
* doc/install.texi (amdgcn): Add gfx1036.
* doc/invoke.texi (-march): Likewise.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (EF_AMDGPU_MACH): GFX1036.
(gcn_gfx1103_s): New.
(isa_hsa_name): Handle gfx1036.
(isa_code): Likewise.
(max_isa_vgprs): Likewise.

Diff:
---
 gcc/config.gcc  |  4 ++--
 gcc/config/gcn/gcn-hsa.h|  6 +++---
 gcc/config/gcn/gcn-opts.h   |  2 ++
 gcc/config/gcn/gcn.cc   | 10 ++
 gcc/config/gcn/gcn.h|  4 +++-
 gcc/config/gcn/gcn.opt  |  3 +++
 gcc/config/gcn/mkoffload.cc |  5 +
 gcc/config/gcn/t-omp-device |  2 +-
 gcc/doc/install.texi|  3 ++-
 gcc/doc/invoke.texi |  3 +++
 libgomp/plugin/plugin-gcn.c |  8 
 11 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 87a5c92b6e3..17873ac2103 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4560,7 +4560,7 @@ case "${target}" in
for which in arch tune; do
eval "val=\$with_$which"
case ${val} in
-   "" | fiji | gfx900 | gfx906 | gfx908 | gfx90a | gfx1030 
| gfx1100 | gfx1103)
+   "" | fiji | gfx900 | gfx906 | gfx908 | gfx90a | gfx1030 
| gfx1036 | gfx1100 | gfx1103)
# OK
;;
*)
@@ -4576,7 +4576,7 @@ case "${target}" in
TM_MULTILIB_CONFIG=
;;
xdefault | xyes)
-   TM_MULTILIB_CONFIG=`echo 
"gfx900,gfx906,gfx908,gfx90a,gfx1030,gfx1100,gfx1103" | sed 
"s/${with_arch},\?//;s/,$//"`
+   TM_MULTILIB_CONFIG=`echo 
"gfx900,gfx906,gfx908,gfx90a,gfx1030,gfx1036,gfx1100,gfx1103" | sed 
"s/${with_arch},\?//;s/,$//"`
;;
*)
TM_MULTILIB_CONFIG="${with_multilib_list}"
diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h
index ac32b8a328f..7d6e3141cea 100644
--- a/gcc/config/gcn/gcn-hsa.h
+++ b/gcc/config/gcn/gcn-hsa.h
@@ -90,7 +90,7 @@ extern unsigned int gcn_local_sym_hash (const char *name);
the ELF flags (e_flags) of that generated file must be identical to those
generated by the compiler.  */
 
-#define NO_XNACK "march=fiji:;march=gfx1030:;march=gfx1100:;march=gfx1103:;" \
+#define NO_XNACK 
"march=fiji:;march=gfx1030:;march=gfx1036:;march=gfx1100:;march=gfx1103:;" \
 /* These match the defaults set in gcn.cc.  */ \
 
"!mxnack*|mxnack=default:%{march=gfx900|march=gfx906|march=gfx908:-mattr=-xnack};"
 #define NO_SRAM_ECC "!march=*:;march=fiji:;march=gfx900:;march=gfx906:;"
@@ -106,8 +106,8 @@ extern unsigned int gcn_local_sym_hash (const char *name);
  "%{" ABI_VERSION_SPEC "} " \
  "%{" NO_XNACK XNACKOPT "} " \
  "%{" NO_SRAM_ECC SRAMOPT "} " \
- 
"%{march=gfx1030|march=gfx1100|march=gfx1103:-mattr=+wavefrontsize64} " \
- "%{march=gfx1030|march=gfx1100|march=gfx1103:-mattr=+cumode} 
" \
+ 
"%{march=gfx1030|march=gfx1036|march=gfx1100|march=gfx1103:-mattr=+wavefrontsize64}
 " \
+ 
"%{march=gfx1030|march=gfx1036|march=gfx1100|march=gfx1103:-mattr=+cumode} " \
  "-filetype=obj"
 #define LINK_SPEC "--pie --export-dynamic"
 #define LIB_SPEC  "-lc"
diff --git a/gcc/config/gcn/gcn-opts.h b/gcc/config/gcn/gcn-opts.h
index 285746f7f4d..49099bad7e7 100644
--- a/gcc/config/gcn/gcn-opts.h
+++ b/gcc/config/gcn/gcn-opts.h
@@ -26,6 +26,7 @@ enum processor_type
   PROCESSOR_GFX908,
   PROCESSOR_GFX90a,
   PROCESSOR_GFX1030,
+  PROCESSOR_GFX1036,
   PROC

[gcc r14-9655] libgcc: arm: fix build for FDPIC target

2024-03-25 Thread Max Filippov via Gcc-cvs
https://gcc.gnu.org/g:c2e68ff9edd5da7a55ba6574b4ce49ce6495b18d

commit r14-9655-gc2e68ff9edd5da7a55ba6574b4ce49ce6495b18d
Author: Max Filippov 
Date:   Fri Mar 22 13:03:46 2024 -0700

libgcc: arm: fix build for FDPIC target

libgcc/
* unwind-arm-common.inc (__gnu_personality_sigframe_fdpic): Cast
last argument of _Unwind_VRS_Set to void *.

Diff:
---
 libgcc/unwind-arm-common.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/unwind-arm-common.inc b/libgcc/unwind-arm-common.inc
index 5453f38186b..576f7e93e8a 100644
--- a/libgcc/unwind-arm-common.inc
+++ b/libgcc/unwind-arm-common.inc
@@ -248,7 +248,7 @@ __gnu_personality_sigframe_fdpic (_Unwind_State state,
  + ARM_SIGCONTEXT_R0;
 /* Restore regs saved on stack by the kernel.  */
 for (i = 0; i < 16; i++)
-   _Unwind_VRS_Set (context, _UVRSC_CORE, i, _UVRSD_UINT32, sp + 4 * i);
+   _Unwind_VRS_Set (context, _UVRSC_CORE, i, _UVRSD_UINT32, (void *)(sp + 
4 * i));
 
 return _URC_CONTINUE_UNWIND;
 }


[gcc r14-9656] Update gcc sv.po

2024-03-25 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:18555b914316e8c1fb11ee821f2ee839d834e58e

commit r14-9656-g18555b914316e8c1fb11ee821f2ee839d834e58e
Author: Joseph Myers 
Date:   Mon Mar 25 18:28:48 2024 +

Update gcc sv.po

* sv.po: Update.

Diff:
---
 gcc/po/sv.po | 700 ---
 1 file changed, 279 insertions(+), 421 deletions(-)

diff --git a/gcc/po/sv.po b/gcc/po/sv.po
index 072bedbd9d5..514eb7c764a 100644
--- a/gcc/po/sv.po
+++ b/gcc/po/sv.po
@@ -32,7 +32,7 @@ msgstr ""
 "Project-Id-Version: gcc 14.1-b20240218\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n";
 "POT-Creation-Date: 2024-02-16 21:35+\n"
-"PO-Revision-Date: 2024-03-17 20:14+0100\n"
+"PO-Revision-Date: 2024-03-24 12:59+0100\n"
 "Last-Translator: Göran Uddeborg \n"
 "Language-Team: Swedish \n"
 "Language: sv\n"
@@ -40363,16 +40363,14 @@ msgid "either %<-fopenacc%> or %<-fopenmp%> must be 
set"
 msgstr "antingen %<-fopenacc%> eller %<-fopenmp%> måste vara satt"
 
 #: config/gcn/mkoffload.cc:1039
-#, fuzzy, gcc-internal-format
-#| msgid "unhandled expression"
+#, gcc-internal-format
 msgid "unhandled architecture"
-msgstr "ohanterat uttryck"
+msgstr "ohanterad arkitektur"
 
 #: config/gcn/mkoffload.cc:1079 config/gcn/mkoffload.cc:1231
-#, fuzzy, gcc-internal-format
-#| msgid "cannot open %s"
+#, gcc-internal-format
 msgid "cannot open %qs"
-msgstr "kan inte öppna %s"
+msgstr "kan inte öppna %qs"
 
 #: config/gcn/mkoffload.cc:1217 config/nvptx/mkoffload.cc:841
 #, gcc-internal-format
@@ -40729,16 +40727,14 @@ msgid "%<-mstringop-strategy=rep_8byte%> not 
supported for 32-bit code"
 msgstr "%<-mstringop-strategy=rep_8byte%> stödjs inte för 32-bitarskod"
 
 #: config/i386/i386-options.cc:2143
-#, fuzzy, gcc-internal-format
-#| msgid "%<-muintr%> not supported for 32-bit code"
+#, gcc-internal-format
 msgid "%<-mapxf%> is not supported for 32-bit code"
-msgstr "%<-muintr%> stödjs inte för 32-bitarskod"
+msgstr "%<-mapxf%> stödjs inte för 32-bitarskod"
 
 #: config/i386/i386-options.cc:2145
-#, fuzzy, gcc-internal-format
-#| msgid "%<-mlam=%> option: [u48|u57] not supported for 32-bit code"
+#, gcc-internal-format
 msgid "%<-mapx-features=%> option is not supported for 32-bit code"
-msgstr "%<-mlam=%> flaggan: [u48|u57] stödjs inte för 32-bitarskod"
+msgstr "flaggan %<-mapx-features=%>- stödjs inte för 32-bitarskod"
 
 #: config/i386/i386-options.cc:2148
 #, gcc-internal-format
@@ -41318,10 +41314,9 @@ msgid "the ABI of passing C structures with zero-width 
bit-fields has changed in
 msgstr "ABI:et för att skicka C-poster med bitfält med nollbredd har ändrats i 
GCC %{12.1%}"
 
 #: config/i386/i386.cc:2722 config/i386/i386.cc:4091 config/i386/i386.cc:4101
-#, fuzzy, gcc-internal-format
-#| msgid "SSE register return with SSE disabled"
+#, gcc-internal-format
 msgid "SSE register return with SSE2 disabled"
-msgstr "SSE-registerretur med SSE avaktiverat"
+msgstr "SSE-registerretur med SSE2 avaktiverat"
 
 #: config/i386/i386.cc:2724
 #, gcc-internal-format
@@ -41329,10 +41324,9 @@ msgid "SSE register return with SSE disabled"
 msgstr "SSE-registerretur med SSE avaktiverat"
 
 #: config/i386/i386.cc:2731
-#, fuzzy, gcc-internal-format
-#| msgid "SSE register argument with SSE disabled"
+#, gcc-internal-format
 msgid "SSE register argument with SSE2 disabled"
-msgstr "SSE-registerargument med SSE avaktiverat"
+msgstr "SSE-registerargument med SSE2 avaktiverat"
 
 #: config/i386/i386.cc:2733
 #, gcc-internal-format
@@ -41436,10 +41430,9 @@ msgid "the alignment of %<_Atomic %T%> fields changed 
in %{GCC 11.1%}"
 msgstr "justeringen av %<_Atomic %T%>-fält ändrades i %{GCC 11.1%}"
 
 #: config/i386/i386.cc:22794
-#, fuzzy, gcc-internal-format
-#| msgid "no low registers available for popping high registers"
+#, gcc-internal-format
 msgid "no register available for profiling %<-mcmodel=large%s%>"
-msgstr "inga låga register tillgängliga för att poppa höga register"
+msgstr "inga register tillgängliga för profilering %<-mcmodel=large%s%>"
 
 #: config/i386/i386.cc:22890
 #, gcc-internal-format
@@ -41447,10 +41440,9 @@ msgid "profiling %<-mcmodel=large%> with PIC is not 
supported"
 msgstr "profileringen %<-mcmodel=large%> med PIC stödjs inte"
 
 #: config/i386/i386.cc:23603
-#, fuzzy, gcc-internal-format
-#| msgid "%<__bfloat16%> is redefined from typedef % to real 
%<__bf16%> since GCC V13, be careful of implicit conversion between %<__bf16%> 
and %; a explicit bitcast may be needed here"
+#, gcc-internal-format
 msgid "%<__bfloat16%> is redefined from typedef % to real %<__bf16%> 
since GCC 13.1, be careful of implicit conversion between %<__bf16%> and 
%; an explicit bitcast may be needed here"
-msgstr "%<__bfloat16%> är omdefinierat från typedef % till reell 
%<__bf16%> sedan GCC V13, var vaksam på implicita konverteringar mellan 
%<__bf16%> och %; en explicit bittypkonvertering kan behövas här"
+msgstr "%<__bfloat16%> är omdefinierat från typedef % till reell 
%<__bf16%> sedan GCC 13.1, var va

[gcc r14-9658] c++: broken direct-init with trailing array member [PR114439]

2024-03-25 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:de0886d48032332d10e4acb5d15c8789b281b6fe

commit r14-9658-gde0886d48032332d10e4acb5d15c8789b281b6fe
Author: Marek Polacek 
Date:   Mon Mar 25 15:32:20 2024 -0400

c++: broken direct-init with trailing array member [PR114439]

can_init_array_with_p is wrongly saying that the init for 's' here:

  struct S {
int *list = arr;
int arr[];
  };

  struct A {
A() {}
S s[2]{};
  };

is invalid.  But as process_init_constructor_array says, for "non-constant
initialization of trailing elements with no explicit initializers" we use
a VEC_INIT_EXPR wrapped in a TARGET_EXPR, built in process_init_constructor.

Unfortunately we didn't have a test for this scenario so I didn't
realize can_init_array_with_p must handle it.

PR c++/114439

gcc/cp/ChangeLog:

* init.cc (can_init_array_with_p): Return true for a VEC_INIT_EXPR
wrapped in a TARGET_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/init/array65.C: New test.

Diff:
---
 gcc/cp/init.cc  |  6 +-
 gcc/testsuite/g++.dg/init/array65.C | 38 +
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index dbd37d47cbf..a93ce00800c 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -950,12 +950,16 @@ can_init_array_with_p (tree type, tree init)
  mem-initializers of a constructor.  */
   if (DECL_DEFAULTED_FN (current_function_decl))
 return true;
-  /* As an extension, we allow copying from a compound literal.  */
   if (TREE_CODE (init) == TARGET_EXPR)
 {
   init = TARGET_EXPR_INITIAL (init);
+  /* As an extension, we allow copying from a compound literal.  */
   if (TREE_CODE (init) == CONSTRUCTOR)
return CONSTRUCTOR_C99_COMPOUND_LITERAL (init);
+  /* VEC_INIT_EXPR is used for non-constant initialization of trailing
+elements with no explicit initializers.  */
+  else if (TREE_CODE (init) == VEC_INIT_EXPR)
+   return true;
 }
 
   return false;
diff --git a/gcc/testsuite/g++.dg/init/array65.C 
b/gcc/testsuite/g++.dg/init/array65.C
new file mode 100644
index 000..0b144f45a9d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array65.C
@@ -0,0 +1,38 @@
+// PR c++/114439
+// { dg-do compile { target c++11 } }
+
+struct S {
+  int *list = arr;
+  __extension__ int arr[];
+};
+
+struct R {
+  int *list = arr;
+  int arr[2];
+};
+
+struct A {
+  A() {}
+  S s[2]{};
+};
+
+struct A2 {
+  A2() {}
+  S s[2]{ {}, {} };
+};
+
+struct B {
+  B() {}
+  R r[2]{};
+};
+
+struct B2 {
+  B2() {}
+  R r[2]{ {}, {} };
+};
+
+struct S1 { S1(); };
+struct S2 {
+  S2() {}
+  S1 a[1] {};
+};


[gcc r14-9659] c++: ICE with noexcept and local specialization, again [PR114349]

2024-03-25 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:8651991fe2ea90a7276e91673b15b5c3865f14d7

commit r14-9659-g8651991fe2ea90a7276e91673b15b5c3865f14d7
Author: Marek Polacek 
Date:   Fri Mar 15 09:23:28 2024 -0400

c++: ICE with noexcept and local specialization, again [PR114349]

Patrick noticed that my r14-9339-gdc6c3bfb59baab patch is wrong;
we're dealing with a noexcept-spec there, not a noexcept-expr, so
setting cp_noexcept_operand et al is incorrect.  Back to the drawing
board then.

To fix noexcept84.C, we should probably avoid doing push_to_top_level
in certain cases.  maybe_push_to_top_level didn't work here as-is, so
I changed it to not push to top level if decl_function_context is
non-null, when we are not dealing with a lambda.

This also fixes c++/114349, introduced by r14-9339.

PR c++/114349

gcc/cp/ChangeLog:

* name-lookup.cc (maybe_push_to_top_level): For a non-lambda,
don't push to top level if decl_function_context is non-null.
* pt.cc (maybe_instantiate_noexcept): Use maybe_push_to_top_level.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept85.C: New test.
* g++.dg/cpp0x/noexcept86.C: New test.

Diff:
---
 gcc/cp/name-lookup.cc   | 11 +++
 gcc/cp/pt.cc| 11 ++-
 gcc/testsuite/g++.dg/cpp0x/noexcept85.C | 33 +
 gcc/testsuite/g++.dg/cpp0x/noexcept86.C | 25 +
 4 files changed, 67 insertions(+), 13 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index dce4caf8981..7af7f00e34c 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -8664,10 +8664,13 @@ maybe_push_to_top_level (tree d)
 {
   /* Push if D isn't function-local, or is a lambda function, for which name
  resolution is already done.  */
-  bool push_to_top
-= !(current_function_decl
-   && !LAMBDA_FUNCTION_P (d)
-   && decl_function_context (d) == current_function_decl);
+  const bool push_to_top
+= (LAMBDA_FUNCTION_P (d)
+   || (TREE_CODE (d) == TYPE_DECL
+  && TREE_TYPE (d)
+  && LAMBDA_TYPE_P (TREE_TYPE (d)))
+   || !current_function_decl
+   || !decl_function_context (d));
 
   if (push_to_top)
 push_to_top_level ();
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 8cf0d5b7a8d..7b00a8615d2 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -26855,7 +26855,7 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t 
complain)
}
   else if (push_tinst_level (fn))
{
- push_to_top_level ();
+ const bool push_to_top = maybe_push_to_top_level (fn);
  push_access_scope (fn);
  push_deferring_access_checks (dk_no_deferred);
  input_location = DECL_SOURCE_LOCATION (fn);
@@ -26878,17 +26878,10 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t 
complain)
  if (orig_fn)
++processing_template_decl;
 
- ++cp_unevaluated_operand;
- ++c_inhibit_evaluation_warnings;
- ++cp_noexcept_operand;
  /* Do deferred instantiation of the noexcept-specifier.  */
  noex = tsubst_expr (DEFERRED_NOEXCEPT_PATTERN (noex),
  DEFERRED_NOEXCEPT_ARGS (noex),
  tf_warning_or_error, fn);
- --cp_unevaluated_operand;
- --c_inhibit_evaluation_warnings;
- --cp_noexcept_operand;
-
  /* Build up the noexcept-specification.  */
  spec = build_noexcept_spec (noex, tf_warning_or_error);
 
@@ -26898,7 +26891,7 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t 
complain)
  pop_deferring_access_checks ();
  pop_access_scope (fn);
  pop_tinst_level ();
- pop_from_top_level ();
+ maybe_pop_from_top_level (push_to_top);
}
   else
spec = noexcept_false_spec;
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept85.C 
b/gcc/testsuite/g++.dg/cpp0x/noexcept85.C
new file mode 100644
index 000..b415bb46bc9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept85.C
@@ -0,0 +1,33 @@
+// PR c++/114349
+// { dg-do compile { target c++11 } }
+
+using A = struct {};
+template  class, typename, typename>
+using B = A;
+template 
+using C = typename T::D;
+struct E {
+  using D = B;
+};
+template  constexpr bool foo (A) { return false; }
+template  struct F {
+  using G = T;
+  using H = E;
+  F(const F &);
+  void operator=(F) noexcept(foo  (H::D{}));
+};
+template 
+using I = F;
+template 
+using J = I;
+struct K {
+  typedef J L;
+  L k;
+  K();
+};
+struct M {
+  bool bar () const;
+  K::L m;
+};
+K n;
+bool M::bar () const { n.k = m; return true; }
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept86.C 
b/gcc/testsuite/g++.dg/cpp0x/noexcept86.C
new file mode 100644
index 000..2d040c090f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept86.C
@@ -0,0 +1,25 @@
+// PR c++/114349
+// { d

[gcc r13-8495] c: Fix ICE for nested enum redefinitions with/without fixed underlying type [PR112571]

2024-03-25 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:f2af129b68bc6b20f79a9a44b28c96650baa702c

commit r13-8495-gf2af129b68bc6b20f79a9a44b28c96650baa702c
Author: Joseph Myers 
Date:   Wed Jan 31 21:39:53 2024 +

c: Fix ICE for nested enum redefinitions with/without fixed underlying type 
[PR112571]

Bug 112571 reports an ICE-on-invalid for cases where an enum is
defined, without a fixed underlying type, inside the enum type
specifier for a definition of that same enum with a fixed underlying
type.

The ultimate cause is attempting to access ENUM_UNDERLYING_TYPE in a
case where it is NULL.  Avoid this by clearing
ENUM_FIXED_UNDERLYING_TYPE_P in thie case of inconsistent definitions.

Bootstrapped wth no regressions for x86_64-pc-linux-gnu.

(Note: for this GCC 13 branch backport, the tests were changed to use
-std=c2x not -std=c23, and c23-enum-9.c was changed to expect
different diagnostics because GCC 13 branch doesn't have the C23 tag
compatibility support for redefinitions of tagged types and
enumerators.)

PR c/112571

gcc/c/
* c-decl.cc (start_enum): Clear ENUM_FIXED_UNDERLYING_TYPE_P when
defining without a fixed underlying type an enumeration previously
declared with a fixed underlying type.

gcc/testsuite/
* gcc.dg/c23-enum-9.c, gcc.dg/c23-enum-10.c: New tests.

(cherry picked from commit d22d1a9346f27db41459738c6eb404f8f0956e6f)

Diff:
---
 gcc/c/c-decl.cc| 7 +--
 gcc/testsuite/gcc.dg/c23-enum-10.c | 6 ++
 gcc/testsuite/gcc.dg/c23-enum-9.c  | 8 
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 1b53f2d0785..7dcb1141bf7 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -9587,8 +9587,11 @@ start_enum (location_t loc, struct c_enum_contents 
*the_enum, tree name,
 
   if (ENUM_FIXED_UNDERLYING_TYPE_P (enumtype)
   && fixed_underlying_type == NULL_TREE)
-error_at (loc, "% declared with but defined without "
- "fixed underlying type");
+{
+  error_at (loc, "% declared with but defined without "
+   "fixed underlying type");
+  ENUM_FIXED_UNDERLYING_TYPE_P (enumtype) = false;
+}
 
   the_enum->enum_next_value = integer_zero_node;
   the_enum->enum_type = enumtype;
diff --git a/gcc/testsuite/gcc.dg/c23-enum-10.c 
b/gcc/testsuite/gcc.dg/c23-enum-10.c
new file mode 100644
index 000..894893133a5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c23-enum-10.c
@@ -0,0 +1,6 @@
+/* PR c/112571.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x" } */
+
+enum X : typeof (enum X { A }); /* { dg-error "declared with but defined 
without fixed underlying type" } */
+/* { dg-error "invalid 'enum' underlying type" "invalid" { target *-*-* } .-1 
} */
diff --git a/gcc/testsuite/gcc.dg/c23-enum-9.c 
b/gcc/testsuite/gcc.dg/c23-enum-9.c
new file mode 100644
index 000..b9a6afe0c77
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c23-enum-9.c
@@ -0,0 +1,8 @@
+/* PR c/112571.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x" } */
+
+enum h : typeof (enum h { D }) { D }; /* { dg-error "declared with but defined 
without fixed underlying type" } */
+/* { dg-error "invalid 'enum' underlying type" "invalid" { target *-*-* } .-1 
} */
+/* { dg-error "redeclaration of 'enum h'" "enumeration" { target *-*-* } .-2 } 
*/
+/* { dg-error "redeclaration of enumerator" "enumerator" { target *-*-* } .-3 
} */


[gcc r14-9661] MIPS: Predefine __mips_strict_alignment if STRICT_ALIGNMENT

2024-03-25 Thread YunQiang Su via Gcc-cvs
https://gcc.gnu.org/g:bb819067b3037dbc847aef6c46b8dc6cd5b50962

commit r14-9661-gbb819067b3037dbc847aef6c46b8dc6cd5b50962
Author: YunQiang Su 
Date:   Wed Mar 20 16:25:04 2024 +0800

MIPS: Predefine __mips_strict_alignment if STRICT_ALIGNMENT

Arm32 predefines __ARM_FEATURE_UNALIGNED if -mno-unaligned-access,
and RISC-V predefines __riscv_misaligned_avoid.

Let's define __mips_strict_alignment for MIPSr6 and -mstrict-align
is used.

Note that, this macro is always defined for pre-R6.

gcc
* config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): Predefine
__mips_strict_alignment if STRICT_ALIGNMENT.

Diff:
---
 gcc/config/mips/mips.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 6444a68dfd5..616a275b918 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -694,6 +694,9 @@ struct mips_cpu_info {
builtin_define ("__mips_compact_branches_always");  \
   else \
builtin_define ("__mips_compact_branches_optimal"); \
+   \
+  if (STRICT_ALIGNMENT)\
+   builtin_define ("__mips_strict_alignment"); \
 }  \
   while (0)