Commit Graph

184173 Commits

Author SHA1 Message Date
GCC Administrator
8cac6af6f8 Daily bump. 2021-04-07 00:16:39 +00:00
Joseph Myers
b29ddf93a4 Update gcc de.po.
* de.po: Update.
2021-04-06 22:41:14 +00:00
Joseph Myers
2a77cc1710 Update gcc sv.po.
* sv.po: Update.
2021-04-06 22:32:29 +00:00
Jason Merrill
de03b82f3c c++: access checking in aggregate initialization [PR96673]
We were deferring access checks while parsing B<int>{}, didn't adjust that
when we went to instantiate the default member initializer for B::c,
deferred access checking for C::C, and then checked it after parsing
B<int>{}, back in the main() context which has no access.  We need to do the
access checks in the class context of the DMI.

I tried fixing this in push_to/pop_from_top_level, but that caused several
regressions.

gcc/cp/ChangeLog:

	PR c++/96673
	* init.c (get_nsdmi): Don't defer access checking.

gcc/testsuite/ChangeLog:

	PR c++/96673
	* g++.dg/cpp1y/nsdmi-aggr13.C: New test.
2021-04-06 16:08:40 -04:00
Jason Merrill
8685348075 c++: C++17 constexpr static data member linkage [PR99901]
C++17 makes constexpr static data members implicitly inline variables.  In
C++14, a subsequent out-of-class declaration is the definition.  We want to
continue emitting a symbol for such a declaration in C++17 mode, for ABI
compatibility with C++14 code that wants to refer to it.

Normally I'd distinguish in- and out-of-class declarations by looking at
DECL_IN_AGGR_P, but we never set DECL_IN_AGGR_P on inline variables.  I
think that's wrong, but don't want to mess with it so close to release.
Conveniently, we already have a test for in-class declaration earlier in the
function.

gcc/cp/ChangeLog:

	PR c++/99901
	* decl.c (cp_finish_decl): mark_needed an implicitly inline
	static data member with an out-of-class redeclaration.

gcc/testsuite/ChangeLog:

	PR c++/99901
	* g++.dg/cpp1z/inline-var9.C: New test.
2021-04-06 14:30:02 -04:00
Iain Buclaw
d48f87d5c1 d: Fix missing call to va_end in getMatchError [PR99917]
Reviewed-on: https://github.com/dlang/dmd/pull/12380

gcc/d/ChangeLog:

	PR d/99917
	* dmd/MERGE: Merge upstream dmd d16195406.
2021-04-06 19:43:31 +02:00
Iain Buclaw
62321ab477 d: Use Array::find to get index of element
gcc/d/ChangeLog:

	* d-codegen.cc (build_frame_type): Use Array::find to get index of
	element.
2021-04-06 19:43:31 +02:00
Iain Buclaw
4993d0265e d: Increment gaggedWarnings if warning or deprecation message was suppressed
gcc/d/ChangeLog:

	* d-diagnostic.cc (vwarning): Increment gaggedWarnings if warning
	message	was suppressed.
	(vdeprecation): Likewise for deprecation messages.
