Commit Graph

193143 Commits

Author SHA1 Message Date
Thomas Schwinge
1f89e48789 libgomp nvptx plugin: Only consider '--with-cuda-driver=[...]' when applicable
They're not applicable in 'PLUGIN_NVPTX_DYNAMIC' configurations.

	libgomp/
	* plugin/Makefrag.am (libgomp_plugin_nvptx_la_CPPFLAGS)
	[PLUGIN_NVPTX_DYNAMIC]: Don't append '$(PLUGIN_NVPTX_CPPFLAGS)'.
	(libgomp_plugin_nvptx_la_LDFLAGS) [PLUGIN_NVPTX_DYNAMIC]: Don't
	append '$(PLUGIN_NVPTX_LDFLAGS)'.
	* Makefile.in: Regenerate.
2022-05-13 14:01:01 +02:00
Alexandre Oliva
04c0a88aab Avoid visiting newly-created blocks in harden-conditionals
Reverse iteration over blocks, in gimple-harden-conditionals.cc, was
supposed to avoid visiting blocks introduced by hardening and
introducing further reversed conditionals and traps for them, but
newly-created blocks may be inserted before the current block, as
shown by the PR105455 testcase.

Use an auto_sbitmap to gather preexisting blocks that need visiting.


for  gcc/ChangeLog

	* gimple-harden-conditionals.cc: Include sbitmap.h.
	(pass_harden_conditional_branches::execute): Skip new blocks.
	(pass_harden_compares::execute): Likewise.
2022-05-13 07:48:51 -03:00
Alexandre Oliva
6aaa1d5739 ada: gcc-if: build proper String_Pointer for Get_External_Name
The compiler is allowed to assume it can access String bounds, such as
the prefix passed to Get_External_Name, even in circumstances in which
the prefix is not going to be used and has_prefix is false, so, from
the C side, we have to build a proper String_Template for the
String_Pointer.


for  gcc/ada/ChangeLog

	* gcc-interface/decl.cc (is_cplusplus_method): Build proper
	String for Get_External_Name.
2022-05-13 07:48:50 -03:00
Alexandre Oliva
9a79854be0 Introduce tests for hardbool Machine_Attribute for Ada
Test for the validity checking performed on nonstandard booleans
annotated with the "hardbool" Machine_Attribute pragma.


for  gcc/testsuite/ChangeLog

	* gnat.dg/hardbool.ads: New.
	* gnat.dg/hardbool.adb: New.
2022-05-13 07:48:49 -03:00
Richard Earnshaw
6a116728e2 arm: correctly handle misaligned MEMs on MVE [PR105463]
Vector operations in MVE must be aligned to the element size, so if we
are asked for a misaligned move in a wider mode we must recast it to a
form suitable for the known alignment (larger elements have better
address offset ranges, so there is some advantage to using wider
element sizes if possible).  Whilst fixing this, also rework the
predicates used for validating operands - the Neon predicates are
not right for MVE.

gcc/ChangeLog:

	PR target/105463
	* config/arm/mve.md (*movmisalign<mode>_mve_store): Use
	mve_memory_operand.
	(*movmisalign<mode>_mve_load): Likewise.
	* config/arm/vec-common.md (movmisalign<mode>): Convert to generator
	form...
	(@movmisalign<mode>): ... thus.  Use generic predicates and then
	rework operands if they are not valid.  For MVE rework to a
	narrower element size if the alignment is not high enough.
2022-05-13 11:24:11 +01:00
Richard Earnshaw
485a0ae098 arm: fix some issues in mve_vector_mem_operand
There are a couple of issues with the mve_vector_mem_operand function.
Firstly, SP is permitted as a register provided there is no write-back
operation.  Secondly, there were some cases where 'strict' was not
being applied when checking which registers had been used.

gcc/ChangeLog:

	* config/arm/arm.cc (mve_vector_mem_operand): Allow SP_REGNUM
	when there is no write-back.  Fix use when strict is true.
2022-05-13 11:24:11 +01:00
Takayuki 'January June' Suwa
112447f856 xtensa: Reflect the 32-bit Integer Divide Option
On Espressif's ESP8266 (based on Tensilica LX106, no hardware divider),
this patch reduces the size of each:

  __moddi3() @ libgcc.a :  969 -> 301 (saves 668)
  __divmoddi4()         : 1111 -> 426 (saves 685)
  __udivmoddi4()        : 1043 -> 319 (saves 724)

in bytes, respectively.

gcc/ChangeLog:

	* config/xtensa/xtensa.h (TARGET_HAS_NO_HW_DIVIDE): New macro
	definition.
2022-05-13 02:31:26 -07:00
Takayuki 'January June' Suwa
d543bac163 xtensa: Rename deprecated extv/extzv insn patterns to extvsi/extzvsi
These patterns were deprecated since GCC 4.8.

gcc/ChangeLog:

	* config/xtensa/xtensa.md (extvsi, extvsi_internal, extzvsi,
	extzvsi_internal): Rename from extv, extv_internal, extzv and
	extzv_internal, respectively.
2022-05-13 02:31:24 -07:00
Eric Botcazou
7b844206ec Fix wrong SRA with VIEW_CONVERT_EXPR and reverse SSO
Most cases of VIEW_CONVERT_EXPRs involving reverse scalar storage order are
disqualified for SRA because they are storage_order_barrier_p, but you can
still have a VIEW_CONVERT_EXPR to a regular composite type being applied to
a component of a record type with reverse scalar storage order.

