Commit Graph

179490 Commits

Author SHA1 Message Date
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
Harald Anlauf
5c5ce60990 PR fortran/90903 [part2] - Add runtime checking for the MVBITS intrinsic
Implement inline expansion of the intrinsic elemental subroutine MVBITS
with optional runtime checks for valid argument range.

gcc/fortran/ChangeLog:

	* iresolve.c (gfc_resolve_mvbits): Remove unneeded conversion of
	FROMPOS, LEN and TOPOS arguments to fit a C int.
	* trans-intrinsic.c (gfc_conv_intrinsic_mvbits): Add inline
	expansion of MVBITS intrinsic elemental subroutine and add code
	for runtime argument checking.
	(gfc_conv_intrinsic_subroutine): Recognise MVBITS intrinsic, but
	defer handling to gfc_trans_call.
	* trans-stmt.c (replace_ss):
	(gfc_trans_call): Adjust to handle inline expansion, scalarization
	of intrinsic subroutine MVBITS in gfc_conv_intrinsic_mvbits.
	* trans.h (gfc_conv_intrinsic_mvbits): Add prototype for
	gfc_conv_intrinsic_mvbits.

gcc/testsuite/ChangeLog:

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

Co-authored-by: Paul Thomas  <pault@gcc.gnu.org>
2020-09-21 21:50:36 +02:00
Ian Lance Taylor
762c16eba6 libsanitizer: rename new libbacktrace symbols
* libbacktrace/backtrace-rename.h (backtrace_uncompress_lzma):
	Define.
	(backtrace_syminfo_to_full_callback): Define.
	(backtrace_syminfo_to_full_error_callback): Define.
2020-09-21 12:03:45 -07:00
Nathan Sidwell
33605e9bef c++: ts_lambda is not needed
We don't need ts_lambda, as IDENTIFIER_LAMBDA_P is sufficient.  Killed thusly.

	gcc/cp/
	* decl.c (xref_tag_1): Use IDENTIFIER_LAMBDA_P to detect lambdas.
	* lambda.c (begin_lambda_type): Use ts_current to push the tag.
	* name-lookup.h (enum tag_scope): Drop ts_lambda.
2020-09-21 11:53:14 -07:00
Iain Sandoe
4f5a297f75 Darwin, testsuite : Skip a test that requires ELF.
The symver support is only available to ELF targets.

gcc/testsuite/ChangeLog:

	* gcc.dg/ipa/symver1.c: Skip for Darwin.
2020-09-21 19:31:22 +01:00
Christophe Lyon
b0c990f266 [arm] gcc.target/arm/cs*: Use dg-add-options arm_arch_v8_1m_main
These testcases need thumb mode, which may not be the default.

Using dg-add-options arm_arch_v8_1m_main ensures that -mthumb is used
and makes the test pass in more configurations.

2020-09-21  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/testsuite/
	* gcc.target/arm/csinc-1.c: Use dg-add-options
	arm_arch_v8_1m_main.
	* gcc.target/arm/csinv-1.c: Likewise.
	* gcc.target/arm/csneg.c: Likewise.
2020-09-21 16:19:00 +00:00
Richard Biener
e6f58fb619 tree-optimization/97139 - fix BB SLP live lane extraction
This fixes SLP live lane extraction with pattern stmts.

2020-09-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/97139
	* tree-vect-slp.c (vect_bb_slp_mark_live_stmts): Only mark the
	pattern root, track visited vectorized stmts.

	* gcc.dg/vect/pr97139.c: New testcase.
2020-09-21 16:54:04 +02:00
Marek Polacek
b6ff694e59 c++: Detect deduction guide redeclaration [PR97099]
[temp.deduct.guide]p3: Two deduction guide declarations in the same
translation unit for the same class template shall not have equivalent
parameter-declaration-clauses.

So let's detect that.

gcc/cp/ChangeLog:

	PR c++/97099
	* decl.c (redeclaration_error_message): Detect a redeclaration of
	deduction guides.

gcc/testsuite/ChangeLog:

	PR c++/97099
	* g++.dg/cpp1z/class-deduction74.C: New test.
2020-09-21 10:11:41 -04:00
Jonathan Wakely
2ec58cfcea libstdc++: Relax constraints on transform_view and elements_view iterators
libstdc++-v3/ChangeLog:

	* include/std/ranges (transform_view, elements_view): Relax
	constraints on operator- for iterators, as per LWG 3483.
	* testsuite/std/ranges/adaptors/elements.cc: Check that we
	can take the difference of two iterators from a non-random
	access range.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
