188829 Commits

Author SHA1 Message Date
Andrew Stubbs
6ca03ca35a amdgcn: Support LLVM 13 assembler syntax
The LLVM devs have changed the assembler architecture attribute names on both
CLI and in the ".amdgcn_target" directive, and changed the attribute syntax
inside the directive, without keeping any backwards compatibility. :-(

This patch improves our configure tests to detect what dialect to use, what
attributes are valid, and adjusts the specs to match.

gcc/ChangeLog:

	* config.in: Regenerate.
	* config/gcn/gcn-hsa.h (X_FIJI): New macro.
	(X_900): New macro.
	(X_906): New macro.
	(X_908): New macro.
	(A_FIJI): Rename to ...
	(S_FIJI): ... this.
	(A_900): Rename to ...
	(S_900): ... this.
	(A_906): Rename to ...
	(S_906): ... this.
	(A_908): Rename to ...
	(S_908): ... this.
	(SRAMOPT): New macro.
	(ASM_SPEC): Adjust xnack option usage.
	* config/gcn/gcn.c (output_file_start): Adjust amdgcn_target usage.
	* configure: Regenerate.
	* configure.ac: Detect LLVM assembler dialect.
2021-10-07 11:26:44 +01:00
Richard Biener
6496ae5c96 Properly parse invariant &MEM addresses in the GIMPLE FE
Currently the frontend rejects those addresses as not lvalues
because the C frontend doens't expect MEM_REF or TARGET_MEM_REF
to appear (but they would be valid lvalues there).  The following
fixes that by amending lvalue_p.

The change also makes the dumping of the source of the testcase
valid for the GIMPLE FE by not eliding the '&' when dumping
string literals.

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

gcc/c/
	* c-typeck.c (lvalue_p): Also allow MEM_REF and TARGET_MEM_REF.

gcc/
	* tree-pretty-print.c (dump_generic_node): Do not elide
	printing '&' when dumping with -gimple.

gcc/testsuite/
	* gcc.dg/gimplefe-47.c: New testcase.
2021-10-07 08:19:39 +02:00
GCC Administrator
57c7ec62ee Daily bump. 2021-10-07 00:16:24 +00:00
Jason Merrill
6aab794614 c++: One more spaceship test.
Jakub suggested adding a variant where we actually try to call the
implicitly deleted operator.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/spaceship-synth8a.C: New test.
2021-10-06 17:14:33 -04:00
H.J. Lu
929cb75e42 libsanitizer: Update LOCAL_PATCHES
* LOCAL_PATCHES: Update to the corresponding revision.
2021-10-06 13:11:34 -07:00
H.J. Lu
bb8adf080e libsanitizer: Apply local patches 2021-10-06 13:08:47 -07:00
H.J. Lu
2e3d50c095 libsanitizer: Merge with upstream
Merged revision: fdf4c035225de52f596899931b1f6100e5e3e928
2021-10-06 13:08:47 -07:00
Jonathan Wakely
881d1689a4 libstdc++: Implement std::move_only_function for C++23 (P0288R9)
libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/std/functional: Include <bits/move_only_function.h>.
	* include/std/version (__cpp_lib_move_only_function): Define.
	* include/bits/mofunc_impl.h: New file.
	* include/bits/move_only_function.h: New file.
	* testsuite/20_util/move_only_function/call.cc: New test.
	* testsuite/20_util/move_only_function/cons.cc: New test.
	* testsuite/20_util/move_only_function/move.cc: New test.
	* testsuite/20_util/move_only_function/version.cc: New test.
2021-10-06 20:12:01 +01:00
Andrew MacLeod
ad451b020a Add range intersect with 2 wide-ints.
Add a more efficent intersect using a lower/upper bound single pair of
wide_ints.

	* gimple-range-cache.cc (non_null_ref::adjust_range): Call new
	intersect routine.
	* gimple-range-fold.cc (adjust_pointer_diff_expr): Ditto.
	(adjust_imagpart_expr): Ditto.
	* value-range.cc (irange::irange_intersect): Call new routine if
	RHS is a single pair.
	(irange::intersect): New wide_int version.
	* value-range.h (class irange): New prototype.
2021-10-06 09:19:06 -04:00
Andrew MacLeod
3ca950c352 Introduce a param-switch-limit for EVRP.
Very large switches cause a lot of range calculations with multiple subranges
to happen.  This can cause quadratic or even exponetial time increases in
large testcases.  This patch introduces a param variable to limit
the size of switches EVRP will process.

	* gimple-range-edge.cc (gimple_outgoing_range::gimple_outgoing_range):
	Add parameter to limit size when recognizing switches.
	(gimple_outgoing_range::edge_range_p): Check size limit.
	* gimple-range-edge.h (gimple_outgoing_range): Add size field.
	* gimple-range-gori.cc (gori_map::calculate_gori): Ignore switches
	that exceed the size limit.
	(gori_compute::gori_compute): Add initializer.
	* params.opt (evrp-switch-limit): New.
	* doc/invoke.texi: Update docs.
2021-10-06 09:18:09 -04:00
Andrew MacLeod
e828f4b589 Use TYPE_MIN/MAX_VALUE in set_varying when possible.
We currently create new trees every time... which is very wasteful and time
consuming. Instead, just use the TYPE_MIN/MAX_VALUE.

	* value-range.h (irange::set_varying): Use TYPE_MIN_VALUE and
	TYPE_MAX_VALUE instead of creating new trees when possible.
2021-10-06 09:11:50 -04:00
Andrew MacLeod
4b8ca6c617 Ranger: More efficient zero/nonzero check.
A recent change introduced a frequent check for zero and non-zero which has
caused a lot of extra temporary trees to be created.  Make the check more
efficent as it is always a pointer and thus unsigned.

	* gimple-range-cache.cc (non_null_ref::adjust_range): Check for
	zero and non-zero more efficently.
2021-10-06 09:11:50 -04:00
Richard Biener
90c3a62272 More consistently dump GIMPLE FE consumable stmts
The following makes more stmts consumable with the GIMPLE FE
when dumping with -gimple.  In particular addresses in GIMPLE
operand position require wrapping with _Literal.

The TDF_ flag space is now exhausted and I've removed overlaps
and re-ordered things as to how it is supposed to work and
made it uint32_t and prepared the operator overloads for an
easy migration to uint64_t once required.

2021-10-05  Richard Biener  <rguenther@suse.de>

	PR c/102605
	* dumpfile.h (TDF_GIMPLE_VAL): New.
	(dump_flag): Re-order and adjust TDF_* flags.  Make
	the enum uint32_t.  Use std::underlying_type in the
	operator overloads.
	(optgroup_flag): Likewise for the operator overloads.
	* tree-pretty-print.c (dump_generic_node): Wrap ADDR_EXPR
	in _Literal if TDF_GIMPLE_VAL.
	* gimple-pretty-print.c (dump_gimple_assign): Add
	TDF_GIMPLE_VAL to flags when dumping operands where only
	is_gimple_val are allowed.
	(dump_gimple_cond): Likewise.
2021-10-06 12:02:14 +02:00
Jakub Jelinek
ba837323db openmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if possible
For the few long double types that do have padding bits, e.g. on x86
the clear_type_padding_in_mask computed mask is
ff ff ff ff ff ff ff ff ff ff 00 00 for 32-bit and
ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 for 64-bit.
Instead of doing __builtin_clear_padding on both operands that will clear the
last 2 or 6 bytes and then memcmp on the whole 12/16 bytes, we can just
memcmp 10 bytes.  The code also handles if the padding would be at the start
or both at the start and end, but everything on byte boundaries only and
non-padding bits being contiguous.
This works around a tree-ssa-dse.c bug (but we need to fix it anyway,
as libstdc++ won't do this and as it can deal with arbitrary types, it even
can't do that generally).

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

	PR tree-optimization/102571
	* c-omp.c (c_finish_omp_atomic): Optimize the case where type has
	padding, but the non-padding bits are contiguous set of bytes
	by adjusting the memcmp call arguments instead of emitting
	__builtin_clear_padding and then comparing all the type's bytes.
2021-10-06 10:40:12 +02:00
Jakub Jelinek
8892d532d6 c++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions [PR102612]
The following patch implements C++23 P2242R3 - Non-literal variables
(and labels and gotos) in constexpr functions.
I think it is mostly straightforward, don't diagnose certain
statements/declarations just because of their presence in
constexpr/consteval functions, but (except for the non-literal type
var declarations which ought to be caught by e.g. constructor or
destructor call during evaluation not being constexpr and for
labels which are now always allowed) diagnose it during constexpr
evaluation.

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

	PR c++/102612
gcc/c-family/
	* c-cppbuiltin.c (c_cpp_builtins): For -std=c++23 predefine
	__cpp_constexpr to 202110L rather than 201907L.
gcc/cp/
	* parser.c (cp_parser_jump_statement): Implement C++23 P2242R3.
	Allow goto expressions in constexpr function bodies for C++23.
	Adjust error message for older standards to mention it.
	* decl.c (start_decl): Allow static and thread_local declarations
	in constexpr function bodies for C++23.  Adjust error message for
	older standards to mention it.
	* constexpr.c (ensure_literal_type_for_constexpr_object): Allow
	declarations of variables with non-literal type in constexpr function
	bodies for C++23.  Adjust error message for older standards to mention
	it.
	(cxx_eval_constant_expression) <case DECL_EXPR>: Diagnose declarations
	of initialization of static or thread_local vars.
	(cxx_eval_constant_expression) <case GOTO_EXPR>: Diagnose goto
	statements for C++23.
	(potential_constant_expression_1) <case DECL_EXPR>: Swap the
	CP_DECL_THREAD_LOCAL_P and TREE_STATIC checks.
	(potential_constant_expression_1) <case LABEL_EXPR>: Allow labels for
	C++23.  Adjust error message for older standards to mention it.
gcc/testsuite/
	* g++.dg/cpp23/feat-cxx2b.C: Expect __cpp_constexpr 202110L rather
	than 201907L.
	* g++.dg/cpp23/constexpr-nonlit1.C: New test.
	* g++.dg/cpp23/constexpr-nonlit2.C: New test.
	* g++.dg/cpp23/constexpr-nonlit3.C: New test.
	* g++.dg/cpp23/constexpr-nonlit4.C: New test.
	* g++.dg/cpp23/constexpr-nonlit5.C: New test.
	* g++.dg/cpp23/constexpr-nonlit6.C: New test.
	* g++.dg/diagnostic/constexpr1.C: Only expect some diagnostics for
	c++20_down.
	* g++.dg/cpp1y/constexpr-label.C: Likewise.
	* g++.dg/cpp1y/constexpr-neg1.C: Likewise.
	* g++.dg/cpp2a/constexpr-try5.C: Likewise.  Adjust some expected
	wording.
	* g++.dg/cpp2a/constexpr-dtor3.C: Likewise.
	* g++.dg/cpp2a/consteval3.C: Likewise.  Add effective target c++20
	and remove dg-options.
2021-10-06 10:28:31 +02:00
Jakub Jelinek
f43eb7707c libcpp: Implement C++23 P2334R1 - #elifdef/#elifndef
This patch implements C++23 P2334R1, which is easy because Joseph has done
all the hard work for C2X already.
Unlike the C N2645 paper, the C++ P2334R1 contains one important addition
(but not in the normative text):
"While this is a new preprocessor feature and cannot be treated as a defect
report, implementations that support older versions of the standard are
encouraged to implement this feature in the older language modes as well
as C++23."
so there are different variants how to implement it.
One is ignoring that sentence and only implementing it
for -std=c++23/-std=gnu++23 like it is only implemented for -std=c2x.
Another option would be to implement it also in the older GNU modes but
not in the C/CXX modes (but it would be strange if we did that just for
C++ and not for C).
Yet another option is to enable it unconditionally.
And yet another option would be to enable it unconditionally but emit
a warning (or pedwarn) when it is seen.
Note, when it is enabled for the older language modes, as Joseph wrote
in the c11-elifdef-1.c testcase, it can result e.g. in rejecting previously
valid code:
 #define A
 #undef B
 #if 0
 #elifdef A
 #error "#elifdef A applied"
 #endif
 #if 0
 #elifndef B
 #error "#elifndef B applied"
 #endif
Note, seems clang went the enable it unconditionally in all standard
versions of both C and C++, no warnings or anything whatsoever, so
essentially treated it as a DR that changed behavior of e.g. the above code.
After feedback, this option enables #elifdef/#elifndef for -std=c2x
and -std=c++2{b,3} and enables it also for -std=gnu*, but for GNU modes
older than C2X or C++23 if -pedantic it emits a pedwarn on the directives
that either would be rejected in the corresponding -std=c* modes, e.g.
  #if 1
  #elifdef A // pedwarn if -pedantic
  #endif
or when the directives would be silently accepted, but when they are
recognized it changes behavior, so e.g.
  #define A
  #if 0
  #elifdef A // pedwarn if -pedantic
  #define M 1
  #endif
It won't pedwarn if the directives would be silently ignored and wouldn't
change anything, like:
  #define A
  #if 0
  #elifndef A
  #define M 1
  #endif
or
  #undef B
  #if 0
  #elifdef B
  #define M 1
  #endif

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

libcpp/
	* init.c (lang_defaults): Implement P2334R1, enable elifdef for
	-std=c++23 and -std=gnu++23.
	* directives.c (_cpp_handle_directive): Support elifdef/elifndef if
	either CPP_OPTION (pfile, elifdef) or !CPP_OPTION (pfile, std).
	(do_elif): For older non-std modes if pedantic pedwarn about
	#elifdef/#elifndef directives that change behavior.
gcc/testsuite/
	* gcc.dg/cpp/gnu11-elifdef-1.c: New test.
	* gcc.dg/cpp/gnu11-elifdef-2.c: New test.
	* gcc.dg/cpp/gnu11-elifdef-3.c: New test.
	* gcc.dg/cpp/gnu11-elifdef-4.c: New test.
	* g++.dg/cpp/elifdef-1.C: New test.
	* g++.dg/cpp/elifdef-2.C: New test.
	* g++.dg/cpp/elifdef-3.C: New test.
	* g++.dg/cpp/elifdef-4.C: New test.
	* g++.dg/cpp/elifdef-5.C: New test.
	* g++.dg/cpp/elifdef-6.C: New test.
	* g++.dg/cpp/elifdef-7.C: New test.
2021-10-06 10:13:51 +02:00
Tobias Burnus
ece8b0fce6 Fortran: Fix deprecate warning with parameter
Only warn with !GCC$ ATTRIBUTES DEPRECATED if
deprecated PARMETERS are actually used.

gcc/fortran/ChangeLog:

	* resolve.c (resolve_values): Only show
	deprecated warning if attr.referenced.

gcc/testsuite/ChangeLog:

	* gfortran.dg/attr_deprecated-2.f90: New test.
2021-10-06 08:47:40 +02:00
prathamesh.kulkarni
e76a7a8a80 [gimple-isel] Remove redundant if condition.
gcc/ChangeLog:
	* gimple-isel.cc (gimple_expand_vec_cond_expr): Remove redundant if
	condition.
2021-10-06 11:21:13 +05:30
Jakub Jelinek
09d886e671 c++: defaulted <=> with bitfields [PR102490]
The testcases in the patch are either miscompiled or ICE with checking,
because the defaulted operator== is synthesized too early (but only if
constexpr), when the corresponding class type is still incomplete type.  The
problem is that at that point the bitfield FIELD_DECLs still have as
TREE_TYPE their underlying type rather than integral type with their
precision and when layout_class_type is called for the class soon after
that, it changes those types but the COMPONENT_REFs type stay the way that
they were during the operator== synthesize_method type and the middle-end is
then upset by the mismatch of types.  As what exact type will be given isn't
just a one liner but quite long code especially for over-sized bitfields, I
think it is best to just not synthesize the comparison operators so early
and call defaulted_late_check for them once again as soon as the class is
complete.

This is also a problem for virtual operator<=>, where we need to compare the
noexcept-specifier to validate the override before the class is complete.
Rather than try to defer that comparison, maybe_instantiate_noexcept now
calls maybe_synthesize_method, which calls build_comparison_op in
non-defining mode if the class isn't complete yet.  In that situation we
also might not have base fields yet, so we look in the binfo for the bases.

Co-authored-by: Jason Merrill <jason@redhat.com>

2021-10-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98712
	PR c++/102490
	* cp-tree.h (maybe_synthesize_method): Declare.
	* method.c (genericize_spaceship): Use
	LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
	LOOKUP_NORMAL for flags.
	(comp_info): Remove defining member.  Add complain, code, retcat.
	(comp_info::comp_info): Adjust.
	(do_one_comp): Split out from build_comparison_op.   Use
	LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
	LOOKUP_NORMAL for flags.
	(build_comparison_op): Add defining argument. Adjust comp_info
	construction.  Use defining instead of info.defining.  Assert that
	if defining, ctype is a complete type.  Walk base binfos.
	(synthesize_method, maybe_explain_implicit_delete,
	explain_implicit_non_constexpr): Adjust build_comparison_op callers.
	(maybe_synthesize_method): New function.
	* class.c (check_bases_and_members): Don't call defaulted_late_check
	for sfk_comparison.
	(finish_struct_1): Call it here instead after class has been
	completed.
	* pt.c (maybe_instantiate_noexcept): Call maybe_synthesize_method
	instead of synthesize_method.

	* g++.dg/cpp2a/spaceship-synth8.C (std::strong_ordering): Provide
	more complete definition.
	(std::strong_ordering::less, std::strong_ordering::equal,
	std::strong_ordering::greater): Define.
	* g++.dg/cpp2a/spaceship-synth12.C: New test.
	* g++.dg/cpp2a/spaceship-synth13.C: New test.
	* g++.dg/cpp2a/spaceship-synth14.C: New test.
	* g++.dg/cpp2a/spaceship-eq11.C: New test.
	* g++.dg/cpp2a/spaceship-eq12.C: New test.
	* g++.dg/cpp2a/spaceship-eq13.C: New test.
2021-10-05 22:41:00 -04:00
GCC Administrator
bb6194e0b4 Daily bump. 2021-10-06 00:16:30 +00:00
qing zhao
433516e1c6 Not add initialization for variables been initialized by FEs [PR102359]
C++ FE creates proxy variables, which have associated DECL_VALUE_EXPR
and have been initialized by FE. For such auto variable, we should not
add initialization when -ftrivial-auto-var-init presents.

	PR middle-end/102359

gcc/ChangeLog:

2021-10-05  qing zhao  <qing.zhao@oracle.com>

	* gimplify.c (gimplify_decl_expr): Not add initialization for an
	auto variable when it has been initialized by frontend.

gcc/testsuite/ChangeLog:

2021-10-05  qing zhao  <qing.zhao@oracle.com>

	* g++.dg/pr102359_1.C: New test.
	* g++.dg/pr102359_2.C: New test.
2021-10-05 16:14:00 -07:00
Than McIntosh
ab67380fe6 compiler: workaround for C++ build template matching quirk
Tweak a couple of places in the types code to use nullptr instead of
NULL to work around a template matching quirk when using certain build
compilers.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/354151
2021-10-05 15:06:19 -07:00
Jakub Jelinek
737f95bab5 c++: Fix apply_identity_attributes [PR102548]
The following testcase ICEs on x86_64-linux with -m32 due to a bug in
apply_identity_attributes.  The function is being smart and attempts not
to duplicate the chain unnecessarily, if either there are no attributes
that affect type identity or there is possibly empty set of attributes
that do not affect type identity in the chain followed by attributes
that do affect type identity, it reuses that attribute chain.

The function mishandles the cases where in the chain an attribute affects
type identity and is followed by one or more attributes that don't
affect type identity (and then perhaps some further ones that do).

There are two bugs.  One is that when we notice first attribute that
doesn't affect type identity after first attribute that does affect type
identity (with perhaps some further such attributes in the chain after it),
we want to put into the new chain just attributes starting from
(inclusive) first_ident and up to (exclusive) the current attribute a,
but the code puts into the chain all attributes starting with first_ident,
including the ones that do not affect type identity and if e.g. we have
doesn't0 affects1 doesn't2 affects3 affects4 sequence of attributes, the
resulting sequence would have
affects1 doesn't2 affects3 affects4 affects3 affects4
attributes, i.e. one attribute that shouldn't be there and two attributes
duplicated.  That is fixed by the a2 -> a2 != a change.

The second one is that we ICE once we see second attribute that doesn't
affect type identity after an attribute that affects it.  That is because
first_ident is set to error_mark_node after handling the first attribute
that doesn't affect type identity (i.e. after we've copied the
[first_ident, a) set of attributes to the new chain) to denote that from
that time on, each attribute that affects type identity should be copied
whenever it is seen (the if (as && as->affects_type_identity) code does
that correctly).  But that condition is false and first_ident is
error_mark_node, we enter else if (first_ident) and use TREE_PURPOSE
/TREE_VALUE/TREE_CHAIN on error_mark_node, which ICEs.  When
first_ident is error_mark_node and a doesn't affect type identity,
we want to do nothing.  So that is the && first_ident != error_mark_node
chunk.

2021-10-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/102548
	* tree.c (apply_identity_attributes): Fix handling of the
	case where an attribute in the list doesn't affect type
	identity but some attribute before it does.

	* g++.target/i386/pr102548.C: New test.
2021-10-05 22:28:38 +02:00
Iain Sandoe
e24760533b Darwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.
This fixes a bootstrap fail because saw_static_libcxx was unused for
targets without support for -Bstatic/dynamic.

The fix applied pushes the -static-libstdc++ back onto the command
line, which allows a target to substitute a static version of the
c++ standard library using specs.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/d/ChangeLog:

	* d-spec.cc (lang_specific_driver): Push the -static-libstdc++
	option back onto the command line for targets without support
	for -Bstatic/dynamic.
2021-10-05 20:54:51 +01:00
Patrick Palka
d4c470c376 c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]
Here during partial ordering of the two partial specializations we end
up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly
thereafter because uses_template_parms(parms) calls potential_const_expr
which doesn't handle NONTYPE_ARGUMENT_PACK.

