platform/upstream/gcc.git
16 months agogcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]
Jonathan Wakely [Fri, 3 Mar 2023 16:41:29 +0000 (16:41 +0000)]
gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]

gcc/ChangeLog:

PR middle-end/109006
* gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.

16 months agogcc: Adjust gdbhooks.py VecPrinter for vec layout changes [PR109006]
Jonathan Wakely [Fri, 3 Mar 2023 16:41:29 +0000 (16:41 +0000)]
gcc: Adjust gdbhooks.py VecPrinter for vec layout changes [PR109006]

gcc/ChangeLog:

PR middle-end/109006
* gdbhooks.py (VecPrinter): Adjust for new vec layout.

16 months agoc++: thinko in extract_local_specs [PR108998]
Patrick Palka [Fri, 3 Mar 2023 16:37:02 +0000 (11:37 -0500)]
c++: thinko in extract_local_specs [PR108998]

In order to fix PR100295, r13-4730-g18499b9f848707 attempted to make
extract_local_specs walk the given pattern twice, ignoring unevaluated
operands the first time around so that we prefer to process a local
specialization in an evaluated context if it appears in one (we process
each local specialization once even if it appears multiple times in the
pattern).

But there's a thinko in the patch, namely that we don't actually walk
the pattern twice since we don't clear the visited set for the second
walk (to avoid processing a local specialization twice) and so the root
node (and any node leading up to an unevaluated operand) is considered
visited already.  So the patch effectively made extract_local_specs
ignore unevaluated operands altogether, which this testcase demonstrates
isn't quite safe (extract_local_specs never sees 'aa' and we don't record
its local specialization, so later we try to specialize 'aa' on the spot
with the args {{int},{17}} which causes us to nonsensically substitute
its auto with 17.)

This patch fixes this by refining the second walk to start from the
trees we skipped over during the first walk.

PR c++/108998

gcc/cp/ChangeLog:

* pt.cc (el_data::skipped_trees): New data member.
(extract_locals_r): Push to skipped_trees any unevaluated
contexts that we skipped over.
(extract_local_specs): For the second walk, start from each
tree in skipped_trees.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-generic11.C: New test.

16 months agos390: libatomic: Fix 16 byte atomic {cas,load,store}
Stefan Schulze Frielinghaus [Fri, 3 Mar 2023 16:09:46 +0000 (17:09 +0100)]
s390: libatomic: Fix 16 byte atomic {cas,load,store}

This is a follow-up to commit a4c6bd0821099f6b8c0f64a96ffd9d01a025c413
introducing a runtime check for alignment for 16 byte atomic
compare-exchange, load, and store.

libatomic/ChangeLog:

* config/s390/cas_n.c: New file.
* config/s390/load_n.c: New file.
* config/s390/store_n.c: New file.

16 months agowaccess: Fix two -Wnonnull warning issues [PR108986]
Jakub Jelinek [Fri, 3 Mar 2023 15:11:11 +0000 (16:11 +0100)]
waccess: Fix two -Wnonnull warning issues [PR108986]

The following patch fixes 2 issues with the -Wnonnull warning.

One, fixed by the second hunk, is that the warning wording is bogus
since r11-3305, instead of printing
warning: argument 1 to ‘int[static 7]’ is null where non-null expected [-Wnonnull]
it prints
warning: argument 1 to ‘int[static 28]’ is null where non-null expected [-Wnonnull]
access_size is measured in bytes, so obviously will be correct as array
number of elements only if it is 1 byte element array.
In the function, access_nelts is either constant (if sizidx == -1) or
when the array size is determined by some other parameter, I believe a value
passed to that argument.
Later on we query the range of it:
      if (get_size_range (m_ptr_qry.rvals, access_nelts, stmt, sizrng, 1))
which I bet must just return accesS_nelts in sizrng[0] and [1] if it is
constant.  access_size is later computed as:
      tree access_size = NULL_TREE;
      if (tree_int_cst_sgn (sizrng[0]) >= 0)
        {
          if (COMPLETE_TYPE_P (argtype))
            {
...
                    wide_int minsize = wi::to_wide (sizrng[0], prec);
                    minsize *= wi::to_wide (argsize, prec);
                    access_size = wide_int_to_tree (sizetype, minsize);
                  }
            }
          else
            access_size = access_nelts;
        }
and immediately after this the code does:
      if (integer_zerop (ptr))
        {
          if (sizidx >= 0 && tree_int_cst_sgn (sizrng[0]) > 0)
            {
some other warning wording
            }
          else if (access_size && access.second.static_p)
            {
this spot
            }
        }
So, because argtype is complete, access_size has been multiplied by
argsize, but in case of this exact warning ("this spot" above)
I believe access_nelts must be really constant, otherwise
"some other warning wording" would handle it.  So, I think access_nelts
is exactly what we want to print there.

The other problem is that since the introduction of -Wdangling-pointer
in r12-6606, the pass has early and late instances and while lots of
stuff in the pass is guarded on being done in the late pass only,
this particular function is not, furthermore it is emitting two different
warnings in a loop and already messes up with stuff like clearing
warning suppression for one of the warning (ugh!).  The end effect is
that we warn twice about the same problem, once in the early and once in
the late pass.  Now, e.g. with -O2 -Wall we warn just once, during the
early pass, as it is then optimized away, so I think just making this
late warning only wouldn't be best.  This patch instead returns early
if either of the warnings is suppressed on the call stmt already.
I think if one of the passes warned on it already (even if say on some other
argument), then warning again (even on some other argument) is unnecessary,
if both problems are visible in the same pass we'll still warn about both.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR c/108986
* gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes):
Return immediately if OPT_Wnonnull or OPT_Wstringop_overflow_ is
suppressed on stmt.  For [static %E] warning, print access_nelts
rather than access_size.  Fix up comment wording.

* gcc.dg/Wnonnull-8.c: New test.

16 months agos390: Use arch14 instead of z16 for -march=native.
Robin Dapp [Wed, 1 Feb 2023 18:39:10 +0000 (19:39 +0100)]
s390: Use arch14 instead of z16 for -march=native.

When compiling on a system where binutils do not yet support the 'z16'
name assembling fails with -march=native on a z16 machine.
Currently, this is interpreted as -march=z16.  This patch uses -march=arch14
instead.

gcc/ChangeLog:

* config/s390/driver-native.cc (s390_host_detect_local_cpu): Use
arch14 instead of z16.

16 months agos390: Fix ifcvt test cases.
Robin Dapp [Wed, 1 Feb 2023 18:33:35 +0000 (19:33 +0100)]
s390: Fix ifcvt test cases.

We seem to flip flop between the "high" and "not low" variants of load on
condition.  Accept both in the affected test cases.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ifcvt-two-insns-bool.c: Allow "high" and
"not low or equal" load on condition variant.
* gcc.target/s390/ifcvt-two-insns-int.c: Dito.
* gcc.target/s390/ifcvt-two-insns-long.c: Dito.

16 months agotestsuite: Do not expect partial vectorization for s390.
Robin Dapp [Thu, 2 Feb 2023 07:39:39 +0000 (08:39 +0100)]
testsuite: Do not expect partial vectorization for s390.

This changes SLP test expectations.  As we only vectorize when no more
than one rgroup is present, no vectorization is performed.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-3.c: Adapt test expectation.
* gcc.dg/vect/slp-multitypes-11.c: Likewise.
* gcc.dg/vect/slp-perm-8.c: Likewise.

16 months agomoxie: enable LRA
Anthony Green [Fri, 3 Mar 2023 13:57:26 +0000 (08:57 -0500)]
moxie: enable LRA

Remove TARGET_LRA_P definition to enable LRA.

gcc/ChangeLog:

* config/moxie/moxie.cc (TARGET_LRA_P): Remove.

16 months agomoxie: fix memory constraints
Anthony Green [Fri, 3 Mar 2023 13:46:10 +0000 (08:46 -0500)]
moxie: fix memory constraints

Change define_constraint to define_memory_constraint where appropriate
to fix LRA for moxie.

gcc/ChangeLog:

* config/moxie/constraints.md (A, B, W): Change
define_constraint to define_memory_constraint.

16 months agodriver: toplev: Fix a typo
Xi Ruoyao [Fri, 3 Mar 2023 08:50:53 +0000 (16:50 +0800)]
driver: toplev: Fix a typo

The driver emits a warning when -fstack-check and
-fstack-clash-protection are used together, but the message refers to
"-fstack-clash_protection" (underline instead of dash).

gcc/ChangeLog:

* toplev.cc (process_options): Fix the spelling of
"-fstack-clash-protection".

16 months agotree-optimization/109002 - partial PRE miscompilation
Richard Biener [Fri, 3 Mar 2023 09:41:29 +0000 (10:41 +0100)]
tree-optimization/109002 - partial PRE miscompilation

Partial PRE ends up miscompiling the testcase in PR109002, likely
involving a corner case when inifinite loops are involved.  The
following avoids the miscompilation by addressing a long-standing
oddity that manifests in odd partial partial redundancies eliminated
that are full redundancies.  The oddity is that while we properly
PHI translate the PA_IN set from the successors when computing
PA_OUT but we fail to do the same for ANTIC_IN which is supposed
to be unioned.  That results in expressions with wrong virtual
operands being placed in the PA_OUT/IN sets and the pruning
machinery to go wrong because it assumes the expressions in the
sets have virtual operands that are valid in the respective blocks.

PR tree-optimization/109002
* tree-ssa-pre.cc (compute_partial_antic_aux): Properly
PHI-translate ANTIC_IN.

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

16 months agolibiberty: fix memory leak in pex-win32.c and refactor
Costas Argyris [Sun, 26 Feb 2023 16:34:11 +0000 (16:34 +0000)]
libiberty: fix memory leak in pex-win32.c and refactor

Fix memory leak of cmdline buffer and refactor to have
cleanup code appear once for all exit cases.

libiberty/ChangeLog:

* pex-win32.c (win32_spawn): Fix memory leak of cmdline
buffer and refactor to have cleanup code appear once
for all exit cases.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agogimple-fold: Fix up fputs -> fwrite folding [PR108988]
Jakub Jelinek [Fri, 3 Mar 2023 10:13:40 +0000 (11:13 +0100)]
gimple-fold: Fix up fputs -> fwrite folding [PR108988]

gimple_fold_builtin_fputs when folding fputs into fwrite emits the third
argument (INTEGER_CST) with incorrect type - get_maxval_strlen or c_strlen
return ssizetype, while fwrite argument is size_type_node.
The following patch fixes that, I've skimmed through the rest of
gimple-fold.cc and in all other places get_maxval_strlen/c_strlen result
was fold_converted to size_type_node already (or GIMPLE cast stmt has been
emitted directly etc.).

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108988
* gimple-fold.cc (gimple_fold_builtin_fputs): Fold len to
size_type_node before passing it as argument to fwrite.  Formatting
fixes.

16 months agolibstdc++: Update Solaris baselines for GCC 13.0
Rainer Orth [Fri, 3 Mar 2023 10:02:50 +0000 (11:02 +0100)]
libstdc++: Update Solaris baselines for GCC 13.0

This patch updates the libstdc++ Solaris baselines for GCC 13.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (Solaris 11.3
and 11.4).

2022-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

16 months agotarget/108738 - limit STV chain discovery
Richard Biener [Thu, 2 Mar 2023 12:43:51 +0000 (13:43 +0100)]
target/108738 - limit STV chain discovery

The following puts a hard limit on the inherently quadratic STV chain
discovery.  Without a limit for the compiler.i testcase in PR26854
we see at -O2

 machine dep reorg                  : 574.45 ( 53%)

with release checking while with the proposed limit it's

 machine dep reorg                  :   2.86 (  1%)

PR target/108738
* config/i386/i386.opt (--param x86-stv-max-visits): New param.
* doc/invoke.texi (--param x86-stv-max-visits): Document it.
* config/i386/i386-features.h (scalar_chain::max_visits): New.
(scalar_chain::build): Add bitmap parameter, return boolean.
(scalar_chain::add_insn): Likewise.
(scalar_chain::analyze_register_chain): Likewise.
* config/i386/i386-features.cc (scalar_chain::scalar_chain):
Initialize max_visits.
(scalar_chain::analyze_register_chain): When we exhaust
max_visits, abort.  Also abort when running into any
disallowed insn.
(scalar_chain::add_insn): Propagate abort.
(scalar_chain::build): Likewise.  When aborting amend
the set of disallowed insn with the insns set.
(convert_scalars_to_vector): Adjust.  Do not convert aborted
chains.