2020-09-21 14:30:38 +01:00
Jonathan Wakely
f10ed928e2 libstdc++: Make std::assume_aligned a constexpr function [PR 97132]
The cast from void* to T* in std::assume_aligned is not valid in a
constexpr function. The optimization hint is redundant during constant
evaluation anyway (the compiler can see the object and knows its
alignment). Simply return the original pointer without applying the
__builtin_assume_aligned hint to it when doing constant evaluation.

This change also removes the preprocessor branch that works around
uintptr_t not being available. We already assume that type is present
elsewhere in the library.

libstdc++-v3/ChangeLog:

	PR libstdc++/97132
	* include/bits/align.h (align) [!_GLIBCXX_USE_C99_STDINT_TR1]:
	Remove unused code.
	(assume_aligned): Do not use __builtin_assume_aligned during
	constant evaluation.
	* testsuite/20_util/assume_aligned/1.cc: Improve test.
	* testsuite/20_util/assume_aligned/97132.cc: New test.
2020-09-21 14:28:58 +01:00
Jakub Jelinek
5187b01a4f Fix fallout from Support new mallinfo2 function.
2020-09-21  Jakub Jelinek  <jakub@redhat.com>

	* configure.ac: Use mallinfo mallinfo2 as first operand of
	gcc_AC_CHECK_DECLS rather than [mallinfo, mallinfo2].
	* configure: Regenerated.
	* config.in: Regenerated.
2020-09-21 14:21:28 +02:00
Andrea Corallo
2c62952f81 aarch64: Do not alter value on a force_reg returned rtx expanding __jcvt
2020-09-17  Andrea Corallo  <andrea.corallo@arm.com>

	* config/aarch64/aarch64-builtins.c
	(aarch64_general_expand_builtin): Use expand machinery not to
	alter the value of an rtx returned by force_reg.
2020-09-21 14:09:17 +02:00
Richard Biener
0df746afc5 tree-optimization/97135 - fix dependence check in store-motion
The following fixes a dependence check where in the particular place
we cannot ignore self-dependences.

2020-09-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/97135
	* tree-ssa-loop-im.c (sm_seq_push_down): Do not ignore
	self-dependences.

	* gcc.dg/torture/pr97135.c: New testcase.
2020-09-21 14:06:36 +02:00
Martin Liska
d726ecd955 Fix ICE in tree-switch-conversion.
With SVE we can end up with:
switch (POLY_INT_CST [2, 2]) <default: <L2> [INV], case 2: <L3> [INV], case 4: <L3> [INV]>
which is fine to expand and we can remove the assert.

gcc/ChangeLog:

	PR tree-optimization/96915
	* tree-switch-conversion.c (switch_conversion::expand): Accept
	also integer constants.

gcc/testsuite/ChangeLog:

	PR tree-optimization/96915
	* gcc.target/aarch64/sve/pr96915.c: New test.
2020-09-21 13:52:03 +02:00
Martin Liska
48b0c1250a POLY_INT_CST: remove extra space in dump
gcc/ChangeLog:

	* print-tree.c (print_node): Remove extra space.
2020-09-21 12:47:32 +02:00
Tobias Burnus
ed5ae55e93 mklog.py: Parse first 10 lines for PR/DR number
contrib/ChangeLog:

	* mklog.py: Parse first 10 lines for PR/DR number
	not only the first line.
2020-09-21 11:22:49 +02:00
Andrea Corallo
f5e73de00e aarch64: Fix ICE on fpsr fpcr getters [PR96968]
gcc/ChangeLog

2020-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	PR target/96968
	* config/aarch64/aarch64-builtins.c
	(aarch64_expand_fpsr_fpcr_setter): Fix comment nit.
	(aarch64_expand_fpsr_fpcr_getter): New function, expand these
	getters using expand_insn machinery.
	(aarch64_general_expand_builtin): Make use of.

gcc/testsuite/ChangeLog

2020-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	PR target/96968
	* gcc.target/aarch64/pr96968.c: New test.
2020-09-21 10:38:23 +02:00
Martin Liska
da87190421 Use ONE_? macros.
gcc/ChangeLog:

	* ggc-common.c (ggc_rlimit_bound): Use ONE_? macro.
	(ggc_min_expand_heuristic): Likewise.
	(ggc_min_heapsize_heuristic): Likewise.
	* ggc-page.c (ggc_collect): Likewise.
	* system.h (ONE_G): Likewise.