2021-04-06 19:43:31 +02:00
Iain Buclaw
dddf3bb0c3 d: Merge upstream dmd 5cc71ff83, druntime 1134b710
D front-end changes:

 - Fix ICEs that occurred when using opaque enums.

 - Update `pragma(printf)' checking code to work on 16-bit targets.

Phobos change:

 - Don't compile in argTypes code on AArch64

Reviewed-on: https://github.com/dlang/dmd/pull/12378
	     https://github.com/dlang/druntime/pull/3431

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 5cc71ff83.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 1134b710.
2021-04-06 19:43:30 +02:00
Jonathan Wakely
406f58e1e3 libstdc++: Add nodiscard attribute to cast-like functions
Add [[nodiscard]] to functions that are effectively just a static_cast,
as per P2351. Also add it to std::addressof.

libstdc++-v3/ChangeLog:

	* include/bits/move.h (forward, move, move_if_noexcept)
	(addressof): Add _GLIBCXX_NODISCARD.
	* include/bits/ranges_cmp.h (identity::operator()): Add
	nodiscard attribute.
	* include/c_global/cstddef (to_integer): Likewise.
	* include/std/bit (bit_cast): Likewise.
	* include/std/utility (as_const, to_underlying): Likewise.
2021-04-06 16:43:25 +01:00
Jonathan Wakely
41019bfae2 libstdc++: Clarify static_assert message
libstdc++-v3/ChangeLog:

	* include/bits/move.h (forward): Change static_assert message
	to be unambiguous about what must be true.
	* testsuite/20_util/forward/c_neg.cc: Adjust dg-error.
	* testsuite/20_util/forward/f_neg.cc: Likewise.
2021-04-06 16:43:24 +01:00
Jonathan Wakely
daef4e4d93 libstdc++: Fix Doxygen warnings
libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h: Use markdown for code font.
	* include/bits/basic_string.h: Fix @param names.
	* include/bits/max_size_type.h: Remove period after @file.
	* include/bits/regex.h: Fix duplicate @retval names, and rename.
	* include/ext/pb_ds/detail/priority_queue_base_dispatch.hpp: Add
	group open to match existing group close.
	* include/ext/pb_ds/priority_queue.hpp: Add blank line before group
	open.
2021-04-06 16:43:24 +01:00
Jonathan Wakely
f0b883464c libstdc++: Fix doxygen markup for group close commands
A change in Doxygen 1.8.16 means that "// @}" is no longer recognized by
Doxygen, so doesn't close a @{ group. A "///" comment needs to be used.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h: Fix doxygen group close.
	* include/bits/basic_ios.h: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/fs_dir.h: Likewise.
	* include/bits/fs_ops.h: Likewise.
	* include/bits/fs_path.h: Likewise.
	* include/bits/functional_hash.h: Likewise.
	* include/bits/gslice.h: Likewise.
	* include/bits/gslice_array.h: Likewise.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/indirect_array.h: Likewise.
	* include/bits/locale_classes.h: Likewise.
	* include/bits/locale_facets.h: Likewise.
	* include/bits/locale_facets_nonio.h: Likewise.
	* include/bits/mask_array.h: Likewise.
	* include/bits/refwrap.h: Likewise.
	* include/bits/regex.h: Likewise.
	* include/bits/regex_automaton.h: Likewise.
	* include/bits/regex_compiler.h: Likewise.
	* include/bits/regex_constants.h: Likewise.
	* include/bits/regex_error.h: Likewise.
	* include/bits/regex_executor.h: Likewise.
	* include/bits/regex_scanner.h: Likewise.
	* include/bits/shared_ptr.h: Likewise.
	* include/bits/shared_ptr_atomic.h: Likewise.
	* include/bits/shared_ptr_base.h: Likewise.
	* include/bits/slice_array.h: Likewise.
	* include/bits/specfun.h: Likewise.
	* include/bits/std_function.h: Likewise.
	* include/bits/std_mutex.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_iterator.h: Likewise.
	* include/bits/stl_iterator_base_types.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_numeric.h: Likewise.
	* include/bits/stl_pair.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_uninitialized.h: Likewise.
	* include/bits/stream_iterator.h: Likewise.
	* include/bits/streambuf_iterator.h: Likewise.
	* include/bits/unique_ptr.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/decimal/decimal: Likewise.
	* include/experimental/any: Likewise.
	* include/experimental/array: Likewise.
	* include/experimental/bits/fs_dir.h: Likewise.
	* include/experimental/bits/fs_fwd.h: Likewise.
	* include/experimental/bits/fs_ops.h: Likewise.
	* include/experimental/bits/fs_path.h: Likewise.
	* include/experimental/buffer: Likewise.
	* include/experimental/internet: Likewise.
	* include/experimental/optional: Likewise.
	* include/experimental/propagate_const: Likewise.
	* include/experimental/socket: Likewise.
	* include/ext/pb_ds/assoc_container.hpp: Likewise.
	* include/ext/pb_ds/detail/priority_queue_base_dispatch.hpp:
	Likewise.
	* include/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp: Likewise.
	* include/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp: Likewise.
	* include/ext/pb_ds/detail/types_traits.hpp: Likewise.
	* include/ext/pb_ds/exception.hpp: Likewise.
	* include/ext/pb_ds/priority_queue.hpp: Likewise.
	* include/ext/pb_ds/tag_and_trait.hpp: Likewise.
	* include/ext/random: Likewise.
	* include/std/any: Likewise.
	* include/std/atomic: Likewise.
	* include/std/bitset: Likewise.
	* include/std/chrono: Likewise.
	* include/std/complex: Likewise.
	* include/std/condition_variable: Likewise.
	* include/std/fstream: Likewise.
	* include/std/future: Likewise.
	* include/std/iostream: Likewise.
	* include/std/istream: Likewise.
	* include/std/mutex: Likewise.
	* include/std/numeric: Likewise.
	* include/std/ostream: Likewise.
	* include/std/ratio: Likewise.
	* include/std/shared_mutex: Likewise.
	* include/std/stdexcept: Likewise.
	* include/std/streambuf: Likewise.
	* include/std/system_error: Likewise.
	* include/std/thread: Likewise.
	* include/std/valarray: Likewise.
	* include/std/variant: Likewise.
	* include/tr1/cmath: Likewise.
	* include/tr1/regex: Likewise.
	* include/tr2/dynamic_bitset: Likewise.
	* libsupc++/atomic_lockfree_defines.h: Likewise.
	* libsupc++/exception: Likewise.
	* libsupc++/exception.h: Likewise.
	* libsupc++/exception_ptr.h: Likewise.
	* libsupc++/nested_exception.h: Likewise.

libstdc++-v3/ChangeLog:

	* include/tr1/regex:
2021-04-06 16:43:24 +01:00
Vladimir N. Makarov
4bbd51afaa [PR99781] Update correctly reg notes in LRA for multi-registers and set up biggest mode safely
The PR is about incorrect use of partial_subreg_p for unordered modes.
I found 2 places of dangerous comparing unordered modes in LRA.  The
patch removes dangerous use of paradoxical_subreg_p and
partial_subreg_p in split_reg and process_bb_lives.  The both places
used them to solve PR77761 long time ago.  But the problem was also
fixed by later patches too (if there is no hard reg explicitly, it
have VOIDmode and we use natural mode to split hard reg live,
otherwise we use the biggest explicitly used mode for hard reg
splitting).  The PR also says about inaccurate update of reg notes in
LRA.  It happens for reg notes which refer for multi-registers.  The
patch also fixes this issue.

gcc/ChangeLog:

	PR target/99781
	* lra-constraints.c (split_reg): Don't check paradoxical_subreg_p.
	* lra-lives.c (clear_sparseset_regnos, regnos_in_sparseset_p): New
	functions.
	(process_bb_lives): Don't update biggest mode of hard reg for
	implicit in multi-register group.  Use the new functions for
	updating dead_set and unused_set by register notes.

gcc/testsuite/ChangeLog:

	PR target/99781
	* g++.target/aarch64/sve/pr99781.C: New.
2021-04-06 09:22:16 -04:00
Xianmiao Qu
498d2ba584 C-SKY: Describe ck802 bypass accurately.
Fix the following warning:
insn-automata.c: In function ‘int maximal_insn_latency(rtx_insn*)’:
insn-automata.c:679:37: warning: array subscript -1 is below array bounds of ‘const unsigned char [19]’ [-Warray-bounds]
  679 |   return default_latencies[insn_code];
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
insn-automata.c:397:30: note: while referencing ‘default_latencies’
  397 |   static const unsigned char default_latencies[] =
      |

gcc/
	* config/csky/csky_pipeline_ck802.md : Use insn reservation name
	instead of *.
2021-04-06 20:48:32 +08:00
H.J. Lu
a32452a544 x86: Update memcpy/memset inline strategies for Skylake family CPUs
Simply memcpy and memset inline strategies to avoid branches for
Skylake family CPUs:

1. With MOVE_RATIO and CLEAR_RATIO == 17, GCC will use integer/vector
   load and store for up to 16 * 16 (256) bytes when the data size is
   fixed and known.
2. Inline only if data size is known to be <= 256.
   a. Use "rep movsb/stosb" with simple code sequence if the data size
      is a constant.
   b. Use loop if data size is not a constant.
3. Use memcpy/memset libray function if data size is unknown or > 256.

On Cascadelake processor with -march=native -Ofast -flto,

1. Performance impacts of SPEC CPU 2017 rate are:

500.perlbench_r  0.17%
502.gcc_r       -0.36%
505.mcf_r        0.00%
520.omnetpp_r    0.08%
523.xalancbmk_r -0.62%
525.x264_r       1.04%
531.deepsjeng_r  0.11%
541.leela_r     -1.09%
548.exchange2_r -0.25%
557.xz_r         0.17%
Geomean         -0.08%

503.bwaves_r     0.00%
507.cactuBSSN_r  0.69%
508.namd_r      -0.07%
510.parest_r     1.12%
511.povray_r     1.82%
519.lbm_r        0.00%
521.wrf_r       -1.32%
526.blender_r   -0.47%
527.cam4_r       0.23%
538.imagick_r   -1.72%
544.nab_r       -0.56%
549.fotonik3d_r  0.12%
554.roms_r       0.43%
Geomean          0.02%

2. Significant impacts on eembc benchmarks are:

eembc/idctrn01   9.23%
eembc/nnet_test  29.26%

gcc/

	* config/i386/x86-tune-costs.h (skylake_memcpy): Updated.
	(skylake_memset): Likewise.
	(skylake_cost): Change CLEAR_RATIO to 17.
	* config/i386/x86-tune.def (X86_TUNE_PREFER_KNOWN_REP_MOVSB_STOSB):
	Replace m_CANNONLAKE, m_ICELAKE_CLIENT, m_ICELAKE_SERVER,
	m_TIGERLAKE and m_SAPPHIRERAPIDS with m_SKYLAKE and m_CORE_AVX512.

gcc/testsuite/

	* gcc.target/i386/memcpy-strategy-9.c: New test.
	* gcc.target/i386/memcpy-strategy-10.c: Likewise.
	* gcc.target/i386/memcpy-strategy-11.c: Likewise.
	* gcc.target/i386/memset-strategy-7.c: Likewise.
	* gcc.target/i386/memset-strategy-8.c: Likewise.
	* gcc.target/i386/memset-strategy-9.c: Likewise.
2021-04-06 05:36:00 -07:00
Richard Biener
e5c170e080 tree-optimization/99880 - avoid vectorizing irrelevant PHI backedge defs
This adds a relevancy check before trying to set the vector def of
a backedge in an unvectorized PHI.

2021-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99880
	* tree-vect-loop.c (maybe_set_vectorized_backedge_value): Only
	set vectorized defs of relevant PHIs.

	* gcc.dg/torture/pr99880.c: New testcase.
2021-04-06 14:20:28 +02:00
Nathan Sidwell
671f9f5c0f c++: Simplify va_arg test
The va_arg scans are just too brittle.  Let's not be that picky.  We
have other tested builtins that are less brittle now anyway.

	gcc/testsuite/
	* g++.dg/modules/builtin-3_a.C: Remove dump scans.
	* g++.dg/modules/builtin-3_b.C: Remove dump scans.
2021-04-06 05:07:17 -07:00
Nathan Sidwell
86532e5419 libcody: Remove FSF license
Apparently this was never needed.

	libcody/
	* LICENSE.gcc: Delete.
2021-04-06 05:07:17 -07:00
Jakub Jelinek
bfeb36bd03 testsuite: Fix up pr96573.c on aarch64 [PR96573]
On Thu, Apr 01, 2021 at 02:16:55PM +0100, Alex Coplan via Gcc-patches wrote:
> FYI, I'm seeing the new test failing on aarch64:
>
> PASS: gcc.dg/pr96573.c (test for excess errors)
> FAIL: gcc.dg/pr96573.c scan-tree-dump optimized "__builtin_bswap"

The vectorizer in the aarch64 case manages to emit a VEC_PERM_EXPR instead
(which is just as efficient).

So, do we want to go for the following (and/or perhaps also restrict the test to
a couple of targets where it works?  In my last distro build it failed only
on aarch64-linux, while armv7hl-linux-gnueabi and
{i686,x86_64,powerpc64le,s390x}-linux were fine)?

2021-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96573
	* gcc.dg/pr96573.c: Instead of __builtin_bswap accept also
	VEC_PERM_EXPR with bswapping permutation.
2021-04-06 12:46:22 +02:00
Richard Biener
58cd9fc8a6 tree-optimization/99924 - visit permute nodes again when partitioning
Since SLP graph partitioning works on scalar stmts (because it's done
for costing) we have to make sure to visit permute nodes multiple
times since they will not pull partitions together.

2021-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99924
	* tree-vect-slp.c (vect_bb_partition_graph_r): Do not mark
	nodes w/o scalar stmts as visited.

	* gfortran.dg/vect/pr99924.f90: New testcase.
2021-04-06 12:15:30 +02:00
Jakub Jelinek
ffc2331d79 testsuite: Fix up g++.dg/ext/vector40.C test
The test FAILs on i686-linux due to -Wpsabi diagnostics.

2021-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/97900
	* g++.dg/ext/vector40.C: Add -Wno-psabi -w to dg-options.
2021-04-06 11:46:32 +02:00
Alex Coplan
16ea7f5789 arm: Fix PCS for SFmode -> SImode libcalls [PR99748]
This patch fixes PR99748 which shows us trying to pass the argument to
__aeabi_f2iz in the VFP register s0 when the library function is
expecting to use the GPR r0. It also fixes the __aeabi_f2uiz case which
was broken in the same way.

For the testcase in the PR, here is the code we generate before the
patch (with -mfloat-abi=hard -march=armv8.1-m.main+mve -O0):

main:
    push    {r7, lr}
    sub     sp, sp, #8
    add     r7, sp, #0
    mov     r3, #1065353216
    str     r3, [r7, #4]    @ float
    vldr.32 s0, [r7, #4]
    bl      __aeabi_f2iz
    mov     r3, r0
    cmp     r3, #1
    [...]

This becomes:

main:
    push    {r7, lr}
    sub     sp, sp, #8
    add     r7, sp, #0
    mov     r3, #1065353216
    str     r3, [r7, #4]    @ float
    ldr     r0, [r7, #4]    @ float
    bl      __aeabi_f2iz
    mov     r3, r0
    cmp     r3, #1
    [...]

after the patch. We see a similar change for the same testcase with a
cast to unsigned instead of int.

gcc/ChangeLog:

	PR target/99748
	* config/arm/arm.c (arm_libcall_uses_aapcs_base): Also use base
	PCS for [su]fix_optab.
2021-04-06 09:06:27 +01:00
Jason Merrill
55f40d968b c++: mangling of lambdas in default args [PR91241]
In this testcase, the parms remembered in LAMBDA_EXPR_EXTRA_SCOPE are no
longer the parms of the FUNCTION_DECL they have as their DECL_CONTEXT, so we
were mangling both lambdas as parm #0.  But since the parms are numbered
from right to left we don't need to need to find them in the FUNCTION_DECL,
we can measure their own DECL_CHAIN.

gcc/cp/ChangeLog:

	PR c++/91241
	* mangle.c (write_compact_number): Add sanity check.
	(write_local_name): Use list_length for parm number.

gcc/testsuite/ChangeLog:

	PR c++/91241
	* g++.dg/abi/lambda-defarg1.C: New test.
2021-04-06 00:12:57 -04:00
Patrick Palka
66de517b1c c++: placeholder type constraint in structured binding [PR99899]
In this PR, we're crashing because the constraint handling inside
do_auto_deduction doesn't expect to see an adc_decomp_type context.
This patch fixes this by treating adc_decomp_type like adc_variable_type
or adc_return_type during placeholder type constraint checking.

Meanwhile, I noticed we weren't checking constraints at all when binding
an array via a structured binding, since do_auto_deduction would exit
early and bypass the constraint check.  This patch fixes this by
replacing the early exit with an appropriate setup of the 'targs'
vector.

gcc/cp/ChangeLog:

	PR c++/99899
	* pt.c (do_auto_deduction): Don't exit early when deducing the
	array type of a structured binding.  Also handle adc_decomp_type
	during constraint checking.

gcc/testsuite/ChangeLog:

	PR c++/99899
	* g++.dg/cpp2a/concepts-placeholder7.C: New test.
	* g++.dg/cpp2a/concepts-placeholder8.C: New test.
2021-04-05 23:35:56 -04:00
GCC Administrator
b1da991623 Daily bump. 2021-04-06 00:16:43 +00:00
Jason Merrill
b07dd9b0d0 c++: -Wunused, constant, and generic lambda [PR96311]
We never called mark_use for a return value in a function with dependent
return type.  In that situation we don't know if the use is as an rvalue or
lvalue, but we can use mark_exp_read instead.

gcc/cp/ChangeLog:

	PR c++/96311
	* typeck.c (check_return_expr): Call mark_exp_read in dependent
	case.

gcc/testsuite/ChangeLog:

	PR c++/96311
	* g++.dg/cpp1y/lambda-generic-Wunused.C: New test.
2021-04-05 17:27:24 -04:00
Jason Merrill
07f56824fd c++: reinterpret_cast from prvalue to rvalue ref [PR98440]
In r260622 I allowed this under the general principle that [basic.lval]
"Whenever a prvalue appears as an operand of an operator that expects a
glvalue for that operand, the temporary materialization conversion (7.3.4)
is applied to convert the expression to an xvalue."  But
[expr.reinterpret.cast] specifically excludes creating a temporary in this
case.

gcc/cp/ChangeLog:

	PR c++/98440
	* typeck.c (build_reinterpret_cast_1): Don't perform
	temporary materialization.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/rv-cast6.C: Expect reinterpret_cast error.
	* g++.dg/cpp0x/reinterpret_cast2.C: Adjust message.
	* g++.old-deja/g++.jason/rvalue3.C: Likewise.
2021-04-05 17:27:00 -04:00
Jason Merrill
9f4c41147a c++: enum in generic lambda in template [PR95317]
Here we weren't instantiating the enumerators because the arglist still had
the template parameter for the generic lambda, so looking one up failed.  We
need to instantiate if the non-lambda enclosing scope is non-dependent.

gcc/cp/ChangeLog:

	PR c++/95317
	* pt.c (lookup_template_class_1): Do tsubst_enum when
	tsubsting a generic lambda.

gcc/testsuite/ChangeLog:

	PR c++/95317
	* g++.dg/cpp1y/lambda-generic-enum1.C: New test.
2021-04-05 15:38:40 -04:00
Jason Merrill
62d60246e5 c++: lambda in DMI in class template [PR95870]
Here enclosing_instantiation_of was failing to find a match because otctx is
struct S<T> and current_function_decl is S<int>::S(), so the latter has more
function contexts, and we end up trying to compare S() to NULL_TREE.

After spending a bit of time working on establishing the correspondence in
this case (class <=> constructor), it occurred to me that we could just use
DECL_SOURCE_LOCATION, which is unique for lambdas, since they cannot be
redeclared.  Since we're so close to release, for now I'm only doing this
for the case that was failing before.

gcc/cp/ChangeLog:

	PR c++/95870
	* pt.c (enclosing_instantiation_of): Compare DECL_SOURCE_LOCATION if
	there is no enclosing non-lambda function.

gcc/testsuite/ChangeLog:

	PR c++/95870
	* g++.dg/cpp0x/lambda/lambda-nsdmi10.C: New test.
2021-04-05 15:37:01 -04:00
Eric Botcazou
7ebdef2076 Fix small regression with -fdump-ada-spec
When the enumeration constants of an enumeration type are defined by
explicit values, the binding generated by -fdump-ada-spec does not use
an enumeration type on the Ada side, because the set of allowed values
in C/C++ is larger than the set of allowed values in Ada, but instead
use an integer subtype and defines a set of explicit constants, which
used to be of this subtype but were changed to the base type at some
point.  This reinstates the subtype for them.

gcc/c-family/
	* c-ada-spec.c (is_simple_enum): Minor tweaks.
	(dump_ada_enum_type): Add TYPE and PARENT parameters.  For non-simple
	enumeral types use again the type name for the enumeration constants.
	(dump_ada_node): Adjust call to dump_ada_enum_type.
	(dump_nested_type): Likewise.
2021-04-05 19:52:29 +02:00
Michael Meissner
f1d012911b Honor --disable-decimal-float on PowerPC Decimal/Float128 conversions
This patch fixes the problem that the Decimal <-> Float128 conversions
were built even if the user configured GCC with --disable-decimal-float.

libgcc/
2021-04-05  Florian Weimer  <fweimer@redhat.com>

	* config/rs6000/t-float128 (fp128_ppc_funcs): Add decimal floating
	point functions for $(decimal_float) only.

Co-Authored-By: Michael Meissner  <meissner@linux.ibm.com>
2021-04-05 13:33:16 -04:00
Nathan Sidwell
dd6f588a7b c++: Unneeded export query [PR 99380]
This problem got introduced fixing a module numbering problem.  When
preprocessing a header unit, we don't need to send an EXPORT query
unless we're also determining dependencies, or the mapper asked us
to.  Sadly the testsuite isn't set up to test this kind of subtlety.
I manually did that with stdin/stdout.

	PR c++/99380
	gcc/cp/
	* module.cc (name_pending_imports): Drop 'atend' parm.  Don't
	query export when not needed.
	(preprocess_module, preprocessed_module): Adjust.
2021-04-05 07:55:41 -07:00
David Malcolm
7d8f4240c9 analyzer: fix ICE on zero-arg calls passed to __attribute__((nonnull)) [PR 99906]
gcc/analyzer/ChangeLog:
	PR analyzer/99906
	* analyzer.cc (maybe_reconstruct_from_def_stmt): Fix NULL
	dereference on calls with zero arguments.
	* sm-malloc.cc (malloc_state_machine::on_stmt): When handling
	__attribute__((nonnull)), only call get_diagnostic_tree if the
	result will be used.

gcc/testsuite/ChangeLog:
	PR analyzer/99906
	* gcc.dg/analyzer/pr99906.c: New test.
2021-04-05 10:51:46 -04:00
David Malcolm
69b66ff023 analyzer: fix apparent hang with -fanalyzer-verbosity=0 [PR analyzer/99886]
The analyzer appeared to enter an infinite loop on malloc-1.c
when -fanalyzer-verbosity=0 was used.  In fact, it was slowly
counting from 0 to 0xffffffff.

Root cause is looping up to effectively ((unsigned)0) - 1 in
diagnostic_manager::consolidate_conditions when there are no events
in the path.

Fixed by the following, which uses signed integers when subtracting
from path->num_events () when simplifying checker_paths.

gcc/analyzer/ChangeLog:
	PR analyzer/99886
	* diagnostic-manager.cc
	(diagnostic_manager::prune_interproc_events): Use signed integers
	when subtracting one from path->num_events ().
	(diagnostic_manager::consolidate_conditions): Likewise.  Convert
	next_idx to a signed int.

gcc/testsuite/ChangeLog:
	PR analyzer/99886
	* gcc.dg/analyzer/pr99886.c: New test.
2021-04-05 10:48:01 -04:00
Jason Merrill
bd89b8fe9e c++: extern template and static data member [PR99066]
'extern template' should mean that the relevant symbols are never emitted.
But in this case we were assuming that DECL_EXTERNAL was already set on the
variable, so we just needed to clear DECL_NOT_REALLY_EXTERN.  Since
DECL_EXTERNAL was not set, we emitted a definition of npos.

gcc/cp/ChangeLog:

	PR c++/99066
	* pt.c (mark_decl_instantiated): Set DECL_EXTERNAL.

gcc/testsuite/ChangeLog:

	PR c++/99066
	* g++.dg/cpp0x/extern_template-6.C: New test.
2021-04-05 09:27:36 -04:00
Jason Merrill
a99a7b0afe c++: constexpr if and nested generic lambda [PR99201]
When building up *_EXTRA_ARGS for a constexpr if or pack expansion, we need
to walk into the body of a lambda to find all the local_specializations that
we need to remember, like we do in find_parameter_packs_r.

gcc/cp/ChangeLog:

	PR c++/99201
	* pt.c (class el_data): Add visited field.
	(extract_local_specs): Pass it to cp_walk_tree.
	(extract_locals_r): Walk into the body of a lambda.

gcc/testsuite/ChangeLog:

	PR c++/99201
	* g++.dg/cpp1z/constexpr-if-lambda4.C: New test.
2021-04-05 08:25:52 -04:00
Jason Merrill
a44a753a35 c++: Fix print-tree for TEMPLATE_DECL
The if allows TEMPLATE_DECL, but then checking DECL_MODULE_IMPORT_P crashes
on TEMPLATE_DECL.  Fixed by stripping TEMPLATE_DECL first.

gcc/cp/ChangeLog:

	* ptree.c (cxx_print_decl): Check DECL_MODULE_IMPORT_P on
	template result.
2021-04-05 08:25:26 -04:00
Iain Buclaw
76a7e7e706 d: Use weak linkage for template symbols instead of gnu.linkonce (PR99914)
The default linkage of templates in the D language is now DECL_WEAK
instead of  DECL_ONE_ONLY, if supported.  This better matches the
expected override semantics of template symbols compiled to object code.

For example:

 module rt.config;
 template rt_flag()
 {
   pragma(mangle, "rt_flag") __gshared bool rt_flag = true;
 }

 module main;
 extern(C) __gshared bool rt_flag = false;

The above currently does not succeed in linking due to there being
multiple definitions of `rt_flag' in different sections that aren't
considered mergeable.