16 months agodebug/108772 - ICE with late debug generated with -flto
Richard Biener [Wed, 1 Mar 2023 09:01:10 +0000 (10:01 +0100)]
debug/108772 - ICE with late debug generated with -flto

When combining -g1 with -flto we run into the DIE location annotation
machinery for globals calling dwarf2out_late_global_decl but not
having any early generated DIE for function scope statics.  In
this process we'd generate a limbo DIE since also the function scope
doesn't have any early generated DIE.  The limbo handling then tries
to force a DIE for the context chain which ultimatively fails and
ICEs at the std namespace decl because at -g1 we don't represent that.

The following avoids this situation by making sure to never generate
any DIEs from dwarf2out_late_global_decl in the in_lto_p path
for function scope globals but rely on DIE generation for
the function to output a DIE for the local static (which doesn't
happen for -g1).

I explored a lot of other options to fix this but in the end this
seems to be the most spot-on fix with the least risk of unwanted
effects.

PR debug/108772
* dwarf2out.cc (dwarf2out_late_global_decl): Do not
generate a DIE for a function scope static.

* g++.dg/lto/pr108772_0.C: New testcase.

16 months ago[PR100127] Test for coroutine header in clang-compatible tests
Alexandre Oliva [Fri, 3 Mar 2023 04:47:00 +0000 (01:47 -0300)]
[PR100127] Test for coroutine header in clang-compatible tests

The test is compatible with clang as well as gcc, but ISTM that
testing for the __clang__ macro is just as potentially error-prone as
macros that used to be GCC-specific are now defined in compilers that
aim for GCC compatibility.  Use a __has_include feature test instead.

for  gcc/testsuite/ChangeLog

PR c++/100127
* g++.dg/coroutines/pr100127.C: Test for header rather than
compiler macro.
* g++.dg/coroutines/pr100772-a.C: Likewise.
* g++.dg/coroutines/pr100772-b.C: Likewise.

16 months ago[vxworks] make wint_t and wchar_t the same distinct type
Alexandre Oliva [Fri, 3 Mar 2023 04:47:04 +0000 (01:47 -0300)]
[vxworks] make wint_t and wchar_t the same distinct type

We used to define WINT_TYPE to WCHAR_TYPE, so that both wint_t and
wchar_t mapped to the same underlying type, but this caused a glitch
in Wstringop-overflow-6.C: on vxworks, wint_t is typedef'ed to
wchar_t, headers got included in the test that declared functions that
take wint_t parameters, and those conflicted with the builtin
declarations that had wint_t mapped to the underlying integral type.

The problem is that, in C++, wchar_t is a distinct type.  Having
wint_t be a typedef to wchar_t in the headers, but a typedef to
wchar_t's underlying integral type in builtins, makes for mismatches
between the declarations.

This patch defines WINT_TYPE to "wchar_t" for vxworks, and adjusts the
fallout, namely:

- since wchar_t may not have been defined yet when
  c_common_nodes_and_builtins runs, use the node already reserved for
  wchar_t for wint_t when WINT_TYPE is defined to wchar_t.

- for the same reason, when WINT_TYPE is wchar_t and we're not
  compiling C++ where wchar_t is a compiler built-in, define
  __WINT_TYPE__ to WCHAR_TYPE rather than WINT_TYPE, because wchar_t
  may not even be defined in the translation unit.

- recognize and handle wchar_type_node when type_suffix is called for
  wint_type_node.

for  gcc/ChangeLog

* config/vx-common.h (WINT_TYPE): Alias to "wchar_t".

for  gcc/c-family/ChangeLog

* c-common.cc (c_common_nodes_and_builtins): Take
wchar_type_node for wint_type_node when aliased.
(c_stddef_cpp_builtins): Define __WINT_TYPE__, when aliased to
wchar_t, to the underlying type rather than wchar_t in
non-C++.
* c-cppbuiltin.cc (type_suffix): Handle wchar_type_node.

16 months ago[c++] suppress redundant null-addr warn in pfn from pmfn
Alexandre Oliva [Fri, 3 Mar 2023 04:46:56 +0000 (01:46 -0300)]
[c++] suppress redundant null-addr warn in pfn from pmfn

When TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, when
we warn about comparing a pointer-to-member-function with NULL, we
also warn about comparing the pointer-to-function extracted from it
with NULL, which is redundant.  Suppress the redundant warning.

for  gcc/cp/ChangeLog

* typeck.cc (cp_build_binary_op): Suppress redundant warning
for pfn null test in pmfn test with vbit-in-delta.

16 months agotestsuite: Tweak gcc.dg/attr-aligned.c for CRIS
Hans-Peter Nilsson [Thu, 16 Feb 2023 19:21:50 +0000 (20:21 +0100)]
testsuite: Tweak gcc.dg/attr-aligned.c for CRIS

tm.texi says for BIGGEST_ALIGNMENT (from which
__BIGGEST_ALIGNMENT__ is derived): "Biggest alignment that
any data type can require on this machine, in bits."

That is, using that value might be too strict for alignment
of *functions* and CRIS requires at least 16-bit alignment
for functions.  But, one purpose of the test is to test that
alignment can be set to a large but valid value, so pick
512, which has some use as a historically required alignment
for certain I/O descriptors.

* gcc.dg/attr-aligned.c: Adjust comment for ALIGN_MAX_STATIC.
(ALIGN_MAX_STATIC): Set to 512 for CRIS.

16 months agod: Allow vectors to be compared for identity [PR108946]
Iain Buclaw [Thu, 2 Mar 2023 23:00:44 +0000 (00:00 +0100)]
d: Allow vectors to be compared for identity [PR108946]

Vector equality and comparisons are now accepted by the language
implementation, but identity wasn't.  Implement it as an extra integer
comparison of the bit-casted bitmask.

PR d/108946

gcc/d/ChangeLog:

* d-target.cc (Target::isVectorOpSupported): Allow identity ops.
* expr.cc (ExprVisitor::visit (IdentityExp *)): Handle vector identity
comparisons.

gcc/testsuite/ChangeLog:

* gdc.dg/simd2a.d: Update test.
* gdc.dg/simd2b.d: Likewise.
* gdc.dg/simd2c.d: Likewise.
* gdc.dg/simd2d.d: Likewise.
* gdc.dg/simd2e.d: Likewise.
* gdc.dg/simd2f.d: Likewise.
* gdc.dg/simd2g.d: Likewise.
* gdc.dg/simd2h.d: Likewise.
* gdc.dg/simd2i.d: Likewise.
* gdc.dg/simd2j.d: Likewise.

16 months agod: Fix ICE on explicit immutable struct import [PR108877]
Iain Buclaw [Mon, 27 Feb 2023 19:46:18 +0000 (20:46 +0100)]
d: Fix ICE on explicit immutable struct import [PR108877]

Const and immutable types are built as variants of the type they are
derived from, and TYPE_STUB_DECL is not set for these variants.

PR d/108877

gcc/d/ChangeLog:

* imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
make_import on TYPE_MAIN_VARIANT.
(ImportVisitor::visit (AggregateDeclaration *)): Likewise.
(ImportVisitor::visit (ClassDeclaration *)): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr108877a.d: New test.
* gdc.dg/pr108877.d: New test.

16 months agod: Add test for PR d/108167 to the testsuite [PR108167]
Iain Buclaw [Mon, 27 Feb 2023 17:38:53 +0000 (18:38 +0100)]
d: Add test for PR d/108167 to the testsuite [PR108167]

The D front-end implementation got fixed in upstream, add test to the
gdc testsuite to check we don't regress on it.

PR d/108167

gcc/testsuite/ChangeLog:

* gdc.dg/pr108167.d: New test.

16 months agod: vector float comparison doesn't result in 0 or -1 [PR108945]
Iain Buclaw [Mon, 27 Feb 2023 15:02:21 +0000 (16:02 +0100)]
d: vector float comparison doesn't result in 0 or -1 [PR108945]

When comparing two vectors, the type of vector was used as the result of
the condition result.  This meant that for floating point comparisons,
each value would either be `0.0' or `-1.0' reinterpreted as an integer,
not the expected integral bitmask values `0' and `-1'.

Instead, use the comparison type determined by truth_type_for as the
result of the comparison.  If a reinterpret is later required by the
final conversion for generating CmpExp, it is still only going to
reinterpret one integer kind as another.

PR d/108945

gcc/d/ChangeLog:

* d-codegen.cc (build_boolop): Evaluate vector comparison as
the truth_type_for vector type.

gcc/testsuite/ChangeLog:

* gdc.dg/pr108945.d: New test.

16 months agoDaily bump.
GCC Administrator [Fri, 3 Mar 2023 00:16:38 +0000 (00:16 +0000)]
Daily bump.

16 months agotestsuite: Fix up memchr-3.c test [PR108991]
Jakub Jelinek [Thu, 2 Mar 2023 23:50:10 +0000 (00:50 +0100)]
testsuite: Fix up memchr-3.c test [PR108991]

The newly added dg-warning directive was missing the comment argument,
so the target selector was treated as comment and the warning was expected
on all targets when it should be expected only on llp64 targets.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108991
* gcc.dg/memchr-3.c: Add missing comment argument to dg-warning
before target selector.

16 months agolibquadmath: Assorted libquadmath strtoflt128 fixes [PR87204, PR94756]
Jakub Jelinek [Thu, 2 Mar 2023 23:40:13 +0000 (00:40 +0100)]
libquadmath: Assorted libquadmath strtoflt128 fixes [PR87204, PR94756]

This patch cherry-pickx 8 commits from glibc which fix various strtod_l
bugs.  Additionally, it makes mp_limb_t 64-bit on llp64 targets like
64-bit cygwin.

2023-03-03  niXman  <i.nixman@autistici.org>
    Jakub Jelinek  <jakub@redhat.com>

PR libquadmath/87204
PR libquadmath/94756
* printf/gmp-impl.h (mp_limb_t, mp_limb_signed_t, BITS_PER_MP_LIMB):
Use 64-bit limbs on LLP64 targets.
* strtod/strtod_l.c (round_and_return): Cherry-pick glibc
9310c284ae9 BZ #16151, 4406c41c1d6 BZ #16965 and fcd6b5ac36a
BZ #23279 fixes.
(____STRTOF_INTERNAL): Cherry-pick glibc b0debe14fcf BZ #23007,
5556d30caee BZ #18247, 09555b9721d and c6aac3bf366 BZ #26137 and
d84f25c7d87 fixes.

16 months agoc++, v3: Emit fundamental tinfos for _Float16/decltype(0.0bf16) types on ia32 with...
Jakub Jelinek [Thu, 2 Mar 2023 23:34:59 +0000 (00:34 +0100)]
c++, v3: Emit fundamental tinfos for _Float16/decltype(0.0bf16) types on ia32 with -mno-sse2 [PR108883]

_Float16 and decltype(0.0bf16) types are on x86 supported only with
-msse2.  On x86_64 that is the default, but on ia32 it is not.
We should still emit fundamental type tinfo for those types in
libsupc++.a/libstdc++.*, regardless of whether libsupc++/libstdc++
is compiled with -msse2 or not, as user programs can be compiled
with different ISA flags from libsupc++/libstdc++ and if they
are compiled with -msse2 and use std::float16_t or std::bfloat16_t
and need RTTI for it, it should work out of the box.  Furthermore,
libstdc++ ABI on ia32 shouldn't depend on whether the library
is compiled with -mno-sse or -msse2.

Unfortunately, just hacking up libsupc++ Makefile/configure so that
a single source is compiled with -msse2 isn't appropriate, because
that TU emits also code and the code should be able to run on CPUs
which libstdc++ supports.  We could add [[gnu::attribute ("no-sse2")]]
there perhaps conditionally, but it all gets quite ugly.

The following patch instead adds a target hook which allows the backend
to temporarily tweak registered types such that emit_support_tinfos
emits whatever is needed.

