]> gcc.gnu.org Git - gcc.git/log
gcc.git
2 years agoPR c++/84964: Middle-end patch to expand_call for ICE after sorry.
Roger Sayle [Thu, 10 Mar 2022 23:49:15 +0000 (23:49 +0000)]
PR c++/84964: Middle-end patch to expand_call for ICE after sorry.

This patch resolves PR c++/84969 which is an ICE in the middle-end after
emitting a "sorry, unimplemented" message, and is a regression from
earlier releases of GCC.  This issue is that after encountering a
function call requiring an unreasonable amount of stack space, the
code continues and falls foul of an assert checking that stack pointer
has been correctly updated.  The fix is to (locally) consider aborted
function calls as "no return", which skips this downstream sanity check.

2022-03-10  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR c++/84964
* calls.cc (expand_call): Ignore stack adjustments after sorry.

gcc/testsuite/ChangeLog
PR c++/84964
* g++.dg/other/pr84964.C: New test case.

2 years agolibstdc++: Do not use fast_float for 16-bit size_t [PR104870]
Jonathan Wakely [Thu, 10 Mar 2022 21:13:20 +0000 (21:13 +0000)]
libstdc++: Do not use fast_float for 16-bit size_t [PR104870]

The preprocessor condition for using fast_float should match the one in
the header, and require at least 32-bit size_t.

libstdc++-v3/ChangeLog:

PR libstdc++/104870
* src/c++17/floating_from_chars.cc: Check __SIZE_WIDTH__ >= 32
before using fast_float.

2 years agoanalyzer: fix ICE with -fanalyzer-transitivity [PR104863]
David Malcolm [Thu, 10 Mar 2022 21:52:01 +0000 (16:52 -0500)]
analyzer: fix ICE with -fanalyzer-transitivity [PR104863]

gcc/analyzer/ChangeLog:
PR analyzer/104863
* constraint-manager.cc (constraint_manager::add_constraint):
Refresh the EC IDs when adding constraints implied by offsets.

gcc/testsuite/ChangeLog:
PR analyzer/104863
* gcc.dg/analyzer/torture/pr104863.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years ago[PR103074] LRA: Check new conflicts when splitting hard reg live range.
Vladimir N. Makarov [Thu, 10 Mar 2022 21:16:00 +0000 (16:16 -0500)]
[PR103074] LRA: Check new conflicts when splitting hard reg live range.

Splitting hard register live range can create (artificial)
conflict of the hard register with another pseudo because of simplified
conflict calculation in LRA.  We should check such conflict on the next
assignment sub-pass and spill and reassign the pseudo if necessary.
The patch implements this.

gcc/ChangeLog:

PR target/103074
* lra-constraints.cc (split_reg): Set up
check_and_force_assignment_correctness_p when splitting hard
register live range.

gcc/testsuite/ChangeLog:

PR target/103074
* gcc.target/i386/pr103074.c: New.

2 years agolibstdc++: Move closing brace outside #endif [PR104866]
Detlef Vollmann [Thu, 10 Mar 2022 16:57:25 +0000 (16:57 +0000)]
libstdc++: Move closing brace outside #endif [PR104866]

libstdc++-v3/ChangeLog:

PR libstdc++/104866
* include/bits/this_thread_sleep.h: Fix order of #endif and
closing brace of namespace.

2 years agoFix multiple issue in the testcase allocate-1.f90.
Hafiz Abid Qadeer [Mon, 31 Jan 2022 19:02:14 +0000 (19:02 +0000)]
Fix multiple issue in the testcase allocate-1.f90.

1. Thomas reported in
https://gcc.gnu.org/pipermail/gcc-patches/2022-January/589039.html
that this testcase is randomly failing. The problem was fixed pool
size which was exhausted when there were a lot of threads. Fixed it
by removing pool_size trait which causes default pool size to be used
which should be big enough.

2. Array indices have been changed to check the last element in the
array.

3. Remove a redundant assignment and move some code to better match
C testcase.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/allocate-1.f90: Remove pool_size
trait.  Test last index in w and v array.  Remove redundant
assignment to V(1).  Move alignment checks at the end of
parallel region.

2 years agoc++: ->template and implicit typedef [PR104608]
Marek Polacek [Tue, 22 Feb 2022 20:03:34 +0000 (15:03 -0500)]
c++: ->template and implicit typedef [PR104608]

Here we have a forward declaration of Parameter for which we create
an implicit typedef, which is a TYPE_DECL.  Then, when looking it up
at template definition time, cp_parser_template_id gets (since r12-6754)
this TYPE_DECL which it can't handle.

This patch defers lookup for TYPE_DECLs that cp_parser_template_id can't
handle, a la r12-6879.

PR c++/104608

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_name): Repeat lookup of
TYPE_DECLs.

gcc/testsuite/ChangeLog:

* g++.dg/parse/template-keyword3.C: New test.
* g++.dg/parse/template-keyword4.C: New test.

2 years agoc++: Don't allow type-constraint auto(x) [PR104752]
Marek Polacek [Wed, 2 Mar 2022 17:12:33 +0000 (12:12 -0500)]
c++: Don't allow type-constraint auto(x) [PR104752]

104752 points out that

  template<class T>
  concept C = true;
  auto y = C auto(1);

is ill-formed as per [dcl.type.auto.deduct]: "For an explicit type conversion,
T is the specified type, which shall be auto." which doesn't allow
type-constraint auto.

PR c++/104752

gcc/cp/ChangeLog:

* semantics.cc (finish_compound_literal): Disallow auto{x} for
is_constrained_auto.
* typeck2.cc (build_functional_cast_1): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/auto-fncast12.C: New test.

2 years agoc++: ICE with operator delete [PR104846]
Marek Polacek [Wed, 9 Mar 2022 16:23:15 +0000 (11:23 -0500)]
c++: ICE with operator delete [PR104846]

This is an ICE-on-invalid with "auto operator delete[] (void *)" whose
return type must be void.  The return type is checked in coerce_delete_type
but we never got there in this test, because we took the wrong path in
grokdeclarator, set type to error_mark_node, ended up creating a FIELD_DECL
with build_decl, and confused grokmethod by giving it a FIELD_DECL.

Fixed by not taking the data member path for a FUNCTION_TYPE.

PR c++/104846

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Check FUNC_OR_METHOD_TYPE_P before giving
data member errors.

gcc/testsuite/ChangeLog:

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

2 years agoc++: allow variadic operator[] for C++23 [PR103460]
Jakub Jelinek [Thu, 10 Mar 2022 14:28:20 +0000 (15:28 +0100)]
c++: allow variadic operator[] for C++23 [PR103460]