In this case the bypass for !useless_type_conversion_p in sra_modify_assign,
albeit already heavily guarded, triggers and may generate wrong code, so the
patch makes sure that it does only when the SSO is the same on both side.

gcc/
	* tree-sra.cc (sra_modify_assign): Check that scalar storage order
	is the same on the LHS and RHS before rewriting one with the model
	of the other.
gcc/testsuite/
	* gnat.dg/sso17.adb: New test.
2022-05-13 11:19:01 +02:00
Eric Botcazou
c77e4873b1 [Ada] Fix incorrect call to inherited function with limited return type
This is a return convention mismatch coming from a discrepancy of the
Returns_By_Ref flag for the inherited function.

gcc/ada/

	* sem_ch3.adb (Derive_Subprogram): For a function, also copy the
	Returns_By_Ref flag from the parent.
2022-05-13 08:04:47 +00:00
Gary Dismukes
ba75fee24d [Ada] Storage_Model_Object fails to return object entity
After a compilation unit containing a Designated_Storage_Model aspect
was processed by the compiler front end, the aspect's expression was
seen as not having been analyzed. In some cases this can lead to the
Storage_Model_Object function not returning the entity of the associated
model object (such as when the model object is specified using an
expanded name). This was due to a second copy of the aspect's expression
being made in Check_Aspect_At_Freeze_Point, and that copy wasn't
analyzed, even though the earlier version of the expression prior to
that copy had been. (The copy is needed for proper checking of Ada's
rules for ensuring that certain aspect expressions resolve the same way
at the freeze point and later at the end of the declarations.) This is
corrected by doing analysis of the new aspect expression within
Check_Aspect_At_Freeze_Point, as is already done in that procedure in
the case of several other aspects.

gcc/ada/

	* sem_ch13.adb (Check_Aspect_At_Freeze_Point): Analyze the
	expression of the aspect at this point, like other aspects that
	denote simple entities. Ensures that function
	Storage_Model_Object will have an entity to retrieve from the
	aspect expression. Also, move comment about aspects that don't
	require delay analysis in front of last alternative of the case
	statement, where it's supposed to be.
2022-05-13 08:04:46 +00:00
Javier Miranda
d663778287 [Ada] Compiler crash on -gnata -O2
gcc/ada/

	* contracts.adb (Build_Unique_Name): New subprogram.
	(Make_Class_Precondition_Subps): Use Build_Unique_Name to
	generate the names of the call helpers and the name of indirect
	call wrappers.
	* freeze.adb (Needs_Wrapper): Remove dead code.
	(Check_Inherited_Conditions): Defer building helpers and ICW
	until all the dispatch table wrappers have been built and
	analyzed. Required to ensure uniqueness in their names because
	when building these wrappers for overlapped subprograms their
	homonym number is not definite until they have been analyzed.
2022-05-13 08:04:45 +00:00
Arnaud Charlet
78e26388ed [Ada] Only use alternate stack when needed
If we're not going to install a signal handler for SIGSEGV then we do
not need an alternate stack to handle this signal (and e.g. stack
overflows).

gcc/ada/

	* libgnarl/s-taprop__linux.adb (Initialize): Do not use an
	alternate stack if no handler for SEGV is installed.
2022-05-13 08:04:45 +00:00
Alexandre Oliva
8150f295ec [Ada] Extend hardcfr testing (documentation)
Having realized that noreturn calls of __builtin_return are special,
and other noreturn calls don't get edges to the exit block, I've
realized the consequences of the logic to insert checking before
noreturn and tail calls were not quite what I'd expected before.

Specifically, noreturn calls other than __builtin_return don't get any
checking whatsoever.  Moreover, optional tail calls are only detected
long after hardcfr; the logic should work for must-tail calls, but
there doesn't seem to be a way to test it.

Documentation has been simplified so as to remove mention of these
possibilities, that can't really be relied on.

gcc/ada/

	* doc/gnat_rm/security_hardening_features.rst (Control Flow
	Redundancy): Drop mentions of noreturn and tail calls.
	* gnat_rm.texi: Regenerate.
2022-05-13 08:04:44 +00:00
Ghjuvan Lacambre
a2cff9e9af [Ada] CUDA: use binder to generate kernel-registration code
Compiling CUDA code requires compiling code for the host (= CPU) and for
the device (= GPU). Device code is embedded into the host code and must
be registered with the CUDA runtime by the host.

The original approach we took for registering CUDA kernels was to
generate the registration-code on a unit basis, i.e. each unit took care
of registering its own kernels. Unfortunately, this makes linking
kernels and device functions that belong to different units much harder.

We thus rework this approach in order to have GNAT generate kernel names
in ALI files. The binder reads the ALI files and generates kernel
registration code for each of the kernels found in ALI files.