Additionally, it makes emit_support_tinfos_1 call emit_tinfo_decl
immediately, so that temporarily created dummy types for emit_support_tinfo
purposes only can be nullified again afterwards.  And removes the
previous fallback_* types used for dfloat*_type_node tinfos even when
decimal types aren't supported.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR target/108883
gcc/
* target.h (emit_support_tinfos_callback): New typedef.
* targhooks.h (default_emit_support_tinfos): Declare.
* targhooks.cc (default_emit_support_tinfos): New function.
* target.def (emit_support_tinfos): New target hook.
* doc/tm.texi.in (emit_support_tinfos): Document it.
* doc/tm.texi: Regenerated.
* config/i386/i386.cc (ix86_emit_support_tinfos): New function.
(TARGET_EMIT_SUPPORT_TINFOS): Redefine.
gcc/cp/
* cp-tree.h (enum cp_tree_index): Remove CPTI_FALLBACK_DFLOAT*_TYPE
enumerators.
(fallback_dfloat32_type, fallback_dfloat64_type,
fallback_dfloat128_type): Remove.
* rtti.cc (emit_support_tinfo_1): If not emitted already, call
emit_tinfo_decl and remove from unemitted_tinfo_decls right away.
(emit_support_tinfos): Move &dfloat*_type_node from fundamentals array
into new fundamentals_with_fallback array.  Call emit_support_tinfo_1
on elements of that array too, with the difference that if
the type is NULL, use a fallback REAL_TYPE for it temporarily.
Drop the !targetm.decimal_float_supported_p () handling.  Call
targetm.emit_support_tinfos at the end.
* mangle.cc (write_builtin_type): Remove references to
fallback_dfloat*_type.  Handle bfloat16_type_node mangling.

16 months agojit, testsuite: fix a failing test by updating its error string [PR107999]
Guillaume Gomez [Thu, 2 Mar 2023 22:52:07 +0000 (17:52 -0500)]
jit, testsuite: fix a failing test by updating its error string [PR107999]

gcc/testsuite/ChangeLog:
PR jit/107999
* jit.dg/test-error-array-bounds.c: Update test.

Signed-off-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
16 months agoIRA: Use minimal cost for hard register movement
Vladimir N. Makarov [Thu, 2 Mar 2023 21:29:05 +0000 (16:29 -0500)]
IRA: Use minimal cost for hard register movement

This is the 2nd attempt to fix PR90706.  IRA calculates wrong AVR
costs for moving general hard regs of SFmode.  This was the reason for
spilling a pseudo in the PR.  In this patch we use smaller move cost
of hard reg in its natural and operand modes.

        PR rtl-optimization/90706

gcc/ChangeLog:

* ira-costs.cc: Include print-rtl.h.
(record_reg_classes, scan_one_insn): Add code to print debug info.
(record_operand_costs): Find and use smaller cost for hard reg
move.

gcc/testsuite/ChangeLog:

* gcc.target/avr/pr90706.c: New.

16 months agoamdgcn: Enable SIMD vectorization of math functions
Kwok Cheung Yeung [Thu, 2 Mar 2023 20:56:53 +0000 (20:56 +0000)]
amdgcn: Enable SIMD vectorization of math functions

Calls to vectorized versions of routines in the math library will now
be inserted when vectorizing code containing supported math functions.

2023-03-02  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Paul-Antoine Arras  <pa@codesourcery.com>

gcc/
* builtins.cc (mathfn_built_in_explicit): New.
* config/gcn/gcn.cc: Include case-cfn-macros.h.
(mathfn_built_in_explicit): Add prototype.
(gcn_vectorize_builtin_vectorized_function): New.
(gcn_libc_has_function): New.
(TARGET_LIBC_HAS_FUNCTION): Define.
(TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Define.

gcc/testsuite/
* gcc.target/gcn/simd-math-1.c: New testcase.
* gcc.target/gcn/simd-math-2.c: New testcase.

libgomp/
* testsuite/libgomp.c/simd-math-1.c: New testcase.

16 months agoc++: more mce_false folding from cp_fully_fold_init [PR108243]
Patrick Palka [Thu, 2 Mar 2023 19:04:50 +0000 (14:04 -0500)]
c++: more mce_false folding from cp_fully_fold_init [PR108243]

We should also fold the overall initializer passed to cp_fully_fold_init
with mce_false, which allows folding of the copy-initialization of
'a1' in the below testcase (the initializer here is an AGGR_INIT_EXPR).

Unfortunately this doesn't help with direct- or default-initialization
because we don't call cp_fully_fold_init in that case, and even if we
did the initializer in that case is expressed as a bare CALL_EXPR
instead of an AGGR_INIT_EXPR, which cp_fully_fold_init can't really
fold.

PR c++/108243
PR c++/97553

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fully_fold): Add an internal overload that
additionally takes and propagate an mce_value parameter, and
define the existing public overload in terms of it.
(cp_fully_fold_init): Pass mce_false to cp_fully_fold.

gcc/testsuite/ChangeLog:

* g++.dg/opt/is_constant_evaluated3.C: New test.

16 months agoc++: constant non-copy-init is manifestly constant [PR108243]
Patrick Palka [Thu, 2 Mar 2023 19:03:21 +0000 (14:03 -0500)]
c++: constant non-copy-init is manifestly constant [PR108243]

According to [basic.start.static]/2 and [expr.const]/2, a variable
with static storage duration initialized with a constant initializer
has constant initialization, and such an initializer is manifestly
constant-evaluated.

For copy initialization, we're already getting this right because in
that case check_initializer would consistently call store_init_value,
which for TREE_STATIC variables calls fold_non_dependent_init with
m_c_e=true.

But for direct (or default) initialization, check_initializer doesn't
always call store_init_value.  We instead however always call
maybe_constant_init from expand_default_init[1], albeit with m_c_e=false
which means we don't get the "manifestly constant-evaluated" part right
for non-copy-init.

This patch fixes this by setting m_c_e=true in maybe_constant_init for
static storage duration variables, mainly for benefit of the call
to maybe_constant_init from expand_default_init.

[1]: this maybe_constant_init call isn't reached in the copy-init
case because there init is a CONSTRUCTOR rather than a TREE_LIST,
and so we exit early from expand_default_init, returning an INIT_EXPR.
This INIT_EXPR is ultimately what causes us to consistently hit the
store_init_value code path from check_initializer in the copy-init case.

PR c++/108243

gcc/cp/ChangeLog:

* constexpr.cc (maybe_constant_init_1): Override
manifestly_const_eval to true if is_static.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/is-constant-evaluated14.C: New test.

16 months agoanalyzer: fix uninit false +ves reading from DECL_HARD_REGISTER [PR108968]
David Malcolm [Thu, 2 Mar 2023 19:01:19 +0000 (14:01 -0500)]
analyzer: fix uninit false +ves reading from DECL_HARD_REGISTER [PR108968]

gcc/analyzer/ChangeLog:
PR analyzer/108968
* region-model.cc (region_model::get_rvalue_1): Handle VAR_DECLs
with a DECL_HARD_REGISTER by returning UNKNOWN.

gcc/testsuite/ChangeLog:
PR analyzer/108968
* gcc.dg/analyzer/uninit-pr108968-register.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agoc++, debug: Fix up locus of DW_TAG_imported_module [PR108716]
Jakub Jelinek [Thu, 2 Mar 2023 18:17:52 +0000 (19:17 +0100)]
c++, debug: Fix up locus of DW_TAG_imported_module [PR108716]

Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct
DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that
change we haven't emitted it at all for a while and after some time
started emitting incorrect locus, in particular the location of } closing
the function.

The problem is that while we have correct EXPR_LOCATION on the USING_STMT,
when genericizing that USING_STMT into IMPORTED_DECL we don't copy the
location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens
to be when it is created.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR debug/108716
* cp-gimplify.cc (cp_genericize_r) <case USING_STMT>: Set
DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
of USING_STMT or input_location.

* g++.dg/debug/dwarf2/pr108716.C: New test.

16 months agovect: Don't apply masks to operations on invariants [PR108979]
Richard Sandiford [Thu, 2 Mar 2023 16:39:50 +0000 (16:39 +0000)]
vect: Don't apply masks to operations on invariants [PR108979]

The loop body in the testcase contains an operation on invariants.
SLP detects this and can hoist/schedule the operation outside of
the loop.  However, after the fix for PR96373, we would try to
apply a loop mask to this operation, even though the mask is
defined in the loop.

The patch does what Richi suggested in the PR: suppress the
masking for externs and constants.

gcc/
PR tree-optimization/108979
* tree-vect-stmts.cc (vectorizable_operation): Don't mask
operations on invariants.

gcc/testsuite/
PR tree-optimization/108979
* gfortran.dg/vect/pr108979.f90: New test.

16 months agoc++: ICE with -Wmismatched-tags and member template [PR106259]
Marek Polacek [Wed, 1 Mar 2023 19:28:46 +0000 (14:28 -0500)]
c++: ICE with -Wmismatched-tags and member template [PR106259]

-Wmismatched-tags warns about the (harmless) struct/class mismatch.
For, e.g.,

  template<typename T> struct A { };
  class A<int> a;

it works by adding A<T> to the class2loc hash table while parsing the
class-head and then, while parsing the elaborate type-specifier, we
add A<int>.  At the end of c_parse_file we go through the table and
warn about the class-key mismatches.  In this PR we crash though; we
have

  template<typename T> struct A {
    template<typename U> struct W { };
  };
  struct A<int>::W<int> w; // #1

where while parsing A and #1 we've stashed
   A<T>
   A<T>::W<U>
   A<int>::W<int>
into class2loc.  Then in class_decl_loc_t::diag_mismatched_tags TYPE
is A<int>::W<int>, and specialization_of gets us A<int>::W<U>, which
is not in class2loc, so we crash on gcc_assert (cdlguide).  But it's
OK not to have found A<int>::W<U>, we should just look one "level" up,
that is, A<T>::W<U>.

It's important to handle class specializations, so e.g.

  template<>
  struct A<char> {
    template<typename U>
    class W { };
  };

where W's class-key is different than in the primary template above,
so we should warn depending on whether we're looking into A<char>
or into a different instantiation.

PR c++/106259

gcc/cp/ChangeLog:

* parser.cc (class_decl_loc_t::diag_mismatched_tags): If the first
lookup of SPEC didn't find anything, try to look for
most_general_template.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-tags-11.C: New test.

16 months agos390: Add LEN_LOAD/LEN_STORE support.
Robin Dapp [Mon, 22 Aug 2022 09:05:39 +0000 (11:05 +0200)]
s390: Add LEN_LOAD/LEN_STORE support.

This patch adds LEN_LOAD/LEN_STORE support for z13 and newer.
It defines a bias value of -1 and implements the LEN_LOAD and LEN_STORE
optabs.

Add vll/vstl testcases adapted from Power.

Also change expectations for SLP testcases with more than one rgroup.

gcc/ChangeLog:

* config/s390/predicates.md (vll_bias_operand): Add -1 bias.
* config/s390/s390.cc (s390_option_override_internal): Make
partial vector usage the default from z13 on.
* config/s390/vector.md (len_load_v16qi): Add.
(len_store_v16qi): Add.

gcc/testsuite/ChangeLog:

* gcc.target/s390/s390.exp: Add partial subdirectory.
* gcc.target/s390/vector/vec-nopeel-2.c: Change test
expectation.
* lib/target-supports.exp: Add s390.
* gcc.target/s390/vector/partial/s390-vec-length-1.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-2.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-3.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-7.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-1.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-2.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-3.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-7.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-small.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length.h: New test.

16 months agosimplify-rtx: Use byte in simplify_subreg rather than assume 0 offset
Andre Vieira [Thu, 2 Mar 2023 14:11:59 +0000 (14:11 +0000)]
simplify-rtx: Use byte in simplify_subreg rather than assume 0 offset

This patch fixes a missed review comment in an earlier patch using byte instead
of a 0 offset.  Also improves the comment as suggested.

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_subreg): Use byte instead
of constant 0 offset.

16 months agogcc.dg/memchr-3.c: Account for LLP64 warnings
Jonathan Yong [Mon, 27 Feb 2023 10:02:32 +0000 (10:02 +0000)]
gcc.dg/memchr-3.c: Account for LLP64 warnings

gcc/testsuite/ChangeLog:

PR middle-end/97956
* gcc.dg/memchr-3.c (memchr): Account for LLP64 warnings.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agogcc.dg/overflow-warn-9.c: Fix LLP64
Jonathan Yong [Mon, 27 Feb 2023 09:49:31 +0000 (09:49 +0000)]
gcc.dg/overflow-warn-9.c: Fix LLP64

gcc/testsuite/ChangeLog:

* gcc.dg/overflow-warn-9.c: Add LLP64 case.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agoMIPS: Bugfix for fix Dejagnu issues with RTL checking enabled.
Robert Suchanek [Thu, 2 Mar 2023 10:37:47 +0000 (10:37 +0000)]
MIPS: Bugfix for fix Dejagnu issues with RTL checking enabled.