2020-09-21 10:09:27 +02:00
Martin Liska
79f4e20dd1 Use SIZE_AMOUNT macro for GGC memory allocation numbers.
gcc/ChangeLog:

	* ggc-common.c (ggc_prune_overhead_list): Use SIZE_AMOUNT.
	* ggc-page.c (release_pages): Likewise.
	(ggc_collect): Likewise.
	(ggc_trim): Likewise.
	(ggc_grow): Likewise.
	* timevar.c (timer::print): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/timevar1.C: Prune more possible number values.
	* g++.dg/ext/timevar2.C: Likewise.
2020-09-21 10:09:26 +02:00
Martin Liska
432c551b17 Support new mallinfo2 function.
gcc/ChangeLog:

	* config.in: Regenerate.
	* configure: Likewise.
	* configure.ac: Detect for mallinfo2.
	* ggc-common.c (defined): Use it.
	* system.h: Handle also HAVE_MALLINFO2.
2020-09-21 10:09:26 +02:00
GCC Administrator
11da31998a Daily bump. 2020-09-21 00:16:24 +00:00
Jonathan Wakely
3c755b428e libstdc++: Fix noexcept-specifier for std::bind_front [PR 97101]
libstdc++-v3/ChangeLog:

	PR libstdc++/97101
	* include/std/functional (bind_front): Fix order of parameters
	in is_nothrow_constructible_v specialization.
	* testsuite/20_util/function_objects/bind_front/97101.cc: New test.
2020-09-21 00:17:02 +01:00
John David Anglin
363e7755f2 Fix linkage with -nodefaultlibs option.
2020-09-20  John David Anglin  < danglin@gcc.gnu.org>

gcc/ChangeLog
	* config/pa/pa-hpux11.h (LINK_GCC_C_SEQUENCE_SPEC): Delete.
	* config/pa/pa64-hpux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
	(ENDFILE_SPEC): Link with libgcc_stub.a and mill.a.
	* config/pa/pa32-linux.h (ENDFILE_SPEC): Link with libgcc.a.
2020-09-20 19:37:17 +00:00
Marek Polacek
0968df43cd c++: Add test for PR90199.
Fixed by r11-2998, which fixed this ICE too.

gcc/testsuite/ChangeLog:

	PR c++/90199
	* g++.dg/cpp1y/constexpr-90199.C: New test.
2020-09-20 15:26:52 -04:00
Jan Hubicka
9044db88d6 Fix ICE during dumping in ipa-modref.
2020-09-20  Jan Hubicka  <hubicka@ucw.cz>

	* ipa-modref.c (dump_lto_records): Fix ICE.
2020-09-20 08:19:56 +02:00
Jan Hubicka
d119f34c95 New modref/ipa_modref optimization passes
2020-09-19  David Cepelik  <d@dcepelik.cz>
	    Jan Hubicka  <hubicka@ucw.cz>

	* Makefile.in: Add ipa-modref.c and ipa-modref-tree.c.
	* alias.c: (reference_alias_ptr_type_1): Export.
	* alias.h (reference_alias_ptr_type_1): Declare.
	* common.opt (fipa-modref): New.
	* gengtype.c (open_base_files): Add ipa-modref-tree.h and ipa-modref.h
	* ipa-modref-tree.c: New file.
	* ipa-modref-tree.h: New file.
	* ipa-modref.c: New file.
	* ipa-modref.h: New file.
	* lto-section-in.c (lto_section_name): Add ipa_modref.
	* lto-streamer.h (enum lto_section_type): Add LTO_section_ipa_modref.
	* opts.c (default_options_table): Enable ipa-modref at -O1+.
	* params.opt (-param=modref-max-bases, -param=modref-max-refs,
	-param=modref-max-tests): New params.
	* passes.def: Schedule pass_modref and pass_ipa_modref.
	* timevar.def (TV_IPA_MODREF): New timevar.
	(TV_TREE_MODREF): New timevar.
	* tree-pass.h (make_pass_modref): Declare.
	(make_pass_ipa_modref): Declare.
	* tree-ssa-alias.c (dump_alias_stats): Include ipa-modref-tree.h
	and ipa-modref.h
	(alias_stats): Add modref_use_may_alias, modref_use_no_alias,
	modref_clobber_may_alias, modref_clobber_no_alias, modref_tests.
	(dump_alias_stats): Dump new stats.
	(nonoverlapping_array_refs_p): Fix formating.
	(modref_may_conflict): New function.
	(ref_maybe_used_by_call_p_1): Use it.
	(call_may_clobber_ref_p_1): Use it.
	(call_may_clobber_ref_p): Update.
	(stmt_may_clobber_ref_p_1): Update.
	* tree-ssa-alias.h (call_may_clobber_ref_p_1): Update.