wg21.link/p2128 removed "with exactly one parameter" from over.sub
section.  grok_op_properties has for that the last 2 lines in:
    case OVL_OP_FLAG_BINARY:
      if (arity != 2)
        {
          if (operator_code == ARRAY_REF && cxx_dialect >= cxx23)
            break;
but unfortunately it isn't enough, we reject variadic operator[]
earlier.  The following patch accepts variadic operator[] for C++23
too.

2022-03-10  Jakub Jelinek  <jakub@redhat.com>

PR c++/103460
* decl.cc (grok_op_properties): Allow variadic operator[] for
C++23.

* g++.dg/cpp23/subscript7.C: New test.

2 years agolibstdc++: Fix std::strong_order to handle NaN on VAX
Jonathan Wakely [Thu, 10 Mar 2022 14:17:03 +0000 (14:17 +0000)]
libstdc++: Fix std::strong_order to handle NaN on VAX

I mistakenly believed that VAX floats do not support NaN, but with GCC
__builtin_isnan(__builtin_nan("")) is true. That means my previous
change to <compare> is wrong, because it fails to handle NaN.

When std::numeric_limits<floating-point-type>::is_iec559 is false, as on
VAX, the standard only requires an ordering that is consistent with the
ordering observed by comparison operators. With this change the ordering
is -NaN < numbers < +NaN, and there is no support for different NaN bit
patterns (as I'm not even sure if GCC supports any for VAX).

libstdc++-v3/ChangeLog:

* libsupc++/compare (_Strong_order::_S_fp_cmp) [__vax__]:
Handle NaN.

2 years agoanalyzer: add notes to write-to-const/string from access attr [PR104793]
David Malcolm [Thu, 10 Mar 2022 14:09:40 +0000 (09:09 -0500)]
analyzer: add notes to write-to-const/string from access attr [PR104793]

The previous patch extended
  -Wanalyzer-write-to-const
  -Wanalyzer-write-to-string-literal
to make use of __attribute__ ((access, ....), but the results could be
inscrutable.

This patch adds notes to such diagnostics to give the user a reason for
why the analyzer is complaining.

Example output:

test.c: In function 'main':
test.c:15:13: warning: write to string literal [-Wanalyzer-write-to-string-literal]
   15 |         if (getrandom((char *)test, sizeof(buf), GRND_RANDOM))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  'main': event 1
    |
    |   15 |         if (getrandom((char *)test, sizeof(buf), GRND_RANDOM))
    |      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |             |
    |      |             (1) write to string literal here
    |
test.c:3:5: note: parameter 1 of 'getrandom' marked with attribute 'access (write_only, 1, 2)'
    3 | int getrandom (void *__buffer, size_t __length,
      |     ^~~~~~~~~

Unfortunately we don't have location information for the attributes
themselves, just the function declaration, and there doesn't seem to be
a good way of getting at the location of the individual parameters from
the middle end (the C and C++ FEs both have get_fndecl_argument_location,
but the implementations are different).

gcc/analyzer/ChangeLog:
PR analyzer/104793
* analyzer.h (class pending_note): New forward decl.
* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
Initialize m_notes.
(saved_diagnostic::operator==): Compare m_notes.
(saved_diagnostic::add_note): New.
(saved_diagnostic::emit_any_notes): New.
(diagnostic_manager::add_note): New.
(diagnostic_manager::emit_saved_diagnostic): Call emit_any_notes
after emitting the warning.
* diagnostic-manager.h (saved_diagnostic::add_note): New decl.
(saved_diagnostic::emit_any_notes): New decl.
(saved_diagnostic::m_notes): New field.
(diagnostic_manager::add_note): New decl.
* engine.cc (impl_region_model_context::add_note): New.
* exploded-graph.h (impl_region_model_context::add_note): New
decl.
* pending-diagnostic.h (class pending_note): New.
(class pending_note_subclass): New template.
* region-model.cc (class reason_attr_access): New.
(check_external_function_for_access_attr): Add class
annotating_ctxt and use it when checking region.
(noop_region_model_context::add_note): New.
* region-model.h (region_model_context::add_note): New vfunc.
(noop_region_model_context::add_note): New decl.
(class region_model_context_decorator): New.
(class note_adding_context): New.

gcc/testsuite/ChangeLog:
PR analyzer/104793
* gcc.dg/analyzer/write-to-const-2.c: Add dg-message directives
for expected notes.
* gcc.dg/analyzer/write-to-function-1.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-2.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-3.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-4.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-5.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: check for writes to consts via access attr [PR104793]
David Malcolm [Thu, 10 Mar 2022 14:04:03 +0000 (09:04 -0500)]
analyzer: check for writes to consts via access attr [PR104793]

This patch extends:
  -Wanalyzer-write-to-const
  -Wanalyzer-write-to-string-literal
so that they will check for __attribute__ ((access, ....) on calls to
externally-defined functions, and complain about read-only regions
pointed to by arguments marked with a "write_only" or "read_write"
attribute.

gcc/analyzer/ChangeLog:
PR analyzer/104793
* region-model.cc
(region_model::check_external_function_for_access_attr): New.
(region_model::handle_unrecognized_call): Call it.
* region-model.h
(region_model::check_external_function_for_access_attr): New decl.
(region_model::handle_unrecognized_call): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/104793
* gcc.dg/analyzer/write-to-const-2.c: New test.
* gcc.dg/analyzer/write-to-function-1.c: New test.
* gcc.dg/analyzer/write-to-string-literal-2.c: New test.
* gcc.dg/analyzer/write-to-string-literal-3.c: New test.
* gcc.dg/analyzer/write-to-string-literal-4.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix duplicates in check_for_tainted_size_arg
David Malcolm [Thu, 10 Mar 2022 14:02:18 +0000 (09:02 -0500)]
analyzer: fix duplicates in check_for_tainted_size_arg

gcc/analyzer/ChangeLog:
* sm-taint.cc (taint_state_machine::check_for_tainted_size_arg):
Avoid generating duplicate saved_diagnostics by only handling the
rdwr_map entry for the ptrarg, not the duplicate entry for the
sizarg.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/taint-size-access-attr-1.c: Add
-fanalyzer-show-duplicate-count to options; verify that a
duplicate was not created for the tainted size.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoipa-cp: Avoid adjusting references through self-recursion (PR 104813)
Martin Jambor [Thu, 10 Mar 2022 13:49:23 +0000 (14:49 +0100)]
ipa-cp: Avoid adjusting references through self-recursion (PR 104813)

When writing the patch that downgrades address-taken references to
load references when IPA-CP can prove that all uses of the taken
address ends up in loads, I unfortunately did not take into account
that find_more_scalar_values_for_callers_subset now happily adds
self-recursive edges to the set of callers which should be immediately
redirected (originally recursion was meant to be handled as edge
redirection in a second pass over the SCC).

The code as it is can now decrement the referece counters too many
times.  This can remedied by removing self-recursive edges earlier, we
already do it because of thunk expansion issues, and so this patch
does exactly that.

gcc/ChangeLog:

2022-03-07  Martin Jambor  <mjambor@suse.cz>

PR ipa/104813
* ipa-cp.cc (create_specialized_node): Move removal of
self-recursive calls from callers vector before refrence
adjustments.

gcc/testsuite/ChangeLog:

2022-03-07  Martin Jambor  <mjambor@suse.cz>

PR ipa/104813
* gcc.dg/ipa/pr104813.c: New test.

2 years agotree-optimization/102943 - use tree form for sbr_sparse_bitmap
Richard Biener [Thu, 10 Mar 2022 12:43:19 +0000 (13:43 +0100)]
tree-optimization/102943 - use tree form for sbr_sparse_bitmap

The following arranges to remove an indirection do the bitvector
in sbr_sparse_bitmap by embedding bitmap_head instead of bitmap
and using the tree form (since we only ever set/query individual
aligned bit chunks).  That shaves off 6 seconds from 70 seconds
of the slowest 521.wrf_r LRANS unit build.

2022-03-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102943
* gimple-range-cache.cc (sbr_sparse_bitmap::bitvec):
Make a bitmap_head.
(sbr_sparse_bitmap::sbr_sparse_bitmap): Adjust and switch
to tree view.
(sbr_sparse_bitmap::set_bb_range): Adjust.
(sbr_sparse_bitmap::get_bb_range): Likewise.

2 years agoada/104861 - use target_noncanonial for Target_Name
Richard Biener [Thu, 10 Mar 2022 12:35:46 +0000 (13:35 +0100)]
ada/104861 - use target_noncanonial for Target_Name

The following arranges for s-oscons.ads to record target_noncanonical
for Target_Name, matching the install directory layout and what
gcc -dumpmachine says.  This fixes build issues with gprbuild.

2022-03-10  Richard Biener  <rguenther@suse.de>

PR ada/104861
gcc/ada/
* gcc-interface/Makefile.in (target_noncanonical): Substitute.
(OSCONS_CPP): Pass target_noncanonical as TARGET.

2 years agotree-optimization/102943 - avoid (re-)computing dominance bitmap
Richard Biener [Thu, 10 Mar 2022 11:40:02 +0000 (12:40 +0100)]
tree-optimization/102943 - avoid (re-)computing dominance bitmap

Currently back_propagate_equivalences tries to optimize dominance
queries in a smart way but it fails to notice that when fast indexes
are available the dominance query is fast (when called from DOM).
It also re-computes the dominance bitmap for each equivalence recorded
on an edge, which for FP are usually several.  Finally it fails to
use the tree bitmap view for efficiency.  Overall this cuts 7
seconds of compile-time from originally 77 in the slowest LTRANS
unit when building 521.wrf_r.

2022-03-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102943
* tree-ssa-dom.cc (back_propagate_equivalences): Only
populate the dominance bitmap if fast queries are not
available.  Use a tree view bitmap.
(record_temporary_equivalences): Cache the dominance bitmap
across all equivalences on the edge.

2 years agolibstdc++: Support VAX floats in std::strong_order
Jonathan Wakely [Tue, 8 Mar 2022 12:15:55 +0000 (12:15 +0000)]
libstdc++: Support VAX floats in std::strong_order

The VAX float and double format does not support NaN, so the
std::partial_ordering returned by <=> will never be 'unordered'. We can
just use the partial_ordering value as the strong_ordering.

libstdc++-v3/ChangeLog:

* libsupc++/compare (_Strong_ordering::_S_fp_cmp) [__vax__]: Use
<=> comparison.

2 years agocontrib: Fix non-portable shell commands in gcc-git-customization.sh [PR102664]
Jonathan Wakely [Wed, 9 Mar 2022 14:53:52 +0000 (14:53 +0000)]
contrib: Fix non-portable shell commands in gcc-git-customization.sh [PR102664]

Use printf instead of echo -n. Use Basic Regular Expressions instead of
sed -r. Check for error from ancient Git versions that don't support the
--git-path option for git-rev-parse. Remove -c flag from install
command, as it's ignored by GNU and BSD install, but means something
different for Solaris and AIX.

contrib/ChangeLog:

PR other/102664
* gcc-git-customization.sh: Fix non-portable commands.

2 years ago[nvptx] Use no,yes for attribute predicable
Tom de Vries [Tue, 8 Mar 2022 12:55:09 +0000 (13:55 +0100)]
[nvptx] Use no,yes for attribute predicable

The documentation states about the predicable instruction attribute:
...
This attribute must be a boolean (i.e. have exactly two elements in its
list-of-values), with the possible values being no and yes.
...

The nvptx port has instead:
...
(define_attr "predicable" "false,true"
  (const_string "true"))
...

Fix this by updating to:
...
(define_attr "predicable" "no,yes"
  (const_string "yes"))
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-08  Tom de Vries  <tdevries@suse.de>

PR target/104840
* config/nvptx/nvptx.md (define_attr "predicable"): Use no,yes instead
of false,true.

2 years ago[nvptx] Disable warp sync in simt region
Tom de Vries [Tue, 8 Mar 2022 09:15:45 +0000 (10:15 +0100)]
[nvptx] Disable warp sync in simt region

I ran into a hang for this code:
...
  #pragma omp target map(tofrom: counter_N0)
  #pragma omp simd
  for (int i = 0 ; i < 1 ; i++ )
    {
      #pragma omp atomic update
      counter_N0 = counter_N0 + 1 ;
    }
...

This has to do with the nature of -muniform-simt.  It has two modes of
operation: inside and outside an SIMT region.

Outside an SIMT region, a warp pretends to execute a single thread, but
actually executes in all threads, to keep the local registers in all threads
consistent.  This approach works unless the insn that is executed is a syscall
or an atomic insn.  In that case, the insn is predicated, such that it
executes in only one thread.  If the predicated insn writes a result to a
register, then that register is propagated to the other threads, after which
the local registers in all threads are consistent again.

Inside an SIMT region, a warp executes in all threads.  However, the
predication and propagation for syscalls and atomic insns is also present
here, because nvptx_reorg_uniform_simt works on all code.  Care has been taken
though to ensure that the predication and propagation is a nop.  That is,
inside an SIMT region:
- the predicate evalutes to true for each thread, and
- the propagation insn copies a register from each thread to the same thread.

That works fine, until we use -mptx=6.0, and instead of using the deprecated
warp propagation insn shfl, we start using shfl.sync:
...
  @%r33 atom.add.u32 _, [%r29], 1;
shfl.sync.idx.b32 %r30, %r30, %r32, 31, 0xffffffff;
...

The shfl.sync specifies a member mask indicating all threads, but given that
the loop only has a single iteration, only thread 0 will execute the insn,
where it will hang waiting for the other threads.

Fix this by predicating the shfl.sync (and likewise, bar.warp.sync and the
uniform warp check) such that it only executes outside the SIMT region.

Tested on x86_64 with nvptx accelerator.

gcc/ChangeLog:

2022-03-08  Tom de Vries  <tdevries@suse.de>

PR target/104783
* config/nvptx/nvptx.cc (nvptx_init_unisimt_predicate)
(nvptx_output_unisimt_switch): Handle unisimt_outside_simt_predicate.
(nvptx_get_unisimt_outside_simt_predicate): New function.
(predicate_insn): New function, factored out of ...
(nvptx_reorg_uniform_simt): ... here.  Predicate all emitted insns.
* config/nvptx/nvptx.h (struct machine_function): Add
unisimt_outside_simt_predicate field.
* config/nvptx/nvptx.md (define_insn "nvptx_warpsync")
(define_insn "nvptx_uniform_warp_check"): Make predicable.

libgomp/ChangeLog:

2022-03-10  Tom de Vries  <tdevries@suse.de>

* testsuite/libgomp.c/pr104783.c: New test.

2 years ago[nvptx] Handle unused result in nvptx_unisimt_handle_set
Tom de Vries [Mon, 7 Mar 2022 14:57:11 +0000 (15:57 +0100)]
[nvptx] Handle unused result in nvptx_unisimt_handle_set

For an example:
...
  #pragma omp target map(tofrom: counter_N0)
  #pragma omp simd
  for (int i = 0 ; i < 1 ; i++ )
    {
      #pragma omp atomic update
      counter_N0 = counter_N0 + 1 ;
    }
...
I noticed that the result of the atomic update (%r30) is propagated:
...
  @%r33 atom.add.u32 _, [%r29], 1;
shfl.sync.idx.b32 %r30, %r30, %r32, 31, 0xffffffff;
...
even though it is unused (which is why the bit bucket operand _ is used).

Fix this by not emitting the shuffle in this case, such that we have instead:
...
  @%r33 atom.add.u32 _, [%r29], 1;
bar.warp.sync 0xffffffff;
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.cc (nvptx_unisimt_handle_set): Handle unused
result.

gcc/testsuite/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

* gcc.target/nvptx/uniform-simt-4.c: New test.

2 years ago[nvptx] Use bit-bucket operand for atom insns
Tom de Vries [Mon, 7 Mar 2022 13:23:03 +0000 (14:23 +0100)]
[nvptx] Use bit-bucket operand for atom insns

For an atomic fetch operation that doesn't use the result:
...
  __atomic_fetch_add (p64, v64, MEMMODEL_RELAXED);
...
we currently emit:
...
  atom.add.u64 %r26, [%r25], %r27;
...

Detect the REG_UNUSED reg-note for %r26, and emit instead:
...
  atom.add.u64 _, [%r25], %r27;
...

Likewise for all atom insns.

Tested on nvptx.

gcc/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

PR target/104815
* config/nvptx/nvptx.cc (nvptx_print_operand): Handle 'x' operand
modifier.
* config/nvptx/nvptx.md: Use %x0 destination operand in atom insns.

gcc/testsuite/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

PR target/104815
* gcc.target/nvptx/atomic-bit-bucket-dest.c: New test.

2 years ago[nvptx] Use atom.and.b64 instead of atom.b64.and
Tom de Vries [Mon, 7 Mar 2022 13:59:02 +0000 (14:59 +0100)]
[nvptx] Use atom.and.b64 instead of atom.b64.and

The ptx manual prescribes the instruction format atom{.space}.op.type but the
compiler currently emits:
...
  atom.b64.and %r31, [%r30], %r32;
...
which uses the instruction format atom{.space}.type.op.

Fix this by emitting instead:
...
  atom.and.b64  %r31, [%r30], %r32;
...

Tested on nvptx.

gcc/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

* config/nvptx/nvptx.md (define_insn "atomic_fetch_<logic><mode>"):
Emit atom.and.b64 instead of atom.b64.and.

gcc/testsuite/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

* gcc.target/nvptx/atomic_fetch-1.c: Update.
* gcc.target/nvptx/atomic_fetch-2.c: Update.

2 years ago[nvptx] Add multilib mptx=3.1
Tom de Vries [Tue, 8 Mar 2022 08:25:39 +0000 (09:25 +0100)]
[nvptx] Add multilib mptx=3.1

With commit 5b5e456f018 ("[nvptx] Build libraries with mptx=3.1") the
intention was that the ptx isa version for all libraries was switched back to
3.1 using MULTILIB_EXTRA_OPTS, without changing the default 6.0.

Further testing revealed that this is not the case, and some libs were still
build with 6.0.

Fix this by introducing an mptx=3.1 multilib.

Adding a multilib should be avoided if possible, because it adds build time.
But I think it's a reasonable trade-off.  With --disable-multilib, the default
lib with misa=sm_30 and mptx=6.0 should be usable in most scenarios.  With
--enable-multilib, we can enable older drivers, as well as generate code
similar to how that was done in previous gcc releases, which is very useful.

Tested on nvptx.

gcc/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

* config/nvptx/t-nvptx (MULTILIB_EXTRA_OPTS): Move mptx=3.1 ...
(MULTILIB_OPTIONS): ... here.

2 years ago[nvptx] Restore default to sm_30
Tom de Vries [Thu, 3 Mar 2022 19:20:41 +0000 (20:20 +0100)]
[nvptx] Restore default to sm_30

With commit 07667c911b1 ("[nvptx] Build libraries with misa=sm_30") the
intention was that the sm_xx for all libraries was switched back to sm_30
using MULTILIB_EXTRA_OPTS, without changing the default sm_35.

Testing on an sm_30 board revealed that still some libs were build with sm_35,
so fix this by switching back to default sm_30.

Tested on nvptx.

gcc/ChangeLog:

2022-03-07  Tom de Vries  <tdevries@suse.de>

PR target/104758
* config/nvptx/nvptx.opt (misa): Set default to sm_30.
* config/nvptx/t-nvptx (MULTILIB_EXTRA_OPTS): Remove misa=sm_30.

2 years ago[OpenACC privatization] Analyze 'lookup_decl'-translated DECL [PR90115, PR102330...
Thomas Schwinge [Mon, 14 Feb 2022 15:56:35 +0000 (16:56 +0100)]
[OpenACC privatization] Analyze 'lookup_decl'-translated DECL [PR90115, PR102330, PR104774]

... so that it matches what we analyze and what we action on.
Fix-up for commit 29a2f51806c5b30e17a8d0e9ba7915a3c53c34ff "openacc:
Add support for gang local storage allocation in shared memory [PR90115]".

PR middle-end/90115
PR middle-end/102330
PR middle-end/104774
gcc/
* omp-low.cc (oacc_privatization_candidate_p)
(oacc_privatization_scan_clause_chain)
(oacc_privatization_scan_decl_chain, lower_oacc_private_marker):
Analyze 'lookup_decl'-translated DECL.
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: Adjust.
* c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104132-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104133-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104774-1.c: Likewise.
* c-c++-common/goacc/privatization-1-compute-loop.c: Likewise.
* c-c++-common/goacc/privatization-1-compute.c: Likewise.
* c-c++-common/goacc/privatization-1-routine_gang-loop.c:
Likewise.
* c-c++-common/goacc/privatization-1-routine_gang.c: Likewise.
* gfortran.dg/goacc-gomp/pr102330-1.f90: Likewise, and subsume...
* gfortran.dg/goacc-gomp/pr102330-2.f90: ... this file, and...
* gfortran.dg/goacc-gomp/pr102330-3.f90: ... this file.
* gfortran.dg/goacc/privatization-1-compute-loop.f90: Adjust.
* gfortran.dg/goacc/privatization-1-compute.f90: Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang-loop.f90:
Likewise.
* gfortran.dg/goacc/privatization-1-routine_gang.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Enhance.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-local-worker-1.c:
Adjust.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-local-worker-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-local-worker-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-local-worker-4.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-local-worker-5.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-vector-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-vector-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-4.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-5.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-6.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-private-vars-loop-worker-7.c:
Likewise.
* testsuite/libgomp.oacc-fortran/optional-private.f90: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: Likewise.
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Likewise.

2 years agoAdd 'c-c++-common/goacc/kernels-decompose-pr104774-1.c' [PR104774]
Thomas Schwinge [Thu, 3 Mar 2022 17:00:52 +0000 (18:00 +0100)]
Add 'c-c++-common/goacc/kernels-decompose-pr104774-1.c' [PR104774]

..., currently XFAILed with 'dg-ice'.

PR middle-end/104774
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-pr104774-1.c: New file.

2 years agoAdd 'gfortran.dg/goacc-gomp/pr102330-{1,2,3}.f90' [PR102330]
Thomas Schwinge [Thu, 27 Jan 2022 13:17:28 +0000 (14:17 +0100)]
Add 'gfortran.dg/goacc-gomp/pr102330-{1,2,3}.f90' [PR102330]

..., currently XFAILed with 'dg-ice'.

PR middle-end/102330
gcc/testsuite/
* gfortran.dg/goacc-gomp/pr102330-1.f90: New file.
* gfortran.dg/goacc-gomp/pr102330-2.f90: Likewise.
* gfortran.dg/goacc-gomp/pr102330-3.f90: Likewise.

2 years agoEnhance further testcases to verify handling of OpenACC privatization level [PR90115]
Thomas Schwinge [Tue, 8 Mar 2022 10:51:55 +0000 (11:51 +0100)]
Enhance further testcases to verify handling of OpenACC privatization level [PR90115]

As originally introduced in commit 11b8286a83289f5b54e813f14ff56d730c3f3185
"[OpenACC privatization] Largely extend diagnostics and corresponding testsuite
coverage [PR90115]".

PR middle-end/90115
gcc/testsuite/
* c-c++-common/goacc/nesting-1.c: Enhance.
* gcc.dg/goacc/nested-function-1.c: Likewise.
* gcc.dg/goacc/nested-function-2.c: Likewise.
* gfortran.dg/goacc/nested-function-1.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-fortran/routine-1.f90: Enhance.
* testsuite/libgomp.oacc-fortran/routine-2.f90: Likewise.
* testsuite/libgomp.oacc-fortran/routine-3.f90: Likewise.
* testsuite/libgomp.oacc-fortran/routine-9.f90: Likewise.

2 years agors6000: Fix up __SIZEOF_{FLOAT,IBM}128__ defines [PR99708]
Jakub Jelinek [Thu, 10 Mar 2022 09:22:27 +0000 (10:22 +0100)]
rs6000: Fix up __SIZEOF_{FLOAT,IBM}128__ defines [PR99708]

As mentioned in the PR, right now on powerpc* __SIZEOF_{FLOAT,IBM}128__
macros are predefined unconditionally, because {ieee,ibm}128_float_type_node
is always non-NULL, doesn't reflect whether __ieee128 or __ibm128 are
actually supported or not.

Based on patch review discussions, the following patch:
1) allows __ibm128 to be used in the sources even when !TARGET_FLOAT128_TYPE,
   as long as long double is double double
2) ensures ibm128_float_type_node is non-NULL only if __ibm128 is supported
3) ensures ieee128_float_type_node is non-NULL only if __ieee128 is supported
   (aka when TARGET_FLOAT128_TYPE)
4) predefines __SIZEOF_IBM128__ only when ibm128_float_type_node != NULL
5) newly predefines __SIZEOF_IEEE128__ if ieee128_float_type_node != NULL
6) predefines __SIZEOF_FLOAT128__ whenever ieee128_float_type_node != NULL
   and __float128 macro is predefined to __ieee128