gcc/ChangeLog:

* config/mips/mips.cc (mips_set_text_contents_type): Use HOST_WIDE_INT
instead of long.
* config/mips/mips-protos.h (mips_set_text_contents_type): Likewise.

Signed-off-by: Xin Liu <xin.liu@oss.cipunited.com>
16 months agoMIPS: Add buildtime option to set msa default
Junxian Zhu [Thu, 2 Mar 2023 10:30:21 +0000 (10:30 +0000)]
MIPS: Add buildtime option to set msa default

Add buildtime option to decide whether will compiler build with `-mmsa` option default.

gcc/ChangeLog:
* config.gcc: add -with-{no-}msa build option.
* config/mips/mips.h: Likewise.
* doc/install.texi: Likewise.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
16 months agoAvoid creating (const (reg ...)) [PR108603]
Richard Sandiford [Thu, 2 Mar 2023 10:30:21 +0000 (10:30 +0000)]
Avoid creating (const (reg ...)) [PR108603]

convert_memory_address_addr_space_1 has two modes: one in which it
tries to create a self-contained RTL expression (which might fail)
and one in which it can emit new instructions where necessary.

When handling a CONST, the function recurses into the CONST's
operand and then constifies the result.  But that's only valid if
the result is still a self-contained expression.  If new instructions
have been emitted, the expression will refer to the (non-constant)
results of those instructions.

In the PR, this caused us to emit a nonsensical (const (reg ...))
REG_EQUAL note.

gcc/
PR tree-optimization/108603
* explow.cc (convert_memory_address_addr_space_1): Only wrap
the result of a recursive call in a CONST if no instructions
were emitted.

gcc/testsuite/
PR tree-optimization/108603
* gcc.target/aarch64/sve/pr108603.c: New test.

16 months agovect: Fix voluntarily-masked negative conditionals [PR108430]
Richard Sandiford [Thu, 2 Mar 2023 10:30:20 +0000 (10:30 +0000)]
vect: Fix voluntarily-masked negative conditionals [PR108430]

vectorizable_condition checks whether a COND_EXPR condition is used
elsewhere with a loop mask.  If so, it applies the loop mask to the
COND_EXPR too, to reduce the number of live masks and to increase the
chance of combining the AND with the comparison.

There is also code to do this for inverted conditions.  E.g. if
we have a < b ? c : d and something else is conditional on !(a < b)
(such as a load in d), we use !(a < b) ? d : c and apply the loop
mask to !(a < b).

This inversion relied on the function's bitop1/bitop2 mechanism.
However, that mechanism is skipped if the condition is split out of
the COND_EXPR as a separate statement.  This meant that we could end
up using the inverse of the intended condition.

There is a separate way of negating the condition when a mask
is being applied (which is also used for EXTRACT_LAST reductions).
This patch uses that instead.

As well as the testcase, this fixes aarch64/sve/vcond_{4,17}_run.c.

gcc/
PR tree-optimization/108430
* tree-vect-stmts.cc (vectorizable_condition): Fix handling
of inverted condition.

gcc/testsuite/
PR tree-optimization/108430
* gcc.target/aarch64/sve/pr108430.c: New test.

16 months agofold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verificatio...
Jakub Jelinek [Thu, 2 Mar 2023 08:27:40 +0000 (09:27 +0100)]
fold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verification [PR108934]

In the following testcase we try to std::bit_cast a (pair of) integral
value(s) which has some non-zero bits in the place of x86 long double
(for 64-bit 16 byte type with 10 bytes actually loaded/stored by hw,
for 32-bit 12 byte) and starting with my PR104522 change we reject that
as native_interpret_expr fails on it.  The PR104522 change extends what
has been done before for MODE_COMPOSITE_P (but those don't have any padding
bits) to all floating point types, because e.g. the exact x86 long double
has various bit combinations we don't support, like
pseudo-(denormals,infinities,NaNs) or unnormals.  The HW handles some of
those as exceptional cases and others similarly to the non-pseudo ones.
But for the padding bits it actually doesn't load/store those bits at all,
it loads/stores 10 bytes.  So, I think we should exempt the padding bits
from the reverse comparison (the native_encode_expr bits for the padding
will be all zeros), which the following patch does.  For bit_cast it is
similar to e.g. ignoring padding bits if the destination is a structure
which has padding bits in there.

The change changed auto-init-4.c to how it has been behaving before the
PR105259 change, where some more VCEs can be now done.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/108934
* fold-const.cc (native_interpret_expr) <case REAL_CST>: Before memcmp
comparison copy the bytes from ptr to a temporary buffer and clearing
padding bits in there.

* gcc.target/i386/auto-init-4.c: Revert PR105259 change.
* g++.target/i386/pr108934.C: New test.

16 months agoopenmp: Fix up error recovery for invalid structured bindings in OpenMP range for...
Jakub Jelinek [Thu, 2 Mar 2023 08:02:12 +0000 (09:02 +0100)]
openmp: Fix up error recovery for invalid structured bindings in OpenMP range for loops [PR105839]

The PR108503 temporary DECL_HAS_VALUE_EXPR_P clearing code can ICE
during recovery, because cp_finish_decomp when it detects errors and
reports them clears DECL_HAS_VALUE_EXPR_P, clears DECL_VALUE_EXPR and
sets TREE_TYPE of the structured binding vars to error_mark_node.
The PR108503 code had an assertion that DECL_HAS_VALUE_EXPR_P is set
so that it can clear it and restore later.

The following patch allows DECL_HAS_VALUE_EXPR_P to be unset if
type is error_mark_node and doesn't set it again in that case.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/105839
* parser.cc (cp_convert_omp_range_for): Allow in assert
decomp_first_name without DECL_HAS_VALUE_EXPR_P if it has
error_mark_node type.
(cp_finish_omp_range_for): Don't set DECL_HAS_VALUE_EXPR_P back
on decls which have error_mark_node type.

* g++.dg/gomp/pr105839-1.C: New test.
* g++.dg/gomp/pr105839-2.C: New test.

16 months agotestsuite/108985 - missing vect_simd_clones target requirement on test
Richard Biener [Thu, 2 Mar 2023 08:03:37 +0000 (09:03 +0100)]
testsuite/108985 - missing vect_simd_clones target requirement on test

Added.

PR testsuite/108985
* gcc.dg/vect/pr108950.c: Require vect_simd_clones.

16 months agotestsuite: Fix g++.dg/ext/attr-copy-2.C for default_packed targets
Hans-Peter Nilsson [Wed, 1 Mar 2023 17:55:27 +0000 (18:55 +0100)]
testsuite: Fix g++.dg/ext/attr-copy-2.C for default_packed targets

For targets where the byte-wise structure element layout is
the same as for attribute-packed, you get a warning when
that's specified.  Thus, expect a warning for such targets.
Note the exclusion of bitfields.

* g++.dg/ext/attr-copy-2.C: Fix for default_packed targets.

16 months agotestsuite: Fix gcc.dg/attr-copy-6.c for user-label-prefixed targets
Hans-Peter Nilsson [Wed, 1 Mar 2023 16:30:07 +0000 (17:30 +0100)]
testsuite: Fix gcc.dg/attr-copy-6.c for user-label-prefixed targets

This fixes:
 Running /x/gcc/testsuite/gcc.dg/dg.exp ...
 ...
 FAIL: gcc.dg/attr-copy-6.c (test for excess errors)
for cris-elf, where gcc.log has:
Excess errors:
/x/gcc/testsuite/gcc.dg/attr-copy-6.c:91:3: error: 'fnoreturn_alias' aliased to undefined symbol 'fnoreturn_name'

Asm-declared identifiers need to prepend __USER_LABEL_PREFIX__
to the asm-name, something which is often overlooked because
it's empty for most targets.  N.B: attribute-alias does not need
the same treatment.  The identical construct added here, is in
several tests.

* gcc.dg/attr-copy-6.c: Prefix asm-declared name with
__USER_LABEL_PREFIX__.

16 months agoanalyzer: Support errno for newlib
Hans-Peter Nilsson [Wed, 1 Mar 2023 02:54:03 +0000 (03:54 +0100)]
analyzer: Support errno for newlib

Without this definition, the errno definition for newlib
isn't recognized as such, and these tests fail for newlib
targets:

FAIL: gcc.dg/analyzer/call-summaries-errno.c  (test for warnings, line 16)
FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for excess errors)
FAIL: gcc.dg/analyzer/errno-1.c  (test for warnings, line 20)
FAIL: gcc.dg/analyzer/errno-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/flex-without-call-summaries.c (test for excess errors)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 31)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 35)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 46)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 56)
FAIL: gcc.dg/analyzer/isatty-1.c (test for excess errors)

gcc/analyzer:
* kf.cc (register_known_functions): Add __errno function for newlib.

16 months agotestsuite: Handle "packed" targets in c-c++-common/auto-init-7.c and -8.c
Hans-Peter Nilsson [Wed, 15 Feb 2023 19:11:58 +0000 (20:11 +0100)]
testsuite: Handle "packed" targets in c-c++-common/auto-init-7.c and -8.c

Looks like there's a failed assumption that
sizeof (union U { char u1[5]; int u2; float u3; }) == 8.
However, for "packed" targets like cris-elf, it's 5.

These two tests have always failed for cris-elf.  I see from
https://gcc.gnu.org/pipermail/gcc-testresults/2023-February/777912.html
that they fail on pru-elf too, but I don't know if the cause
(and/or remedy) is the same.

IMHO this is preferred over the alternative; splitting up
that last line into two lines, like:
/* { dg-final { scan-tree-dump "temp4 = \
 .DEFERRED_INIT \\(8, 2, \&\"temp4\"" "gimple" { target { ! default_packed } } } } */
/* { dg-final { scan-tree-dump "temp4 = \
 .DEFERRED_INIT \\(5, 2, \&\"temp4\"" "gimple" { target default_packed } } } */

gcc/testsuite:
* c-c++-common/auto-init-7.c, c-c++-common/auto-init-8.c: Also
match targets where sizeof (union U) == 5, like "packed" targets.

16 months agoDaily bump.
GCC Administrator [Thu, 2 Mar 2023 00:17:28 +0000 (00:17 +0000)]
Daily bump.

16 months agoc++: can't eval PTRMEM_CST in incomplete class [PR107574]
Marek Polacek [Thu, 2 Feb 2023 23:15:37 +0000 (18:15 -0500)]
c++: can't eval PTRMEM_CST in incomplete class [PR107574]

Here we're attempting to evaluate a PTRMEM_CST in a class that hasn't
been completed yet, but that doesn't work:

        /* We can't lower this until the class is complete.  */
        if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
          return cst;

and then this unlowered PTRMEM_CST is used as EXPR in

    tree op1 = build_nop (ptrdiff_type_node, expr);

and we crash in a subsequent cp_fold_convert which gets type=ptrdiff_type_node,
expr=PTRMEM_CST and does

  else if (TREE_CODE (expr) == PTRMEM_CST
           && same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
                           PTRMEM_CST_CLASS (expr)))

where TYPE_PTRMEM_CLASS_TYPE (type) is going to crash since the type
is ptrdiff_type_node.  We could just add a TYPE_PTRMEM_P check before
accessing TYPE_PTRMEM_CLASS_TYPE but I think it's nicer to explain why
we couldn't evaluate the expression.

PR c++/107574

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression): Emit an error when
a PTRMEM_CST cannot be evaluated.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/ptrmem-cst1.C: New test.

16 months agoc++: streamline tf_qualifying_scope usage
Patrick Palka [Wed, 1 Mar 2023 23:25:44 +0000 (18:25 -0500)]
c++: streamline tf_qualifying_scope usage

This patch introduces a convenience wrapper tsubst_scope for tsubst'ing
into a type with tf_qualifying_scope set, and makes suitable callers use
it instead of explicitly setting tf_qualifying_scope.  This patch also
makes tsubst_copy immediately delegate to tsubst for all type trees,
which allows tsubst_copy to be oblivious to the tf_qualifying_scope flag.

gcc/cp/ChangeLog:

* pt.cc (tsubst_scope): Define.
(tsubst_decl) <case USING_DECL>: Call tsubst_scope instead of
calling tsubst_scope with tf_qualifying_scope set.
(tsubst_qualified_id): Call tsubst_scope instead of
calling tsubst with tf_qualifying_scope set.
(tsubst_copy): Immediately delegate to tsubst for all TYPE_P
trees.  Remove tf_qualifying_scope manipulation.
<case SCOPE_REF>: Call tsubst_scope instead of calling
tsubst with tf_qualifying_scope set.