This patch fixes this by extending potential_constant_expression to handle
NONTYPE_ARGUMENT_PACK appropriately.

	PR c++/102547

gcc/cp/ChangeLog:

	* constexpr.c (potential_constant_expression_1): Handle
	NONTYPE_ARGUMENT_PACK.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/variadic-partial2.C: New test.
	* g++.dg/cpp0x/variadic-partial2a.C: New test.
2021-10-05 15:35:21 -04:00
Aldy Hernandez
ec0124e0ac Loosen loop crossing restriction in threader.
Crossing loops is generally discouraged from the threader, but we can
make an exception when we don't cross the latch or enter another loop,
since this is just an early exit out of the loop.

In fact, the whole threaded path is logically outside the loop.  This
has nice secondary effects.  For example, objects on the threaded path
will no longer necessarily be live throughout the loop, so we can get
register allocation improvements.  The threaded path can physically
move outside the loop resulting in better icache efficiency, etc.

Tested on x86-64 Linux, and on a visium-elf cross making sure that the
following tests do not have an abort in the final assembly:

gcc.c-torture/execute/960218-1.c
gcc.c-torture/execute/visium-pending-4.c
gcc.c-torture/execute/pr58209.c

gcc/ChangeLog:

	* tree-ssa-threadupdate.c (jt_path_registry::cancel_invalid_paths):
	Loosen restrictions

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/ssa-thread-valid.c: New test.
2021-10-05 18:24:30 +02:00
Jonathan Wakely
1f51e9af7b libstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)
The recently approved P2251R1 paper requires these types to be trivially
copyable. They always have been in libstdc++, but add tests to check it.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string_view/requirements/trivially_copyable.cc:
	New test.
	* testsuite/23_containers/span/trivially_copyable.cc: New test.
