Commit Graph

190106 Commits

Author SHA1 Message Date
Iain Buclaw 185b307b03 darwin, d: Support outfile substitution for libphobos
In the gdc driver, this takes the previous fix for the Darwin D
bootstrap, and extends it to the -static-libphobos option as well.
Rather than pushing the -static-libphobos option back onto the command
line, the setting of SKIPOPT is instead conditionally removed.  The same
change has been repeated for -static-libstdc++ so there is now no need
to call generate_option to re-add it.

In the gcc driver, -static-libphobos has been added as a common option,
validated, and a new outfile substition added to config/darwin.h to
correctly replace -lgphobos with libgphobos.a.

gcc/ChangeLog:

	* common.opt (static-libphobos): Add option.
	* config/darwin.h (LINK_SPEC): Substitute -lgphobos with libgphobos.a
	when linking statically.
	* gcc.c (driver_handle_option): Set -static-libphobos as always valid.

gcc/d/ChangeLog:

	* d-spec.cc (lang_specific_driver): Set SKIPOPT on -static-libstdc++
	and -static-libphobos only when target supports LD_STATIC_DYNAMIC.
	Remove generate_option to re-add -static-libstdc++.

libphobos/ChangeLog:

	* testsuite/testsuite_flags.in: Add libphobos library directory as
	search path to --gdcldflags.
2021-12-01 19:49:44 +01:00
Jason Merrill 53caa4723d c++: constexpr, fold, weak redecl, fp/0 [PR103310]
For PR61825, honza changed tree_single_nonzero_warnv_p to prevent a later
declaration from marking a function as weak after we've determined that it
wasn't weak before.  But we shouldn't do that for speculative folding; we
should only do it when we actually need a constant value.  In C++, such a
context is called "manifestly constant-evaluated".  In fold, this seems to
correspond to the folding_initializer flag, since in C this situation only
occurs in static initializers.

This change makes nonzero-1.c well-formed; I've added a nonzero-1a.c to
verify that we delete the null check eventually if there is no weak
redeclaration.

The varasm.c change is so that if we do get the weak redeclaration error, we
get it at the position of the weak declaration rather than the previous
declaration.

Using the FOLD_INIT paths also affects floating point arithmetic: notably,
this makes floating point division by zero in a manifestly
constant-evaluated context constant, as in a C static initializer.  I've had
some success convincing CWG that this is the right direction; C++ should
follow C's floating point semantics more than we have been doing, and Joseph
says that the C policy is that Annex F overrides other parts of the standard
that say that some operations are undefined.  But since we're in stage 3,
I'm only making this change with the new flag -fconstexpr-fp-except.  It may
turn on by default in a future release.

I think this distinction is only relevant for binary operations; arithmetic
for the floating point case, comparison for possibly non-zero addresses.

	PR c++/103310

gcc/ChangeLog:

	* fold-const.c (maybe_nonzero_address): Use get_create or get
	depending on folding_initializer.
	(fold_binary_initializer_loc): New.
	* fold-const.h (fold_binary_initializer_loc): Declare.
	* varasm.c (mark_weak): Don't use the decl location.
	* doc/invoke.texi: Document -fconstexpr-fp-except.

gcc/c-family/ChangeLog:

	* c.opt: Add -fconstexpr-fp-except.

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_binary_expression): Use
	fold_binary_initializer_loc if manifestly cxeval.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-fp-except1.C: New test.
	* g++.dg/cpp1z/constexpr-if36.C: New test.
	* gcc.dg/tree-ssa/nonzero-1.c: Now well-formed.
	* gcc.dg/tree-ssa/nonzero-1a.c: New test.
2021-12-01 13:24:36 -05:00
Bill Schmidt d683a1b3e8 rs6000: Mirror fix for PR102347 in new builtins support
Recently Kewen fixed a problem in the old builtins support where
rs6000_builtin_decl prematurely indicated that a target builtin is
unavailable.  This also needs to be done for the new builtins support, but in
this case we have to ensure the error message is still produced from the
overload support in rs6000-c.c.  Unfortunately, this is less straightforward
than it could be, because header file includes need to be adjusted to make this
happen.  Someday we'll consolidate all the builtin code in one file and this
won't have to be so ugly.

2021-12-01  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	PR target/102347
	* config/rs6000/rs6000-c.c (rs6000-builtins.h): Stop including.
	(rs6000-internal.h): Include.
	(altivec_resolve_new_overloaded_builtin): Move call to
	rs6000_invalid_new_builtin here from rs6000_new_builtin_decl.
	* config/rs6000/rs6000-call.c (rs6000-builtins.h): Stop including.
	(rs6000_invalid_new_builtin): Remove static qualifier.
	(rs6000_new_builtin_decl): Remove test for supported builtin.
	* config/rs6000/rs6000-internal.h (rs6000-builtins.h): Include.
	(rs6000_invalid_new_builtin): Declare.
	* config/rs6000/rs6000.c (rs6000-builtins.h): Don't include.
