Commit Graph

179534 Commits

Author SHA1 Message Date
Tom de Vries
28d3b78dff [testsuite] Add missing require-effective-target alloca
Add missing require-effect-target alloca directives.

Tested on nvptx.

gcc/testsuite/ChangeLog:

	* gcc.dg/Warray-bounds-63.c: Add require-effective-target alloca.
	* gcc.dg/Warray-bounds-66.c: Same.
	* gcc.dg/atomic/stdatomic-vm.c: Same.
2020-09-23 09:20:55 +02:00
Clément Chigot
e884ced052 syscall: fix TestForeground for AIX
Syscall function can't be used on AIX. Therefore, Ioctl in
TestForeground must call raw_ioctl.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175080
2020-09-22 20:07:34 -07:00
Clément Chigot
1260f69aeb syscall: remove ptrace syscall on ppc64
ptrace is available only for 32 bits programs.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/252558
2020-09-22 19:55:34 -07:00
David Malcolm
c1c2ccc74c Add $(ZLIBINC) to CFLAGS-analyzer/engine.o
gcc/ChangeLog:
	* Makefile.in: Add $(ZLIBINC) to CFLAGS-analyzer/engine.o.
2020-09-22 21:19:14 -04:00
David Malcolm
fefc209299 analyzer: use switch in exploded_node::on_stmt
This patch replaces a sequence of dyn_cast to different gimple stmt
types in exploded_node::on_stmt with a switch on the gimple_code.  This
makes clearer which kinds of stmt are currently treated as no-ops, as a
precursor to handling them properly.

No functional change intended.

gcc/analyzer/ChangeLog:
	* engine.cc (exploded_node::on_stmt): Replace sequence of dyn_cast
	with switch.
2020-09-22 21:17:56 -04:00
Clément Chigot
63cd53d2f5 runtime, net: fix build errors on AIX
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/235158
2020-09-22 17:29:52 -07:00
Ian Lance Taylor
e41e66b78d libbacktrace: handle pc == low correctly
* dwarf.c (report_inlined_functions): Handle PC == -1 and PC ==
	p->low.
	(dwarf_lookup_pc): Likewise.
2020-09-22 17:28:24 -07:00
GCC Administrator
521d271140 Daily bump. 2020-09-23 00:16:27 +00:00
Ian Lance Taylor
5d2d79c8d9 go.test: update issue4458.go for recent change 2020-09-22 16:36:44 -07:00
Jan Hubicka
5cfb06b61b Ignore clobbers in modref
* ipa-modref.c (analyze_stmt): Ignore gimple clobber.
2020-09-22 22:36:01 +02:00
Patrick Palka
d6587211c0 c++: Return only in-scope tparms in keep_template_parm [PR95310]
In the testcase below, the dependent specializations iter_reference_t<F>
and iter_reference_t<Out> share the same tree due to specialization
caching.  So when find_template_parameters walks through the
requires-expression (as part of normalization), it sees and includes the
out-of-scope template parameter F in the list of template parameters
it found within the requires-expression (along with Out and N).

From a correctness perspective this is harmless since the parameter mapping
routines only care about the level and index of each parameter, so F is
no different from Out in that sense.  And it's also harmless that two
parameters in the parameter mapping have the same level and index.

But having both Out and F in the parameter mapping means extra work for
hash_atomic_constrant, tsubst_parameter_mapping and get_mapped_args; and
it also means we print this irrelevant template parameter in the
testcase's diagnostics (via pp_cxx_parameter_mapping):

  in requirements with ‘Out o’ [with N = (const int&)&a; F = const int*; Out = const int*]

This patch makes keep_template_parm return only in-scope template
parameters by looking into ctx_parms for the corresponding in-scope
one, through a new helper function corresponding_template_parameter.

(That we sometimes print irrelevant template parameters in diagnostics
is also the subject of PR99 and PR66968, so the above diagnostic issue
could likely be fixed in a more general way, but this targeted fix to
keep_template_parm is perhaps worthwhile on its own.)