7) removes ptr_*128_float_type_node which nothing uses
8) in order not to ICE during builtin initialization when
   ibm128_float_type_node == NULL, uses long_double_type_node as fallback
   for the __builtin_{,un}pack_ibm128 builtins
9) errors when those builtins are called used when
   ibm128_float_type_node == NULL (during their expansion)
10) moves the {,un}packif -> {,un}packtf remapping for these builtins in
    expansion earlier, so that we don't ICE on them if not -mabi=ieeelongdouble

2022-03-10  Jakub Jelinek  <jakub@redhat.com>

PR target/99708
* config/rs6000/rs6000.h (enum rs6000_builtin_type_index): Remove
RS6000_BTI_ptr_ieee128_float and RS6000_BTI_ptr_ibm128_float.
(ptr_ieee128_float_type_node, ptr_ibm128_float_type_node): Remove.
* config/rs6000/rs6000-builtin.cc (rs6000_type_string): Return
"**NULL**" if type_node is NULL first.  Handle
ieee128_float_type_node.
(rs6000_init_builtins): Don't initialize ptr_ieee128_float_type_node
and ptr_ibm128_float_type_node.  Set ibm128_float_type_node and
ieee128_float_type_node to NULL rather than long_double_type_node if
they aren't supported.  Do support __ibm128 even if
!TARGET_FLOAT128_TYPE when long double is double double.
(rs6000_expand_builtin): Error if bif_is_ibm128 and
!ibm128_float_type_node.  Remap RS6000_BIF_{,UN}PACK_IF to
RS6000_BIF_{,UN}PACK_TF much earlier and only use bif_is_ibm128 check
for it.
* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
__SIZEOF_FLOAT128__ here and only iff __float128 macro is defined.
(rs6000_cpu_cpp_builtins): Don't define __SIZEOF_FLOAT128__ here.
Define __SIZEOF_IBM128__=16 if ieee128_float_type_node is non-NULL.
Formatting fix.
* config/rs6000/rs6000-gen-builtins.cc: Document ibm128 attribute.
(struct attrinfo): Add isibm128 member.
(TYPE_MAP_SIZE): Remove.
(type_map): Use [] instead of [TYPE_MAP_SIZE].  For "if" use
ibm128_float_type_node only if it is non-NULL, otherwise fall back
to long_double_type_node.  Remove "pif" entry.
(parse_bif_attrs): Handle ibm128 attribute and print it for debugging.
(write_decls): Output bif_ibm128_bit and bif_is_ibm128.
(write_type_node): Use sizeof type_map / sizeof type_map[0]
instead of TYPE_MAP_SIZE.
(write_bif_static_init): Handle isibm128.
* config/rs6000/rs6000-builtins.def: Document ibm128 attribute.
(__builtin_pack_ibm128, __builtin_unpack_ibm128): Add ibm128
attribute.