The compiler flag enabling toggling of this has been given a clearer
named `-fweak-templates', which distinguishes itself from G++ `-fweak',
which is intended only for testing.

gcc/d/ChangeLog:

	PR d/99914
	* d-lang.cc (d_init): Disable flag_weak_templates if no support for
	weak or one-only symbols.
	* d-tree.h (VAR_OR_FUNCTION_DECL_CHECK): New macro.
	(DECL_INSTANTIATED): New macro.
	(d_comdat_linkage): Remove declaration.
	(d_linkonce_linkage): Remove declaration.
	(set_linkage_for_decl): New declaration.
	* decl.cc (DeclVisitor::visit (StructDeclaration *)): Replace call to
	d_linkonce_linkage with setting DECL_INSTANTIATED.
	(DeclVisitor::visit (ClassDeclaration *)): Likewise.
	(DeclVisitor::visit (EnumDeclaration *)): Likewise.
	(DeclVisitor::visit (InterfaceDeclaration *)): Remove call to
	d_linkonce_linkage.
	(get_symbol_decl): Call set_linkage_for_decl instead of
	d_linkonce_linkage.
	(d_finish_decl): Call set_linkage_for_decl.
	(d_comdat_linkage): Made function static.  Only set DECL_COMDAT for
	DECL_INSTANTIATED decls.
	(d_linkonce_linkage): Remove function.
	(d_weak_linkage): New function.
	(set_linkage_for_decl): New function.
	* gdc.texi (Runtime Options): Rename -fno-weak to -fno-weak-templates,
	update documentation of option.
	* lang.opt (fweak): Rename option to ...
	(fweak-templates): ... this.  Update help string.
	* modules.cc (get_internal_fn): Add Prot parameter.  Set generated
	function flag.
	(build_internal_fn): Update call to get_internal_fn.
	(build_dso_cdtor_fn): Likewise.
	(register_moduleinfo): Call d_finish_decl on dso_slot_node and
	dso_initialized_node.
	* typeinfo.cc (TypeInfoVisitor::internal_reference): Call
	set_linkage_for_decl instead of d_comdat_linkage.
	(TypeInfoDeclVisitor::visit (TypeInfoDeclaration *)): Remove calls to
	d_linkonce_linkage and d_comdat_linkage.
	(get_cpp_typeinfo_decl): Likewise.