gcc/ada/

	* ali.adb: Introduce new 'K' line in ALI files, used to
	represent CUDA kernel entries.
	* ali.ads: Create new CUDA_Kernels table, which contains entries
	of type CUDA_Kernel_Record. Each CUDA_Kernel_Record corresponds
	to a K line in an ali file.
	* bindgen.adb: Introduce new Gen_CUDA_Init procedure in the
	binder, which generates CUDA kernel registration code.
	* gnat_cuda.adb: Move Get_CUDA_Kernels spec to package spec to
	make it available to bindgen.adb.
	* gnat_cuda.ads: Likewise.
	* lib-writ.adb: Introduce new Output_CUDA_Symbols procedure,
	which generates one 'K' line in the ALI file per visible CUDA
	kernel.
	* opt.ads: Introduce Enable_CUDA_Expansion option, triggered by
	using the -gnatd_c flag.
	* switch-b.adb: Likewise.
	* switch-c.adb: Likewise.
2022-05-13 08:04:43 +00:00
Marc Poulhiès
e3584606f5 [Ada] Fix iterated component association for array aggregate
Create a scope for the Ada 2022 iterated component association loops. In
the case of elements needing finalization, the late expansion would
crash on references to the loop variable within the loop body.

gcc/ada/

	* exp_aggr.adb (Gen_Loop): Create scope for loop variable of
	iterated components.
2022-05-13 08:04:42 +00:00
Yannick Moy
4c9a8183b3 [Ada] Simplify helper units for formal hashed sets/maps
As tampering checks do not exist in formal hashed sets and maps, remove
the machinery for such checks in the version of generic key and node
operations for formal sets/maps. Update comments as well.

gcc/ada/

	* libgnat/a-chtgfk.adb (Checked_Equivalent_Keys, Checked_Index):
	Remove useless functions.
	(Delete_Key_Sans_Free, Find, Generic_Conditional_Insert): Adapt
	to removal of wrapper functions.
	* libgnat/a-chtgfk.ads (Checked_Equivalent_Keys, Checked_Index):
	Remove useless functions.
	* libgnat/a-chtgfo.adb (Checked_Index): Remove useless function.
	(Clear): Delete code commented out regarding Busy and Lock
	management.
	(Delete_Node_At_Index): Delete unused procedure.
	(Delete_Node_Sans_Free, Free, Generic_Read, Next): Adapt to
	removal of wrapper functions.
	* libgnat/a-chtgfo.ads (Checked_Index): Remove useless function.
	(Delete_Node_At_Index): Delete unused procedure.
2022-05-13 08:04:41 +00:00
Yannick Moy
f8e12e7862 [Ada] Adapt body of formal sets and maps for SPARK
Remove violations of SPARK rules, to prepare for the proof of hashed
sets and maps:

- Make the type of hash tables not tagged, so that it will be possible
  to mark the type of nodes as having relaxed initialization.

- Remove comparison of addresses as check or optimization: as a check,
  it is not necessary in SPARK as the caller cannot pass in aliased
  parameters in such cases; as an optimization, it is not possible in
  SPARK code.

- Avoid aliasing when inserting a node in the hash table. The code for
  insertion in sets and maps was explicitly aliasing a global for the
  container and a parameter for its hash table component, both being
  written. Rewrite the code to pass only the hash table as parameter.

- Insert constants for subtype constraints, which cannot depend on
  variables in SPARK code.

- Use procedures instead of functions when side-effects are expected.

- Rename variables whose value is only written through calls and not
  read, using Unused prefix, so that flow analysis does not warn about
  it.

gcc/ada/

	* libgnat/a-cfhama.adb (Generic_Allocate): Retype to avoid
	aliasing.
	(Assign, Move): Remove address comparison.
	(Include): Insert constants for subtype constraints.
	(Insert): Rewrite to avoid aliasing and function with side-effects.
	* libgnat/a-cfhase.adb (Generic_Allocate): Retype to avoid
	aliasing.
	(Assign, Move): Remove address comparison.
	(Difference, Intersection, Is_Subset, Overlap,
	Symmetric_Difference, Union): Remove address comparison.  Insert
	constants for subtype constraints.
	(Insert): Rewrite to avoid aliasing and function with
	side-effects.
	* libgnat/a-chtgfk.adb (Checked_Equivalent_Keys, Checked_Index,
	Delete_Key_Sans_Free, Find, Generic_Replace_Element, Index):
	Type for hash tables not tagged anymore.
	(Generic_Conditional_Insert): New_Node generic formal is a
	procedure taking the hash table as first parameter now, to avoid
	aliasing in the caller.
	* libgnat/a-chtgfk.ads: Same.
	* libgnat/a-chtgfo.adb (Checked_Index, Clear,
	Delete_Node_At_Index, Delete_Node_Sans_Free, First, Free,
	Generic_Allocate, Generic_Iteration, Generic_Read,
	Generic_Write, Index, Next): Type for hash tables not tagged
	anymore.
	(Generic_Equal): Removed tagged. Remove address comparison.
	* libgnat/a-chtgfo.ads: Same.
	* libgnat/a-cohata.ads (Hash_Table_Type): Remove tagged.
2022-05-13 08:04:40 +00:00
Yannick Moy
2e2f53d50c [Ada] Remove dependency on tampering checks and controlled types for formal
Formal hashed sets and maps are now using a different type of hash table
that does not require controlled types. This is possible because formal
containers do not rely on tampering checks, as cursors do not hold a
pointer to a single matching container, but are logical indexes that can
be used with multiple containers.