* gcc.dg/pr99708.c: New test.
* gcc.target/powerpc/pr99708-2.c: New test.
* gcc.target/powerpc/convert-fp-128.c (mode_kf): Define only if
__FLOAT128_TYPE__ is defined.

2 years agocontrib: Fix up git-descr.sh regression [PR102664]
Jakub Jelinek [Thu, 10 Mar 2022 08:42:03 +0000 (09:42 +0100)]
contrib: Fix up git-descr.sh regression [PR102664]

On Wed, Mar 09, 2022 at 12:40:24PM -0500, Patrick Palka via Gcc-patches wrote:
> On Wed, Mar 9, 2022 at 8:54 AM Mikael Morin <morin-mikael@orange.fr> wrote:
> > Le 08/03/2022 Ã  18:58, Jonathan Wakely via Gcc-patches a Ã©crit :
> > > Replace \([0-9]\+\) with \([0-9][0-9]*\) or with \([1-9][0-9]*\) in release branch numbers, where
> > > a leading zero does not occur.
> > >
> > Note that you also changed some gcc-[0-9]* to gcc-[1-9]*, which is a
> > typo/thinko I guess?  It looks like it wouldn’t match gcc-10 any more
> > for example…
>
> Perhaps related to this, I noticed the following
>   git gcc-descr ea1ce0d163ea1d63b6837144ae4be51d92630007
> now fails with
>   fatal: No tags can describe 'ea1ce0d163ea1d63b6837144ae4be51d92630007'.
> instead of outputting
>   r0-52309-gea1ce0d163ea1d

That is because of those [0-9] to [1-9] changes which prevent
basepoints/gcc-0 from working.  While basepoints/gcc-005 etc. are certainly
unexpected, basepoints/gcc-0 needs to work.

2022-03-10  Jakub Jelinek  <jakub@redhat.com>

PR other/102664
* git-descr.sh: Replace all [1-9] occurrences with [0-9].
* git-undescr.sh: Likewise.

2 years agoPR c++/95999: Improved error recovery in enumeration lists.
Roger Sayle [Thu, 10 Mar 2022 07:41:12 +0000 (07:41 +0000)]
PR c++/95999: Improved error recovery in enumeration lists.

This patch resolves PR c++/95999 which is an ICE-after-error regression
in the g++ front-end.  When parsing an enumerator list, the C++ parser
assumes that cp_parser_constant_expression always returns either an
INTEGER_CST or error_mark_node, but in the testcase reported in the
PR, it actually returns a VAR_DECL.

The usual (but perhaps controversial) design philosophy is that the
routine that reports the error normally has a duty to indicate this to
the rest of the compiler (via error_mark_node), but here the return
value from calling require_rvalue_constant_expression (parser.cc:10666)
is ignored.  I initially experimented with setting EXPRESSION to
error_mark_node here in cp_parser_constant_expression but (perhaps
conveniently) that's insufficient to resolve the problem.  The simple
fix in this patch is to tweak the two places that require INTEGER_CST
to treat all other tree types as though they are error_mark_node.

2022-03-10  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
PR c++/95999
* decl.cc (finish_enum_value_list): If VALUE isn't an INTEGER_CST
consider it to be zero (i.e. treat it like error_mark_node).
(build_enumerator): Likewise, if PREV_VALUE isn't an INTEGER_CST,
set VALUE to error_mark_node.

gcc/testsuite/ChangeLog
PR c++/95999
* g++.dg/parse/pr95999.C: New test case.

2 years agoPR c++/39751: ICE-on-invalid parsing regression.
Roger Sayle [Thu, 10 Mar 2022 07:32:06 +0000 (07:32 +0000)]
PR c++/39751: ICE-on-invalid parsing regression.

This is a fix for PR c++/39751 which is an ICE-on-invalid regression in
the C++ parser after encountering the end of file.  The one line change
is to check that the tokens cached in DECL_PENDING_INLINE_INFO haven't
been purged before processing them in cp_parser_late_parsing_for_member.

2022-03-10  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
PR c++/39751
* parser.cc (cp_parser_late_parsing_for_member): Confirm the token
stream hasn't been purged before processing DECL_PENDING_INLINE.

gcc/testsuite/ChangeLog
PR c++/39751
* g++.dg/parse/pr39751.C: New test case.

2 years agoDaily bump.
GCC Administrator [Thu, 10 Mar 2022 00:16:28 +0000 (00:16 +0000)]
Daily bump.

2 years agolibstdc++: Avoid implicit narrowing from uint128_t [PR104859]
Patrick Palka [Wed, 9 Mar 2022 23:48:52 +0000 (18:48 -0500)]
libstdc++: Avoid implicit narrowing from uint128_t [PR104859]

We need to be explicit about narrowing conversions from uint128_t since,
on targets that lack __int128, this type is defined as an integer-class
type that is only _explicitly_ convertible to the builtin integer types.
This issue was latent until r12-7563-ge32869a17b788b made the frontend
correctly reject explicit conversion functions during (dependent)
copy-initialization.

PR libstdc++/104859

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (__floating_to_chars_hex):
Be explicit when narrowing the shifted effective_mantissa,
since it may have an integer-class type.

2 years agoc: Revert C2x changes to function type compatibility
Joseph Myers [Wed, 9 Mar 2022 22:51:23 +0000 (22:51 +0000)]
c: Revert C2x changes to function type compatibility

In commit cc806126215c3f4dc187eff3bf923458d8cc6b4f, I implemented
changes that C2x had made to compatibility of unprototyped and
prototyped function types.

C2x has since completely removed unprototyped function types, making
() in a function declaration mean (void) as in C++.  While that change
isn't appropriate at the current development stage for GCC 12, it does
mean that it doesn't make sense for GCC 12 to have different rules for
unprototyped functions in C2x mode than in other modes or previous and
subsequent GCC versions.  Thus, revert the previous change to avoid it
getting into a GCC release, and update the corresponding tests to
expect the same behavior with -std=c2x as with -std=c11 (they will of
course need to change again after implementing () as meaning (void)).

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

gcc/c/
* c-typeck.cc (function_types_compatible_p): Do not handle C2X
differently from earlier standards for unprototyped function type
compatibility.

gcc/testsuite/
* gcc.dg/c11-unproto-1.c, gcc.dg/c11-unproto-2.c: Update comments.
* gcc.dg/c2x-unproto-1.c, gcc.dg/c2x-unproto-2.c: Expect same
results as in C11 mode.  Update comments.

2 years agoFortran: improve error recovery on invalid array section
Harald Anlauf [Wed, 9 Mar 2022 20:58:26 +0000 (21:58 +0100)]
Fortran: improve error recovery on invalid array section

gcc/fortran/ChangeLog:

PR fortran/104849
* expr.cc (find_array_section): Avoid NULL pointer dereference on
invalid array section.

gcc/testsuite/ChangeLog:

PR fortran/104849
* gfortran.dg/pr104849.f90: New test.

2 years agotoplevel: Makefile.def: Make configure-sim depend on all-readline
Hans-Peter Nilsson [Wed, 9 Mar 2022 19:54:37 +0000 (20:54 +0100)]
toplevel: Makefile.def: Make configure-sim depend on all-readline

Without this, a "make all-sim" without the equivalent of
libreadline-dev installed on the build system, won't
properly pick up the in-tree readline build, and you'll see:

mkdir -p -- ./sim
Configuring in ./sim
configure: creating cache ./config.cache
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... cris-axis-elf
checking for x86_64-pc-linux-gnu-gcc... gcc
checking whether the C compiler works... yes
...
checking for library containing tgetent... -ltermcap
checking for readline in -lreadline... no
configure: error: the required "readline" library is missing
make[1]: *** [Makefile:11188: configure-sim] Error 1
make[1]: Leaving directory '/home/hp/sim/b'

The sim dependency on readline is apparently (nominally)
valid as there's a readline call in sim/erc32/sis.c.

2022-02-21  Hans-Peter Nilsson  <hp@axis.com>

* Makefile.def (dependencies): Make configure-sim depend on
all-readline.
* Makefile.in: Regenerate.

2 years agoGCN: Implement __atomic_compare_exchange_{1,2} in libgcc [PR102215]
Tobias Burnus [Wed, 9 Mar 2022 18:34:48 +0000 (19:34 +0100)]
GCN: Implement __atomic_compare_exchange_{1,2} in libgcc [PR102215]

libgcc/ChangeLog:

PR target/102215
* config/gcn/atomic.c (__sync_val_compare_and_swap_##SIZE): Move
a line up to non-arg-dependent value first.
(__ATOMIC_COMPARE_EXCHANGE): Define + call to generate
__atomic_compare_exchange_{1,2}.

2 years agoRestore INDIRECT_REF asm operand heuristic with MEM_REF
Richard Biener [Wed, 9 Mar 2022 14:17:27 +0000 (15:17 +0100)]
Restore INDIRECT_REF asm operand heuristic with MEM_REF

As noticed we are looking for INDIRECT_REF with allows_mem to avoid
a copy since then we're sure the operand is in memory (assuming
*& is folded).  But INDIRECT_REFs are no longer a thing, the following
replaces the check with a check for a MEM_REF with a non-ADDR_EXPR
operand.  This should fix the regression part without fully
exploring all possibilities around tcc_reference operands.

I've placed an assert that we do not see an INDIRECT_REF here.
While we gimplify asm operands we never do any checking on its
IL afterwards.

2022-03-09  Richard Biener  <rguenther@suse.de>

* cfgexpand.cc (expand_gimple_asm): Special-case MEM_REF
with non-decl operand, avoiding a copy.

2 years agox86: Define LIBGCC2_UNWIND_ATTRIBUTE on ia32 [PR104781]
Jakub Jelinek [Wed, 9 Mar 2022 14:25:30 +0000 (15:25 +0100)]
x86: Define LIBGCC2_UNWIND_ATTRIBUTE on ia32 [PR104781]

On Mon, Mar 07, 2022 at 07:06:28AM -0800, H.J. Lu wrote:
> Since eh_return doesn't work with stack realignment, disable SSE on
> unwind-c.c and unwind-dw2.c to avoid stack realignment with the 4-byte
> incoming stack to avoid SSE usage which is caused by

The following change does that using LIBGCC2_UNWIND_ATTRIBUTE macro instead,
for ia32 only by forcing -mgeneral-regs-only on routines that call
__builtin_eh_return in libgcc.

2022-03-09  Jakub Jelinek  <jakub@redhat.com>

PR target/104781
* config/i386/i386.h (LIBGCC2_UNWIND_ATTRIBUTE): Define for ia32.