gcc/testsuite/ChangeLog:

	PR d/99914
	* gdc.dg/pr99914.d: New test.
2021-04-05 13:40:36 +02:00
Sandra Loosemore
3cb9e3aee9 Trivial testsuite fixes for nios2-elf.
nios2-elf defaults to -fno-delete-null-pointer-checks, which causes
failures in tests that assume the option is enabled.  Make the
dependence explicit.

2021-04-04  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/testsuite/

	* gcc.dg/ipa/propmalloc-4.c: Add -fdelete-null-pointer-checks.
	* gcc.dg/tree-ssa/evrp11.c: Likewise.
2021-04-04 17:55:46 -07:00
GCC Administrator
914728849a Daily bump. 2021-04-05 00:16:27 +00:00
Jason Merrill
c3d3bb0f03 c++: array new initialized from a call [PR99643]
Here the get_foo() call results in a TARGET_EXPR, which we strip in
massage_init_elt, but then when build_vec_init tries to use it to initialize
the array element we crash because build_aggr_init expects a class rvalue to
have a TARGET_EXPR.  So don't strip it.

The stripping was added in r206639 for PR59659, so I checked that removing
it didn't significantly increase compile time or memory usage for that
testcase; compile time was unaffected, memory usage increased by 0.00004%.

gcc/cp/ChangeLog:

	PR c++/99643
	* typeck2.c (massage_init_elt): Don't strip TARGET_EXPR.