2021-12-01 12:17:22 -06:00
Aldy Hernandez 54ebec35ab path solver: Use only one ssa_global_cache.
We're using a temporary range cache while computing ranges for PHIs to
make sure the real cache doesn't get set until all PHIs are computed.
With the ltrans beast in LTO mode this causes undue overhead.

Since we already have a bitmap to indicate whether there's a cache
entry, we can avoid the extra cache object by clearing it while PHIs
are being calculated.

gcc/ChangeLog:

	PR tree-optimization/103409
	* gimple-range-path.cc (path_range_query::compute_ranges_in_phis):
	Do all the work with just one ssa_global_cache.
	* gimple-range-path.h: Remove m_tmp_phi_cache.
2021-12-01 17:11:12 +01:00
Jonathan Wakely 056551414a libstdc++: Clear RB tree after moving elements [PR103501]
If the allocator-extended move constructor move-constructs each element
into the new container, the contents of the old container are left in
moved-from states. We cannot know if those states preserve the
container's ordering and uniqueness guarantees, so just erase all
moved-from elements.

libstdc++-v3/ChangeLog:

	PR libstdc++/103501
	* include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&, false_type)):
	Clear container if elements have been moved-from.
	* testsuite/23_containers/map/allocator/move_cons.cc: Expect
	moved-from container to be empty.
	* testsuite/23_containers/multimap/allocator/move_cons.cc:
	Likewise.
	* testsuite/23_containers/multiset/allocator/103501.cc: New test.
	* testsuite/23_containers/set/allocator/103501.cc: New test.
2021-12-01 15:00:33 +00:00
Jonathan Wakely 74d14778e7 libstdc++: Define std::__is_constant_evaluated() for internal use
This adds std::__is_constant_evaluated() as a C++11 wrapper for
__builtin_is_constant_evaluated, but just returning false if the
built-in isn't supported by the compiler. This allows us to use it
throughout the library without checking __has_builtin every time.

Some uses in std::vector and std::string can only be constexpr when the
std::is_constant_evaluated() function actually works, so we might as
well guard them with a relevant macro and call that function directly,
rather than the built-in or std::__is_constant_evaluated().