gcc/cp/ChangeLog:

	PR c++/95310
	* pt.c (corresponding_template_parameter): Define.
	(keep_template_parm): Use it to adjust the given template
	parameter to the corresponding in-scope one from ctx_parms.

gcc/testsuite/ChangeLog:

	PR c++/95310
	* g++.dg/concepts/diagnostic15.C: New test.
2020-09-22 16:26:52 -04:00
Patrick Palka
c4e4e163c7 c++: Add test for PR96652
Fixed by r11-3361.

gcc/testsuite/ChangeLog:

	PR c++/96652
	* g++.dg/cpp0x/decltype-96652.C: New test.
2020-09-22 16:26:49 -04:00
Jan Hubicka
39b3b1bdd9 Fix ipa-modref selftest and destructor
* ipa-modref-tree.c: Add namespace selftest.
	(modref_tree_c_tests): Rename to ...
	(ipa_modref_tree_c_tests): ... this.
	* ipa-modref.c (pass_modref): Remove destructor.
	(ipa_modref_c_finalize): New function.
	* ipa-modref.h (ipa_modref_c_finalize): Declare.
	* selftest-run-tests.c (selftest::run_tests): Call
	ipa_modref_c_finalize.
	* selftest.h (ipa_modref_tree_c_tests): Declare.
	* toplev.c: Include ipa-modref-tree.h and ipa-modref.h
	(toplev::finalize): Call ipa_modref_c_finalize.
2020-09-22 22:16:00 +02:00
Nathan Sidwell
7d8177b027 c++: Remove a broken error-recovery path
The remaining use of xref_tag_from_type was also suspicious.  It turns
out to be an error path.  At parse time we diagnose that a class
definition cannot appear, but we swallow the definition.  This code
was attempting to push it into the global scope (or find a conflict).
This seems needless, just return error_mark_node.  This was the
simpler fix than going through the parser and figuring out how to get
it to put in error_mark_node at the right point.

	gcc/cp/
	* cp-tree.h (xref_tag_from_type): Don't declare.
	* decl.c (xref_tag_from_type): Delete.
	* pt.c (lookup_template_class_1): Erroneously located class
	definitions just give error_mark, don't try and inject it into the
	namespace.
2020-09-22 12:31:39 -07:00
Jakub Jelinek
bc13106e04 c++: Ignore __sanitizer_ptr_{sub,cmp} builtin calls during constant expression evaluation [PR97145]
These two builtin calls are added already during parsing before pointer
subtractions or comparisons, normally they perform runtime verification
of whether the pointers point to the same object or different objects,
but during constant expressione valuation we don't really need those
builtins for anything.

2020-09-22  Jakub Jelinek  <jakub@redhat.com>

	PR c++/97145
	* constexpr.c (cxx_eval_builtin_function_call): Return void_node for
	calls to __sanitize_ptr_{sub,cmp} builtins.

	* g++.dg/asan/pr97145.C: New test.
2020-09-22 21:08:02 +02:00
Jonathan Wakely
49ff88bd0d libstdc++: Fix out-of-bounds string_view access in filesystem::path [PR 97167]
libstdc++-v3/ChangeLog:

	PR libstdc++/97167
	* src/c++17/fs_path.cc (path::_Parser::root_path()): Check
	for empty string before inspecting the first character.
	* testsuite/27_io/filesystem/path/append/source.cc: Append
	empty string_view to path.
2020-09-22 20:02:58 +01:00
David Malcolm
809192e77e analyzer: add -fdump-analyzer-json
I've found this useful for debugging state explosions in the analyzer.