2020-09-20 07:27:48 +02:00
GCC Administrator
2fe5b7d1f6 Daily bump. 2020-09-20 00:16:23 +00:00
Martin Sebor
3f9a497d1b Extend -Warray-bounds to detect out-of-bounds accesses to array parameters.
gcc/ChangeLog:

	PR middle-end/82608
	PR middle-end/94195
	PR c/50584
	PR middle-end/84051
	* gimple-array-bounds.cc (get_base_decl): New function.
	(get_ref_size): New function.
	(trailing_array): New function.
	(array_bounds_checker::check_array_ref): Call them.  Handle arrays
	declared in function parameters.
	(array_bounds_checker::check_mem_ref):  Same.  Handle references to
	dynamically allocated arrays.

gcc/testsuite/ChangeLog:

	PR middle-end/82608
	PR middle-end/94195
	PR c/50584
	PR middle-end/84051
	* c-c++-common/Warray-bounds.c: Adjust.
	* gcc.dg/Wbuiltin-declaration-mismatch-9.c: Adjust.
	* gcc.dg/Warray-bounds-63.c: New test.
	* gcc.dg/Warray-bounds-64.c: New test.
	* gcc.dg/Warray-bounds-65.c: New test.
	* gcc.dg/Warray-bounds-66.c: New test.
	* gcc.dg/Warray-bounds-67.c: New test.
2020-09-19 17:56:13 -06:00
Martin Sebor
baad4c48a8 Extend -Wstringop-overflow to detect out-of-bounds accesses to array parameters.
gcc/ChangeLog:

	PR c/50584
	* builtins.c (warn_for_access): Add argument.  Distinguish between
	reads and writes.
	(check_access): Add argument.  Distinguish between reads and writes.
	(gimple_call_alloc_size): Set range even on failure.
	(gimple_parm_array_size): New function.
	(compute_objsize): Call it.
	(check_memop_access): Pass check_access an additional argument.
	(expand_builtin_memchr, expand_builtin_strcat): Same.
	(expand_builtin_strcpy, expand_builtin_stpcpy_1): Same.
	(expand_builtin_stpncpy, check_strncat_sizes): Same.
	(expand_builtin_strncat, expand_builtin_strncpy): Same.
	(expand_builtin_memcmp): Same.
	* builtins.h (compute_objsize): Declare a new overload.
	(gimple_parm_array_size): Declare.
	(check_access): Add argument.
	* calls.c (append_attrname): Simplify.
	(maybe_warn_rdwr_sizes): Handle internal attribute access.
	* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Avoid adding
	quotes.

gcc/testsuite/ChangeLog:

	PR c/50584
	* c-c++-common/Wsizeof-pointer-memaccess1.c: Disable new expected
	warnings.
	* g++.dg/ext/attr-access.C: Update text of expected warnings.
	* gcc.dg/Wstringop-overflow-23.c: Same.
	* gcc.dg/Wstringop-overflow-24.c: Same.
	* gcc.dg/attr-access-none.c: Same.
	* gcc.dg/dfp/composite-type.c: Prune expected warnings.
	* gcc.dg/torture/pr57147-1.c: Add a member to an otherwise empty
	struct to avoid a warning.
	* gcc.dg/torture/pr57147-3.c: Same.
	* gcc.dg/Warray-bounds-30.c: Adjust.
	* gcc.dg/attr-access-none.c: Same.
	* gcc.dg/Wstringop-overflow-40.c: New test.
	* gcc.dg/attr-access-2.c: New test.
2020-09-19 17:37:05 -06:00
Martin Sebor
72be80e47d Make use of new attribute access infrastructure in -Wuninitialized (PR 50584).
gcc/ChangeLog:

	* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Handle attribute
	access internal representation of arrays.

gcc/testsuite/ChangeLog:

	* gcc.dg/uninit-37.c: New test.
2020-09-19 17:34:31 -06:00
Martin Sebor
6450f07388 Infrastructure & C front end changes for array parameter checking (PR c/50584).
gcc/ChangeLog:

	PR c/50584
	* attribs.c (decl_attributes): Also pass decl along with type
	attributes to handlers.
	(init_attr_rdwr_indices): Change second argument to attribute chain.
	Handle internal attribute representation in addition to external.
	(get_parm_access): New function.
	(attr_access::to_internal_string): Define new member function.
	(attr_access::to_external_string): Define new member function.
	(attr_access::vla_bounds): Define new member function.
	* attribs.h (struct attr_access): Declare new members.
	(attr_access::from_mode_char): Define new member function.
	(get_parm_access): Declare new function.
	* calls.c (initialize_argument_information): Pass function type
	attributes to init_attr_rdwr_indices.
	* doc/invoke.texi (-Warray-parameter, -Wvla-parameter): Document.
	* tree-pretty-print.c (dump_generic_node): Correct handling of
	qualifiers.
	* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Same.
	* tree.h (access_mode): Add new enumerator.