2021-10-05 16:47:30 +01:00
Jan-Benedict Glaw
370374c4d9 Mark argument as unused
The `loc` argument may or may not be used, depending on some #ifdefs.
Mark it as ATTRIBUTE_UNUSED, though it might be worth polishing the
whole target hook to not depend on the #ifdef'ed code at all.

gcc/ChangeLog:

	* common/config/avr/avr-common.c (avr_handle_option): Mark
	argument as ATTRIBUTE_UNUSED.
2021-10-05 17:20:05 +02:00
Jeff Law
f9e6f20f28 Fix s390 test to have pointer type for computed goto
gcc/testsuite
	* gcc.target/s390/pr80725.c: Ensure computed goto is used on
	a pointer type.
2021-10-05 11:15:02 -04:00
Jan-Benedict Glaw
5b4bf54a00 Fix redefinition warning
gcc/ChangeLog:

	* config/lm32/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC):
	Undefine before redefinition.
2021-10-05 17:08:23 +02:00
Jonathan Wakely
6da36b7d0e libstdc++: Simplify constraints for std::any construction
libstdc++-v3/ChangeLog:

	* include/bits/utility.h (__is_in_place_type_v): Define
	variable template to detect in_place_type_t specializations.
	(__is_in_place_type): Replace class template with alias
	template using __is_in_place_type_v.
	* include/std/any (any(T&&)): Check __is_in_place_type first and
	avoid instantiating is_copy_constructible unnecessarily.