gcc/analyzer/ChangeLog:
	* analysis-plan.cc: Include "json.h".
	* analyzer.opt (fdump-analyzer-json): New.
	* call-string.cc: Include "json.h".
	(call_string::to_json): New.
	* call-string.h (call_string::to_json): New decl.
	* checker-path.cc: Include "json.h".
	* constraint-manager.cc: Include "json.h".
	(equiv_class::to_json): New.
	(constraint::to_json): New.
	(constraint_manager::to_json): New.
	* constraint-manager.h (equiv_class::to_json): New decl.
	(constraint::to_json): New decl.
	(constraint_manager::to_json): New decl.
	* diagnostic-manager.cc: Include "json.h".
	(saved_diagnostic::to_json): New.
	(diagnostic_manager::to_json): New.
	* diagnostic-manager.h (saved_diagnostic::to_json): New decl.
	(diagnostic_manager::to_json): New decl.
	* engine.cc: Include "json.h", <zlib.h>.
	(exploded_node::status_to_str): New.
	(exploded_node::to_json): New.
	(exploded_edge::to_json): New.
	(exploded_graph::to_json): New.
	(dump_analyzer_json): New.
	(impl_run_checkers): Call it.
	* exploded-graph.h (exploded_node::status_to_str): New decl.
	(exploded_node::to_json): New.
	(exploded_edge::to_json): New.
	(exploded_graph::to_json): New.
	* pending-diagnostic.cc: Include "json.h".
	* program-point.cc: Include "json.h".
	(program_point::to_json): New.
	* program-point.h (program_point::to_json): New decl.
	* program-state.cc: Include "json.h".
	(extrinsic_state::to_json): New.
	(sm_state_map::to_json): New.
	(program_state::to_json): New.
	* program-state.h (extrinsic_state::to_json): New decl.
	(sm_state_map::to_json): New decl.
	(program_state::to_json): New decl.
	* region-model-impl-calls.cc: Include "json.h".
	* region-model-manager.cc: Include "json.h".
	* region-model-reachability.cc: Include "json.h".
	* region-model.cc: Include "json.h".
	* region-model.h (svalue::to_json): New decl.
	(region::to_json): New decl.
	* region.cc: Include "json.h".
	(region::to_json: New.
	* sm-file.cc: Include "json.h".
	* sm-malloc.cc: Include "json.h".
	* sm-pattern-test.cc: Include "json.h".
	* sm-sensitive.cc: Include "json.h".
	* sm-signal.cc: Include "json.h".
	(signal_delivery_edge_info_t::to_json): New.
	* sm-taint.cc: Include "json.h".
	* sm.cc: Include "diagnostic.h", "tree-diagnostic.h", and
	"json.h".
	(state_machine::state::to_json): New.
	(state_machine::to_json): New.
	* sm.h (state_machine::state::to_json): New.
	(state_machine::to_json): New.
	* state-purge.cc: Include "json.h".
	* store.cc: Include "json.h".
	(binding_key::get_desc): New.
	(binding_map::to_json): New.
	(binding_cluster::to_json): New.
	(store::to_json): New.
	* store.h (binding_key::get_desc): New decl.
	(binding_map::to_json): New decl.
	(binding_cluster::to_json): New decl.
	(store::to_json): New decl.
	* supergraph.cc: Include "json.h".
	(supergraph::to_json): New.
	(supernode::to_json): New.
	(superedge::to_json): New.
	* supergraph.h (supergraph::to_json): New decl.
	(supernode::to_json): New decl.
	(superedge::to_json): New decl.
	* svalue.cc: Include "json.h".
	(svalue::to_json): New.

gcc/ChangeLog:
	* doc/analyzer.texi (Other Debugging Techniques): Mention
	-fdump-analyzer-json.
	* doc/invoke.texi (Static Analyzer Options): Add
	-fdump-analyzer-json.
2020-09-22 14:47:03 -04:00
David Faust
7c8ba5da80 bpf: use xBPF signed div, mod insns when available
The 'mod' and 'div' operators in eBPF are unsigned, with no signed
counterpart. xBPF adds two new ALU operations, sdiv and smod, for
signed division and modulus, respectively. Update bpf.md with
'define_insn' blocks for signed div and mod to use them when targetting
xBPF, and add new tests to ensure they are used appropriately.

2020-09-17  David Faust  <david.faust@oracle.com>

gcc/
	* config/bpf/bpf.md: Add defines for signed div and mod operators.

gcc/testsuite/
	* gcc.target/bpf/diag-sdiv.c: New test.
	* gcc.target/bpf/diag-smod.c: New test.
	* gcc.target/bpf/xbpf-sdiv-1.c: New test.
	* gcc.target/bpf/xbpf-smod-1.c: New test.
2020-09-22 20:31:35 +02:00
Clément Chigot
30bf947649 compiler: call runtime.eqtype for non-interface type switch on aix
All type switch clauses must call runtime.eqtype if the linker isn't
able to merge type descriptors pointers. Previously, only interface-type
clauses were doing it.

Updates golang/go#39276

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/255202
2020-09-22 10:24:07 -07:00
Tobias Burnus
f74c87f85f libgomp.fortran/pr66199-5.f90: Make stop codes unique
libgomp/ChangeLog:

	PR fortran/95654
	* testsuite/libgomp.fortran/pr66199-5.f90: Make stop codes unique.
2020-09-22 19:16:34 +02:00
Glen Joseph Fernandes
15139af6fb libstdc++: Fix overflow handling in std::align
libstdc++-v3/ChangeLog:

	* include/bits/align.h (align): Fix overflow handling.
	* testsuite/20_util/align/3.cc: New test.
2020-09-22 17:49:48 +01:00
Nathan Sidwell
7dfffe3241 c++: fix injected friend of template class
In working on fixing hiddenness, I discovered some suspicious code in
template instantiation.  I suspect it dates from when we didn't do the
hidden friend injection thing at all.  The xreftag finds the same
class, but makes it visible to name lookup.  Which is wrong.
hurrah, fixing a bug by deleting code!

	gcc/cp/
	* pt.c (instantiate_class_template_1): Do not repush and unhide
	injected friend.
	gcc/testsuite/
	* g++.old-deja/g++.pt/friend34.C: Check injected friend is still
	invisible.
2020-09-22 09:05:20 -07:00
Jonathan Wakely
160061ac10 libstdc++: Introduce new headers for C++20 ranges components
This introduces two new headers:

<bits/ranges_base.h> defines the minimal components needed
for using C++20 ranges (customization point objects such as
std::ranges::begin, concepts such as std::ranges::range, etc.)

<bits/ranges_util.h> includes <bits/ranges_base.h> and additionally
defines subrange, which is needed by <bits/ranges_algo.h>.

Most of the content of <bits/ranges_base.h> was previously defined in
<bits/range_access.h>, but a few pieces were only defined in <ranges>.
This meant the entire <ranges> header was needed in <algorithm> and
<memory>, even though they don't use all the range adaptors.

By moving the ranges components out of <bits/range_access.h> that file
is left defining just the contents of [iterator.range] i.e. std::begin,
std::end, std::size etc. and not C++20 ranges components.

For consistency with other C++20 ranges headers, <bits/range_cmp.h> is
renamed to <bits/ranges_cmp.h>.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new headers and adjust for renamed
	header.
	* include/Makefile.in: Regenerate.
	* include/bits/iterator_concepts.h: Adjust for renamed header.
	* include/bits/range_access.h (ranges::*): Move to new
	<bits/ranges_base.h> header.
	* include/bits/ranges_algobase.h: Include new <bits/ranges_base.h>
	header instead of <ranges>.
	* include/bits/ranges_algo.h: Include new <bits/ranges_util.h>
	header.
	* include/bits/range_cmp.h: Moved to...
	* include/bits/ranges_cmp.h: ...here.
	* include/bits/ranges_base.h: New header.
	* include/bits/ranges_util.h: New header.
	* include/experimental/string_view: Include new
	<bits/ranges_base.h> header.
	* include/std/functional: Adjust for renamed header.
	* include/std/ranges (ranges::view_base, ranges::enable_view)
	(ranges::dangling, ranges::borrowed_iterator_t): Move to new
	<bits/ranges_base.h> header.
	(ranges::view_interface, ranges::subrange)
	(ranges::borrowed_subrange_t): Move to new <bits/ranges_util.h>
	header.
	* include/std/span: Include new <bits/ranges_base.h> header.
	* include/std/string_view: Likewise.
	* testsuite/24_iterators/back_insert_iterator/pr93884.cc: Add
	missing <ranges> header.
	* testsuite/24_iterators/front_insert_iterator/pr93884.cc:
	Likewise.
2020-09-22 15:45:54 +01:00
Marek Polacek
7df1534c13 testsuite: Prune more output in timevar1.C.
gcc/testsuite/ChangeLog:

	* g++.dg/ext/timevar1.C: Also prune N%.
2020-09-22 09:25:51 -04:00
Marek Polacek
c8042d5f6c testsuite: Prune more output in timevar2.C.
gcc/testsuite/ChangeLog:

	* g++.dg/ext/timevar2.C: Also prune N%.
2020-09-22 09:00:41 -04:00
Martin Liska
c6df6039e9 switch lowering: limit number of cluster attemps
gcc/ChangeLog:

	PR tree-optimization/96979
	* doc/invoke.texi: Document new param max-switch-clustering-attempts.
	* params.opt: Add new parameter.
	* tree-switch-conversion.c (jump_table_cluster::find_jump_tables):
	Limit number of attempts.
	(bit_test_cluster::find_bit_tests): Likewise.

gcc/testsuite/ChangeLog:

	PR tree-optimization/96979
	* g++.dg/tree-ssa/pr96979.C: New test.
2020-09-22 14:38:46 +02:00
Stefan Schulze Frielinghaus
1a84651d16 IBM Z: Try to make use of load-and-test instructions
This patch enables a peephole2 optimization which transforms a load of
constant zero into a temporary register which is then finally used to
compare against a floating-point register of interest into a single load
and test instruction.  However, the optimization is only applied if both
registers are dead afterwards and if we test for (in)equality only.
This is relaxed in case of fast math.

This is a follow up to PR88856.

gcc/ChangeLog:

	* config/s390/s390.md ("*cmp<mode>_ccs_0", "*cmp<mode>_ccz_0",
	"*cmp<mode>_ccs_0_fastmath"): Basically change "*cmp<mode>_ccs_0" into
	"*cmp<mode>_ccz_0" and for fast math add "*cmp<mode>_ccs_0_fastmath".

gcc/testsuite/ChangeLog:

	* gcc.target/s390/load-and-test-fp-1.c: Change test to include all
	possible combinations of dead/live registers and comparisons (equality,
	relational).
	* gcc.target/s390/load-and-test-fp-2.c: Same as load-and-test-fp-1.c
	but for fast math.
	* gcc.target/s390/load-and-test-fp.h: New test included by
	load-and-test-fp-{1,2}.c.
2020-09-22 13:55:42 +02:00
Tom de Vries
c0e9cee285 [libgomp, nvptx] Print error log for link error
By running libgomp test-case libgomp.c/target-28.c with GOMP_NVPTX_PTXRW=w
(using a maintenance patch that adds support for this env var), we dump the
ptx in target-28.exe to file.  By editing one ptx file to rename
gomp_nvptx_main to gomp_nvptx_main2 in both declaration and call, and
running with GOMP_NVPTX_PTXRW=r, we trigger a link error:
...
$ GOMP_NVPTX_PTXRW=r ./target-28.exe
libgomp: cuLinkComplete error: unknown error
...
The error is somewhat uninformative.

Fix this by dumping the error log returned by the failing cuda call, such
that we have instead:
...
$ GOMP_NVPTX_PTXRW=r ./target-28.exe
libgomp: Link error log error   : \
  Undefined reference to 'gomp_nvptx_main2' in ''
libgomp: cuLinkComplete error: unknown error
...

Build on x86_64 with nvptx accelerator, tested libgomp.

libgomp/ChangeLog:

	* plugin/plugin-nvptx.c (link_ptx): Print elog if cuLinkComplete call
	fails.
2020-09-22 13:38:00 +02:00
Kyrylo Tkachov
30957092db AArch64: Implement missing vcls intrinsics on unsigned types
This patch implements some missing intrinsics that perform a CLS on unsigned SIMD types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
	PR target/71233
	* config/aarch64/arm_neon.h (vcls_u8, vcls_u16, vcls_u32,
	vclsq_u8, vclsq_u16, vclsq_u32): Define.

gcc/testsuite/
	PR target/71233
	* gcc.target/aarch64/simd/vcls_unsigned_1.c: New test.
2020-09-22 12:03:49 +01:00
Kyrylo Tkachov
d4703be185 AArch64: Implement missing vceq*_p* intrinsics
This patch implements some missing vceq* intrinsics on poly types.
The behaviour is to produce the appropriate CMEQ instruction as for the unsigned types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
	PR target/71233
	* config/aarch64/arm_neon.h (vceqq_p64, vceqz_p64, vceqzq_p64): Define.

gcc/testsuite/

	PR target/71233
	* gcc.target/aarch64/simd/vceq_poly_1.c: New test.
2020-09-22 12:00:38 +01:00
Kyrylo Tkachov
fa9ad35dae AArch64: Implement poly-type vadd intrinsics
This implements the vadd[p]_p* intrinsics.
In terms of functionality they are aliases of veor operations on the relevant unsigned types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
	PR target/71233
	* config/aarch64/arm_neon.h (vadd_p8, vadd_p16, vadd_p64, vaddq_p8,
	vaddq_p16, vaddq_p64, vaddq_p128): Define.

gcc/testsuite/
	PR target/71233
	* gcc.target/aarch64/simd/vadd_poly_1.c: New test.
2020-09-22 11:58:36 +01:00
Sergei Trofimovich
4ecf368f4b gcov: fix TOPN streaming from shared libraries
Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

	PR gcov-profile/96913
	* libgcov-driver.c (write_one_data): Avoid function pointer
	comparison in TOP streaming decision.
2020-09-22 11:41:04 +01:00
Jakub Jelinek
46a2741547 Fix some typos
2020-09-22  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* params.opt (--param=modref-max-tests=): Fix typo in help text:
	perofmed -> performed.
	* common.opt: Fix typo: incrmeental -> incremental.
	* ipa-modref.c: Fix typos: recroding -> recording, becaue -> because,
	analsis -> analysis.
	(class modref_summaries): Fix typo: betweehn -> between.
	(analyze_call): Fix typo: calle -> callee.
	(read_modref_records): Fix typo: expcted -> expected.
	(pass_ipa_modref::execute): Fix typo: calle -> callee.
gcc/c-family/
	* c.opt (Wbuiltin-declaration-mismatch): Fix typo in variable name:
	warn_builtin_declaraion_mismatch -> warn_builtin_declaration_mismatch.
2020-09-22 10:45:06 +02:00
Jakub Jelinek
466b907fad ipa: Fix up ipa modref option help texts
This fixes
FAIL: compiler driver --help=common option(s): "^ +-.*[^:.]$" absent from output: "  --param=modref-max-tests=   Maximum number of tests perofmed by modref query"
FAIL: compiler driver --help=optimizers option(s): "^ +-.*[^:.]$" absent from output: "  -fipa-modref                Perform interprocedural modref analysis"

2020-09-22  Jakub Jelinek  <jakub@redhat.com>

	* common.opt (-fipa-modref): Add dot at the end of option help.
	* params.opt (--param=modref-max-tests=): Likewise.
2020-09-22 10:02:47 +02:00
Jonathan Wakely
7825399092 libstdc++: Use correct argument type for __use_alloc, again [PR 96803]
While backporting 5494edae83 I noticed
that it's still not correct. I made the allocator-extended constructor
use the right type for the uses-allocator construction detection, but I
used an rvalue when it should be a const lvalue.

This should fix it properly this time.

libstdc++-v3/ChangeLog:

	PR libstdc++/96803
	* include/std/tuple
	(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
	Use correct value category in __use_alloc call.
	* testsuite/20_util/tuple/cons/96803.cc: Check with constructors
	that require correct value category to be used.
2020-09-22 08:42:18 +01:00
Jan Hubicka
d149962d6a Add no strict aliasing to m128-check.h
* gcc.target/i386/m128-check.h: Add no-strict-aliasing
2020-09-22 09:29:56 +02:00
Patrick Palka
37edf28c24 libstdc++: Remove overzealous static_asserts from std::span
For a span with statically empty extent, we currently model the
preconditions of front(), back(), and operator[] as if they are
mandates, by using a static_assert to verify that extent != 0.  This
causes us to reject valid programs that would instantiate these member
functions and at runtime never call them.

Since they are already followed by more general runtime asserts, this
patch just removes these static_asserts altogether,

libstdc++-v3/ChangeLog:

	* include/std/span (span::front): Remove static_assert.
	(span::back): Likewise.
	(span::operator[]): Likewise.
	* testsuite/23_containers/span/back_neg.cc: Rewrite to verify
	that we check the preconditions of back() only when it's called.
	* testsuite/23_containers/span/front_neg.cc: Likewise for
	front().
	* testsuite/23_containers/span/index_op_neg.cc: Likewise for
	operator[].
2020-09-21 23:21:34 -04:00
Patrick Palka
813ad9c4dd libstdc++: Fix division by zero in std::sample
This fixes a division by zero in the selection-sampling std::__sample
overload when the input range is empty (and hence __unsampled_sz is 0).

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (__sample): Exit early when the
	input range is empty.
	* testsuite/25_algorithms/sample/3.cc: New test.
2020-09-21 20:48:23 -04:00
Patrick Palka
f017952d31 libstdc++: Mark some more algorithms constexpr for C++20
As per P0202.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (for_each_n): Mark constexpr for C++20.
	(search): Likewise for the overload that takes a searcher.
	* testsuite/25_algorithms/for_each/constexpr.cc: Test constexpr
	std::for_each_n.
	* testsuite/25_algorithms/search/constexpr.cc: Test constexpr
	std::search overload that takes a searcher.
2020-09-21 20:48:17 -04:00
GCC Administrator
44135373fc Daily bump. 2020-09-22 00:16:31 +00:00
Ian Lance Taylor
27edc6c3e2 compiler: finalize methods for type aliases of struct types
Previously we would finalize the methods of the alias type itself, but
since its a type alias we really need to finalize the methods of the
aliased type.

Also, handle method expressions of unnamed struct types.

Test case is https://golang.org/cl/251168.

Fixes golang/go#38125

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/251279
2020-09-21 15:53:48 -07:00
David Malcolm
1e19ecd79b analyzer: fix ICE on bogus decl of memset [PR97130]
Verify that arguments are pointers before calling handling code
that calls deref_rvalue on them.

gcc/analyzer/ChangeLog:
	PR analyzer/97130
	* region-model-impl-calls.cc (call_details::get_arg_type): New.
	* region-model.cc (region_model::on_call_pre): Check that the
	initial arg is a pointer before calling impl_call_memset and
	impl_call_strlen.
	* region-model.h (call_details::get_arg_type): New decl.

gcc/testsuite/ChangeLog:
	PR analyzer/97130
	* gcc.dg/analyzer/pr97130.c: New test.
2020-09-21 18:50:08 -04:00
David Malcolm
15e7b93ba4 analyzer: decls are not on the heap
Whilst debugging the remaining state explosion in PR analyzer/93355
I noticed that half of the states at an exploding program point had:
  'malloc': {'&buf': 'non-heap'}
whereas the other half didn't, presumably depending on whether the path
to each enode had used this local buffer:
  char buf[400];

This patch tweaks malloc_state_machine::get_default_state to be smarter
about this, so that we can implicitly treat pointers to decls as
non-heap, preventing pointless differences between sm_state_map
instances.  With that, all of the states in question have equal (empty)
malloc sm-state - though the state explosion continues for other reasons.

gcc/analyzer/ChangeLog:
	PR analyzer/93355
	* sm-malloc.cc (malloc_state_machine::get_default_state): Look at
	the base region when considering pointers.  Treat pointers to
	decls as being non-heap.
2020-09-21 18:49:22 -04:00
Jonathan Wakely
7db5967f10 libstdc++: Use __builtin_expect in __glibcxx_assert
libstdc++-v3/ChangeLog:

	* include/bits/c++config (__replacement_assert): Add noreturn
	attribute.
	(__glibcxx_assert_impl): Use __builtin_expect to hint that the
	assertion is expected to pass.
2020-09-21 23:43:25 +01:00
Jonathan Wakely
aecea4158f libstdc++: Fix constraints for drop_view::begin() const [LWG 3482]
libstdc++-v3/ChangeLog:

	* include/std/ranges (drop_view::begin()): Adjust constraints
	to match the correct condition for O(1) ranges::next (LWG 3482).
	* testsuite/std/ranges/adaptors/drop.cc: Check that iterator is
	cached for non-sized_range.
2020-09-21 23:43:25 +01:00
Clément Chigot
be3027e9c8 go/internal/gccgoimporter: recognize aixbigafMagic archives
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/255201
2020-09-21 15:42:00 -07:00
Marek Polacek
defceb206b c++: DR 1722: Make lambda to function pointer conv noexcept [PR90583]
DR 1722 clarifies that the conversion function from lambda to pointer to
function should be noexcept(true).

gcc/cp/ChangeLog:

	PR c++/90583
	DR 1722
	* lambda.c (maybe_add_lambda_conv_op): Mark the conversion function
	as noexcept.

gcc/testsuite/ChangeLog:

	PR c++/90583
	DR 1722
	* g++.dg/cpp0x/lambda/lambda-conv14.C: New test.
2020-09-21 18:13:37 -04:00
Marek Polacek
7029dfa38b c++: Implement -Wctad-maybe-unsupported.
I noticed that clang++ has this CTAD warning and thought that it might
be useful to have it.  From clang++: "Some style guides want to allow
using CTAD only on types that "opt-in"; i.e. on types that are designed
to support it and not just types that *happen* to work with it."

So this warning warns when CTAD deduced a type, but the type does not
define any deduction guides.  In that case CTAD worked only because the
compiler synthesized the implicit deduction guides.  That might not be
intended.

It can be suppressed by adding a deduction guide that will never be
considered:

  struct allow_ctad_t;
  template <typename T> struct S { S(T) {} };
  S(allow_ctad_t) -> S<void>;

This warning is off by default.  It doesn't warn when the type comes
from a system header unless -Wsystem-headers.

gcc/c-family/ChangeLog:

	* c.opt (Wctad-maybe-unsupported): New option.

gcc/cp/ChangeLog:

	* pt.c (deduction_guides_for): Add a bool parameter.  Set it.
	(do_class_deduction): Warn when CTAD succeeds but the type doesn't
	have any explicit deduction guides.

gcc/ChangeLog:

	* doc/invoke.texi: Document -Wctad-maybe-unsupported.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wctad-maybe-unsupported.C: New test.
	* g++.dg/warn/Wctad-maybe-unsupported2.C: New test.
	* g++.dg/warn/Wctad-maybe-unsupported3.C: New test.
	* g++.dg/warn/Wctad-maybe-unsupported.h: New file.
2020-09-21 17:48:11 -04:00
Ian Lance Taylor
68402af1c6 libgo: don't put golang.org packages in zstdpkglist.go
This ensures that internal/goroot.IsStandardPackage does not treat
golang.org packages as being in the standard library.

For golang/go#41368
Fixes golang/go#41499

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/256319
2020-09-21 14:11:01 -07:00
Martin Sebor
05193687dd Avoid incidental failures due to implicit attribute access.
gcc/testsuite/ChangeLog:

	PR c/50584
	* gcc.dg/ipa/ipa-sra-1.c: Use a plain pointer for argv instead of array.
	* gcc.dg/ipa/ipa-sra-12.c: Same.
	* gcc.dg/ipa/ipa-sra-13.c: Same.
	* gcc.dg/ipa/ipa-sra-14.c: Same.
	* gcc.dg/ipa/ipa-sra-15.c: Same.
2020-09-21 14:54:58 -06:00