16 months agoanalyzer: fixes to side-effects for built-in functions [PR107565]
David Malcolm [Wed, 1 Mar 2023 22:24:32 +0000 (17:24 -0500)]
analyzer: fixes to side-effects for built-in functions [PR107565]

Previously, if the analyzer saw a call to a non-pure and non-const
built-in function that it didn't have explicit knowledge of the behavior
of, it would fall back to assuming that the builtin could have arbitrary
behavior, similar to a function defined outside of the current TU.

However, this only worked for BUILTIN_NORMAL functions that matched
gimple_builtin_call_types_compatible_p; for BUILT_IN_FRONTEND and
BUILT_IN_MD, and for mismatched types the analyzer would erroneously
assume that the builtin had no side-effects, leading e.g. to
PR analyzer/107565, where the analyzer falsely reported that x
was still uninitialized after this target-specific builtin:

  _1 = __builtin_ia32_rdrand64_step (&x);

This patch generalizes the handling to cover all classes of builtin,
fixing the above false positive.

Unfortunately this patch regresses gcc.dg/analyzer/pr99716-1.c due to
the:
  fprintf (fp, "hello");
being optimized to:
   __builtin_fwrite ("hello", 1, (ssizetype)5, fp_6);
and the latter has gimple_builtin_call_types_compatible_p return false,
whereas the original call had it return true.  I'm assuming that this is
an optimization bug, and have filed it as PR middle-end/108988.  The
effect on the analyzer is that it fails to recognize the call to
__builtin_fwrite and instead assumes arbitraty side-effects (including
that it could call fclose on fp, hence the report about the leak goes
away).

I tried various more involved fixes with new heuristics for handling
built-ins that aren't explicitly covered by the analyzer, but those
fixes tended to introduce many more regressions, so I'm going with this
simpler fix.

gcc/analyzer/ChangeLog:
PR analyzer/107565
* region-model.cc (region_model::on_call_pre): Flatten logic by
returning early.  Consolidate logic for detecting const and pure
functions.  When considering whether an unhandled built-in
function has side-effects, consider all kinds of builtin, rather
than just BUILT_IN_NORMAL, and don't require
gimple_builtin_call_types_compatible_p.

gcc/testsuite/ChangeLog:
PR analyzer/107565
* gcc.dg/analyzer/builtins-pr107565.c: New test.
* gcc.dg/analyzer/pr99716-1.c (test_2): Mark the leak as xfailing.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agolibstdc++: Fix typo in comment in bits/cow_string.h
Jonathan Wakely [Wed, 1 Mar 2023 18:58:38 +0000 (18:58 +0000)]
libstdc++: Fix typo in comment in bits/cow_string.h

libstdc++-v3/ChangeLog:

* include/bits/cow_string.h: Fix typo in comment.

16 months agolibstdc++: Make std::chrono::current_zone() default to UTC
Jonathan Wakely [Tue, 28 Feb 2023 21:07:48 +0000 (21:07 +0000)]
libstdc++: Make std::chrono::current_zone() default to UTC

This is consistent with the behaviour of glibc, which assumes UTC when
/etc/localtime and TZ do not identify a valid time zone. The fallback
tzdb used when no valid tzdata exists always contains the UTC zone, so
this change means we have a valid tzdb and valid current zone even in
the degenerate case.

With this default we no longer need the AIX-specific kluge to try and
identify TZ values specifying a 0-offset zone. We can just use the UTC
default for those, as it has the same effect.

It's still possible for chrono::current_zone() to fail, because the user
could have provided a custom tzdata.zi file which doesn't contain the
UTC time zone, so the "UTC" default would fail to find a valid zone, and
throw an exception. That's just user error, they should not provide bad
data and expect reasonable behaviour.

libstdc++-v3/ChangeLog:

* src/c++20/tzdb.cc (chrono::tzdb::current_zone()) Use "UTC" if
current time zone cannot be determined.
* testsuite/std/time/tzdb/1.cc: Remove conditions based on
HAVE_TZDB macro and test all members unconditionally.

16 months agoc++: unevaluated array new-expr size constantness [PR108219]
Patrick Palka [Wed, 1 Mar 2023 19:09:37 +0000 (14:09 -0500)]
c++: unevaluated array new-expr size constantness [PR108219]

Here we're mishandling the unevaluated array new-expressions due to a
supposed non-constant array size ever since r12-5253-g4df7f8c79835d569
made us no longer perform constant evaluation of non-manifestly-constant
expressions within unevaluated contexts.  This shouldn't make a difference
here since the array sizes are constant literals, except they're expressed
as NON_LVALUE_EXPR location wrappers around INTEGER_CST, wrappers which
used to get stripped as part of constant evaluation and now no longer do.
Moreover it means build_vec_init can't constant fold the MINUS_EXPR
'maxindex' passed from build_new_1 when in an unevaluated context (since
it tries reducing it via maybe_constant_value called with mce_unknown).

This patch fixes these issues by making maybe_constant_value (and
fold_non_dependent_expr) try folding an unevaluated non-manifestly-constant
operand via fold(), as long as it simplifies to a simple constant, rather
than doing no simplification at all.  This covers e.g. simple arithmetic
and casts including stripping of location wrappers around INTEGER_CST.

In passing, this patch also fixes maybe_constant_value to avoid constant
evaluating an unevaluated operand when called with mce_false, by adjusting
the early exit test appropriately.

Co-authored-by: Jason Merrill <jason@redhat.com>
PR c++/108219
PR c++/108218

gcc/cp/ChangeLog:

* constexpr.cc (fold_to_constant): Define.
(maybe_constant_value): Move up early exit test for unevaluated
operands.  Try reducing an unevaluated operand to a constant via
fold_to_constant.
(fold_non_dependent_expr_template): Add early exit test for
CONSTANT_CLASS_P nodes.  Try reducing an unevaluated operand
to a constant via fold_to_constant.
* cp-tree.h (fold_to_constant): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/new6.C: New test.
* g++.dg/cpp2a/concepts-new1.C: New test.

16 months agoOpenMP: Ignore side-effects when finding struct comps [PR108545]
Tobias Burnus [Wed, 1 Mar 2023 14:11:53 +0000 (15:11 +0100)]
OpenMP: Ignore side-effects when finding struct comps [PR108545]

With volatile, two 'x.data' comp refs aren't regarded as identical,
causing that the two items in the first map of
  map(to:x.a, x.a.data) map(pset: x.a.data)
end up in separate 'map(struct:x)', which will cause a later ICE.

Solution: Ignore side effects when checking the operands in the hash
for being equal. (Do so by creating a variant of tree_operand_hash
that calls operand_equal_p with OEP_MATCH_SIDE_EFFECTS.)

gcc/ChangeLog:

PR middle-end/108545
* gimplify.cc (struct tree_operand_hash_no_se): New.
(omp_index_mapping_groups_1, omp_index_mapping_groups,
omp_reindex_mapping_groups, omp_mapped_by_containing_struct,
omp_tsort_mapping_groups_1, omp_tsort_mapping_groups,
oacc_resolve_clause_dependencies, omp_build_struct_sibling_lists,
gimplify_scan_omp_clauses): Use tree_operand_hash_no_se instead
of tree_operand_hash.

gcc/testsuite/ChangeLog:

PR middle-end/108545
* c-c++-common/gomp/map-8.c: New test.
* gfortran.dg/gomp/map-9.f90: New test.

16 months agoanalyzer: fix infinite recursion false +ves [PR108935]
David Malcolm [Wed, 1 Mar 2023 13:54:43 +0000 (08:54 -0500)]
analyzer: fix infinite recursion false +ves [PR108935]

gcc/analyzer/ChangeLog:
PR analyzer/108935
* infinite-recursion.cc (contains_unknown_p): New.
(sufficiently_different_region_binding_p): New function, splitting
out inner loop from...
(sufficiently_different_p): ...here.  Extend detection of unknown
svalues to also include svalues that contain unknown.  Treat
changes in frames below the entry to the recursion as being
sufficiently different to reject being an infinite recursion.

gcc/testsuite/ChangeLog:
PR analyzer/108935
* gcc.dg/analyzer/infinite-recursion-pr108935-1.c: New test.
* gcc.dg/analyzer/infinite-recursion-pr108935-1a.c: New test.
* gcc.dg/analyzer/infinite-recursion-pr108935-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agogcc: Remove size limit of PCH for *-*-mingw32 hosts
LIU Hao [Tue, 10 May 2022 05:19:07 +0000 (13:19 +0800)]
gcc: Remove size limit of PCH for *-*-mingw32 hosts

PCHs can now be relocated, so the size limit makes no sense any more.

This patch was submited to MSYS2 9 months ago for GCC 12. No issue has been reported so far.

Reference: https://github.com/msys2/MINGW-packages/blob/717d5a5a09e2370e3bd7e12b393a26dbfbe48921/mingw-w64-gcc/0010-Fix-using-large-PCH.patch
Signed-off-by: LIU Hao <lh_mouse@126.com>
gcc/ChangeLog:

PR pch/14940
* config/i386/host-mingw32.cc (mingw32_gt_pch_get_address):
Remove the size limit `pch_VA_max_size`

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agoharden-sls-6.c: Fix warning on LLP64
Jonathan Yong [Wed, 15 Feb 2023 13:42:12 +0000 (13:42 +0000)]
harden-sls-6.c: Fix warning on LLP64

gcc/testsuite/ChangeLog:

* gcc.target/i386/harden-sls-6.c: Fix warning on LLP64
targets.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agoOpenMP/Fortran: Fix handling of optional is_device_ptr + bind(C) [PR108546]
Tobias Burnus [Wed, 1 Mar 2023 12:53:09 +0000 (13:53 +0100)]
OpenMP/Fortran: Fix handling of optional is_device_ptr + bind(C) [PR108546]

For is_device_ptr, optional checks should only be done before calling
libgomp, afterwards they are NULL either because of absent or, by
chance, because it is unallocated or unassociated (for pointers/allocatables).

Additionally, it fixes an issue with explicit mapping for 'type(c_ptr)'.

PR middle-end/108546

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_trans_omp_clauses): Fix mapping of
type(C_ptr) variables.

gcc/ChangeLog:

* omp-low.cc (lower_omp_target): Remove optional handling
on the receiver side, i.e. inside target (data), for
use_device_ptr.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/is_device_ptr-3.f90: New test.
* testsuite/libgomp.fortran/use_device_ptr-optional-4.f90: New test.

16 months agoubsan: Add another testcase for [0] array in the middle of struct [PR108894]
Jakub Jelinek [Wed, 1 Mar 2023 09:49:38 +0000 (10:49 +0100)]
ubsan: Add another testcase for [0] array in the middle of struct [PR108894]

I think it is useful to cover also this, rather than just arrays at the
flexible array member positions.

2023-03-01  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/108894
* c-c++-common/ubsan/bounds-16.c: New test.

16 months agocfgexpand: Handle WIDEN_{PLUS,MINUS}_EXPR and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR...
Jakub Jelinek [Wed, 1 Mar 2023 09:26:46 +0000 (10:26 +0100)]
cfgexpand: Handle WIDEN_{PLUS,MINUS}_EXPR and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR in expand_debug_expr [PR108967]

When these tree codes were introduced, expand_debug_expr hasn't been
updated to handle them.  For the VEC_*_EXPR we currently mostly punt, the
non-vector ones can be handled easily.  In release compilers this doesn't
ICE, but with checking we ICE so that we make sure to handle all the needed
tree codes there.

2023-03-01  Jakub Jelinek  <jakub@redhat.com>

PR debug/108967
* cfgexpand.cc (expand_debug_expr): Handle WIDEN_{PLUS,MINUS}_EXPR
and VEC_WIDEN_{PLUS,MINUS}_{HI,LO}_EXPR.

* g++.dg/debug/pr108967.C: New test.

16 months agoc++: Don't recurse on DECL_INITIAL for DECL_EXPR on non-VAR_DECLs [PR108606]
Jakub Jelinek [Wed, 1 Mar 2023 09:22:59 +0000 (10:22 +0100)]
c++: Don't recurse on DECL_INITIAL for DECL_EXPR on non-VAR_DECLs [PR108606]

The r13-2965-g73d9b0e5947e16 change changed the line touched in this patch
from
      return RECUR (tmp, want_rval);
to
      return RECUR (DECL_INITIAL (tmp), want_rval);