For simplicity of the package organisation, and symmetry with other
versions of containers, add a formal version of hashed types in the
shared Ada.Containers.Hash_Tables unit. This unit should be specialized
to only include the formal version of hash tables for runtimes that
do not support controlled types (so that the dependency on
Ada.Containers.Helpers can be removed).

The new versions of units for generic keys and operations are modified
versions of the units for bounded containers, with all tampering checks
removed (they were no-op in formal containers). A declaration of
constant Checks is added at the start of the body, as these units cannot
use the version in Ada.Containers.Helpers.

gcc/ada/

	* Makefile.rtl: Add new files.
	* libgnat/a-cfhama.adb: Use formal version of hash tables.
	* libgnat/a-cfhama.ads: Same.
	* libgnat/a-cfhase.adb: Same.
	* libgnat/a-cfhase.ads: Same.
	* libgnat/a-chtgfk.adb: New unit for formal containers, modified
	version of Generic_Bounded_Keys.
	* libgnat/a-chtgfk.ads: Same.
	* libgnat/a-chtgfo.adb: New unit for formal containers, modified
	version of Generic_Bounded_Operations.
	* libgnat/a-chtgfo.ads: Same.
	* libgnat/a-cohata.ads (Generic_Formal_Hash_Table_Types): Third
	version of the type for hash tables, equivalent to the bounded
	version without tampering checks.
2022-05-13 08:04:39 +00:00
Javier Miranda
6d22fb118f [Ada] Ada ABI change when building with assertions
Compiling with and without assertions enabled the name of some generated
symbols differ; this is an issue when using pre-built libraries.

gcc/ada/

	* freeze.adb (Check_Inherited_Conditions): Dispatch table
	wrappers must be placed in the list of entities of their scope
	at the same place of their wrapped primitive. This is required
	for private types since these wrappers are built when their full
	tagged type declaration is frozen but they may override a
	primitive defined in the public part of the package (and it is
	important to maintain the wrapper in the list of public entities
	of the package to ensure their correct visibility).
2022-05-13 08:04:39 +00:00
Johannes Kanig
17a89d8214 [Ada] Take into account GNSA_ROOT env var for prefix
The GNSA_ROOT environment variable can be used to indicate to the
compiler how to find the runtime directory.

gcc/ada/

	* osint.ads, osint.adb (Relocate_Path): If the GNSA_ROOT
	environment variable is set, we use that as the prefix, instead
	of computing the prefix from the executable location.
2022-05-13 08:04:38 +00:00
Steve Baird
b77029ff25 [Ada] Implement late initialization rules for type extensions
Default initialization of a record object is required to initialize any
components that "require late initialization" after other components.
This includes the case of a type extension; "late initialization"
components of the parent type are required to be initialized after
non-late-init extension components. This is implemented by generalizing
the use of an existing init proc parameter. Previously, the init proc
for a tagged type took a Boolean parameter indicating whether or not to
initialize the Tag component. With this change, this parameter can now
take on any of four values indicating whether to perform

   1) Full initialization (including the tag component).
   2) Full initialization except for the tag component.
   3) Early (non-tag) initialization only.
   4) Late (non-tag) initialization only.

With this change, the init proc for a type extension has the option of
performing the early and late portions of the parent's initialization
via two separate calls to the parent type's init proc.

gcc/ada/

	* exp_ch3.ads (Build_Intialization_Call): Add new formal
	parameter, Init_Control_Actual, with default value. Clients
	outside of package Exp_Ch3 are unaffected.
	* exp_ch3.adb (Initialization_Control): new package; support for
	this 4-valued parameter.  The existing Requires_Late_Init
	function is moved into this new package.
	(Build_Initialization_Call): Add new formal parameter for
	subprogram body, use this new formal parameter in generating an
	init proc call.
	(Build_Record_Init_Proc): Replace Set_Tag Boolean formal
	parameter with 4-valued Init_Control_Formal. Wrap if-statements
	with appropriate conditions around tag initialization, early
	initialization, and late initialization statements.
	* exp_util.adb (Build_Task_Image_Decl): Avoid problem with
	duplicate declarations when an init proc for a type extension
	calls the parent type's init proc twice.
2022-05-13 08:04:37 +00:00
Ed Schonberg
7b6fa643ef [Ada] Handle IN iterator for class-wide derived object of iterator type
The compiler currently rejects iterating on an interface type derived
from an iterator type.

See Ada RM 5.5.1(6/3) and 5.5.2(3/3).

gcc/ada/

	* sem_ch5.adb (Analyze_Iterator_Specification): Fix Typ in the
	case of a class-wide derived iterator.
2022-05-13 08:04:36 +00:00
Yannick Moy
3fe35ab093 [Ada] Facilitate proof of Overwrite in bounded strings library
Consistently use >= operator in both the code and contracts of
function/procedure Overwrite, to facilitate proof, instead of the strict
inequality > sometimes, as only New_Item remains in the result in the
case of equal size too.

gcc/ada/

	* libgnat/a-strbou.ads (Overwrite): Switch to >= operator in
	contracts.
	* libgnat/a-strsup.adb (Super_Overwrite): Switch to >= operator
	in code of procedure (function already uses it).
	* libgnat/a-strsup.ads (Super_Overwrite): Switch to >= operator
	in contracts.