2 years agoc++: non-constant non-dependent decltype folding [PR104823]
Patrick Palka [Wed, 9 Mar 2022 13:42:37 +0000 (08:42 -0500)]
c++: non-constant non-dependent decltype folding [PR104823]

When processing a non-dependent decltype operand we want to instantiate
it even if it's non-constant, since non-dependent decltype is always
resolved ahead of time.  But currently finish_decltype_type uses
instantiate_non_dependent_expr, which instantiates only potentially
constant expressions, and this causes us to miss diagnosing the narrowing
conversion in S{id(v)} in the below testcase because we never instantiate
this non-constant non-dependent decltype operand.

In light of

  > On Mon, 7 Mar 2022, Jason Merrill wrote:
  >> On 3/7/22 14:41, Patrick Palka wrote:
  >>> instantiate_non_dependent_expr instantiates only potentially constant
  >>> expressions
  >>
  >> Hmm, that now strikes me as a problematic interface, as we don't know whether
  >> what we get back is template or non-template trees.

this patch drops the potentially-constant check in i_n_d_e and turns
its dependence check into a checking_assert, since most callers already
check that the argument is non-dependent; thus i_n_d_e now instantiates
even non-constant expressions and always returns non-templated trees.
This patch also relaxes the dependence check in i_n_d_e to use the
_uneval version (since that's what finish_decltype_type uses) and
strengthens the dependence checks used by other callers accordingly.

In cp_parser_parenthesized_expression_list_elt we were calling
instantiate_non_dependent_expr (when parsing an attribute list) without
first checking for non-dependence.  We could fix this by guarding the
call appropriately, but I noticed we also fold non-dependent attributes
later from cp_check_const_attribute, so this earlier folding is at best
redundant.  And it currently causes us to reject constexpr-attribute4.C
below due to the second folding seeing non-templated trees.  Thus the
right solution here seems to be to remove this unguarded call to i_n_d_e
so that we end up instantiating non-dependent attributes only once.

Finally, after calling i_n_d_e in finish_decltype_type we need to keep
processing_template_decl cleared for sake of the later call to
lvalue_kind, which handles templated and non-templated COND_EXPR
differently.  Otherwise we'd incorrectly reject the declaration of g in
cpp0x/cond2.C with:

  error: 'g' declared as function returning a function

PR c++/104823

gcc/cp/ChangeLog:

* except.cc (build_noexcept_spec): Strengthen dependence check
to instantiation_dependent_expression_p.
* parser.cc (cp_parser_parenthesized_expression_list_elt):
Remove fold_expr_p parameter, and don't call
instantiate_non_dependent_expr.
(cp_parser_parenthesized_expression_list): Adjust accordingly.
* pt.cc (expand_integer_pack): Strengthen dependence check
to instantiation_dependent_expression_p.
(instantiate_non_dependent_expr_internal): Adjust comment.
(instantiate_non_dependent_expr_sfinae): Likewise.  Drop
the potentially-constant check, and relax and turn the
dependence check into a checking assert.
(instantiate_non_dependent_or_null): Adjust comment.
* semantics.cc (finish_decltype_type): Keep
processing_template_decl cleared after calling
instantiate_non_dependent_expr_sfinae.

gcc/testsuite/ChangeLog:

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

2 years agoc++: detecting copy-init context during CTAD [PR102137]
Patrick Palka [Wed, 9 Mar 2022 13:42:32 +0000 (08:42 -0500)]
c++: detecting copy-init context during CTAD [PR102137]

Here we're failing to communicate to cp_finish_decl from tsubst_expr
that we're in a copy-initialization context (via the LOOKUP_ONLYCONVERTING
flag), which causes us to always consider explicit deduction guides when
performing CTAD for a templated variable initializer.

It turns out this bug also affects consideration of explicit conversion
operators for the same reason.  But consideration of explicit constructors
seems unaffacted thanks to code in build_aggr_init that sets
LOOKUP_ONLYCONVERTING when the initializer represents copy-initialization.

So this patch fixes this by making cp_finish_decl set LOOKUP_ONLYCONVERTING
just like build_aggr_init does, by inspecting the initializer, so that
callers don't need to explicitly pass this flag appropriately.

PR c++/102137
PR c++/87820

gcc/cp/ChangeLog:

* cp-tree.h (is_copy_initialization): Declare.
* decl.cc (cp_finish_decl): Set LOOKUP_ONLYCONVERTING
when is_copy_initialization is true.
* init.cc (build_aggr_init): Split out copy-initialization
check into ...
(is_copy_initialization): ... here.
* pt.cc (instantiate_decl): Pass 0 instead of
LOOKUP_ONLYCONVERTING as flags to cp_finish_decl.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/explicit15.C: New test.
* g++.dg/cpp1z/class-deduction108.C: New test.

2 years agoc++: merge default targs for function templates [PR65396]
Patrick Palka [Wed, 9 Mar 2022 13:42:19 +0000 (08:42 -0500)]
c++: merge default targs for function templates [PR65396]

We currently merge default template arguments for class templates, but
not for function templates.  This patch fixes this by factoring out the
argument merging logic in redeclare_class_template into a separate
function and using it in duplicate_decls as well.

PR c++/65396

gcc/cp/ChangeLog:

* cp-tree.h (merge_default_template_args): Declare.
* decl.cc (merge_default_template_args): Define, factored out
from redeclare_class_template.
(duplicate_decls): Use it when merging member function template
and free function declarations.
* pt.cc (redeclare_class_template): Factor out default argument
merging logic into merge_default_template_args.  Improve location
of a note when there's a template parameter kind mismatch.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/vt-34314.C: Adjust expected location of
"redeclared here" note.
* g++.dg/template/pr92440.C: Likewise.
* g++.old-deja/g++.pt/redecl1.C: Adjust expected location of
"redefinition of default argument" error.
* g++.dg/template/defarg23.C: New test.
* g++.dg/template/defarg23a.C: New test.

2 years agotestsuite/104759 - adjust gcc.dg/vect/vect-multitypes-12.c
Richard Biener [Wed, 9 Mar 2022 13:37:35 +0000 (14:37 +0100)]
testsuite/104759 - adjust gcc.dg/vect/vect-multitypes-12.c

This adjusts gcc.dg/vect/vect-multitypes-12.c to just look for the
interesting loop vectorization.

2022-03-09  Richard Biener  <rguenther@suse.de>

PR testsuite/104759
* gcc.dg/vect/vect-multitypes-12.c: Adjust.

2 years agomiddle-end/104786 - ICE with asm and VLA
Richard Biener [Wed, 9 Mar 2022 09:55:49 +0000 (10:55 +0100)]
middle-end/104786 - ICE with asm and VLA

The following fixes an ICE observed with a MEM_REF allows_mem asm
operand referencing a VLA.  The following makes sure to not attempt
to go the temporary creation way when we cannot.

2022-03-09  Richard Biener  <rguenther@suse.de>

PR middle-end/104786
* cfgexpand.cc (expand_asm_stmt): Do not generate a copy
for VLAs without an upper size bound.

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

2 years agovect: fix out-of-bound access in supports_vec_convert_optab_p [PR 104851]
Xi Ruoyao [Wed, 9 Mar 2022 03:46:03 +0000 (11:46 +0800)]
vect: fix out-of-bound access in supports_vec_convert_optab_p [PR 104851]

Calling VECTOR_MODE_P with MAX_MACHINE_MODE has caused out-of-bound
access.

gcc/

PR tree-optimization/104851
* optabs-query.cc (supports_vec_convert_optab_p): Fix off-by-one
error.

2 years agoFortran: Fix CLASS handling in SIZEOF intrinsic
Tobias Burnus [Wed, 9 Mar 2022 09:25:11 +0000 (10:25 +0100)]
Fortran: Fix CLASS handling in SIZEOF intrinsic

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_sizeof): Fix CLASS handling.

gcc/testsuite/ChangeLog:

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

2 years agoc, c++, c-family: -Wshift-negative-value and -Wshift-overflow* tweaks for -fwrapv...
Jakub Jelinek [Wed, 9 Mar 2022 08:15:28 +0000 (09:15 +0100)]
c, c++, c-family: -Wshift-negative-value and -Wshift-overflow* tweaks for -fwrapv and C++20+ [PR104711]

As mentioned in the PR, different standards have different definition
on what is an UB left shift.  They all agree on out of bounds (including
negative) shift count.
The rules used by ubsan are:
C99-C2x ((unsigned) x >> (uprecm1 - y)) != 0 then UB
C++11-C++17 x < 0 || ((unsigned) x >> (uprecm1 - y)) > 1 then UB
C++20 and later everything is well defined
Now, for C++20, I've in the P1236R1 implementation added an early
exit for -Wshift-overflow* warning so that it never warns, but apparently
-Wshift-negative-value remained as is.  As it is well defined in C++20,
the following patch doesn't enable -Wshift-negative-value from -Wextra
anymore for C++20 and later, if users want for compatibility with C++17
and earlier get the warning, they still can by using -Wshift-negative-value
explicitly.
Another thing is -fwrapv, that is an extension to the standards, so it is up
to us how exactly we define that case.  Our ubsan code treats
TYPE_OVERFLOW_WRAPS (type0) and cxx_dialect >= cxx20 the same as only
diagnosing out of bounds shift count and nothing else and IMHO it is most
sensical to treat -fwrapv signed left shifts the same as C++20 treats
them, https://eel.is/c++draft/expr.shift#2
"The value of E1 << E2 is the unique value congruent to E1×2^E2 modulo 2^N,
where N is the width of the type of the result.
[Note 1: E1 is left-shifted E2 bit positions; vacated bits are zero-filled.
— end note]"
with no UB dependent on the E1 values.  The UB is only
"The behavior is undefined if the right operand is negative, or greater
than or equal to the width of the promoted left operand."
Under the hood (except for FEs and ubsan from FEs) GCC middle-end doesn't
consider UB in left shifts dependent on the first operand's value, only
the out of bounds shifts.

While this change isn't a regression, I'd think it is useful for GCC 12,
it doesn't add new warnings, but just removes warnings that aren't
appropriate.

2022-03-09  Jakub Jelinek  <jakub@redhat.com>

PR c/104711
gcc/
* doc/invoke.texi (-Wextra): Document that -Wshift-negative-value
is enabled by it only for C++11 to C++17 rather than for C++03 or
later.
(-Wshift-negative-value): Similarly (except here we stated
that it is enabled for C++11 or later).
gcc/c-family/
* c-opts.cc (c_common_post_options): Don't enable
-Wshift-negative-value from -Wextra for C++20 or later.
* c-ubsan.cc (ubsan_instrument_shift): Adjust comments.
* c-warn.cc (maybe_warn_shift_overflow): Use TYPE_OVERFLOW_WRAPS
instead of TYPE_UNSIGNED.
gcc/c/
* c-fold.cc (c_fully_fold_internal): Don't emit
-Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS.
* c-typeck.cc (build_binary_op): Likewise.
gcc/cp/
* constexpr.cc (cxx_eval_check_shift_p): Use TYPE_OVERFLOW_WRAPS
instead of TYPE_UNSIGNED.
* typeck.cc (cp_build_binary_op): Don't emit
-Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS.
gcc/testsuite/
* c-c++-common/Wshift-negative-value-1.c: Remove
dg-additional-options, instead in target selectors of each diagnostic
check for exact C++ versions where it should be diagnosed.
* c-c++-common/Wshift-negative-value-2.c: Likewise.
* c-c++-common/Wshift-negative-value-3.c: Likewise.
* c-c++-common/Wshift-negative-value-4.c: Likewise.
* c-c++-common/Wshift-negative-value-7.c: New test.
* c-c++-common/Wshift-negative-value-8.c: New test.
* c-c++-common/Wshift-negative-value-9.c: New test.
* c-c++-common/Wshift-negative-value-10.c: New test.
* c-c++-common/Wshift-overflow-1.c: Remove
dg-additional-options, instead in target selectors of each diagnostic
check for exact C++ versions where it should be diagnosed.
* c-c++-common/Wshift-overflow-2.c: Likewise.
* c-c++-common/Wshift-overflow-5.c: Likewise.
* c-c++-common/Wshift-overflow-6.c: Likewise.
* c-c++-common/Wshift-overflow-7.c: Likewise.
* c-c++-common/Wshift-overflow-8.c: New test.
* c-c++-common/Wshift-overflow-9.c: New test.
* c-c++-common/Wshift-overflow-10.c: New test.
* c-c++-common/Wshift-overflow-11.c: New test.
* c-c++-common/Wshift-overflow-12.c: New test.