The remaining checks of the __cpp_lib_is_constant_evaluated macro could
now be replaced by checking __cplusplus >= 202002 instead, but there's
no practical difference. We still need some kind of preprocessor check
there anyway.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Change macro name.
	* include/bits/allocator.h (allocate, deallocate): Use
	std::__is_constant_evaluated() unconditionally, instead of
	checking whether std::is_constant_evaluated() (or the built-in)
	can be used.
	* include/bits/basic_string.h: Check new macro. call
	std::is_constant_evaluated() directly in C++20-only code that is
	guarded by a suitable macro.
	* include/bits/basic_string.tcc: Likewise.
	* include/bits/c++config (__is_constant_evaluated): Define.
	(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Replace with ...
	(_GLIBCXX_HAVE_IS_CONSTANT_EVALUATED): New macro.
	* include/bits/char_traits.h (char_traits): Replace conditional
	calls to std::is_constant_evaluated with unconditional calls to
	std::__is_constant_evaluated.
	* include/bits/cow_string.h: Use new macro.
	* include/bits/ranges_algobase.h (__copy_or_move): Replace
	conditional calls to std::is_constant_evaluated with unconditional
	calls to std::__is_constant_evaluated.
	(__copy_or_move_backward, __fill_n_fn): Likewise.
	* include/bits/ranges_cmp.h (ranges::less): Likewise.
	* include/bits/stl_algobase.h (lexicographical_compare_three_way):
	Likewise.
	* include/bits/stl_bvector.h: Call std::is_constant_evaluated
	directly in C++20-only code that is guarded by a suitable macro.
	* include/bits/stl_construct.h (_Construct, _Destroy, _Destroy_n):
	Replace is_constant_evaluated with __is_constant_evaluated.
	* include/bits/stl_function.h (greater, less, greater_equal)
	(less_equal): Replace __builtin_is_constant_evaluated and
	__builtin_constant_p with __is_constant_evaluated.
	* include/bits/stl_vector.h: Call std::is_constant_evaluated()
	in C++20-only code.
	* include/debug/helper_functions.h (__check_singular): Use
	__is_constant_evaluated instead of built-in, or remove check
	entirely.
	* include/std/array (operator<=>): Use __is_constant_evaluated
	unconditionally.
	* include/std/bit (__bit_ceil): Likewise.
	* include/std/type_traits (is_constant_evaluated): Define using
	'if consteval' if possible.
	* include/std/version: Use new macro.
	* libsupc++/compare: Use __is_constant_evaluated instead of
	__builtin_is_constant_evaluated.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error lines.
2021-12-01 15:00:33 +00:00
Jonathan Wakely 2b83bc6097 libstdc++: Optimize ref-count updates in COW std::string
Most ref-count updates in the COW string are done via the functions in
<ext/atomicity.h>, which will use non-atomic ops when the program is
known to be single-threaded. The _M_is_leaked() and _M_is_shared()
functions use __atomic_load_n directly, because <ext/atomicity.h>
doesn't provide a load operation. Those functions can check the
__is_single_threaded() predicate to avoid using __atomic_load_n when not
needed.

The move constructor for the fully-dynamic-string increments the
ref-count by either 2 or 1, for leaked or non-leaked strings
respectively. That can be changed to use a non-atomic store of 1 for all
non-shared strings. It can be non-atomic because even if the program is
multi-threaded, conflicting access to the rvalue object while it's being
moved from would be data race anyway. It can store 1 directly for all
non-shared strings because it doesn't matter whether the initial
refcount was -1 or 0, it should be 1 after the move constructor creates
a second owner.

libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h (basic_string::_M_is_leaked): Use
	non-atomic load when __is_single_threaded() is true.
	(basic_string::_M_is_shared): Likewise.
	(basic_string::(basic_string&&)) [_GLIBCXX_FULLY_DYNAMIC_STRING]:
	Use non-atomic store when rvalue is not shared.
2021-12-01 15:00:33 +00:00
Jonathan Wakely e9089e4fa9 libstdc++: Avoid unwanted allocations in filesystem::path
When using COW strings, accessing _M_pathname[0] and similar non-const
accessors can cause the string to "leak", meaning it reallocates itself
if it shares ownership with another string object.

This causes test failures for --enable-fully-dynamic-string builds:
/home/jwakely/src/gcc/libstdc++-v3/testsuite/experimental/filesystem/path/construct/90634.cc:62: void test01(): Assertion 'bytes_allocated == 0' failed.
FAIL: experimental/filesystem/path/construct/90634.cc execution test

This FAIL happens because the fully-dynamic move constructor results in
shared ownership, so for path(std::move(std::string("foo"))) the
_M_pathname member shares ownership with the temporary, and the
non-const accesses in _M_split_cmpts() cause a new copy of the string to
be allocated. This un-sharing is wasteful, and entirely unnecessary when
sharing ownership with an rvalue that is about to release its ownership
anyway. Even for lvalues, sharing ownership is not a problem and
reallocating a unique copy of the string is wasteful.

This removes non-const accesses of _M_pathname in the
path::_M_split_cmpts() members.

libstdc++-v3/ChangeLog:

	* src/c++17/fs_path.cc (path::_M_split_cmpts()): Remove
	micro-optimization for "/" path.
	* src/filesystem/path.cc (path::_M_split_cmpts()): Only access
	the contents of _M_pathname using const member functions.
2021-12-01 15:00:32 +00:00
Richard Sandiford 1e625a44f6 vect: Tighten check for SLP memory groups [PR103517]
When checking for compatible stmts, vect_build_slp_tree_1 did:

	       && !(STMT_VINFO_GROUPED_ACCESS (stmt_info)
		    && (first_stmt_code == ARRAY_REF
			|| first_stmt_code == BIT_FIELD_REF
			|| first_stmt_code == INDIRECT_REF
			|| first_stmt_code == COMPONENT_REF
			|| first_stmt_code == MEM_REF)))

That is, it allowed any rhs_code as long as the first_stmt_code
looked valid.  This had the effect of allowing IFN_MASK_LOAD
to be paired with an earlier non-call code (but didn't allow
the reverse).

This patch makes the check symmetrical.

gcc/
	PR tree-optimization/103517
	* tree-vect-slp.c (vect_build_slp_tree_1): When allowing two
	different component references, check the codes of both them,
	rather than just the first.

gcc/testsuite/
	PR tree-optimization/103517
	* gcc.dg/vect/pr103517.c: New test.
2021-12-01 14:36:24 +00:00
Andrew MacLeod cb137e8572 Also pre-process PHIs in range-of-stmt.
PR tree-optimization/103464
	* gimple-range.cc (gimple_ranger::prefill_name): Process phis also.
	(gimple_ranger::prefill_stmt_dependencies): Ditto.
2021-12-01 09:10:41 -05:00
Alex Coplan a7fede6704 testsuite: Fix typo in comment in aapcs64 test
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/aapcs64/macro-def.h (PTR): Fix typo in
	comment.
2021-12-01 13:59:32 +00:00
Iain Buclaw d376b73aa1 doc, d: Add note that D front end now requires GDC installed in order to bootstrap.
gcc/ChangeLog:

	* doc/install.texi (Prerequisites): Add note that D front end now
	requires GDC installed in order to bootstrap.
	(Building): Add D compiler section, referencing prerequisites.