2021-10-05 15:56:56 +01:00
Jonathan Wakely
824e085573 libstdc++: Add test for std::cmp_greater
This was omitted from the commit that added these comparisons.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/integer_comparisons/greater.cc: New test.
2021-10-05 15:56:55 +01:00
Jonathan Wakely
313193edfc libstdc++: Improve test for printing volatile pointers
libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc:
	Check result matches non-volatile pointer.
2021-10-05 15:56:55 +01:00
Richard Biener
d4f6dbe183 Allow more kinds of invariant addresses in GIMPLE FE
The gimple FE is too restrictive in what it accepts as
literals, the following makes it also accept &a[10] for example.

2021-10-05  Richard Biener  <rguenther@suse.de>

	PR c/102605
gcc/c/
	* gimple-parser.c (c_parser_gimple_postfix_expression):
	Accept more address _Literals.

gcc/testsuite/
	* gcc.dg/gimplefe-46.c: New testcase.
2021-10-05 16:37:39 +02:00
Patrick Palka
f3930418cb c++: templated static local var has value-dep addr [PR98930]
Here uses_template_parms returns false for the dependent type A<&impl::i>,
which causes tsubst_aggr_type to think it's non-dependent and not bother
substituting into it, leading to breakage.

This patch fixes this by making has_value_dependent_address also return
true for templated static local variables.

	PR c++/98930