This is on DECL_EXPR handling code, where tmp can be lots of different
trees and DECL_INITIAL unfortunately also means different things on
different trees.
It is the initializer on VAR_DECL, DECL_ARG_TYPE on PARM_DECLs (though
those are unlikely to have DECL_EXPRs), for FUNCTION_DECLs the body,
..., USING_DECL_DECLS on USING_DECLs and DECL_FRIENDLIST on TYPE_DECLs.

The testcase below ICEs because we have a DECL_EXPR for TYPE_DECL
which has non-NULL DECL_FRIENDLIST and we certainly can't recurse on
the friend list.

The following patch will RECUR on DECL_INITIAL only for VAR_DECLs and
for anything else just return true.

2023-03-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/108606
* constexpr.cc (potential_constant_expression_1) <case DECL_EXPR>:
Only recurse on DECL_INITIAL (tmp) if tmp is a VAR_DECL, otherwise
just return true.

* g++.dg/cpp1y/pr108606.C: New test.

16 months agotree-optimization/108970 - ICE with vectorizer peeling
Richard Biener [Wed, 1 Mar 2023 08:10:19 +0000 (09:10 +0100)]
tree-optimization/108970 - ICE with vectorizer peeling

The function slpeel_can_duplicate_loop_p fails to verify we can
copy blocks, instead slpeel_tree_duplicate_loop_to_edge_cfg does
but that's too late.  The following fixes this, also simplifying
error reporting which is somewhat pointless if we ICE immediately.

PR tree-optimization/108970
* tree-vect-loop-manip.cc (slpeel_can_duplicate_loop_p):
Check we can copy the BBs.
(slpeel_tree_duplicate_loop_to_edge_cfg): Avoid redundant
check.
(vect_do_peeling): Streamline error handling.

* gcc.dg/pr108970.c: New testcase.

16 months agolto: Fix up lto_fixup_prevailing_type [PR108910]
Jakub Jelinek [Wed, 1 Mar 2023 08:54:52 +0000 (09:54 +0100)]
lto: Fix up lto_fixup_prevailing_type [PR108910]

Without LTO, TYPE_POINTER_TO/TYPE_REFERENCE_TO chains are only maintained
inside of build_{pointer,reference}_type_for_mode and those routines
ensure that the pointer/reference type added to the chain is really
without any user attributes (unless something would modify the types
in place, but that would be wrong).

Now, LTO adds stuff to these chains in lto_fixup_prevailing_type but
doesn't guarantee that.  The testcase in the PR (which I'm not including
for testsuite because when (I hope) the aarch64 backend bug will be fixed,
the testcase would work either way) shows a case where user has
TYPE_USER_ALIGN type with very high alignment, as there aren't enough
pointers to float in the code left that one becomes the prevailing one
(because types with attributes are created with build_distinct_type_copy
and thus their own TYPE_MAIN_VARIANTs), lto_fixup_prevailing_type puts
it into the TYPE_POINTER_TO chain of float and later on during expansion
of __builtin_cexpif expander uses build_pointer_type (float_type_node)
to emit a sincosf call and instead of getting a normal pointer type gets
this non-standard one.

The following patch fixes that by not adding into those chains
types with TYPE_ATTRIBUTES, and for REFERENCE_TYPEs not even with
TYPE_REF_IS_RVALUE - while the C++ FE adds those into those chains,
it always ensures such a type goes immediately after the corresponding
non-TYPE_REF_IS_RVALUE REFERENCE_TYPE with the same
mode/TYPE_REF_CAN_ALIAS_ALL, so LTO would need to ensure that too, but
TYPE_REF_IS_RVALUE types are looked that way only in the C++ FE.

2023-03-01  Jakub Jelinek  <jakub@redhat.com>

PR target/108910
* lto-common.cc (lto_fixup_prevailing_type): Don't add t to
TYPE_POINTER_TO or TYPE_REFERENCE_TO chain if it has
TYPE_ATTRIBUTES or is TYPE_REF_IS_RVALUE.

16 months agotree-optimization/108950 - widen-sum reduction ICE
Richard Biener [Tue, 28 Feb 2023 14:34:27 +0000 (15:34 +0100)]
tree-optimization/108950 - widen-sum reduction ICE

When we end up with a widen-sum with an invariant smaller operand
the reduction code uses a wrong vector type for it, causing
IL checking ICEs.  The following fixes that and the inefficiency
of using a widen-sum with a widenend invariant operand as well
by actually performing the check the following comment wants.

PR tree-optimization/108950
* tree-vect-patterns.cc (vect_recog_widen_sum_pattern):
Check oprnd0 is defined in the loop.
* tree-vect-loop.cc (vectorizable_reduction): Record all
operands vector types, compute that of invariants and
properly update their SLP nodes.

* gcc.dg/vect/pr108950.c: New testcase.

16 months agors6000: Allow powerpc64 to be unset for implicit 64 bit [PR108240]
Kewen Lin [Wed, 1 Mar 2023 05:17:48 +0000 (23:17 -0600)]
rs6000: Allow powerpc64 to be unset for implicit 64 bit [PR108240]

Before r13-4894, if 64 bit is explicitly specified, option
powerpc64 is explicitly enabled too; while if 64 bit is
implicitly enabled and there is no explicit setting for
option powerpc64, option powerpc64 is eventually enabled
or not would rely on the default value of the used cpu.
It's initially set as the setting for 64 bit, but later if
the used cpu doesn't have powerpc64 supported by default,
it gets cleared.

To keep it consistent with before (also the relevant error/
warning messages), this patch is to allow that powerpc64
can be unset if 64 bit is enabled implicitly, and only stop
it from being unset if 64 bit is enabled explicitly.

Note that since the behaviors are different for implicit
and explicit 64 bit, I failed to construct one solid test
case since it becomes fragile once RUNTESTFLAGS specifying
-m64 explicitly.

PR target/108240

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Allow
implicit powerpc64 setting to be unset if 64 bit is enabled implicitly.

16 months agotestsuite: Fix analyzer errors for newlib-fd
Hans-Peter Nilsson [Tue, 28 Feb 2023 17:37:32 +0000 (18:37 +0100)]
testsuite: Fix analyzer errors for newlib-fd

Investigating analyzer testsuite errors for cris-elf.  The same are
seen for pru-elf according to posts to gcc-testresults@.

The test fd-access-mode-target-headers.c uses the analyzer
"sm-fd" which for this use requires (e.g.) that constants
O_ACCMODE, O_RDONLY and O_WRONLY are defined as literal
constants.  While for glibc, O_ACCMODE is defined as:
 #define O_ACCMODE 0003
in newlib, it's defined as:
 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
and the analyzer is not able to make use of an expression
like this (even though O_RDONLY, O_WRONLY and O_RDWR are
defined as literal constants and the whole evaluates to 3).
Better do as for AIX and skip this test.

testsuite:
* gcc.dg/analyzer/fd-access-mode-target-headers.c: Skip for
newlib targets too.

16 months agoDaily bump.
GCC Administrator [Wed, 1 Mar 2023 00:18:20 +0000 (00:18 +0000)]
Daily bump.

16 months agoc++: non-dependent variable template-id [PR108848]
Patrick Palka [Tue, 28 Feb 2023 20:05:30 +0000 (15:05 -0500)]
c++: non-dependent variable template-id [PR108848]

Here we're treating deeming the non-dependent variable template-id
tag<int> as dependent ever since r226642 gave variable TEMPLATE_ID_EXPR
an empty type, which causes the call to finish_template_variable from
finish_id_expression_1 to be unreachable at template parse time.  Thus
we're led into thinking tag<int>.var<void> refers to a dependent name.

This patch fixes this by making finish_id_expression_1 instantiate a
variable template-id as long as it's not dependent according to the
dependence test in lookup_and_finish_template_variable rather than
according to type_dependent_expression_p.

PR c++/108848

gcc/cp/ChangeLog:

* pt.cc (finish_template_variable): Move dependence check
to here from ...
(lookup_and_finish_template_variable): ... here.
* semantics.cc (finish_id_expression_1): Call
finish_template_variable sooner, before (and regardless of) the
type_dependent_expression_p test.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/noexcept1.C: Don't expect a bogus "different
exception specifier" error.  Expect a separate "not usable
in a constant expression" error.
* g++.dg/cpp1y/var-templ75.C: New test.
* g++.dg/cpp1y/var-templ76.C: New test.

16 months agoFixing PR107411
Qing Zhao [Tue, 28 Feb 2023 17:11:05 +0000 (17:11 +0000)]
Fixing PR107411

This is a bug in tree-ssa-uninit.cc.
When doing the following:

  /* Ignore the call to .DEFERRED_INIT that define the original
     var itself as the following case:
       temp = .DEFERRED_INIT (4, 2, “alt_reloc");
       alt_reloc = temp;
     In order to avoid generating warning for the fake usage
     at alt_reloc = temp.
  */

We need to compare the var name inside the .DEFERRED_INIT call
(the 3rd argument) and the name for the LHS variable. if they are the same,
we will NOT report the warning.

There is one issue when we get the name for the LHS variable. when the
variable doesn't have a DECL_NAME (it's not a user declared variable,
which is the case for this bug):

  _1 = .DEFERRED_INIT (4, 2, &"D.2389"[0]);
  D.2389 = _1;

The current checking just ignores this case, and still report the warning.

The fix is very simple, when getting the name for the LHS variable, we should
consider this case and come up with the name the same way as we construct the
3rd argument for the call to .DEFERRED_INIT (please refer to the routine
"gimple_add_init_for_auto_var")

PR middle-end/107411

gcc/ChangeLog:

PR middle-end/107411
* gimplify.cc (gimple_add_init_for_auto_var): Use sprintf to replace
xasprintf.
* tree-ssa-uninit.cc (warn_uninit): Handle the case when the
LHS varaible of a .DEFERRED_INIT call doesn't have a DECL_NAME.

gcc/testsuite/ChangeLog:

PR middle-end/107411
* g++.dg/pr107411.C: New test.

16 months agoFix build warnings noreturn M2RTS and fix calls to RegisterModule [PR108956]
Gaius Mulley [Tue, 28 Feb 2023 15:35:12 +0000 (15:35 +0000)]
Fix build warnings noreturn M2RTS and fix calls to RegisterModule [PR108956]

mc needs a fix to optionally suppress the generation of the noreturn
attribute when building M2RTS.  All the hand built C++ modules calling
RegisterModule must supply the library name.  These changes require
the boot strap tools mc and pge to be rebuilt.

gcc/m2/ChangeLog:

PR modula2/108956
* Make-lang.in (m2/gm2-libs-boot/M2RTS.o): New specific rule to
add the --suppress-noreturn option.
* Make-maintainer.in (m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.o): New
specific rule to add the --suppress-noreturn option.
(m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.o): New
specific rule to add the --suppress-noreturn option.
(m2/gm2-pg-boot/$(SRC_PREFIX)%.o): Add missing $(srcdir).
(m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o): New
specific rule to add the --suppress-noreturn option.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Add missing $(srcdir).
* gm2-libs-ch/UnixArgs.cc (LIBNAME): New define.
(_M2_UnixArgs_ctor): Add LIBNAME parameter to RegisterModule.
* gm2-libs-ch/dtoa.cc (LIBNAME): New define.
(_M2_dtoa_ctor): Add LIBNAME parameter to RegisterModule.
* gm2-libs-ch/ldtoa.cc (LIBNAME): New define.
(_M2_ldtoa_ctor): Add LIBNAME parameter to RegisterModule.
* pge-boot/m2rts.h (M2RTS_RegisterModule): Add libname
parameter.
* gm2-libs-ch/m2rts.h (M2RTS_RegisterModule): Add libname
parameter.
* mc-boot-ch/GUnixArgs.cc (_M2_UnixArgs_ctor): Remove.
* pge-boot/GUnixArgs.cc (LIBNAME): New define.
(_M2_UnixArgs_ctor): Add LIBNAME parameter to RegisterModule.
* gm2-libs/RTint.def (AttachVector): Rename parameter.
* mc-boot/GDynamicStrings.c: Rebuilt.
* mc-boot/GFIO.c: Rebuilt.
* mc-boot/GIndexing.c: Rebuilt.
* mc-boot/GM2EXCEPTION.c: Rebuilt.
* mc-boot/GPushBackInput.c: Rebuilt.
* mc-boot/GRTExceptions.c: Rebuilt.
* mc-boot/GRTint.c: Rebuilt.
* mc-boot/GRTint.h: Rebuilt.
* mc-boot/GStdIO.c: Rebuilt.
* mc-boot/GStringConvert.c: Rebuilt.
* mc-boot/GSysStorage.c: Rebuilt.
* mc-boot/Gdecl.c: Rebuilt.
* mc-boot/Gkeyc.c: Rebuilt.
* mc-boot/GmcComment.c: Rebuilt.
* mc-boot/GmcComp.c: Rebuilt.
* mc-boot/GmcDebug.c: Rebuilt.
* mc-boot/GmcMetaError.c: Rebuilt.
* mc-boot/GmcOptions.c: Rebuilt.
* mc-boot/GmcOptions.h: Rebuilt.
* mc-boot/GmcStack.c: Rebuilt.
* mc-boot/GnameKey.c: Rebuilt.
* mc-boot/GsymbolKey.c: Rebuilt.
* mc/decl.mod:: Rebuilt.
* mc/mcOptions.def: Rebuilt.
* mc/mcOptions.mod:: Rebuilt.
* pge-boot/GDynamicStrings.c: Rebuilt.
* pge-boot/GFIO.c: Rebuilt.
* pge-boot/GIndexing.c: Rebuilt.
* pge-boot/GM2EXCEPTION.c: Rebuilt.
* pge-boot/GM2RTS.c: Rebuilt.
* pge-boot/GNameKey.c: Rebuilt.
* pge-boot/GPushBackInput.c: Rebuilt.
* pge-boot/GRTExceptions.c: Rebuilt.
* pge-boot/GStdIO.c: Rebuilt.
* pge-boot/GSymbolKey.c: Rebuilt.
* pge-boot/GSysStorage.c: Rebuilt.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
16 months agoc++: variable template and targ deduction [PR108550]
Marek Polacek [Wed, 22 Feb 2023 00:13:59 +0000 (19:13 -0500)]
c++: variable template and targ deduction [PR108550]