2021-12-01 11:56:37 +01:00
Iain Buclaw 47fe7be66e d: Update documentation of new D language options.
Adds documentation for the following:

    - New switch that controls what code is generated on a contract
      failure (throw or abort).
    - New switch that controls mangling of D types in `extern(C++)`
      code, as well as setting the compile-time value of
      `__traits(getTargetInfo "cppStd")`
    - New switches that generate C++ headers from D source files.
    - New switch to save expanded mixins to a file.
    - New switches that now distinguish between D language changes that
      are either (a) an experimental feature or an upcoming breaking
      change, (b) a warning or help on an upcoming change, or (c) revert
      of a change for users who don't want to deal with the breaking
      change for now.

gcc/d/ChangeLog:

	* gdc.texi (Runtime Options): Document -fcheckaction=, -fextern-std=,
	-fpreview=, -frevert=.
	(Code Generation): Document -fdump-c++-spec=, -fdump-c++-spec-verbose,
	-fsave-mixins=.
	(Warnings): Update list of supported -ftransitions=.
2021-12-01 11:56:37 +01:00
Eric Botcazou 82a7daa31a [Ada] Fix incorrect fixed-point computation in expression function
gcc/ada/

	* einfo.ads (E_Decimal_Fixed_Point_Subtype): Fix pasto.
	* freeze.adb (Freeze_Fixed_Point_Type): Retrieve the underlying type
	of the first subtype and do not use a stale value of Small_Value.
	* sem_res.adb (Resolve_Real_Literal): In the case of a fixed-point
	type, make sure that the base type is frozen and use its Small_Value
	to compute the corresponding integer value of the literal.
2021-12-01 10:24:43 +00:00
Piotr Trojanek ba12deb955 [Ada] Tune whitespace of the bounded lists Aggregate aspect
gcc/ada/

	* libgnat/a-cbdlli.ads (List): Remove extra space in Aggregate
	aspect.
2021-12-01 10:24:43 +00:00
Gary Dismukes 38e7e9ac15 [Ada] Allow formal functions to have a default in the form of an expression function
gcc/ada/

	* doc/gnat_rm/implementation_defined_pragmas.rst: Add
	documentation of the new form of formal subprogram default in
	the section on language extensions (pragma Extensions_Allowed).
	* gnat_rm.texi: Regenerate.
	* gen_il-gen-gen_nodes.adb: Add Expression as a syntactic field
	of N_Formal_(Abstract|Concrete)_Subprogram_Declaration nodes.
	* par-ch12.adb (P_Formal_Subprogram_Declaration): Add parsing
	support for the new default of a parenthesized expression for
	formal functions. Issue an error when extensions are not
	allowed, suggesting use of -gnatX. Update comment with extended
	syntax for SUBPROGRAM_DEFAULT.
	* sem_ch12.adb (Analyze_Formal_Subprogram_Declaration): Issue an
	error when an expression default is given for an abstract formal
	function. When a default expression is present for a formal
	function, install the function's formals and preanalyze the
	expression.
	(Instantiate_Formal_Subprogram): Fix typo in RM paragraph in a
	comment.  When a formal function has a default expression,
	create a body for the function that will evaluate the expression
	and will be called when the default applies in an instantiation.
	The implicit function is marked as inlined and as having
	convention Intrinsic.
2021-12-01 10:24:43 +00:00
Eric Botcazou bbafa6251e [Ada] Do not return freeze nodes for start of early call regions
gcc/ada/

	* sem_elab.adb (Previous_Suitable_Construct): New function declared
	in the Early_Call_Region_Processor package.
	(Find_ECR): Call it to get the previous node at the start.
	(Include): Call it to get the previous node during the traversal.
2021-12-01 10:24:43 +00:00
Bob Duff 9ce9322ccc [Ada] Fix crash on pragma Compile_Time_Warning/Error
gcc/ada/

	* sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not
	follow the Corresponding_Spec pointer if Acts_As_Spec is True,
	because Corresponding_Spec is Empty in that case, so we would
	exit the loop prematurely, and incorrectly think we are not
	inside a generic unit when we are.
2021-12-01 10:24:42 +00:00
Bob Duff 1010cb00c8 [Ada] Syntax error on "not null procedure"
gcc/ada/

	* par-ch3.adb (P_Access_Type_Definition): If Not_Null_Subtype is
	True, give an error in the access-to-subprogram cases.
2021-12-01 10:24:42 +00:00
Eric Botcazou 70b29d02f4 [Ada] Tidy up freezing code for instantiations (continued)
gcc/ada/

	* sem_ch12.adb (Freeze_Package_Instance): Move up.
2021-12-01 10:24:42 +00:00
Eric Botcazou 49b8a94b88 [Ada] Tidy up freezing code for instantiations
gcc/ada/

	* sem_ch12.adb (Freeze_Subprogram_Body): Rename into...
	(Freeze_Subprogram_Instance): ...this and change the name of the
	first parameter and local variables for the sake of consistency.
	(Insert_Freeze_Node_For_Instance): Use local variable Par_Inst.
	(Install_Body): Rename into...
	(Freeze_Package_Instance): ...this, remove first parameter and
	change the name of local variables for the sake of consistency.
	Do not deal with the special case of incomplete actual types here
	and do not insert the body.
	(Instantiate_Package_Body): Deal with the special case of incomplete
	actual types here and insert the body.  Call Freeze_Package_Instance
	only if expansion is done.
	(Instantiate_Subprogram_Body): Minor consistency tweak.