gcc/cp/ChangeLog:

	* pt.c (has_value_dependent_address): Return true for a static
	local variable from a function template.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/nontype4.C: New test.
	* g++.dg/cpp1z/nontype4a.C: New test.
2021-10-05 09:50:02 -04:00
Tobias Burnus
7f4192dd3d gfortran.dg/gomp/pr43711.f90: Change dg-* for XFAIL->PASS
gcc/testsuite/
	* gfortran.dg/gomp/pr43711.f90: Add dg-error + dg-prune-output,
	remove dg-excess-errors to change XFAIL to PASS.
2021-10-05 14:28:10 +02:00
Richard Biener
9856132b5b Make flow of option processing more readily visible
This moves calls to various option processing stages to one place,
toplev::main.

2021-10-05  Richard Biener  <rguenther@suse.de>

	* toplev.c (no_backend): Remove global var.
	(process_options): Pass in no_backend, move post_options
	langhook call to toplev::main.
	(do_compile): Pass in no_backend, move process_options call
	to toplev::main.
	(toplev::run_self_tests): Check no_backend at the caller.
	(toplev::main): Call post_options and process_options
	split out from do_compile, do self-tests only if
	no_backend is initialized.
2021-10-05 13:34:43 +02:00
Richard Biener
eded910509 Amend function names with UID when dumping with TDF_UID
The following makes sure to amend more function names with the
associated DECL_UID when dumping with TDF_UID, in particular
function names printed as part of calls and in the function header.
That allows one to more easily follow the call flow of PR102528
where coroutines cause three clones of the name 'test2' that are
not distinguishable otherwise.