In this test, we get a bogus error because we failed to deduce the auto in
constexpr auto is_pointer_v = is_pointer<Tp>::value;
to bool.  Then ensure_literal_type_for_constexpr_object thinks the object
isn't literal and an error is reported.

This is another case of the interaction between tf_partial and 'auto',
where the auto was not reduced so the deduction failed.  In more detail:
we have

  Wrap1<int>()

in the code and we need to perform OR -> fn_type_unification.  The targ
list is incomplete, so we do
      tsubst_flags_t ecomplain = complain | tf_partial | tf_fndecl_type;
      fntype = tsubst (TREE_TYPE (fn), explicit_targs, ecomplain, NULL_TREE);
where TREE_TYPE (fn) is struct integral_constant <T402> (void).  Then
we substitute the return type, which results in tsubsting is_pointer_v<int>.
is_pointer_v is a variable template with a placeholder type:

  template <class Tp>
  constexpr auto is_pointer_v = is_pointer<Tp>::value;

so we find ourselves in lookup_and_finish_template_variable.  tf_partial is
still set, so finish_template_variable -> instantiate_template -> tsubst
won't reduce the level of auto.  But then we do mark_used which eventually
calls do_auto_deduction which clears tf_partial, because we want to replace
the auto now.  But we hadn't reduced auto's level so this fails.  And
since we're not in an immediate context, we emit a hard error.

I suppose that when we reach lookup_and_finish_template_variable it's
probably time to clear tf_partial.  (I added an assert and our testsuite
doesn't have a test whereby we get to lookup_and_finish_template_variable
while tf_partial is still active.)

PR c++/108550

gcc/cp/ChangeLog:

* pt.cc (lookup_and_finish_template_variable): Clear tf_partial.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/var-templ70.C: New test.
* g++.dg/cpp1y/var-templ71.C: New test.
* g++.dg/cpp1y/var-templ72.C: New test.

16 months agoc++: ICE with constexpr variable template [PR107938]
Marek Polacek [Thu, 23 Feb 2023 22:54:47 +0000 (17:54 -0500)]
c++: ICE with constexpr variable template [PR107938]

Since r11-557, cp_finish_decl can call check_initializer even in
a template for a constexpr initializer.  That ultimately leads to
convert_for_assignment and check_address_or_pointer_of_packed_member,
where we crash, because it doesn't expect that the CALL_EXPR is
a function object.  Q has a constexpr operator(), but since we're
in a template, q(0) is a CALL_EXPR whose CALL_EXPR_FN is just
a VAR_DECL; it hasn't been converted to Q::operator<int>(&q, 0) yet.
I propose to robustify check_address_or_pointer_of_packed_member.

var-templ74.C has an XFAIL, subject to 107939.