2022-05-13 08:04:35 +00:00
Etienne Servais
9e5b1b076a [Ada] Fix code example on representation clause
The column is superfluous, component names are missing.

gcc/ada/

	* doc/gnat_rm/representation_clauses_and_pragmas.rst: Fix code
	snippet.
	* gnat_rm.texi: Regenerate.
2022-05-13 08:04:35 +00:00
Eric Botcazou
85df62468c [Ada] Do not overwrite limited view of result type
This removes obsolete code that overwrites a limited view present as the
result type of a function during the tentative analysis of prefixed
views for function calls involving tagged types. The original view is
necessary for the code generator to break the circularity present in
this setup.

The change also adds a couple of guards for the illegal case where the
limited view is the only view available when the function is invoked.

gcc/ada/

	* aspects.adb (Find_Value_Of_Aspect): Add guard.
	* sem_ch4.adb (Complete_Object_Operation): Remove obsolete code.
	* sem_ch5.adb (Has_Sec_Stack_Default_Iterator): Add guard.
2022-05-13 08:04:34 +00:00
Javier Miranda
18e278727e [Ada] Wrong address for class-wide interface access conversion
The compiler generates wrong code on instantiations of package
Address_To_Access_Conversions when the generic formal is a class-wide
interface type; this causes wrong dispatching calls when the
access-to-class-wide-interface object returned by To_Pointer is used to
dispatch a call.

gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference): The expansion of
	'Address in a call to an instantiation of the implicit
	subprogram To_Pointer with a class-wide interface type target
	requires adding an implicit type conversion to force
	displacement of the "this" pointer.
2022-05-13 08:04:33 +00:00
Javier Miranda
fafccfbf77 [Ada] Crash in task body reference to discriminant
The compiler may crash processing the successor or predecessor of a task
type discrete discriminant.

gcc/ada/

	* sem_attr.adb (Resolve_Attribute): Ensure that attribute
	expressions are resolved at this stage; required for preanalyzed
	references to discriminants since their resolution (and
	expansion) will take care of updating their Entity attribute to
	reference their discriminal.
2022-05-13 08:04:33 +00:00
Justin Squirek
6a28d40dc4 [Ada] Improve expected type error messages
This patch improves error messages concerning type mismatches by
printing the actual expected type in more cases instead of the expected
type's first subtype.

gcc/ada/

	* sem_util.adb (Wrong_Type): Avoid using the first subtype of
	the expected type in error messages when the expected type is
	not internally generated.
2022-05-13 08:04:32 +00:00
Alexandre Oliva
cf54619a8e [Ada] Document control flow redundancy
Add documentation about -fharden-control-flow-redundancy.

gcc/ada/

	* doc/gnat_rm/security_hardening_features.rst: Add subsection on
	Control Flow Redundancy.
	* gnat_rm.texi: Regenerate.
2022-05-13 08:04:31 +00:00
Eric Botcazou
0145570e89 [Ada] Fix compiler crash on FOR iteration scheme over container
The front-end drops a freeze node on the floor because it puts the node
into the Condition_Actions of an N_Iteration_Scheme of a FOR loop.

gcc/ada/

	* exp_util.adb (Insert_Actions) <N_Iteration_Scheme>: Check that
	it is a WHILE iteration scheme before using Condition_Actions.
2022-05-13 08:04:30 +00:00
Piotr Trojanek
83bacaa9b5 [Ada] Remove obsolete uses of Unchecked_Conversion from Ada 83
Similar to a recent removal of obsolete uses of Unchecked_Deallocation.

In Ada 83 the Unchecked_Conversion was a top-level unit; since Ada 95 it
is an obsolete renaming of Ada.Unchecked_Conversion. GNAT doesn't warn
yet about uses of these obsolete renamings, but it still seems better to
avoid them.

gcc/ada/

	* atree.adb, gen_il-gen.adb, osint.adb, set_targ.adb,
	sinput.adb, table.adb, treepr.adb, types.ads: Replace uses of
	Unchecked_Conversion in the compiler itself.
	* libgnarl/a-reatim.adb, libgnarl/s-osinte__gnu.ads,
	libgnarl/s-osinte__kfreebsd-gnu.ads, libgnat/a-coboho.adb,
	libgnat/a-stuten.ads, libgnat/s-putima.adb: Likewise in the
	runtime.
	* doc/gnat_ugn/gnat_and_program_execution.rst: Likewise in
	documentation.
	* gnat_ugn.texi: Regenerate.
2022-05-13 08:04:30 +00:00
Piotr Trojanek
cb50998584 [Ada] Remove obsolete uses of Unchecked_Deallocation from Ada 83
In Ada 83 the Unchecked_Deallocation was a top-level unit; since Ada 95
it is an obsolete renaming of Ada.Unchecked_Deallocation. GNAT doesn't
yet warn about uses of these obsolete renamings, but it still seems
better to avoid them.

Cleanup before adding a new instance of Unchecked_Deallocation.
Offending occurrences found with grep.

gcc/ada/

	* butil.adb, sem.adb, sinput.adb, types.ads, xref_lib.adb:
	Replace uses of Unchecked_Deallocation with
	Ada.Unchecked_Deallocation.
	* doc/gnat_ugn/gnat_and_program_execution.rst: Likewise for the
	documentation; fix casing of GNAT.IO.
	* gnat_ugn.texi: Regenerate.