2021-12-01 10:24:42 +00:00
Etienne Servais 17fa48b12d [Ada] Fix typo in comment
gcc/ada/

	* sem_aggr.adb (Resolve_Aggregate): Fix typo in comment.
2021-12-01 10:24:42 +00:00
Steve Baird bb2fc099e2 [Ada] Improve support for casing on types with controlled parts
gcc/ada/

	* sem_case.adb (Check_Bindings): Provide a second strategy for
	implementing bindings and choose which strategy to use for a
	given binding. The previous approach was to introduce a new
	object and assign the bound value to the object.  The new
	approach is to introduce a renaming of a dereference of an
	access value that references the appropriate subcomponent, so no
	copies are made.  The original strategy is still used if the
	type of the object is elementary.  When the renaming approach is
	used, the initialization of the access value is not generated
	until expansion. Until this missing initialization is added, the
	tree looks like a known-at-compile-time dereference of a null
	access value: Temp : Some_Access_Type; Obj : Designated_Type
	renames Temp.all; This leads to problems, so a bogus initial
	value is provided here and then later deleted during expansion.
	(Check_Composite_Case_Selector): Disallow a case selector
	expression that requires finalization. Note that it is ok if the
	selector's type requires finalization, as long as the expression
	itself doesn't have any "newly constructed" parts.
	* exp_ch5.adb (Pattern_Match): Detect the case where analysis of
	a general (i.e., composite selector type) case statement chose
	to implement a binding as a renaming rather than by making a
	copy. In that case, generate the assignments to initialize the
	access-valued object whose designated value is later renamed
	(and remove the bogus initial value for that object that was
	added during analysis).
	* sem_util.ads, sem_util.adb: Add new function
	Is_Newly_Constructed corresponding to RM 4.4 term.
2021-12-01 10:24:42 +00:00
Richard Kenner be6bb3fc57 [Ada] Fix issues with ignored ghost code and unnesting
gcc/ada/

	* frontend.adb (Frontend): Do unnesting after ignored ghost code
	has been removed.
	* inline.adb (Analyze_Inlined_Bodies): Don't put ignored ghost
	entities on inlined subprogram list.
2021-12-01 10:24:41 +00:00
Ghjuvan Lacambre dbdb6b93a2 [Ada] Make Timed_Task_Entry_Call's defer_abort nestable
gcc/ada/

	* libgnarl/s-tasren.adb (Timed_Task_Entry_Call): Replace
	Defer_Abort and Undefer_Abort with Defer_Abort_Nestable and
	Undefer_Abort_Nestable.
2021-12-01 10:24:41 +00:00
Ghjuvan Lacambre e3102ec09c [Ada] Do not free task for _parent
gcc/ada/

	* exp_ch7.adb (Cleanup_Record): Don't process parent.
2021-12-01 10:24:41 +00:00
Justin Squirek b940999de4 [Ada] Spurious warning when using 'Type_Key on generic formal
gcc/ada/

	* sem_attr.adb (Type_Key): Avoid premature use warnings when the
	prefix is a generic actual.
2021-12-01 10:24:41 +00:00
Richard Kenner 8ba38e8c8b [Ada] Create object file for ignored ghost compilation unit
gcc/ada/

	* gnat1drv.adb (Gnat1drv): Force generation of object file if
	compilation unit is an ignored ghost.
2021-12-01 10:24:41 +00:00
Patrick Bernardi 621cccba3f [Ada] RTEMS: add traceback support for AArch64
gcc/ada/

	* tracebak.c: Add AArch64 RTEMS support.
2021-12-01 10:24:41 +00:00
Patrick Bernardi ff46a531c5 [Ada] Add signal to exception mapping for RTEMS
gcc/ada/

	* init.c: Add __gnat_error_handler and __gnat_install_handler
	for RTEMS.
2021-12-01 10:24:40 +00:00
Eric Botcazou 38df84ae8a [Ada] Fix small discrepancy between -gnatG and -gnatD[G] outputs
gcc/ada/

	* sprint.ads (Source_Dump): Fix typo in comment.
	* sprint.adb (Source_Dump): Set Dump_Freeze_Null for both -gnatG
	and -gnatD.
	* switch-c.adb (Scan_Front_End_Switches) <'D'>: Remove obsolete
	kludge.