2021-10-05  Richard Biener  <rguenther@suse.de>

	* tree-cfg.c (dump_function_to_file): Dump the UID of the
	function as part of the name when requested.
	* tree-pretty-print.c (dump_function_name): Dump the UID when
	requested and the langhook produced the actual name.
2021-10-05 12:35:40 +02:00
Richard Biener
604459a095 More .DEFERRED_INIT expansion rework
This avoids looking at the type size and instead uses the size
as passed to .DEFERRED_INIT to determine the size of the non-MEM
to be initialized.  It also arranges for possibly poly-int
inits to always use zero-initialization rather than not initializing
and when we need to pun puns the LHS instead of the constant value.

That correctly initializes the variable-size typed array in the
testcase for PR102285 and the SVE vector in PR102587 where for
the testcase I needed to add a SVE capable -march as to not
ICE later.

2021-10-05  Richard Biener  <rguenther@suse.de>

	PR middle-end/102587
	PR middle-end/102285
	* internal-fn.c (expand_DEFERRED_INIT): Fall back to
	zero-initialization as last resort, use the constant
	size as given by the DEFERRED_INIT argument to build
	the initializer.

	* gcc.target/aarch64/sve/pr102587-1.c: Add -march=armv8.3-a+sve.
	* gcc.target/aarch64/sve/pr102587-2.c: Likewise.