2022-05-13 08:04:29 +00:00
Marc Poulhiès
84f2013979 [Ada] Fix the Ada 2022 iterated component association RM reference
Fix the error message pointing to the Ada reference section on mixed
iterated component association being forbidden.  Remove useless loop.

gcc/ada/

	* sem_aggr.adb (Resolve_Array_Aggregate): Fix ARM reference.
	Remove useless loop.
2022-05-13 08:04:28 +00:00
Etienne Servais
9bea1bd335 [Ada] Fix typo on "that"
gcc/ada/

	* sem_ch3.adb (Analyze_Subtype_Declaration): Fix typo in
	comment.
2022-05-13 08:04:27 +00:00
Justin Squirek
fa45988cc0 [Ada] Spurious access error in function returning type with access discriminant
This patch fixes an issue in the compiler whereby incorrect
accessibility checks were generated in functions returning types with
unconstrained access discriminants when the value supplied for the
discriminant is a formal parameter.

More specifically, accessibility checks for return statements featuring
a result type having access discriminants were incorrectly being
performed against the level of the function declaration instead of the
level of the master of the call.

gcc/ada/

	* sem_ch6.adb (Check_Return_Construct_Accessibility): Modify
	generation of run-time accessibility checks to account for cases
	where Extra_Accessibility_Of_Result should be used versus the
	level of the enclosing subprogram. Use original node to avoid
	checking against expanded code. Disable check generation for
	tagged type case.
	(Is_Formal_Of_Current_Function): Added to encompass a predicate
	used within Check_Return_Construct_Accessibility to test if an
	associated expression is related to a relevant formal.
	* sem_util.adb, sem_util.ads (Enclosing_Subprogram): Modified to
	accept Node_Or_Entity_Id.
	(Innermost_Master_Scope_Depth): Calculate level based on the
	subprogram of a return statement instead of the one returned by
	Current_Subprogram.
	(Needs_Result_Accessibility_Level): Remove
	Disable_Coextension_Cases constant, and disable the tagged type
	case for performance reasons.
2022-05-13 08:04:27 +00:00
Piotr Trojanek
74ce1d5a6c [Ada] Accept effectively volatile components in actuals
In SPARK we forbid names that are effectively volatile for reading if
they occur in actual subprogram parameters. We wrongly rejected
references to components, which are not names in Ada.

gcc/ada/

	* sem_res.adb (Flag_Effectively_Volatile_Objects): Ignore
	component and discriminant identifiers.
2022-05-13 08:04:26 +00:00
Piotr Trojanek
7427e673d8 [Ada] Remove redundant guard in checks for volatile actuals
When flagging names of volatile objects occurring in actual parameters
we guard against identifiers without entity. This is redundant, because
earlier in the resolution of actual parameters we already guard against
actuals with Any_Type.

Code cleanup related to handling of volatile components; behaviour is
unaffected.

gcc/ada/

	* sem_res.adb (Flag_Effectively_Volatile_Objects): Remove
	redundant guard.
2022-05-13 08:04:25 +00:00
Justin Squirek
8a8366d496 [Ada] Ineffective use type clause warnings cause compile time crash
This patch corrects an error in the compiler whereby the presence of a
generic instance featuring a use type clause at library level may cause
a crash at compile time when warnings for ineffective use clauses are
enabled and the type in question is already use visible.

gcc/ada/

	* sem_ch8.adb (Determine_Package_Scope): Created to centralize
	the calculation of which package a given use clause belongs to.
	(Most_Descendant_Use_Clause): Modified to call
	Determine_Package_Scope.
	* sem_util.adb, sem_util.ads (Enclosing_Package): Modified to
	handle both entity and node ids.
2022-05-13 08:04:24 +00:00
Christophe Lyon
bac63f1ea9 testsuite: Make AArch64 attributes_7.c generate unique report lines.
This test is executed in both C and C++ modes, lines 98 and 100 pass
in C++ and are xfail in C.

This results in similar lines in gcc.sum and g++.sum, differing by the
PASS or XFAIL prefix, which confuses compare_test: it reports these
tests twice, as "now fail, but worked before" and "now work, but
didn't before". To make the diagnostic different betweek C and C++, I
use $tool in the dg-error comment field.

2022-05-13  Christophe Lyon  <christophe.lyon@arm.com>

	gcc/testsuite/
	* gcc.target/aarch64/sve/acle/general/attributes_7.c: Make
	diagnostic unique.
2022-05-13 10:03:05 +02:00
Richard Biener
ba2068893c Make gimple_build main workers more flexible
The following makes the main gimple_build API take a
gimple_stmt_iterator, whether to insert before or after and
an iterator update argument to make it more convenient to use
in certain situations (see the tree-vect-generic.cc hunks for
an example).  It also makes the case we insert into the IL
somewhat distinct from inserting into a standalone sequence in
that it simplifies built expressions the same way as inserting
and calling fold_stmt (..., follow_all_ssa_edges) would.  When
inserting into a standalone sequence we restrict simplification
to defs within the currently building sequence.