2021-12-01 10:24:40 +00:00
Yannick Moy 790b875210 [Ada] Improve error messages for dot notation when -gnatX not used
gcc/ada/

	* einfo.ads (Direct_Primitive_Operations): Update the doc to
	indicate that this field is used for all types now.
	* sem_ch4.adb (Try_Object_Operation): Add parameter
	Allow_Extensions set to True to pretend that extensions are
	allowed.
	* sem_ch4.ads: Same.
	* sem_ch6.adb: Do not require Extensions_Allowed.
	* sem_ch8.adb (Find_Selected_Component): Remove duplicate
	"where" in comment.  Improve the error messages regarding use of
	prefixed calls.
2021-12-01 10:24:40 +00:00
Yannick Moy be8de8e127 [Ada] Add query for extended precision floating-point types
gcc/ada/

	* sem_util.adb (Is_Extended_Precision_Floating_Point_Type): New
	function.
	* sem_util.ads (Is_Extended_Precision_Floating_Point_Type): New
	function.
2021-12-01 10:24:40 +00:00
Piotr Trojanek 0f3dfe41cb [Ada] Replace low-level detection of subprograms with high-level wrapper
gcc/ada/

	* exp_aggr.adb, sem_cat.adb, sem_ch10.adb, sem_ch12.adb,
	sem_elim.adb, sem_util.adb: Replace uses of Subprogram_Kind with
	Is_Subprogram.
2021-12-01 10:24:40 +00:00
Piotr Trojanek a41a910745 [Ada] Sync whitespace between variants of Indefinite_Holders unit
gcc/ada/

	* libgnat/a-coinho.ads: Sync whitespace with
	a-coinho__shared.ads.
	* libgnat/a-coinho__shared.ads: Sync whitespace with
	a-coinho.ads.
2021-12-01 10:24:40 +00:00
Piotr Trojanek ef520c0baf [Ada] Sort list of Ada runtime units in Makefile.rtl
gcc/ada/

	* Makefile.rtl (GNATRTL_TASKING_OBJS): Sort.
	(GNATRTL_NONTASKING_OBJS): Sort.
2021-12-01 10:24:40 +00:00
Piotr Trojanek 0c18fdf1d2 [Ada] Whitespace cleanup in Makefile.rtl dependency rules
gcc/ada/

	* Makefile.rtl: Remove extra whitespace in special compilation
	rules.
2021-12-01 10:24:39 +00:00
Piotr Trojanek 6054bc84f0 [Ada] Document System.Atomic_Counters as supported on ARM and AARCH64
gcc/ada/

	* doc/gnat_rm/the_gnat_library.rst (System.Atomic_Counters):
	Sync description with comment in s-atocou.ads.
	* gnat-style.texi, gnat_rm.texi, gnat_ugn.texi: Regenerate.
2021-12-01 10:24:39 +00:00
Yannick Moy aeaabe7b3c [Ada] Improve messages on incorrect state refinement in SPARK
gcc/ada/

	* sem_ch10.adb (Is_Private_Library_Unit): Move query to
	Sem_Util for sharing.
	* sem_ch7.adb (Analyze_Package_Body_Helper): Add continuation
	message.
	* sem_prag.adb (Analyze_Part_Of): Call new function
	Is_Private_Library_Unit.
	(Check_Valid_Library_Unit_Pragma): Specialize error messages on
	misplaced pragmas.
	(Analyze_Refined_State_In_Decl_Part): Recognize missing Part_Of
	on object in private part.
	* sem_util.adb (Check_State_Refinements): Add continuation
	message.
	(Find_Placement_In_State_Space): Fix detection of placement,
	which relied wrongly on queries In_Package_Body/In_Private_Part
	which do not provide the right information here for all cases.
	(Is_Private_Library_Unit): Move query here for sharing.
	* sem_util.ads (Is_Private_Library_Unit): Move query here for
	sharing.
2021-12-01 10:24:39 +00:00
Gary Dismukes 7b4069fb7c [Ada] Storage error on untagged prefixed subprogram calls with -gnatX
gcc/ada/

	* sem_ch3.adb (Analyze_Full_Type_Declaration): If the full type
	has a primitives list but its base type doesn't, set the base
	type's list to the full type's list (covers certain constrained
	cases, such as for arrays).
	(Analyze_Incomplete_Type_Decl): Unconditionally initialize an
	incomplete type's primitives list.
	(Analyze_Subtype_Declaration): Unconditionally set a subtype's
	primitives list to the base type's list, so the lists are
	shared.
	(Build_Derived_Private_Type): Unconditionally initialize a
	derived private type's list to a new empty list.
	(Build_Derived_Record_Type): Unconditionally initialize a
	derived record type's list to a new empty list (now a single
	call for tagged and untagged cases).
	(Derived_Type_Declaration): Unconditionally initialize a derived
	type's list to a new empty list in error cases (when Parent_Type
	is undefined or illegal).
	(Process_Full_View): Unconditionally copy the primitive
	operations from the private view to the full view (rather than
	conditioning it on whether extensions are enabled).
	* sem_ch7.adb (New_Private_Type): Unconditionally initialize an
	untagged private type's primitives list to a new empty list.