gcc/c-family/ChangeLog:

	PR c/50584
	* c-attribs.c (c_common_attribute_table): Add "arg spec" attribute.
	(handle_argspec_attribute): New function.
	(get_argument, get_argument_type): New functions.
	(append_access_attrs): Add overload.  Handle internal attribute
	representation in addition to external.
	(handle_access_attribute): Handle internal attribute representation
	in addition to external.
	(build_attr_access_from_parms): New function.

gcc/c-family/ChangeLog:

	PR c/50584
	* c-common.h (warn_parm_array_mismatch): Declare new function.
	(has_attribute): Move declaration of an existing function.
	(build_attr_access_from_parms): Declare new function.
	* c-warn.c (parm_array_as_string): Define new function.
	(plus_one):  Define new function.
	(warn_parm_ptrarray_mismatch): Define new function.
	(warn_parm_array_mismatch):  Define new function.
	(vla_bound_parm_decl): New function.
	* c.opt (-Warray-parameter, -Wvla-parameter): New options.
	* c-pretty-print.c (pp_c_type_qualifier_list): Don't print array type
	qualifiers here...
	(c_pretty_printer::direct_abstract_declarator): ...but instead print
	them in brackets here.  Also print [static].  Strip extraneous
	expressions from VLA bounds.

gcc/c/ChangeLog:

	PR c/50584
	* c-decl.c (lookup_last_decl): Define new function.
	(c_decl_attributes): Call it.
	(start_decl): Add argument and use it.
	(finish_decl): Call build_attr_access_from_parms and decl_attributes.
	(get_parm_array_spec): Define new function.
	(push_parm_decl): Call get_parm_array_spec.
	(start_function): Call warn_parm_array_mismatch.  Build attribute
	access and add it to current function.
	* c-parser.c (c_parser_declaration_or_fndef): Diagnose mismatches
	in forms of array parameters.
	* c-tree.h (start_decl): Add argument.

gcc/testsuite/ChangeLog:

	PR c/50584
	* gcc.dg/attr-access-read-write-2.c: Adjust text of expected message.
	* c-c++-common/Warray-bounds-6.c: Correct C++ declaration, adjust
	text of expected diagnostics.
	* gcc.dg/Wbuiltin-declaration-mismatch-9.c: Prune expected warning.
	* gcc.dg/Warray-parameter-2.c: New test.
	* gcc.dg/Warray-parameter-3.c: New test.
	* gcc.dg/Warray-parameter-4.c: New test.
	* gcc.dg/Warray-parameter-5.c: New test.
	* gcc.dg/Warray-parameter.c: New test.
	* gcc.dg/Wvla-parameter-2.c: New test.
	* gcc.dg/Wvla-parameter-3.c: New test.
	* gcc.dg/Wvla-parameter.c: New test.