The patch only amends the tree_code gimple_build API, I will
followup with converting the rest as well.  The patch got larger
than intended because the template forwarders now use gsi_last
which introduces a dependency on gimple-iterator.h requiring
mass #include re-org across the tree.  There are two frontend
specific files including gimple-fold.h just for some padding
clearing stuff - I've removed the include and instead moved
the declarations to fold-const.h (but not the implementations).
Otherwise I'd have to include half of the middle-end headers in
those files which I didn't much like.

2022-05-12  Richard Biener  <rguenther@suse.de>

gcc/cp/
	* constexpr.cc: Remove gimple-fold.h include.

gcc/c-family/
	* c-omp.cc: Remove gimple-fold.h include.

gcc/analyzer/
	* supergraph.cc: Re-order gimple-fold.h include.

gcc/
	* gimple-fold.cc (gimple_build): Adjust for new
	main API.
	* gimple-fold.h (gimple_build): New main APIs with
	iterator, insert direction and iterator update.
	(gimple_build): New forwarder template.
	(clear_padding_type_may_have_padding_p): Remove.
	(clear_type_padding_in_mask): Likewise.
	(arith_overflowed_p): Likewise.
	* fold-const.h (clear_padding_type_may_have_padding_p): Declare.
	(clear_type_padding_in_mask): Likewise.
	(arith_overflowed_p): Likewise.
	* tree-vect-generic.cc (gimplify_build3): Use main gimple_build API.
	(gimplify_build2): Likewise.
	(gimplify_build1): Likewise.
	* ubsan.cc (ubsan_expand_ptr_ifn): Likewise, avoid extra
	compare stmt.
	* gengtype.cc (open_base_files): Re-order includes.
	* builtins.cc: Re-order gimple-fold.h include.
	* calls.cc: Likewise.
	* cgraphbuild.cc: Likewise.
	* cgraphunit.cc: Likewise.
	* config/rs6000/rs6000-builtin.cc: Likewise.
	* config/rs6000/rs6000-call.cc: Likewise.
	* config/rs6000/rs6000.cc: Likewise.
	* config/s390/s390.cc: Likewise.
	* expr.cc: Likewise.
	* fold-const.cc: Likewise.
	* function-tests.cc: Likewise.
	* gimple-match-head.cc: Likewise.
	* gimple-range-fold.cc: Likewise.
	* gimple-ssa-evrp-analyze.cc: Likewise.
	* gimple-ssa-evrp.cc: Likewise.
	* gimple-ssa-sprintf.cc: Likewise.
	* gimple-ssa-warn-access.cc: Likewise.
	* gimplify.cc: Likewise.
	* graphite-isl-ast-to-gimple.cc: Likewise.
	* ipa-cp.cc: Likewise.
	* ipa-devirt.cc: Likewise.
	* ipa-prop.cc: Likewise.
	* omp-low.cc: Likewise.
	* pointer-query.cc: Likewise.
	* range-op.cc: Likewise.
	* tree-cfg.cc: Likewise.
	* tree-if-conv.cc: Likewise.
	* tree-inline.cc: Likewise.
	* tree-object-size.cc: Likewise.
	* tree-ssa-ccp.cc: Likewise.
	* tree-ssa-dom.cc: Likewise.
	* tree-ssa-forwprop.cc: Likewise.
	* tree-ssa-ifcombine.cc: Likewise.
	* tree-ssa-loop-ivcanon.cc: Likewise.
	* tree-ssa-math-opts.cc: Likewise.
	* tree-ssa-pre.cc: Likewise.
	* tree-ssa-propagate.cc: Likewise.
	* tree-ssa-reassoc.cc: Likewise.
	* tree-ssa-sccvn.cc: Likewise.
	* tree-ssa-strlen.cc: Likewise.
	* tree-ssa.cc: Likewise.
	* value-pointer-equiv.cc: Likewise.
	* vr-values.cc: Likewise.

gcc/testsuite/
	* gcc.dg/plugin/diagnostic_group_plugin.c: Reorder or remove
	gimple-fold.h include.
	* gcc.dg/plugin/diagnostic_plugin_show_trees.c:
	Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_inlining.c:
	Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_metadata.c:
	Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_paths.c:
	Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c:
	Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c:
	Likewise.
	* gcc.dg/plugin/finish_unit_plugin.c: Likewise.
	* gcc.dg/plugin/ggcplug.c: Likewise.
	* gcc.dg/plugin/must_tail_call_plugin.c: Likewise.
	* gcc.dg/plugin/one_time_plugin.c: Likewise.
	* gcc.dg/plugin/selfassign.c: Likewise.
	* gcc.dg/plugin/start_unit_plugin.c: Likewise.
	* g++.dg/plugin/selfassign.c: Likewise.
2022-05-13 08:18:33 +02:00
Alexandre Oliva
90a8eab4a1 [PR105455] Set edge probabilities when hardening conditionals
When turning unconditional edges into conditional, as in
gimple-harden-conditionals.cc:insert_check_and_trap, the newly-created
edge's probability comes out uninitialized, while the previously
unconditional edge's probability is presumably
profile_probability::always.

Mixing initialized and uninitialized probabilities before expand
breaks predict.cc:force_edge_cold: the initialized probability may end
up copied to a REG_BR_PROB note in a conditional branch insn, but if
force_edge_cold is called on that edge, it will find another edge with
uninitialized probability and assume the note is absent.  Later on,
rtl_verify_edges complains that the note does not match the
probability modified by force_edge_cold in the edge.