2021-12-01 10:24:39 +00:00
Etienne Servais ab59968427 [Ada] Avoid duplication for Sets functions
gcc/ada/

	* libgnat/a-cbhase.adb, libgnat/a-cborse.adb,
	libgnat/a-cihase.adb, libgnat/a-ciorse.adb,
	libgnat/a-cohase.adb, libgnat/a-coorse.adb
	(Constant_Reference,Reference_Preserving_Key): Refactor using
	the equivalence stated in the RM.
2021-12-01 10:24:39 +00:00
Piotr Trojanek 659e775a17 [Ada] Simplify building of inequality function body
gcc/ada/

	* exp_ch3.adb (Make_Eq_Body): Refactor to avoid appending to an
	empty list; also, when exiting early we will not create any
	list; fix style in comment.
2021-12-01 10:24:39 +00:00
Piotr Trojanek f05f68bc00 [Ada] Cleanup listing of representation info
gcc/ada/

	* repinfo.adb (List_Entities): Simplify detection of entries;
	refactor potentially redundant comparison.
2021-12-01 10:24:38 +00:00
Jakub Jelinek cf23d58df2 i386: Fix up some minor formatting issues and one inconsistency
While looking at a proposed vendor backport, I've noticed some
formatting issues in x86-tune.def.  Also, in all spots m_GENERIC
comes last, except one recently changed, I think it is useful to have
m_GENERIC always last for consistency.

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

	* config/i386/x86-tune.def (X86_TUNE_SCHEDULE,
	X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY,
	X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Formatting fixes.
	(X86_TUNE_USE_GATHER): Put m_GENERIC last for consistency.
2021-12-01 10:22:55 +01:00
Jakub Jelinek c264208e16 libcpp: Enable P1949R7 for C++98 too [PR100977]
On Mon, Nov 29, 2021 at 05:53:58PM -0500, Jason Merrill wrote:
> I'm inclined to go ahead and change C++98 as well; I doubt anyone is relying
> on the particular C++98 extended character set rules, and we already accept
> the union of the different sets when not pedantic.

Ok, here is an incremental patch to do that also for -std={c,gnu}++98.

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

	PR c++/100977
	* init.c (struct lang_flags): Remove cxx23_identifiers.
	(lang_defaults): Remove cxx23_identifiers initializers.
	(cpp_set_lang): Don't copy cxx23_identifiers.
	* include/cpplib.h (struct cpp_options): Adjust comment about
	c11_identifiers.  Remove cxx23_identifiers field.
	* lex.c (warn_about_normalization): Use cplusplus instead of
	cxx23_identifiers.
	* charset.c (ucn_valid_in_identifier): Likewise.

	* g++.dg/cpp/ucnid-1.C: Adjust expected diagnostics.
	* g++.dg/cpp/ucnid-1-utf8.C: Likewise.
2021-12-01 10:21:20 +01:00
Jakub Jelinek 35f2c098c8 simplify-rtx: Punt on simplify_associative_operation with large operands [PR102356]
Seems simplify_associate_operation is quadratic, which isn't a big deal
for use during combine and other similar RTL passes, because those never
try to combine expressions from more than a few instructions and because
those instructions need to be recognized the machine description also bounds
how many expressions can appear in there.
var-tracking has depth limits only for some cases and unlimited depth
for the vt_expand_loc though:
 /* This is the value used during expansion of locations.  We want it
    to be unbounded, so that variables expanded deep in a recursion
    nest are fully evaluated, so that their values are cached
    correctly.  We avoid recursion cycles through other means, and we
    don't unshare RTL, so excess complexity is not a problem.  */
 #define EXPR_DEPTH (INT_MAX)
 /* We use this to keep too-complex expressions from being emitted as
    location notes, and then to debug information.  Users can trade
    compile time for ridiculously complex expressions, although they're
    seldom useful, and they may often have to be discarded as not
    representable anyway.  */
 #define EXPR_USE_DEPTH (param_max_vartrack_expr_depth)

IMO for very large expressions it isn't worth trying to reassociate though,
in fact e.g. for the new testcase below keeping it as is has bigger chance
of generating smaller debug info which the dwarf2out.c part of the change
tries to achieve - if a binary operation has the same operands, we can
use DW_OP_dup and not bother computing the possibly large operand again.

The patch fixes it by adding a counter to simplify_context and counting
how many times simplify_associative_operation has been called during
a single outermost simplify_* call, and once it reaches some maximum
(currently 64), it stops reassociating.

Another possibility to deal with the power expressions in debug info
would be to introduce some new RTL operation for the pow{,i} (x, n)
case, allow that solely in debug insns and expand those into DWARF
using a loop.  But that seems like quite a lot of work for something rarely
used (especially when powi for larger n is only useful for 0 and 1 inputs
because anything else overflows).

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

	PR rtl-optimization/102356
	* rtl.h (simplify_context): Add assoc_count member and
	max_assoc_count static member.
	* simplify-rtx.c (simplify_associative_operation): Don't reassociate
	more than max_assoc_count times within one outermost simplify_* call.
	* dwarf2out.c (mem_loc_descriptor): Optimize binary operation
	with both operands the same using DW_OP_dup.

	* gcc.dg/pr102356.c: New test.
2021-12-01 10:16:57 +01:00
Jakub Jelinek ac5fd364f0 libcpp: Fix up #__VA_OPT__ handling [PR103415]
stringify_arg uses pfile->u_buff to create the string literal.
Unfortunately, paste_tokens -> _cpp_lex_direct -> lex_number -> _cpp_unaligned_alloc
can in some cases use pfile->u_buff too, which results in losing everything
prepared for the string literal until the token pasting.

The following patch fixes that by not calling paste_token during the
construction of the string literal, but doing that before.  All the tokens
we are processing have been pushed into a token buffer using
tokens_buff_add_token so it is fine if we paste some of them in that buffer
(successful pasting creates a new token in that buffer), move following
tokens if any to make it contiguous, pop (throw away) the extra tokens at
the end and then do stringify_arg.

Also, paste_tokens now copies over PREV_WHITE and PREV_FALLTHROUGH flags
from the original lhs token to the replacement token.  Copying that way
the PREV_WHITE flag is needed for the #__VA_OPT__ handling and copying
over PREV_FALLTHROUGH fixes the new Wimplicit-fallthrough-38.c test.

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

	PR preprocessor/103415
libcpp/
	* macro.c (stringify_arg): Remove va_opt argument and va_opt handling.
	(paste_tokens): On successful paste or in PREV_WHITE and
	PREV_FALLTHROUGH flags from the *plhs token to the new token.
	(replace_args): Adjust stringify_arg callers.  For #__VA_OPT__,
	perform token pasting in a separate loop before stringify_arg call.
gcc/testsuite/
	* c-c++-common/cpp/va-opt-8.c: New test.
	* c-c++-common/Wimplicit-fallthrough-38.c: New test.
2021-12-01 10:07:59 +01:00
Tamar Christina 29df53fe34 middle-end: move bitmask match.pd pattern and update tests
Following the previous bugfix this addresses the cosmetic and test issues.

The vector tests are moved to vect and the scalar are left where they are.

gcc/ChangeLog:

	* match.pd: Move below pattern that rewrites to EQ, NE.
	* tree.c (bitmask_inv_cst_vector_p): Correct do .. while indentation.

gcc/testsuite/ChangeLog:

	* gcc.dg/bic-bitmask-10.c: Moved to gcc.dg/vect/vect-bic-bitmask-10.c.
	* gcc.dg/bic-bitmask-11.c: Moved to gcc.dg/vect/vect-bic-bitmask-11.c.
	* gcc.dg/bic-bitmask-12.c: Moved to gcc.dg/vect/vect-bic-bitmask-12.c.
	* gcc.dg/bic-bitmask-3.c: Moved to gcc.dg/vect/vect-bic-bitmask-3.c.
	* gcc.dg/bic-bitmask-23.c: Moved to gcc.dg/vect/vect-bic-bitmask-23.c.
	* gcc.dg/bic-bitmask-2.c: Moved to gcc.dg/vect/vect-bic-bitmask-2.c.
	* gcc.dg/bic-bitmask-4.c: Moved to gcc.dg/vect/vect-bic-bitmask-4.c.
	* gcc.dg/bic-bitmask-5.c: Moved to gcc.dg/vect/vect-bic-bitmask-5.c.
	* gcc.dg/bic-bitmask-6.c: Moved to gcc.dg/vect/vect-bic-bitmask-6.c.
	* gcc.dg/bic-bitmask-8.c: Moved to gcc.dg/vect/vect-bic-bitmask-8.c.
	* gcc.dg/bic-bitmask-9.c: Moved to gcc.dg/vect/vect-bic-bitmask-9.c.
2021-12-01 08:40:25 +00:00
Siddhesh Poyarekar da9386f9a7 tree-optimization/103456 - Record only successes from object_sizes_set
Avoid overwriting osi->changed if object_sizes_set does not update the
size, so that a previous success in the same pass is not overwritten.
This fixes the bootstrap-ubsan build config, which was failing due to
incorrect object size.

gcc/ChangeLog:

	PR tree-optimization/103456
	* tree-object-size.c (merge_object_sizes): Update osi->changed
	only if object_sizes_set succeeded.

gcc/testsuite/ChangeLog:

	PR tree-optimization/103456
	* gcc.dg/ubsan/pr103456.c: New test.

Co-authored-by: Martin Liška <mliska@suse.cz>
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2021-12-01 13:57:50 +05:30
GCC Administrator c177e80609 Daily bump. 2021-12-01 00:17:04 +00:00