gcc/testsuite/ChangeLog:

	PR c++/99643
	* g++.dg/cpp0x/initlist-new5.C: New test.
2021-04-03 20:59:00 -04:00
GCC Administrator
c0756c4eb3 Daily bump. 2021-04-04 00:16:26 +00:00
Iain Buclaw
5a0aa603b2 d: Merge upstream dmd 3b808e838, druntime 483bc129, phobos f89dc217a
D front-end changes:

 - Explicit package visibility attribute is now always applied to
   introducing scopes.

 - Added `__traits(totype, string)' to convert mangled type string to an
   existing type.

 - Printf-like and scanf-like functions are now detected by prefixing
   them with `pragma(printf)' for printf-like functions or
   `pragma(scanf)' for scanf-like functions.

 - Added `__c_wchar_t', `__c_complex_float', `__c_complex_double', and
   `__c_complex_real' types for interfacing with C and C++.

 - Template alias parameters can now be instantiated with basic types,
   such as `int` or `void function()`.

 - Mixins can now be used as types in the form `mixin(string) var'.

 - Mixin expressions can take an argument list, same as `pragma(msg)'.

 - Implement DIP1034, add `typeof(*null)' types to represent `noreturn'.

 - `pragma(msg)' can print expressions of type `void'.

 - It is now an error to use private variables selectively imported from
   other modules.  Due to a bug, some imported private members were
   visible from other modules, violating the specification.

 - Added new syntax to declare an alias to a function type using the
   `alias' syntax based on the assignment operator.

 - Function literals can now return a value by reference.

Phobos changes:

 - Synchronize C bindings with the latest port fixes in upstream druntime.

 - Added alias for a `noreturn' type in object.d

 - Make use of the new `pragma(printf)' and `pragma(scanf)' pragmas, fix
   all code that got flagged as being incorrect.

 - Fixed code that relied on bugs in the D import package system.