This patch sets probabilities for edges affected by hardening of
conditionals, both the newly-created edges to trap blocks and the
previously-unconditional edges, so that the former are considered
never taken, while the latter are confirmed as always taken.


for  gcc/ChangeLog

	PR rtl-optimization/105455
	* gimple-harden-conditionals.cc (insert_check_and_trap): Set
	probabilities for newly-conditional edges.

for  gcc/testsuite/ChangeLog

	PR rtl-optimization/105455
	* gcc.dg/pr105455.c: New.
2022-05-13 03:00:29 -03:00
liuhongt
8ab4b48415 Strip of a vector load which is only used partially.
Optimize

  _4 = VEC_PERM_EXPR <_1, _1, { 4, 5, 6, 7, 4, 5, 6, 7 }>;
  _5 = BIT_FIELD_REF <_4, 128, 0>;

to

  _5 = BIT_FIELD_REF <_1, 128, 128>;

gcc/ChangeLog:

	PR tree-optimization/102583
	* tree-ssa-forwprop.cc (simplify_bitfield_ref): Extended to a
	contiguous stride in the VEC_PERM_EXPR.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr102583.c: New test.
	* gcc.target/i386/pr92645-2.c: Adjust testcase.
	* gcc.target/i386/pr92645-3.c: Ditto.
2022-05-13 09:02:48 +08:00
GCC Administrator
49ace834ab Daily bump. 2022-05-13 00:16:30 +00:00
Patrick Palka
3e948d645b c++: tighten TMPL_ARGS_LEVEL macro
This patch makes TMPL_ARGS_LEVEL verify the level argument is valid when
the one-dimensional vector case.  Doing so uncovered a couple of latent
issues: in try_class_unification, we weren't correctly copying targs
when it's two-dimensional, and in unify_pack_expansion it seems an
inequality test needs to be reversed.  This patch fixes both issues, and
in passing makes the former function free the temporary copy of targs.

gcc/cp/ChangeLog:

	* cp-tree.h (TMPL_ARGS_LEVEL): Assert LEVEL is 1 when
	TMPL_ARGS_HAVE_MULTIPLE_LEVELS is false.
	* pt.cc (try_class_unification): Correctly copy multidimensional
	targs.  Free the copy of targs.
	(unify_pack_expansion): Fix level comparison.
2022-05-12 16:52:06 -04:00
David Edelsohn
995060aa5e testsuite: PPC vector double requires VSX
pr101168.C uses __vector double, which requires VSX, not just Altivec.
This patch invokes the testcase with the -mvsx option.

	* g++.target/powerpc/pr101168.C: Require VSX.
2022-05-12 14:51:30 -04:00
Jonathan Wakely
a0080f0285 libstdc++: Remove whitespace before preprocessor directives
These are harmless, but also unnecessary and inconsistent (and their
removal was requested by PR libstdc++/17632).

libstdc++-v3/ChangeLog:

	* config/locale/dragonfly/numeric_members.cc: Remove whitespace.
	* config/locale/gnu/numeric_members.cc: Likewise.
	* include/bits/locale_facets_nonio.h: Likewise.
	* libsupc++/typeinfo: Likewise.
2022-05-12 18:04:01 +01:00
Thomas Schwinge
dcc266796a Refactor '-ldl' handling for libgomp proper and plugins
Instead of implicit global 'LIBS="-ldl $LIBS"' via 'AC_CHECK_LIB', make
'-ldl' explicit for libgomp proper, and clean up 'PLUGIN_GCN_LIBS',
'PLUGIN_NVPTX_LIBS' accordingly.

	libgomp/
	* Makefile.am (libgomp_la_LIBADD): Initialize.
	* plugin/configfrag.ac (DL_LIBS): New.
	(PLUGIN_GCN_LIBS): Remove.
	(PLUGIN_NVPTX_LIBS): Don't set in the 'PLUGIN_NVPTX_DYNAMIC' case.
	* plugin/Makefrag.am (libgomp_la_LIBADD)
	(libgomp_plugin_gcn_la_LIBADD): Consider '$(DL_LIBS)'.
	(libgomp_plugin_nvptx_la_LIBADD) <PLUGIN_NVPTX_DYNAMIC>: Likewise.
	* Makefile.in: Regenerate.
	* config.h.in: Likewise.
	* configure: Likewise.
	* testsuite/Makefile.in: Likewise.
2022-05-12 15:11:30 +02:00
Richard Biener
dfda40f814 rtl-optimization/105577 - RTL DSE and non-call EH
When one of the first two stages of DSE removes a throwing stmt
we have to purge dead EH edges before the DF re-analyze fires off
a fast DCE since that cannot cope with the situation.

2022-05-12  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/105577
	* dse.cc (rest_of_handle_dse): Make sure to purge dead EH
	edges before running fast DCE via df_analyze.
2022-05-12 15:05:45 +02:00
Piotr Trojanek
c4471a4a3c [Ada] Skip postponed validation checks with compilation errors
If there are compilation errors then gigi doesn't backannotate the AST
with sizes, alignment, etc. The postponed compilation validation checks
can then easily crash or give spurious errors. We now just skip them.

gcc/ada/

	* gnat1drv.adb (Gnat1drv): Skip postponed checks when there are
	errors.
2022-05-12 12:38:42 +00:00