2021-10-05 10:36:11 +02:00
Jonathan Wakely
7646847df7 libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]
libstdc++-v3/ChangeLog:

	PR c++/102535
	* testsuite/20_util/is_trivially_constructible/value.cc: Adjust
	expected value for C++20.
2021-10-05 09:35:47 +01:00
Jonathan Wakely
9665c2e768 libstdc++: Add noexcept to some std::function internals
libstdc++-v3/ChangeLog:

	* include/bits/std_function.h (_Any_data::_M_access): Add
	noexcept.
	(_Function_base::_Base_manager::_M_get_pointer): Likewise.
	(_Function_base::_Base_manager::_M_not_empty_function):
	Likewise.
2021-10-05 09:35:47 +01:00
Jonathan Wakely
96955a82f0 libstdc++: Support printing volatile pointers (P1147R1)
To avoid needing to export a new symbol from the library (for now) the
new member function uses __attribute__((always_inline)).

libstdc++-v3/ChangeLog:

	* include/std/ostream (operator<<(const volatile void*)):
	Add new overload, as per P1147R1.
	* testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc:
	New test.
2021-10-05 09:35:47 +01:00
Jonathan Wakely
9e136807c5 libstdc++: Update __cpp_lib_adaptor_iterator_pair_constructor value
I started implementing this feature before it was voted into the C++ WP,
and forgot to update the feature test macro after it was approved.