Reviewed-on: https://github.com/dlang/dmd/pull/12339
	     https://github.com/dlang/druntime/pull/3422
	     https://github.com/dlang/phobos/pull/7932

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 3b808e838.
	* Make-lang.in (D_FRONTEND_OBJS): Add d/chkformat.o.
	* d-codegen.cc (build_struct_literal): Handle special enums.
	* d-convert.cc (convert_expr): Handle noreturn type.
	(convert_for_condition): Likewise.
	* d-target.cc (Target::_init): Set type for wchar_t.
	(TargetCPP::derivedClassOffset): New method.
	(Target::libraryObjectMonitors): New method.
	* decl.cc (get_symbol_decl): Set TREE_THIS_VOLATILE for functions of
	type noreturn.
	* toir.cc (IRVisitor::visit (ReturnStatement *)): Handle returning
	noreturn types.
	* types.cc (TypeVisitor::visit (TypeNoreturn *)): New method.
	(TypeVisitor::visit (TypeEnum *)): Handle special enums.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime 483bc129.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES_DARWIN): Add
	core/sys/darwin/fcntl.d.
	(DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/unistd.d.
	(DRUNTIME_DSOURCES_WINDOWS): Add core/sys/windows/stdc/malloc.d.
	* libdruntime/Makefile.in: Regenerate.
	* src/MERGE: Merge upstream phobos f89dc217a.
	* src/Makefile.am (PHOBOS_DSOURCES): Add std/regex/internal/tests2.d.
	* src/Makefile.in: Regenerate.
	* testsuite/libphobos.exceptions/chain.d: Fix format arguments.
	* testsuite/libphobos.exceptions/line_trace.d: Likewise.
2021-04-04 01:26:20 +02:00
Alexandre Oliva
ba0f690266 initialize pr94314-3.C counter
The int counter in the main loop was uninitialized, so we might end up
looping a very large number of times before completing successfully.
I suspect that was unintended, so I'm adding a zero initializer.


for  gcc/testsuite/ChangeLog

	* g++.dg/pr94314-3.C: Zero-initialize main loop counter.
2021-04-03 19:54:39 -03:00
Alexandre Oliva
5bba3415ec silence expected psabi warning in ipa-sra-19 on ppc-vxworks
The default CPU for our ppc-vx7r2 toolchain has no support for altivec
or vsx, so an ABI without vector support is selected.  The selected
calling conventions do not cover passing or returning vector types, so
-Wpsabi warns about such uses.

powerpc-ibm-aix* already silences these warnings with -Wno-psabi;
this patch extends that to powerpc-wrs-vxworks* too.


for  gcc/testsuite/ChangeLog

	* gcc.dg/ipa/ipa-sra-19.c: Extend -Wno-psabi to ppc-vx7r2.
2021-04-03 19:54:37 -03:00
Marek Polacek
a809d8a737 c++: GC during late parsing collects live data [PR91416]
Coming back to
<https://gcc.gnu.org/pipermail/gcc-patches/2019-August/527699.html>:

This is a crash that points to a GC problem.  Consider this test:

  __attribute__ ((unused)) struct S {
    S() { }
  } s;

We're parsing a simple-declaration.  While parsing the decl specs, we parse
the attribute, which means creating a TREE_LIST using ggc_alloc_*.

A function body is a complete-class context so when parsing the
member-specification of this class-specifier, we parse the bodies of the
functions we'd queued in cp_parser_late_parsing_for_member.  This then
leads to this call chain:
cp_parser_function_definition_after_declarator -> expand_or_defer_fn ->
expand_or_defer_fn_1 -> maybe_clone_body -> expand_or_defer_fn ->
cgraph_node::finalize_function -> ggc_collect.

In this test, the ggc_collect call collects the TREE_LIST we had
allocated, and a crash duly ensues.

I couldn't do what Richard suggested, that is, attach the attribute list
to struct S, because we don't pass decl_specs from cp_parser_type_specifier
down to cp_parser_class_specifier.  Therefore I've attempted to do "push the
decl_specifiers onto a vec that is a GC root", except I couldn't really push
the decl_specifiers, because first I'd have to mark cp_decl_specifier_seq with
GTY(()) and even that wouldn't be enough for me to be able to create

  static GTY(()) vec<cp_decl_specifier_seq *, va_gc>

But here we only care about cp_decl_specifier_seq::attributes, so the
patch is just this.  I've also extended the test so now we test a nested
class too.

gcc/cp/ChangeLog:

	PR c++/91416
	* parser.c: Create a GC root for attributes in a decl specifier.
	(cp_parser_type_specifier): Push/pop ->attributes onto/from it.

gcc/testsuite/ChangeLog:

	PR c++/91416
	* g++.dg/other/gc7.C: New test.
2021-04-03 18:20:56 -04:00
Iain Sandoe
89bc1d4e7c Darwin : Fix out-of-bounds access to df_regs_ever_live.
During changes made for LRA (or, perhaps, even before) we omitted
a check that the current register we are working on is a hard reg
before we tried to note its liveness.

A stage 1 built with fsanitize=address catches this, as does any
attempt to build master with clang and -std=c++11.

gcc/ChangeLog:

	* config/darwin.c (machopic_legitimize_pic_address): Check
	that the current pic register is one of the hard reg set
	before setting liveness.
2021-04-03 21:28:15 +01:00
Iain Sandoe
ad7c6298b6 Darwin : Fix whitespace and delete unused code (NFC).
Fix some incorrect indenting and remove two cases where we had
code '#if 0'-d out.

gcc/ChangeLog:

	* config/darwin.c (machopic_legitimize_pic_address): Fix
	whitespace, remove unused code.
2021-04-03 21:27:23 +01:00
Paul Thomas
fc27115d61 Fortran: Fix ICE on wrong code [PR99818].
2021-04-03  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/ChangeLog

	PR fortran/99818
	* interface.c (compare_parameter): The codimension attribute is
	applied to the _data field of class formal arguments.

gcc/testsuite/ChangeLog

	PR fortran/99818
	* gfortran.dg/coarray_48.f90: New test.
2021-04-03 12:49:50 +01:00