2020-09-19 17:34:31 -06:00
Sandra Loosemore
3696a50bee Change C front end to emit structured loop and switch tree nodes.
2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/c
	* c-decl.c (c_break_label, c_cont_label): Delete, and replace
	with...
	(in_statement): New.
	(start_function): Adjust for above change.
	(c_push_function_context, c_pop_function_context): Likewise.
	* c-lang.h (struct language_function): Likewise.
	* c-objc-common.h (LANG_HOOKS_BLOCK_MAY_FALLTHRU): Define.
	* c-parser.c (objc_foreach_break_label, objc_foreach_continue_label):
	New.
	(c_parser_statement_after_labels): Adjust calls to c_finish_bc_stmt.
	(c_parser_switch_statement): Adjust break/switch context handling
	and calls to renamed functions.
	(c_parser_while_statement): Adjust break/switch context handling and
	build a WHILE_STMT.
	(c_parser_do_statement): Ditto, with DO_STMT respectively.
	(c_parser_for_statement): Ditto, with FOR_STMT respectively.
	(c_parser_omp_for_loop): Adjust break/switch context handling.
	* c-tree.h (c_break_label, c_cont_label): Delete.
	(IN_SWITCH_STMT, IN_ITERATION_STMT): Define.
	(IN_OMP_BLOCK, IN_OMP_FOR, IN_OBJC_FOREACH): Define.
	(in_statement, switch_statement_break_seen_p): Declare.
	(c_start_case, c_finish_case): Renamed to...
	(c_start_switch, c_finish_switch).
	(c_finish_bc_stmt): Adjust arguments.
	* c-typeck.c (build_function_call_vec): Don't try to print
	statements with %qE format.
	(struct c_switch):  Rename switch_expr field to switch_stmt.
	Add break_stmt_seen_p field.
	(c_start_case): Rename to c_start_switch.  Build a SWITCH_STMT
	instead of a SWITCH_EXPR.  Update for changes to struct c_switch.
	(do_case): Update for changes to struct c_switch.
	(c_finish_case): Rename to c_finish_switch.  Update for changes to
	struct c_switch and change of representation from SWITCH_EXPR to
	SWITCH_STMT.
	(c_finish_loop): Delete.
	(c_finish_bc_stmt): Update to reflect changes to break/continue
	state representation.  Build a BREAK_STMT or CONTINUE_STMT instead
	of a GOTO_EXPR except for objc foreach loops.

	gcc/objc
	* objc-act.c (objc_start_method_definition): Update to reflect
	changes to break/continue state bookkeeping in C front end.

	gcc/testsuite/
	* gcc.dg/gomp/block-7.c: Update expected error message wording.
2020-09-19 13:54:16 -07:00
Sandra Loosemore
a85e5696a3 Work around bootstrap failure in Fortran front end.
Switching the C++ front end to lower loops the same was as the C front
end triggered this error when bootstrapping the Fortran front end:

/path/to/gcc/fortran/interface.c:3546:12: error: '*new_arg' may be used uninitialized [-Werror=maybe-uninitialized]
 3546 |   new_arg[i]->next = NULL;
      |   ~~~~~~~~~^

Work around this by adding an assertion, which seems appropriate for
documentation and good coding practices anyway.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/fortran/
	* interface.c (gfc_compare_actual_formal): Add assertion after
	main processing loop to silence maybe-uninitialized error.
2020-09-19 13:54:16 -07:00
Sandra Loosemore
83e037364e Use C-style loop lowering instead of C++-style.
The C and C++ front ends used to use the same strategy of lowering
loops to gotos with the end test canonicalized to the bottom of the
loop.  In 2014 the C++ front end was changed to emit LOOP_EXPRs
instead (commit 1a45860e7757ee054f6bf98bee4ebe5c661dfb90).

As part of the unification of the C and C++ loop handling, it's
desirable to use the same lowering strategy for both languages.
Applying the C++ strategy to C caused a number of regressions in C
optimization tests, related to flipping the sense of the COND_EXPR for
the exit test and changes in block ordering in the output code.  Many
of these regressions just require updating regexps in the test cases
but a few appear to be genuine optimization failures.  Since it
appears the optimizers handle the C code better than C++ code, let's
go back to using the C strategy for both languages.  The rationale for
the 2014 C++ patch (support for constexpr evaluation) has been solved
in other ways meanwhile.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/c-family/
	* c-gimplify.c (genericize_c_loop): Rewrite to match
	c_finish_loop in c-typeck.c.