2 years agosimplify-rtx: Fix up SUBREG_PROMOTED_SET arguments [PR104839]
Jakub Jelinek [Wed, 9 Mar 2022 08:12:38 +0000 (09:12 +0100)]
simplify-rtx: Fix up SUBREG_PROMOTED_SET arguments [PR104839]

The following testcase is miscompiled on powerpc64le-linux at -O1 and higher
(except for -Og).  The bug was introduced in r12-3252-gcad36f38576a6a7
which for SIGN_EXTEND from SUBREG_PROMOTED_SIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 1) (but that makes temp
SUBREG_PROMOTED_UNSIGNED_P because SRP_UNSIGNED is 1) and similarly the
ZERO_EXTEND from SUBREG_PROMOTED_UNSIGNED_P SUBREG used
SUBREG_PROMOTED_SET (temp, 0) (but that makes temp
SUBREG_PROMOTED_SIGNED_P because SRP_SIGNED is 0).
The following patch fixes that (swaps the 0s and 1s), but for better
readability uses the SRP_* constants.
rtl.h has:
/* Valid for subregs which are SUBREG_PROMOTED_VAR_P().  In that case
   this gives the necessary extensions:
   0  - signed (SPR_SIGNED)
   1  - normal unsigned (SPR_UNSIGNED)
   2  - value is both sign and unsign extended for mode
        (SPR_SIGNED_AND_UNSIGNED).
   -1 - pointer unsigned, which most often can be handled like unsigned
        extension, except for generating instructions where we need to
        emit special code (ptr_extend insns) on some architectures
        (SPR_POINTER). */
The expr.c change in the same commit looks ok to me (passes unsignedp
to SUBREG_PROMOTED_SET, so 0 for signed, 1 for unsigned).

2022-03-09  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/104839
* simplify-rtx.cc (simplify_unary_operation_1) <case SIGN_EXTEND>:
Use SRP_SIGNED instead of incorrect 1 in SUBREG_PROMOTED_SET.
(simplify_unary_operation_1) <case ZERO_EXTEND>: Use SRP_UNSIGNED
instead of incorrect 0 in SUBREG_PROMOTED_SET.

* gcc.c-torture/execute/pr104839.c: New test.

2 years agomips: avoid signed overflow in LUI_OPERAND [PR104842]
Xi Ruoyao [Tue, 8 Mar 2022 17:08:58 +0000 (01:08 +0800)]
mips: avoid signed overflow in LUI_OPERAND [PR104842]

gcc/

PR target/104842
* config/mips/mips.h (LUI_OPERAND): Cast the input to an unsigned
value before adding an offset.

2 years agocontrib: Fix non-portable sed commands in gcc-descr [PR102664/]
Jonathan Wakely [Tue, 8 Mar 2022 17:40:48 +0000 (17:40 +0000)]
contrib: Fix non-portable sed commands in gcc-descr [PR102664/]

POSIX sed does not support \? or \+ in its Basic Regular Expression
grammar. Replace the \(tags/\)\? part of the pattern with a substitution
to remove ^tags/ before other substitutions. Replace \([0-9]\+\) with
\([0-9][0-9]*\) or with \([1-9][0-9]*\) in release branch numbers, where
a leading zero does not occur.

contrib/ChangeLog:

PR other/102664
* git-descr.sh: Use portable sed commands.
* git-undescr.sh: Likewise.

2 years agoDaily bump.
GCC Administrator [Wed, 9 Mar 2022 00:16:29 +0000 (00:16 +0000)]
Daily bump.

2 years agoPR c++/96440: ICE-on-invalid-code error recovery.
Roger Sayle [Tue, 8 Mar 2022 23:33:46 +0000 (23:33 +0000)]
PR c++/96440: ICE-on-invalid-code error recovery.

This patch fixes PR c++/96440 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
PR c++/96440
* decl.cc (start_decl): Defend against prefix_attributes being
error_mark_node.

gcc/testsuite/ChangeLog
PR c++/96440
* g++.dg/cpp0x/pr96440.C: New test case.

2 years agoFortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]
Tobias Burnus [Tue, 8 Mar 2022 23:26:14 +0000 (00:26 +0100)]
Fortran: Fix gfc_conv_gfc_desc_to_cfi_desc with NULL [PR104126]

PR fortran/104126
gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Handle NULL
without MOLD.

gcc/testsuite/ChangeLog:

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

2 years agoPR c++/96437: ICE-on-invalid-code error recovery.
Roger Sayle [Tue, 8 Mar 2022 23:23:19 +0000 (23:23 +0000)]
PR c++/96437: ICE-on-invalid-code error recovery.

This patch fixes PR c++/96437 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
PR c++/96437
* parser.cc (synthesize_implicit_template_parm): Check that
TREE_VALUE (new_parm) isn't error_mark_node before setting its
DECL_VIRTUAL_P.

gcc/testsuite/ChangeLog
PR c++/96437
* g++.dg/cpp2a/pr96437.C: New test case.

2 years agoPR c++/96329: ICE-on-invalid-code error recovery.
Roger Sayle [Tue, 8 Mar 2022 23:18:34 +0000 (23:18 +0000)]
PR c++/96329: ICE-on-invalid-code error recovery.

This patch fixes PR c++/96329 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
PR c++/96329
* parser.cc (cp_parser_linkage_specification): Treat the case where
linkage is error_mark_node as "invalid linkage-specification".

gcc/testsuite/ChangeLog
PR c++/96329
* g++.dg/template/pr96329.C: New test case.

2 years agoc++: Wrong error with alias template in class tmpl [PR104108]
Marek Polacek [Tue, 8 Mar 2022 18:55:15 +0000 (13:55 -0500)]
c++: Wrong error with alias template in class tmpl [PR104108]

In r10-6329 I tried to optimize the number of calls to v_d_e_p in
convert_nontype_argument by remembering whether the expression was
value-dependent in a bool flag.  I did that wrongly assuming that its
value-dependence will not be changed by build_converted_constant_expr.
This testcase shows that it can: b_c_c_e gets a VAR_DECL for m_parameter,
which is not value-dependent, but we're converting it to "const int &"
so it returns

  (const int &)(const int *) &m_parameter

which suddenly becomes value-dependent because of the added ADDR_EXPR:
has_value_dependent_address is now true because m_parameter's context S<T>
is dependent.  With this bug in place, we went to the second branch here:

      if (TYPE_REF_OBJ_P (TREE_TYPE (expr)) && val_dep_p)
        /* OK, dependent reference.  We don't want to ask whether a DECL is
           itself value-dependent, since what we want here is its address.  */;
      else
        {
          expr = build_address (expr);

          if (invalid_tparm_referent_p (type, expr, complain))
            return NULL_TREE;
        }

wherein build_address created a bad tree and then i_t_r_p complained.

PR c++/104108

gcc/cp/ChangeLog:

* pt.cc (convert_nontype_argument): Recompute
value_dependent_expression_p after build_converted_constant_expr.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-74.C: New test.

2 years agocompiler: ignore function type result name in export data
Ian Lance Taylor [Tue, 8 Mar 2022 21:30:02 +0000 (13:30 -0800)]
compiler: ignore function type result name in export data

This change ensures that we never output a result name in the export
data if there is only a single result.  Previously we would output a ?
if the single result had a name.  That made the output unstable,
because the hashing ignores the result name, so whether we output a ?
or not depended on how equal hash elements were handled.

For https://gcc.gnu.org/PR104832

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/390874

2 years agoc++: Attribute deprecated/unavailable divergence
Marek Polacek [Wed, 2 Mar 2022 15:48:26 +0000 (10:48 -0500)]
c++: Attribute deprecated/unavailable divergence

Attributes deprecated and unavailable are largely the same, except
that the former produces a warning whereas the latter produces an error.
So is_late_template_attribute should treat them the same.  Confirmed by
Iain that this divergence is not intentional:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-February/591007.html>.

gcc/cp/ChangeLog:

* decl2.cc (is_late_template_attribute): Do not defer attribute
unavailable.
* pt.cc (tsubst_enum): Set TREE_UNAVAILABLE.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-unavailable-9.C: Add dg-error.

2 years agoFortran: do not frontend-optimize MINLOC/MAXLOC for character arrays
Harald Anlauf [Tue, 8 Mar 2022 20:47:04 +0000 (21:47 +0100)]
Fortran: do not frontend-optimize MINLOC/MAXLOC for character arrays

gcc/fortran/ChangeLog:

PR fortran/104811
* frontend-passes.cc (optimize_minmaxloc): Do not attempt
frontend-optimization of MINLOC/MAXLOC for character arrays, as
there is no suitable code yet for inline expansion.

gcc/testsuite/ChangeLog:

PR fortran/104811
* gfortran.dg/minmaxloc_16.f90: New test.

2 years agoc++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]
Jakub Jelinek [Tue, 8 Mar 2022 20:41:21 +0000 (21:41 +0100)]
c++: Don't suggest cdtor or conversion op identifiers in spelling hints [PR104806]

On the following testcase, we emit "did you mean '__dt '?" in the error
message.  "__dt " shows there because it is dtor_identifier, but we
shouldn't suggest those to the user, they are purely internal and can't
be really typed by the user because of the final space in it.

2022-03-08  Jakub Jelinek  <jakub@redhat.com>

PR c++/104806
* search.cc (lookup_field_fuzzy_info::fuzzy_lookup_field): Ignore
identifiers with space at the end.

* g++.dg/spellcheck-pr104806.C: New test.

2 years agoarm: Remove unused variable arm_binop_none_none_unone_qualifiers
Christophe Lyon [Fri, 4 Mar 2022 14:44:15 +0000 (15:44 +0100)]
arm: Remove unused variable arm_binop_none_none_unone_qualifiers

Commits r12-7342 and r12-7344 made some cleanup, leaving
arm_binop_none_none_unone_qualifiers unused.
This is causing build failures with -Werror (eg bootstrap).

This patch fixes the problem by removing the definition of
arm_binop_none_none_unone_qualifiers and
BINOP_NONE_NONE_UNONE_QUALIFIERS which are now unused.

Tested by bootstraping on arm-linux-gnueaibhf.