I noticed that our -Waddress-of-packed-member tests weren't testing
member functions, added thus.  (I was tempted to check
FUNCTION_POINTER_TYPE_P but that doesn't include METHOD_TYPE.)

PR c++/107938

gcc/c-family/ChangeLog:

* c-warn.cc (check_address_or_pointer_of_packed_member): Check
POINTER_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/var-templ73.C: New test.
* g++.dg/cpp1y/var-templ74.C: New test.
* g++.dg/warn/Waddress-of-packed-member3.C: New test.

16 months agoubsan: Honor -fstrict-flex-arrays= in -fsanitize=bounds [PR108894]
Jakub Jelinek [Tue, 28 Feb 2023 10:38:46 +0000 (11:38 +0100)]
ubsan: Honor -fstrict-flex-arrays= in -fsanitize=bounds [PR108894]

While this isn't really a regression, the -fstrict-flex-arrays*
option is new in GCC 13 and so I think we should make -fsanitize=bounds
play with it well from the beginning.

The current behavior is that -fsanitize=bounds considers all trailing
arrays as flexible member-like arrays and both -fsanitize=bounds and
-fsanitize=bounds-strict because of a bug don't even instrument
[0] arrays at all, not as trailing nor when followed by other members.

I think -fstrict-flex-arrays* options can be considered as language
mode changing options, by default flexible member-like arrays are
handled like flexible arrays, but that option can change the set of
the arrays which are treated like that.  So, -fsanitize=bounds should
change with that on what is considered acceptable and what isn't.
While -fsanitize=bounds-strict should reject them all always to
continue previous behavior.

The following patch implements that.  To support [0] array instrumentation,
I had to change the meaning of the bounds argument to .UBSAN_BOUNDS,
previously it was the TYPE_MAX_VALUE of the domain unless ignore_off_by_one
(used for taking address of the array element rather than accessing it;
in that case 1 is added to the bound argument) and the later lowered checks
were if (index > bound) report_failure ().
The problem with that is that for [0] arrays where (at least for C++)
the max value is all ones, for accesses that condition will be never true;
for addresses of elements it was working (in C++) correctly before.
This patch changes it to add 1 + ignore_off_by_one, so -1 becomes 0 or
1 for &array_ref and changing the lowering to be if (index >= bound)
report_failure ().  Furthermore, as C represents the [0] arrays with
NULL TYPE_MAX_VALUE, I treated those like the C++ ones.

2023-02-28  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/108894
gcc/
* ubsan.cc (ubsan_expand_bounds_ifn): Emit index >= bound
comparison rather than index > bound.
* gimple-fold.cc (gimple_fold_call): Use tree_int_cst_lt
rather than tree_int_cst_le for IFN_UBSAN_BOUND comparison.
* doc/invoke.texi (-fsanitize=bounds): Document that whether
flexible array member-like arrays are instrumented or not depends
on -fstrict-flex-arrays* options of strict_flex_array attributes.
(-fsanitize=bounds-strict): Document that flexible array members
are not instrumented.
gcc/c-family/
* c-common.h (c_strict_flex_array_level_of): Declare.
* c-common.cc (c_strict_flex_array_level_of): New function,
moved and renamed from c-decl.cc's strict_flex_array_level_of.
* c-ubsan.cc (ubsan_instrument_bounds): Fix comment typo.  For
C check c_strict_flex_array_level_of whether a trailing array
should be treated as flexible member like.  Handle C [0] arrays.
Add 1 + index_off_by_one rather than index_off_by_one to bounds
and use tree_int_cst_lt rather than tree_int_cst_le for idx vs.
bounds comparison.
gcc/c/
* c-decl.cc (strict_flex_array_level_of): Move to c-common.cc
and rename to c_strict_flex_array_level_of.
(is_flexible_array_member_p): Adjust caller.
gcc/testsuite/
* gcc.dg/ubsan/bounds-4.c: New test.
* gcc.dg/ubsan/bounds-4a.c: New test.
* gcc.dg/ubsan/bounds-4b.c: New test.
* gcc.dg/ubsan/bounds-4c.c: New test.
* gcc.dg/ubsan/bounds-4d.c: New test.
* g++.dg/ubsan/bounds-1.C: New test.

16 months agotestsuite/108942 - use sizetype in GIMPLE FE testcase
Richard Biener [Tue, 28 Feb 2023 10:36:01 +0000 (11:36 +0100)]
testsuite/108942 - use sizetype in GIMPLE FE testcase

The following properly uses __SIZETYPE__ for pointer offsets.

PR testsuite/108942
* gcc.dg/torture/ssa-fre-7.c: Use __SIZETYPE__.

16 months agolibstdc++: Fix uses_allocator_construction_args for pair<T&&, U&&> [PR108952]
Jonathan Wakely [Mon, 27 Feb 2023 22:34:57 +0000 (22:34 +0000)]
libstdc++: Fix uses_allocator_construction_args for pair<T&&, U&&> [PR108952]

This implements LWG 3527 which fixes the handling of pair<T&&, U&&> in
std::uses_allocator_construction_args.

libstdc++-v3/ChangeLog:

PR libstdc++/108952
* include/bits/uses_allocator_args.h
(uses_allocator_construction_args): Implement LWG 3527.
* testsuite/20_util/pair/astuple/get-2.cc: New test.
* testsuite/20_util/scoped_allocator/108952.cc: New test.
* testsuite/20_util/uses_allocator/lwg3527.cc: New test.

16 months agolibstdc++: Do not use memmove for 1-element ranges [PR108846]
Jonathan Wakely [Sat, 25 Feb 2023 14:28:36 +0000 (14:28 +0000)]
libstdc++: Do not use memmove for 1-element ranges [PR108846]

This avoids overwriting tail padding when algorithms like std::copy are
used to write a single value through a pointer to a base subobject.

The pointer arithmetic on a Base* is valid for N==1, but the copy/move
operation needs to be done using assignment, not a memmove or memcpy of
sizeof(Base) bytes.

Instead of putting a check for N==1 in all of copy, copy_n, move etc.
this adds it to the __copy_move and __copy_move_backward partial
specializations used for trivially copyable types. When N==1 those
partial specializations dispatch to new static member functions of the
partial specializations for non-trivial types, so that a copy/move
assignment is done appropriately for the _IsMove constant.

libstdc++-v3/ChangeLog:

PR libstdc++/108846
* include/bits/stl_algobase.h (__copy_move<false, false, RA>)
Add __assign_one static member function.
(__copy_move<true, false, RA>): Likewise.
(__copy_move<IsMove, true, RA>): Do not use memmove for a single
value.
(__copy_move_backward<IsMove, true, RA>): Likewise.
* testsuite/25_algorithms/copy/108846.cc: New test.
* testsuite/25_algorithms/copy_backward/108846.cc: New test.
* testsuite/25_algorithms/copy_n/108846.cc: New test.
* testsuite/25_algorithms/move/108846.cc: New test.
* testsuite/25_algorithms/move_backward/108846.cc: New test.

16 months agolibstdc++: Add likely/unlikely attributes to <codecvt> implementation
Jonathan Wakely [Fri, 24 Feb 2023 21:28:11 +0000 (21:28 +0000)]
libstdc++: Add likely/unlikely attributes to <codecvt> implementation

For the common case of converting valid text this improves performance
significantly.

libstdc++-v3/ChangeLog:

* src/c++11/codecvt.cc: Add [[likely]] and [[unlikely]]
attributes.

16 months agoFortran: Eliminate nuisance warnings by initializing.
Jerry DeLisle [Sun, 26 Feb 2023 04:30:35 +0000 (20:30 -0800)]
Fortran: Eliminate nuisance warnings by initializing.

Set sstride[0] and mstride[0] to zero, eliminating some warnings.

libgfortran/ChangeLog:

* generated/pack_c10.c (pack_c10): Regenerated.
* generated/pack_c16.c (pack_c16): Regenerated.
* generated/pack_c17.c (pack_c17): Regenerated.
* generated/pack_c4.c (pack_c4): Regenerated.
* generated/pack_c8.c (pack_c8): Regenerated.
* generated/pack_i1.c (pack_i1): Regenerated.
* generated/pack_i16.c (pack_i16): Regenerated.
* generated/pack_i2.c (pack_i2): Regenerated.
* generated/pack_i4.c (pack_i4): Regenerated.
* generated/pack_i8.c (pack_i8): Regenerated.
* generated/pack_r10.c (pack_r10): Regenerated.
* generated/pack_r16.c (pack_r16): Regenerated.
* generated/pack_r17.c (pack_r17): Regenerated.
* generated/pack_r4.c (pack_r4): Regenerated.
* generated/pack_r8.c (pack_r8): Regenerated.
* generated/spread_c10.c (spread_c10): Regenerated.
* generated/spread_c16.c (spread_c16): Regenerated.
* generated/spread_c17.c (spread_c17): Regenerated.
* generated/spread_c4.c (spread_c4): Regenerated.
* generated/spread_c8.c (spread_c8): Regenerated.
* generated/spread_i1.c (spread_i1): Regenerated.
* generated/spread_i16.c (spread_i16): Regenerated.
* generated/spread_i2.c (spread_i2): Regenerated.
* generated/spread_i4.c (spread_i4): Regenerated.
* generated/spread_i8.c (spread_i8): Regenerated.
* generated/spread_r10.c (spread_r10): Regenerated.
* generated/spread_r16.c (spread_r16): Regenerated.
* generated/spread_r17.c (spread_r17): Regenerated.
* generated/spread_r4.c (spread_r4): Regenerated.
* generated/spread_r8.c (spread_r8): Regenerated.
* intrinsics/execute_command_line.c (execute_command_line_i4),
(execute_command_line_i8): Set estat_initial to zero.
* intrinsics/pack_generic.c (pack_internal): Set sstride[0] and
mstride[0] to zero.
* intrinsics/spread_generic.c (spread_internal): Set sstride[0].
* m4/pack.m4: Set sstride[0] and mstride[0].
* m4/spread.m4: Set sstride[0].

16 months agotestsuite: No xfail infoleak-vfio_iommu_type1.c bogus for default_packed
Hans-Peter Nilsson [Mon, 27 Feb 2023 19:44:46 +0000 (20:44 +0100)]
testsuite: No xfail infoleak-vfio_iommu_type1.c bogus for default_packed

There are no messages about padding for targets that don't
pad, i.e. default_packed.  Noticed for cris-elf, verified
for pru-elf at gcc-testresults@.

testsuite:
* gcc.dg/plugin/infoleak-vfio_iommu_type1.c: Don't xfail bogus
message for "default_packed" targets.

16 months agotestsuite: Shorten multiline pattern message to the same for fail and pass
Hans-Peter Nilsson [Mon, 27 Feb 2023 19:00:25 +0000 (20:00 +0100)]
testsuite: Shorten multiline pattern message to the same for fail and pass

As recommended by testsuite maintainer: Regression analysis
works only if the string is the same.

testsuite:
* lib/multiline.exp (handle-multiline-outputs): Shorten
message to the same for fail and pass.

16 months agotestsuite: Remove xfail gcc.dg/tree-ssa/pr91091-2.c RHS ! natural_alignment_32
Hans-Peter Nilsson [Mon, 27 Feb 2023 17:40:02 +0000 (18:40 +0100)]
testsuite: Remove xfail gcc.dg/tree-ssa/pr91091-2.c RHS ! natural_alignment_32

Reacting to a long-standing XPASS for CRIS.  This one is
slightly brown paper-bag level; it was never the here-removed
xfailed scan that failed and I didn't notice that XPASS when
reporting success on the commit as a whole.  It's not logical to
re-read what was just-written even with overlap issues, and I'm
sure that edit was originally a copy-pasto.  I checked
historical m68k-linux and pru-elf test-results too, to verify
that I got that part right.

PR testsuite/91419
* gcc.dg/tree-ssa/pr91091-2.c:15 Remove xfail for RHS.

16 months agoUpdate cpplib sr.po, sv.po
Joseph Myers [Tue, 28 Feb 2023 01:18:28 +0000 (01:18 +0000)]
Update cpplib sr.po, sv.po

* sr.po, sv.po: Update.

16 months agotestsuite: Add CRIS to targets not xfailing gcc.dg/attr-alloc_size-11.c:50,51
Hans-Peter Nilsson [Mon, 27 Feb 2023 16:22:44 +0000 (17:22 +0100)]
testsuite: Add CRIS to targets not xfailing gcc.dg/attr-alloc_size-11.c:50,51

Reacting to a long-standing XPASS for CRIS.  Maybe better do
as https://gcc.gnu.org/PR79356#c11 suggests: xfail it for
x86 only ...except I see m68k also does not xpass.

testsuite:
PR testsuite/79356
* gcc.dg/attr-alloc_size-11.c: Add CRIS to the list
of targets excluding xfail on lines 50 and 51.

16 months agotestsuite: Add -fno-ivopts to gcc.dg/Wuse-after-free-2.c, PR108828
Hans-Peter Nilsson [Fri, 24 Feb 2023 16:22:02 +0000 (17:22 +0100)]
testsuite: Add -fno-ivopts to gcc.dg/Wuse-after-free-2.c, PR108828

For cris-elf before this patch, ever since it was added,
this test gets:

Running /x/gcc/testsuite/gcc.dg/dg.exp ...
FAIL: gcc.dg/Wuse-after-free-2.c  (test for warnings, line 115)
FAIL: gcc.dg/Wuse-after-free-2.c  (test for warnings, line 116)

and comparing tree dumps with a native x86_64-pc-linux-gnu
run shows a suspicious difference in the "180t.ivopts" dump.
Indeed -fno-ivopts makes the warning appear for cris-elf
too.  It was suggested to simply add -fno-ivopts to the
test-flags, like before -fno-tree-loop-distribute-patterns
was added; thus.

PR tree-optimization/108828
* gcc.dg/Wuse-after-free-2.c: Add -fno-ivopts.

16 months agoDaily bump.
GCC Administrator [Tue, 28 Feb 2023 00:18:40 +0000 (00:18 +0000)]
Daily bump.

16 months agoFortran: fix corner case of IBITS intrinsic [PR108937]
Harald Anlauf [Mon, 27 Feb 2023 20:37:11 +0000 (21:37 +0100)]
Fortran: fix corner case of IBITS intrinsic [PR108937]

gcc/fortran/ChangeLog:

PR fortran/108937
* trans-intrinsic.cc (gfc_conv_intrinsic_ibits): Handle corner case
LEN argument of IBITS equal to BITSIZE(I).

gcc/testsuite/ChangeLog:

PR fortran/108937
* gfortran.dg/ibits_2.f90: New test.

16 months agoi386: Do not constrain fmod and remainder patterns with flag_finite_math_only [PR108922]
Uros Bizjak [Mon, 27 Feb 2023 21:10:01 +0000 (22:10 +0100)]
i386: Do not constrain fmod and remainder patterns with flag_finite_math_only [PR108922]

According to Intel ISA manual, fprem and fprem1 return NaN when invalid
arithmetic exception is generated. This is documented in Table 8-10 of the
ISA manual and makes these two instructions fully IEEE compatible.

The reverted patch was based on the data from table 3-30 and 3-31 of the
Intel ISA manual, where results in case of st(0) being infinity or
st(1) being 0 are not specified.

2023-02-27  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/108922
Revert:
* config/i386/i386.md (fmodxf3): Enable for flag_finite_math_only only.
(fmod<mode>3): Ditto.
(fpremxf4_i387): Ditto.
(reminderxf3): Ditto.
(reminder<mode>3): Ditto.
(fprem1xf4_i387): Ditto.

16 months agoFix RTL simplifications of FFS, POPCOUNT and PARITY.
Roger Sayle [Mon, 27 Feb 2023 17:26:54 +0000 (17:26 +0000)]
Fix RTL simplifications of FFS, POPCOUNT and PARITY.

In 2011, the rtl.texi documentation was updated to reflect that the
modes of the RTX unary operations FFS, POPCOUNT and PARITY should
match those of their operands.  Unfortunately, some of the transformations
in simplify-rtx.cc predate this tightening of RTL semantics, and have
not (until now) been updated/fixed.  i.e. The POPCOUNT and PARITY
optimizations were "correct" when I added them back in 2007.

2023-02-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* simplify-rtx.cc (simplify_unary_operation_1) <case FFS>: Avoid
generating FFS with mismatched operand and result modes, by using
an explicit SIGN_EXTEND/ZERO_EXTEND.
<case POPCOUNT>: Likewise, for POPCOUNT of ZERO_EXTEND.
<case PARITY>: Likewise, for PARITY of {ZERO,SIGN}_EXTEND.

16 months agolibgm2/libm2pim/sckt.cc:254:3: warning: memset() called to fill 0 bytes [PR108944]
Gaius Mulley [Mon, 27 Feb 2023 16:29:18 +0000 (16:29 +0000)]
libgm2/libm2pim/sckt.cc:254:3: warning: memset() called to fill 0 bytes [PR108944]

The pattern parameter to memset is second.  Correct an obvious mistake
in libm2pim/sckt.cc.

libgm2/ChangeLog:

PR modula2/108944
* libm2pim/sckt.cc (getLocalIP): Correct parameter order.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
16 months agodon't declare header-defined functions both static and inline, cont.
Patrick Palka [Mon, 27 Feb 2023 15:12:25 +0000 (10:12 -0500)]
don't declare header-defined functions both static and inline, cont.

This fixes some header-defined functions that are undesirably declared
static and weren't caught by the "^static inline" pattern used for the
main patch r13-6096-gcb3e0eac262e55.

gcc/ChangeLog:

* hash-table.h (gt_pch_nx(hash_table<D>)): Remove static.
* lra-int.h (lra_change_class): Likewise.
* recog.h (which_op_alt): Likewise.
* sel-sched-ir.h (sel_bb_empty_or_nop_p): Declare inline
instead of static.

16 months agolibstdc++: Add Doxygen comment for string::resize_and_overwite
Jonathan Wakely [Thu, 23 Feb 2023 15:50:28 +0000 (15:50 +0000)]
libstdc++: Add Doxygen comment for string::resize_and_overwite

This is a complicated API that should be clearly documented.

Also improve the comment on basic_ios::_M_setstate.

libstdc++-v3/ChangeLog:

* include/bits/basic_ios.h (basic_ios::_M_setstate): Add
caveat to comment.
* include/bits/basic_string.h (resize_and_overwrite): Add
doxygen comment.

16 months agoxtensa: Make use of CLAMPS instruction if configured
Takayuki 'January June' Suwa [Sun, 26 Feb 2023 17:27:42 +0000 (02:27 +0900)]
xtensa: Make use of CLAMPS instruction if configured

This patch introduces the use of CLAMPS instruction when the instruction
is configured.

    /* example */
    int test(int a) {
      if (a < -512)
        return -512;
      if (a > 511)
        return 511;
      return a;
    }

    ;; prereq: TARGET_CLAMPS
    test:
clamps a2, a2, 9
ret.n

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h (xtensa_match_CLAMPS_imms_p):
New prototype.
* config/xtensa/xtensa.cc (xtensa_match_CLAMPS_imms_p):
New function.
* config/xtensa/xtensa.h (TARGET_CLAMPS): New macro definition.
* config/xtensa/xtensa.md (*xtensa_clamps): New insn pattern.

16 months agogcc: xtensa: add XCHAL_HAVE_{CLAMPS,DEPBITS,EXCLUSIVE,XEA3} to dynconfig
Max Filippov [Mon, 27 Feb 2023 01:46:08 +0000 (17:46 -0800)]
gcc: xtensa: add XCHAL_HAVE_{CLAMPS,DEPBITS,EXCLUSIVE,XEA3} to dynconfig

gcc/
* config/xtensa/xtensa-dynconfig.cc (xtensa_get_config_v2)
(xtensa_get_config_v3): New functions.

include/
* xtensa-dynconfig.h (xtensa_config_v3): New struct.
(xtensa_get_config_v3): New declaration.
(XCHAL_HAVE_CLAMPS, XCHAL_HAVE_DEPBITS, XCHAL_HAVE_EXCLUSIVE)
(XCHAL_HAVE_XEA3, XTENSA_CONFIG_V3_ENTRY_LIST): New definitions.
(XTENSA_CONFIG_INSTANCE_LIST): Add xtensa_config_v3 instance.
(XTENSA_CONFIG_ENTRY_LIST): Add XTENSA_CONFIG_V3_ENTRY_LIST.