2020-09-19 13:54:16 -07:00
Sandra Loosemore
cba079f354 Move loop and switch tree data structures from cp/ to c-family/.
This patch moves the definitions for DO_STMT, FOR_STMT, WHILE_STMT,
SWITCH_STMT, BREAK_STMT, and CONTINUE_STMT from the C++ front end to
c-family.  This includes the genericizers, pretty-printers, and dump
support as well as the tree definitions and accessors.  Some related
code for OMP_FOR and similar OMP constructs is also moved.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/c-family/
	* c-common.c (c_block_may_fallthrough): New, split from
	cxx_block_may_fallthrough in the cp front end.
	(c_common_init_ts): Move handling of loop and switch-related
	statements here from the cp front end.
	* c-common.def (FOR_STMT, WHILE_STMT, DO_STMT): Move here from
	cp front end.
	(BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise.
	* c-common.h (c_block_may_fallthru): Declare.
	(bc_state_t): Move here from cp front end.
	(save_bc_state, restore_bc_state): Declare.
	(c_genericize_control_stmt): Declare.
	(WHILE_COND, WHILE_BODY): Likewise.
	(DO_COND, DO_BODY): Likewise.
	(FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise.
	(SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise.
	(SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise.
	(SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise.
	(LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise.
	* c-dump.c (dump_stmt): Copy from cp front end.
	(c_dump_tree): Move code to handle structured loop and switch
	tree nodes here from cp front end.
	* c-gimplify.c: Adjust includes.
	(enum bc_t, bc_label, begin_bc_block, finish_bc_block): Move from
	cp front end.
	(save_bc_state, restore_bc_state): New functions using old code
	from cp front end.
	(get_bc_label, expr_loc_or_loc): Move from cp front end.
	(genericize_c_loop): Move from cp front end.
	(genericize_for_stmt, genericize_while_stmt): Likewise.
	(genericize_do_stmt, genericize_switch_stmt): Likewise.
	(genericize_continue_stmt, genericize_break_stmt): Likewise.
	(genericize_omp_for_stmt): Likewise.
	(c_genericize_control_stmt): New function using code split from
	cp front end.
	(c_genericize_control_r): New.
	(c_genericize): Call walk_tree with c_genericize_control_r.
	* c-pretty-print.c (c_pretty_printer::statement): Move code to handle
	structured loop and switch tree nodes here from cp front end.

	gcc/cp/
	* cp-gimplify.c (enum bc_t, bc_label): Move to c-family.
	(begin_bc_block, finish_bc_block, get_bc_label): Likewise.
	(genericize_cp_loop): Likewise.
	(genericize_for_stmt, genericize_while_stmt): Likewise.
	(genericize_do_stmt, genericize_switch_stmt): Likewise.
	(genericize_continue_stmt, genericize_break_stmt): Likewise.
	(genericize_omp_for_stmt): Likewise.
	(cp_genericize_r): Call c_genericize_control_stmt instead of
	above functions directly.
	(cp_genericize): Call save_bc_state and restore_bc_state instead
	of manipulating bc_label directly.
	* cp-objcp-common.c (cxx_block_may_fallthru): Defer to
	c_block_may_fallthru instead of handling SWITCH_STMT here.
	(cp_common_init_ts): Move handling of loop and switch-related
	statements to c-family.
	* cp-tree.def (FOR_STMT, WHILE_STMT, DO_STMT): Move to c-family.
	(BREAK_STMT, CONTINUE_STMT, SWITCH_STMT): Likewise.
	* cp-tree.h (LABEL_DECL_BREAK, LABEL_DECL_CONTINUE): Likewise.
	(WHILE_COND, WHILE_BODY): Likewise.
	(DO_COND, DO_BODY): Likewise.
	(FOR_INIT_STMT, FOR_COND, FOR_EXPR, FOR_BODY, FOR_SCOPE): Likewise.
	(SWITCH_STMT_COND, SWITCH_STMT_BODY): Likewise.
	(SWITCH_STMT_TYPE, SWITCH_STMT_SCOPE): Likewise.
	(SWITCH_STMT_ALL_CASES_P, SWITCH_STMT_NO_BREAK_P): Likewise.
	* cxx-pretty-print.c (cxx_pretty_printer::statement): Move code
	to handle structured loop and switch tree nodes to c-family.
	* dump.c (cp_dump_tree): Likewise.

	gcc/
	* doc/generic.texi (Basic Statements): Document SWITCH_EXPR here,
	not SWITCH_STMT.
	(Statements for C and C++): Rename node to reflect what
	the introduction already says about sharing between C and C++
	front ends.  Copy-edit and correct documentation for structured
	loops and switch.
2020-09-19 13:54:16 -07:00
Harald Anlauf
f7d2d4be76 PR fortran/97036 - [F2018] Allow ELEMENTAL RECURSIVE procedure prefix
gcc/fortran/ChangeLog:

	* symbol.c (gfc_check_conflict): Allow ELEMENTAL RECURSIVE
	procedure prefix for -std=f2018.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr97036.f90: New test.
2020-09-19 20:46:38 +02:00
H.J. Lu
c66c004ad6 x86: Add a testcase for PR target/96861
Add a testcase to verify that -march=skylake-avx512 -mtune=skylake-avx512
generates desired code sequence.

	PR target/96861
	* gcc.target/i386/pr96861.c: New test.
2020-09-19 10:03:10 -07:00
Patrick Palka
e5d72c840a c++: Fix self-mapping in map_arguments [PR96531, PR97103]
With r10-8077 we stopped passing the argified current_template_parms to
normalize_constraint_expression from finish_nested_requirement, and
instead made map_arguments perform a self-mapping of parameters when
args is NULL.  But we're currently not handling parameter packs and
BOUND_TEMPLATE_TEMPLATE_PARMs properly during this self-mapping, which
leads to ICEs later during satisfaction.

To properly handle self-mapping of a parameter pack, this patch
extends template_parm_to_arg to handle TEMPLATE_PARM_P nodes, and
makes map_arguments use it.  (This change revealed that the call to
template_parm_to_arg in convert_generic_types_to_packs was a no-op
because the argument 't' is never a TREE_LIST, so this patch
additionally removes this call.)

As for bound ttps, map_arguments before r10-8077 would map a
BOUND_TEMPLATE_TEMPLATE_PARM not to itself but to its underlying
TEMPLATE_TEMPLATE_PARM.  We could restore this behavior in
map_arguments, but since a bound ttp is not really a template parameter
it seems better to make keep_template_parm not give us a bound ttp in
the first place.  So this patch makes keep_template_parm return the
underlying ttp when it sees a bound ttp.

gcc/cp/ChangeLog:

	PR c++/96531
	PR c++/97103
	* constraint.cc (map_arguments): Call template_parm_to_arg
	in the self-mapping case.
	(finish_shorthand_constraint): No need to build a TREE_LIST
	before calling template_parm_to_arg.
	* pt.c (template_parm_to_arg): Rewrite to handle TEMPLATE_PARM_P
	nodes as well as DECL_TEMPLATE_PARM_P nodes, and to make the
	overlying TREE_LIST node optional.
	(keep_template_parm): Don't record a BOUND_TEMPLATE_TEMPLATE_PARM,
	instead record its corresponding TEMPLATE_TEMPLATE_PARM.
	(convert_generic_types_to_packs): Don't call
	template_parm_to_arg.

gcc/testsuite/ChangeLog:

	PR c++/96531
	PR c++/97103
	* g++.dg/cpp2a/concepts-ttp2.C: New test.
	* g++.dg/cpp2a/concepts-variadic1.C: New test.
2020-09-19 11:17:46 -04:00
Patrick Palka
dea470d091 c++: std::is_constant_evaluated inside constraint [PR97051]
According to [expr.const]/14, the result of substitution into an atomic
constraint is manifestly constant-evaluated; this patch adjusts the call
to maybe_constant_value in satisfy_atom to that effect.

gcc/cp/ChangeLog:

	PR c++/97051
	* constraint.cc (satisfy_atom): Pass true as the
	manifestly_const_eval argument to maybe_constant_value.

gcc/testsuite/ChangeLog:

	PR c++/97051
	* g++.dg/cpp2a/is-constant-evaluated11.C: New test.
2020-09-19 11:17:41 -04:00
liuhongt
83858ba1db Increase rtx cost of sse_to_integer in skylake_cost.
As https://gcc.gnu.org/pipermail/gcc-patches/2019-August/528839.html
indicates, movement between SSE and gpr should be much expensive than
movement inside gpr(which is 2 as default).

gcc/ChangeLog

	PR target/96861
	* config/i386/x86-tune-costs.h (skylake_cost): increase rtx
	cost of sse_to_integer from 2 to 6.

gcc/testsuite

	* gcc.target/i386/pr95021-3.c: Add -mtune=generic.
2020-09-19 22:54:02 +08:00
GCC Administrator
239601c53b Daily bump. 2020-09-19 00:16:29 +00:00
Jakub Jelinek
4a5ff2b56b c++: Add testcase for already fixed PR97105
This has been fixed by the PR bootstrap/97118 fix.

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

	PR c++/97105
	* g++.dg/template/pr97105.C: New test.
2020-09-19 00:09:11 +02:00
David Malcolm
1df487a520 analyzer: fix warning_event::get_desc for global state changes
When experimenting the a new state_machine with global state I noticed
that the fallback handling in warning_event::get_desc assumes we have
per-value states, and ICEs on global states.  Fixed thusly.

gcc/analyzer/ChangeLog:
	* checker-path.cc (warning_event::get_desc): Handle global state
	changes.
2020-09-18 17:39:46 -04:00
David Malcolm
c89956cba9 analyzer: handle strdup and strndup
gcc/analyzer/ChangeLog:
	* sm-malloc.cc (malloc_state_machine::on_stmt): Handle strdup and
	strndup as being malloc-like allocators.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/strdup-1.c: New test.
	* gcc.dg/analyzer/strndup-1.c: New test.
2020-09-18 17:38:34 -04:00
Jason Merrill
e1a1808cd1 c++: Fix bootstrap failure. [PR97118]
gcc/cp/ChangeLog:

	PR bootstrap/97118
	* decl.c (complete_vars): Only call layout_var_decl if completing
	the type succeeded.
2020-09-18 15:35:26 -04:00