2022-03-04  Christophe Lyon  <christophe.lyon@arm.com>

gcc/
* config/arm/arm-builtins.cc
(arm_binop_none_none_unone_qualifiers): Delete.
(BINOP_NONE_NONE_UNONE_QUALIFIERS): Delete.

2 years agoDarwin: Address a translation comment [PR104552].
Iain Sandoe [Tue, 8 Mar 2022 15:28:05 +0000 (15:28 +0000)]
Darwin: Address a translation comment [PR104552].

This amends an error message to correct punctuation and a little
better wording.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR translation/104552

gcc/ChangeLog:

* config/host-darwin.cc (darwin_gt_pch_get_address): Amend
the PCH out of memory error message punctuation and wording.

2 years agoanalyzer: more test coverage of leak detection [PR99771]
David Malcolm [Tue, 8 Mar 2022 19:16:48 +0000 (14:16 -0500)]
analyzer: more test coverage of leak detection [PR99771]

gcc/testsuite/ChangeLog:
PR analyzer/99771
* gcc.dg/analyzer/leak-4.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agortl: ICE with thread_local and inline asm [PR104777]
Marek Polacek [Mon, 7 Mar 2022 21:15:46 +0000 (16:15 -0500)]
rtl: ICE with thread_local and inline asm  [PR104777]

In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can
jump to a label, the insn should be a JUMP_INSN.

However, as the following testcase shows, non-null ASM_OPERANDS_LABEL_VEC
doesn't guarantee that the rtx has any actual labels it can branch to.
Here, the rtvec has 0 elements because expand_asm_stmt created it:

  rtvec labelvec = rtvec_alloc (nlabels); // nlabels == 0

This causes an ICE in update_br_prob_note: BRANCH_EDGE (bb) crashes
because there's no branch edge.  I think we can fix this by checking
that there is at least one label the asm can jump to before wrapping
the ASM_OPERANDS in a JUMP_INSN.

PR rtl-optimization/104777

gcc/ChangeLog:

* rtl.cc (classify_insn): For ASM_OPERANDS, return JUMP_INSN only if
ASM_OPERANDS_LABEL_VEC has at least one element.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/tls/pr104777.c: New test.

2 years agox86: Disallow unsupported EH return
H.J. Lu [Fri, 4 Mar 2022 13:53:14 +0000 (05:53 -0800)]
x86: Disallow unsupported EH return

Disallow stack realignment and regparm nested function with EH return
since they don't work together.

gcc/

PR target/104781
* config/i386/i386.cc (ix86_expand_epilogue): Sorry if there is
stack realignment or regparm nested function with EH return.

gcc/testsuite/

PR target/104781
* gcc.target/i386/eh_return-1.c: Add -mincoming-stack-boundary=4.
* gcc.target/i386/eh_return-2.c: Likewise.

2 years agoarm: MVE: Relax addressing modes for full loads and stores
Andre Vieira [Tue, 8 Mar 2022 17:46:40 +0000 (17:46 +0000)]
arm: MVE: Relax addressing modes for full loads and stores

This patch relaxes the addressing modes for the mve full load and stores (by
full loads and stores I mean non-widening or narrowing loads and stores resp).
The code before was requiring a LO_REGNUM for these, where this is only a
requirement if the load is widening or the store narrowing.

gcc/ChangeLog:

PR target/104790
* config/arm/arm.h (MVE_STN_LDW_MODE): New MACRO.
* config/arm/arm.cc (mve_vector_mem_operand): Relax constraint on base
register for non widening loads or narrowing stores.

2 years agoFix typo in gcc/params.opt.
Eric Gallager [Tue, 8 Mar 2022 17:14:33 +0000 (12:14 -0500)]
Fix typo in gcc/params.opt.

Addresses one of the points raised in #104552; checking in under
the "obvious" rule.

gcc/ChangeLog:
PR translation/104552
* params.opt: Fix typo.

2 years agocontrib: Fix gcc-descr script [PR102664]
Jonathan Wakely [Tue, 8 Mar 2022 16:44:17 +0000 (16:44 +0000)]
contrib: Fix gcc-descr script [PR102664]

POSIX expr does not support the 'match' keyword, so the git-descr.sh
scripts should use ':' instead.

contrib/ChangeLog:

PR other/102664
* git-descr.sh: Use portable form of expr match.

2 years agotree-optimization/84201 - add --param vect-induction-float
Richard Biener [Tue, 8 Mar 2022 11:07:07 +0000 (12:07 +0100)]
tree-optimization/84201 - add --param vect-induction-float

This adds a --param to allow disabling of vectorization of
floating point inductions.  Ontop of -Ofast this should allow
549.fotonik3d_r to not miscompare.

2022-03-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84201
* params.opt (-param=vect-induction-float): Add.
* doc/invoke.texi (vect-induction-float): Document.
* tree-vect-loop.cc (vectorizable_induction): Honor
param_vect_induction_float.

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

2 years agolibstdc++: Remove incorrect copyright notice from header
Jonathan Wakely [Tue, 8 Mar 2022 09:14:33 +0000 (09:14 +0000)]
libstdc++: Remove incorrect copyright notice from header

This file has the SGI copyright notice, but contains no code from
the SGI STL. It was entirely written by me in 2019, originally as part
of the <memory> header. When I extracted it into a new header I
accidentally copied across the SGI copyright, but that only applies to
some much older parts of <memory>.

libstdc++-v3/ChangeLog:

* include/bits/uses_allocator_args.h: Remove incorrect copyright
notice.

2 years agovect: disable bitmask tests on sparc
Tamar Christina [Tue, 8 Mar 2022 11:32:59 +0000 (11:32 +0000)]
vect: disable bitmask tests on sparc

These testcases declare requiring vect_int which sparc declares as well however
sparc doesn't have an optab to vectorize comparisons so these testcases fail to
vectorize and so the tests fail.

As such best coure of action is to just skip them on sparc as comparisons are
somewhat expected from a target that can do SIMD.

gcc/testsuite/ChangeLog:

PR tree-optimization/104755
* gcc.dg/vect/vect-bic-bitmask-10.c: Disable sparc.
* gcc.dg/vect/vect-bic-bitmask-11.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-12.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-2.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-23.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-3.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-4.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-5.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-6.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-8.c: Likewise.
* gcc.dg/vect/vect-bic-bitmask-9.c: Likewise.

2 years agoparams: Remove repeated word "that" in parameter description
Martin Jambor [Tue, 8 Mar 2022 10:32:15 +0000 (11:32 +0100)]
params: Remove repeated word "that" in parameter description

One of the mistakes reported in PR 104552 is repeated "that" in
description of ipa-cp-recursive-freq-factor which I introduced.  This
patch removes one of them.

gcc/ChangeLog:

2022-03-07  Martin Jambor  <mjambor@suse.cz>

PR translation/104552
* params.opt (ipa-cp-recursive-freq-factor): Remove repeated word
"that" in the description.

2 years agotree-optimization/104825 - guard modref query
Richard Biener [Tue, 8 Mar 2022 07:42:58 +0000 (08:42 +0100)]
tree-optimization/104825 - guard modref query

The following makes sure to guard the modref query in VN on a
pointer typed argument.

2022-03-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/104825
* tree-ssa-sccvn.cc (visit_reference_op_call): Properly
guard modref get_ao_ref on a pointer typed argument.

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

2 years agoOptimize v4si broadcast for noavx512vl.
liuhongt [Thu, 3 Mar 2022 05:31:39 +0000 (13:31 +0800)]
Optimize v4si broadcast for noavx512vl.

This will enable below

-       vbroadcastss    .LC1(%rip), %xmm0
+       movl    $-45, %edx
+       vmovd   %edx, %xmm0
+       vpshufd $0, %xmm0, %xmm0

According to microbenchmark, it's faster than broadcast from memory
for TARGET_INTER_UNIT_MOVES_TO_VEC.

gcc/ChangeLog:

* config/i386/sse.md (*vec_dupv4si): Disable memory operand
for !TARGET_INTER_UNIT_MOVES_TO_VEC when prefer_for_speed.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr100865-8a.c: Adjust testcase.
* gcc.target/i386/pr100865-8c.c: Ditto.
* gcc.target/i386/pr100865-9c.c: Ditto.