This defines it to the correct value, as specified in the C++23 draft.

libstdc++-v3/ChangeLog:

	* include/bits/stl_queue.h
	(__cpp_lib_adaptor_iterator_pair_constructor): Set to correct
	value.
	* include/bits/stl_stack.h
	(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
	* include/std/version
	(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
	* testsuite/23_containers/queue/cons_from_iters.cc: Update
	expected value.
	* testsuite/23_containers/stack/cons_from_iters.cc: Likewise.
2021-10-05 09:35:46 +01:00
Eric Botcazou
bbdf2d3967 [Ada] Plug small loophole with boolean values
gcc/ada/

	* gcc-interface/trans.c (gnat_to_gnu): Do not wrap boolean values
	referenced in pragmas.
2021-10-05 08:20:08 +00:00
Eric Botcazou
eae33329ea [Ada] Do not unconditionally inline expression functions with -gnatd.8
gcc/ada/

	* gcc-interface/trans.c (Subprogram_Body_to_gnu): Do not set the
	DECL_DISREGARD_INLINE_LIMITS flag if -gnatd.8 is specified.
2021-10-05 08:20:08 +00:00
Bob Duff
650ad524d8 [Ada] Fix latent bug in set_end_locus_from_node
gcc/ada/

	* gcc-interface/trans.c (set_end_locus_from_node): Check that
	Handled_Statement_Sequence is not Empty before calling
	End_Label, because the Empty node has no End_Label, and
	depending on the exact node layout chosen by gen_il, calling
	End_Label might crash, or might work OK by accident.
2021-10-05 08:20:08 +00:00
Eric Botcazou
07ad659daf [Ada] Minor include directives placement adjustment
gcc/ada/

	* gcc-interface/cuintp.c: Adjust placement of include directive.
	* gcc-interface/targtyps.c: Likewise.
2021-10-05 08:20:07 +00:00
Alexandre Oliva
a23e02091e [Ada] introduce stack scrub (strub) feature
gcc/ada/

	* doc/gnat_rm.rst: Add...
	* doc/gnat_rm/security_hardening_features.rst: New.
	* doc/gnat_rm/about_this_guide.rst: Link to new chapter.
	* gnat_rm.texi: Regenerate.
	* gcc-interface/utils.c (handle_strub_attribute): New.
	(gnat_internal_attribute_table): Add strub.
	* libgnat/a-except.adb: Make Rcheck_CE_* strub-callable.
	* libgnat/a-except.ads (Raise_Exception): Likewise.
	(Raise_Exception_Always): Likewise.
	* libgnat/s-arit128.ads (Multiply_With_Ovflo_Check128):
	Likewise.
	* libgnat/s-arit64.ads (Multiply_With_Ovflo_Check64):
	Likewise.
	* libgnat/s-secsta.ads (SS_Allocate, SS_Mark, SS_Release):
	Likewise.
2021-10-05 08:20:07 +00:00
Eric Botcazou
b1657ff3a0 [Ada] Mark private component renaming as coming from source
gcc/ada/

	* exp_ch9.adb (Install_Private_Data_Declarations): Copy the Sloc of
	components for the local renamings as well as the Comes_From_Source
	flag, and also set Warnings_Off on them.  Use Nam local variable.
2021-10-05 08:20:07 +00:00
Arnaud Charlet
3a0302e07c [Ada] Add comments in Ada.Task_Initialization
gcc/ada/

	* libgnarl/a-tasini.ads (Set_Initialization_Handler): Update
	comments.
2021-10-05 08:20:06 +00:00