2 years agoDaily bump.
GCC Administrator [Tue, 8 Mar 2022 00:16:32 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: tweak to (*(fn))() patch [PR104618]
Jason Merrill [Mon, 28 Feb 2022 16:05:34 +0000 (12:05 -0400)]
c++: tweak to (*(fn))() patch [PR104618]

Other callers of mark_single_function might also want to look through these
wrapapers.

PR c++/104618

gcc/cp/ChangeLog:

* decl2.cc (mark_single_function): Look through parens and location
wrapper.
* typeck.cc (cp_build_addr_expr_1): Not here.

2 years agoUpdate gcc fr.po, sv.po
Joseph Myers [Mon, 7 Mar 2022 21:44:04 +0000 (21:44 +0000)]
Update gcc fr.po, sv.po

* fr.po, sv.po: Update.

2 years agoFortran: Fix gfc_maybe_dereference_var [PR104430][PR99585]
Tobias Burnus [Mon, 7 Mar 2022 21:11:33 +0000 (22:11 +0100)]
Fortran: Fix gfc_maybe_dereference_var [PR104430][PR99585]

PR fortran/99585
PR fortran/104430

gcc/fortran/ChangeLog:

* trans-expr.cc (conv_parent_component_references): Fix comment;
simplify comparison.
(gfc_maybe_dereference_var): Avoid d referencing a nonpointer.

gcc/testsuite/ChangeLog:

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

2 years agoanalyzer: fix leak suppression at end of 'main' [PR101983]
David Malcolm [Mon, 7 Mar 2022 19:19:30 +0000 (14:19 -0500)]
analyzer: fix leak suppression at end of 'main' [PR101983]

PR analyzer/101983 reports what I thought were false positives
from -Wanalyzer-malloc-leak, but on closer inspection, the
analyzer is correctly reporting heap-allocated buffers that are
no longer reachable.

However, these "leaks" occur at the end of "main".  The analyzer already
has some logic to avoid reporting leaks at the end of main, where the
leak is detected at the end of the EXIT basic block.  However, in this case,
the leak is detected at the clobber in BB 2 here:
  <bb 2> :
  func (&res);
  res ={v} {CLOBBER(eol)};
  _4 = 0;

  <bb 3> :
<L0>:
  return _4;

where we have a chain BB 2 -> BB 3 -> EXIT BB.

This patch generalizes the "are we at the end of 'main'" detection to
handle such cases, silencing -Wanalyzer-malloc-leak on them.

There's a remaining issue where the analyzer unhelpfully describes one
of the leaking values as '<unknown>', rather than 'res.a', but I'm
leaving that for a followup (covered by PR analyzer/99771).

gcc/analyzer/ChangeLog:
PR analyzer/101983
* engine.cc (returning_from_function_p): New.
(impl_region_model_context::on_state_leak): Use it when rejecting
leaks at the return from "main".

gcc/testsuite/ChangeLog:
PR analyzer/101983
* gcc.dg/analyzer/pr101983-main.c: New test.
* gcc.dg/analyzer/pr101983-not-main.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoFortran: Fix typos
Tobias Burnus [Mon, 7 Mar 2022 16:20:52 +0000 (17:20 +0100)]
Fortran: Fix typos

gcc/fortran/ChangeLog:

* array.cc (gfc_ref_dimen_size): Fix comment typo.
* dump-parse-tree.cc (gfc_dump_c_prototypes): Likewise.
* frontend-passes.cc (cfe_code): Likewise.
* gfortran.texi: Likewise.
* resolve.cc (generate_component_assignments): Likewise.
* simplify.cc (gfc_simplify_this_image): Likewise.
* trans-expr.cc (trans_scalar_class_assign,
gfc_maybe_dereference_var): Likewise.
* intrinsic.texi: Remove word duplication.
* invoke.texi: Likewise.

2 years agodoc: Remove redundant sentence about modules being in C++20
Jonathan Wakely [Mon, 7 Mar 2022 16:08:10 +0000 (16:08 +0000)]
doc: Remove redundant sentence about modules being in C++20

As C++20 has already been published, we don't need to link to the draft
(which is now the C++23 draft anyway). And there's no need to say it's
part of the C++20 spec, or that there might be defect reports. That's
true for everything in C++20, so calling it out here just for Modules
isn't needed.

gcc/ChangeLog:

* doc/invoke.texi (C++ Modules): Remove anachronism.

2 years agolibstdc++: Use visibility pragmas instead of attributes [PR104807]
Jonathan Wakely [Mon, 7 Mar 2022 15:07:05 +0000 (15:07 +0000)]
libstdc++: Use visibility pragmas instead of attributes [PR104807]

The _GLIBCXX_PSEUDO_VISIBILITY macro isn't defined until after including
os_defines.h, so we can't use _GLIBCXX_VISIBILITY early in c++config.
Replace the uses of that macro with #pragma visibility push(default)
instead.

libstdc++-v3/ChangeLog:

PR libstdc++/104807
* include/bits/c++config (__terminate, __glibcxx_assert_fail):
Replace _GLIBCXX_VISIBILITY on function with visibility pragma.
(__is_constant_evaluated): Add visibility pragma.

2 years agoopts: fix -gtoggle + optimize attribute
Martin Liska [Fri, 4 Feb 2022 14:50:17 +0000 (15:50 +0100)]
opts: fix -gtoggle + optimize attribute

Note -fvar-tracking is enabled automatically with OPT_LEVELS_1_PLUS and
so we need to drop it if we are called from optimize attribute and the
option is unset.

PR middle-end/104381

gcc/ChangeLog:

* opts.cc (finish_options): If debug info is disabled
(debug_info_level) and -fvar-tracking is unset, disable it.

gcc/testsuite/ChangeLog:

* gcc.dg/pr104381.c: New test.

2 years agoAdd missing space in various string literals
Jakub Jelinek [Mon, 7 Mar 2022 14:16:56 +0000 (15:16 +0100)]
Add missing space in various string literals

After more than 2 years I've run my
https://gcc.gnu.org/ml/gcc-patches/2017-02/msg00844.html
script again.  While it has lots of false positives, it discovered
two bugs.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
* c-parser.cc (c_parser_omp_clause_map): Add missing space in string
literal.
gcc/cp/
* parser.cc (cp_parser_omp_clause_map): Add missing space in string
literal.

2 years agoFix up duplicated duplicated words in comments
Jakub Jelinek [Mon, 7 Mar 2022 14:00:20 +0000 (15:00 +0100)]
Fix up duplicated duplicated words in comments

Like in r10-7215-g700d4cb08c88aec37c13e21e63dd61fd698baabc 2 years ago,
I've run
grep -v 'long long\|optab optab\|template template\|double double' *.{[chS],cc} */*.{[chS],cc} *.def config/*/* 2>/dev/null | grep ' \([a-zA-Z]\+\) \1 '
and for the cases that looked clearly wrong changed them, mostly by removing
one of the duplicated words but in some cases with other changes.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree-ssa-propagate.cc: Fix up duplicated word issue in a comment.
* config/riscv/riscv.cc: Likewise.
* config/darwin.h: Likewise.
* config/i386/i386.cc: Likewise.
* config/aarch64/thunderx3t110.md: Likewise.
* config/aarch64/fractional-cost.h: Likewise.
* config/vax/vax.cc: Likewise.
* config/rs6000/pcrel-opt.md: Likewise.
* config/rs6000/predicates.md: Likewise.
* ctfc.h: Likewise.
* tree-ssa-uninit.cc: Likewise.
* value-relation.h: Likewise.
* gimple-range-gori.cc: Likewise.
* ipa-polymorphic-call.cc: Likewise.
* pointer-query.cc: Likewise.
* ipa-sra.cc: Likewise.
* internal-fn.cc: Likewise.
* varasm.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
gcc/analyzer/
* store.cc: Fix up duplicated word issue in a comment.
* analyzer.cc: Likewise.
* engine.cc: Likewise.
* sm-taint.cc: Likewise.
gcc/c-family/
* c-attribs.cc: Fix up duplicated word issue in a comment.
gcc/cp/
* cvt.cc: Fix up duplicated word issue in a comment.
* pt.cc: Likewise.
* module.cc: Likewise.
* coroutines.cc: Likewise.
gcc/fortran/
* trans-expr.cc: Fix up duplicated word issue in a comment.
* gfortran.h: Likewise.
* scanner.cc: Likewise.
gcc/jit/
* libgccjit.h: Fix up duplicated word issue in a comment.

2 years agoarm: add missing space to error.
Martin Liska [Mon, 7 Mar 2022 13:16:21 +0000 (14:16 +0100)]
arm: add missing space to error.

PR target/104794

gcc/ChangeLog:

* config/arm/arm.cc (arm_option_override_internal): Add missing
space.

2 years agotree-optimization/104782 - adjust PR101636 fix
Richard Biener [Mon, 7 Mar 2022 10:11:44 +0000 (11:11 +0100)]
tree-optimization/104782 - adjust PR101636 fix

This reverts the reversion of r10-5979 amending the CTOR case
with a comment as to why the conversion is not necessary there.
It also adds a testcase (but not for the CTOR case).

2022-03-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/104782
* tree-vect-slp.cc (vectorize_slp_instance_root_stmt):
Re-instantiate r10-5979 fix, add comment.

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

2 years agoMSP430: fix error message.
Martin Liska [Mon, 7 Mar 2022 10:41:52 +0000 (11:41 +0100)]
MSP430: fix error message.

PR target/104797

gcc/ChangeLog:

* config/msp430/msp430.cc (msp430_expand_delay_cycles): Remove
parenthesis from built-in name.

2 years agoarm: fix option quoting in error messages.
Martin Liska [Mon, 7 Mar 2022 10:25:18 +0000 (11:25 +0100)]
arm: fix option quoting in error messages.

PR target/104794

gcc/ChangeLog:

* config/arm/arm.cc (arm_option_override_internal): Fix quoting
of options in error messages.
(arm_option_reconfigure_globals): Likewise.

2 years agotranslation: reuse string and use switch for codes
Martin Liska [Mon, 7 Mar 2022 09:56:43 +0000 (10:56 +0100)]
translation: reuse string and use switch for codes

PR target/104794

gcc/ChangeLog:

* config/arm/arm-builtins.cc (arm_expand_builtin): Reuse error
message.  Fix ARM_BUILTIN_WRORHI and ARM_BUILTIN_WRORH that can
have only range [0,32].

2 years agos390: Fix up *cmp_and_trap_unsigned_int<mode> constraints [PR104775]
Jakub Jelinek [Mon, 7 Mar 2022 10:14:04 +0000 (11:14 +0100)]
s390: Fix up *cmp_and_trap_unsigned_int<mode> constraints [PR104775]

The following testcase fails to assemble due to clgte %r6,0(%r1,%r10)
insn not being accepted by assembler.
My rough understanding is that in the RSY-b insn format the spot
in other formats used for index registers is used instead for M3 what
kind of comparison it is, so this patch follows what other similar
instructions use for constraint (i.e. one without index register).

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

PR target/104775
* config/s390/s390.md (*cmp_and_trap_unsigned_int<mode>): Use
S constraint instead of T in the last alternative.

* gcc.target/s390/pr104775.c: New test.

2 years agotranslation: small fixes
Martin Liska [Mon, 7 Mar 2022 10:02:15 +0000 (11:02 +0100)]
translation: small fixes

PR translation/90148

gcc/fortran/ChangeLog:

* intrinsic.cc (gfc_is_intrinsic): Remove asterisk from error
message.

gcc/ChangeLog:

* plugin.cc (default_plugin_dir_name): Remove <dir> from error
message.

2 years agoFix translation strings.
Martin Liska [Mon, 7 Mar 2022 09:41:11 +0000 (10:41 +0100)]
Fix translation strings.

PR translation/90148

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_linux64_override_options): Put
quote to a proper place.
* plugin.cc (default_plugin_dir_name): Likewise.

gcc/fortran/ChangeLog:

* intrinsic.cc (gfc_is_intrinsic): Put
quote to a proper place.

2 years agorx: Fix translation string.
Martin Liska [Mon, 7 Mar 2022 09:33:57 +0000 (10:33 +0100)]
rx: Fix translation string.

PR target/99297

gcc/ChangeLog:

* config/rx/rx.cc (rx_expand_builtin_mvtc): Fix translation
string.

2 years agoi386: Fix up cond_{and,ior,xor,mul}* [PR104779]
Jakub Jelinek [Mon, 7 Mar 2022 08:40:51 +0000 (09:40 +0100)]
i386: Fix up cond_{and,ior,xor,mul}* [PR104779]

The following testcase ICEs, because the cond_andv* expander
has vector_operand predicates in both of the commutative inputs
and calls gen_andv*_mask which calls ix86_binary_operator_ok
in its condition, but nothing calls ix86_fixup_binary_operands_no_copy
during the expansion, which means cond_* accepts even operands
like 2 MEMs which then can't be matched.

The following patch handles it like most other insns that the other
cond_* patterns use - by having a separate define_expand that calls
ix86_fixup_binary_operands_no_copy and define_ins with
ix86_binary_operator_ok.

2022-03-07  Jakub Jelinek  <jakub@redhat.com>

PR target/104779
* config/i386/sse.md (avx512dq_mul<mode>3<mask_name>): New
define_expand pattern.  Rename define_insn to ...
(*avx512dq_mul<mode>3<mask_name>): ... this.
(<code><mode>3_mask): New any_logic define_expand pattern.
(<mask_codefor><code><mode>3<mask_name>): Rename to ...
(*<code><mode>3<mask_name>): ... this.

* gcc.target/i386/pr104779.c: New test.

2 years agolibstdc++: vxworks: remove stray <iostream> include
Rasmus Villemoes [Fri, 4 Mar 2022 08:18:39 +0000 (09:18 +0100)]
libstdc++: vxworks: remove stray <iostream> include

There doesn't seem to be any reason for this TU to include
<iostream>, and it causes errors when the resulting libstdc++ is used
on our VxWorks 5.5 target - presumably because now libstdc++ itself
contains an instance of std::ios_base::Init. Which should be mostly
harmless, but apparently isn't, and from a QoI viewpoint should
probably be avoided anyway.

libstdc++-v3/ChangeLog:

* config/locale/vxworks/ctype_members.cc: Remove <iostream>
  include.

This page took 0.122322 seconds and 5 git commands to generate.