Thomas Schwinge [Tue, 10 May 2022 13:56:08 +0000 (15:56 +0200)]
Advise to call 'internal_error' instead of 'abort' or 'fancy_abort'
gcc/
* diagnostic.cc: Don't advise to call 'abort' instead of
'internal_error'.
* system.h: Advise to call 'internal_error' instead of 'abort' or
'fancy_abort'.
Suggested-by: Richard Biener <richard.guenther@gmail.com>
Frederik Harwath [Tue, 17 May 2022 14:02:01 +0000 (16:02 +0200)]
graphite: Fix minor mistakes in comments
gcc/ChangeLog:
* graphite-sese-to-poly.cc (build_poly_sr_1): Fix a typo and
a reference to a variable which does not exist.
* graphite-isl-ast-to-gimple.cc (gsi_insert_earliest): Fix typo
in comment.
Frederik Harwath [Tue, 17 May 2022 14:00:57 +0000 (16:00 +0200)]
graphite: Rename isl_id_for_ssa_name
The SSA names for which this function gets used are always SCoP
parameters and hence "isl_id_for_parameter" is a better name. It also
explains the prefix "P_" for those names in the ISL representation.
gcc/ChangeLog:
* graphite-sese-to-poly.cc (isl_id_for_ssa_name): Rename to ...
(isl_id_for_parameter): ... this new function name.
(build_scop_context): Adjust function use.
Tobias Burnus [Tue, 17 May 2022 13:52:24 +0000 (15:52 +0200)]
libgomp.texi: Document OpenMP context selectors
libgomp/
* libgomp.texi (Offload-Target Specifics): New chapter; add section
to document OpenMP context selectors.
Tobias Burnus [Tue, 17 May 2022 13:48:40 +0000 (15:48 +0200)]
gcn/t-omp-device: Add 'amdgcn' as 'arch' [PR105602]
Improve cross-compiler handling.
gcc/ChangeLog:
PR target/105602
* config/gcn/t-omp-device (arch): Add 'amdgcn' besides existing 'gcn'.
* config/gcn/gcn.cc (gcn_omp_device_kind_arch_isa): Likewise.
Jakub Jelinek [Tue, 17 May 2022 13:40:27 +0000 (15:40 +0200)]
openmp: Add support for inoutset depend-kind
This patch adds support for inoutset depend-kind in depend
clauses. It is very similar to the in depend-kind in that
a task with a dependency with that depend-kind is dependent
on all previously created sibling tasks with matching address
unless they have the same depend-kind.
In the in depend-kind case everything is dependent except
for in -> in dependency, for inoutset everything is
dependent except for inoutset -> inoutset dependency.
mutexinoutset is also similar (everything is dependent except
for mutexinoutset -> mutexinoutset dependency), but there is
also the additional restriction that only one task with
mutexinoutset for each address can be scheduled at once (i.e.
mutual exclusitivty). For now we support mutexinoutset
the same as inout/out, but the inoutset support is full.
In order not to bump the ABI for dependencies each time
(we've bumped it already once, the old ABI supports only
inout/out and in depend-kind, the new ABI supports
inout/out, mutexinoutset, in and depobj), this patch arranges
for inoutset to be at least for the time being always handled
as if it was specified through depobj even when it is not.
So it uses the new ABI for that and inoutset are represented
like depobj - pointer to a pair of pointers where the first one
will be the actual address of the object mentioned in depend
clause and second pointer will be (void *) GOMP_DEPEND_INOUTSET.
2022-05-17 Jakub Jelinek <jakub@redhat.com>
gcc/
* tree-core.h (enum omp_clause_depend_kind): Add
OMP_CLAUSE_DEPEND_INOUTSET.
* tree-pretty-print.cc (dump_omp_clause): Handle
OMP_CLAUSE_DEPEND_INOUTSET.
* gimplify.cc (gimplify_omp_depend): Likewise.
* omp-low.cc (lower_depend_clauses): Likewise.
gcc/c-family/
* c-omp.cc (c_finish_omp_depobj): Handle
OMP_CLAUSE_DEPEND_INOUTSET.
gcc/c/
* c-parser.cc (c_parser_omp_clause_depend): Parse
inoutset depend-kind.
(c_parser_omp_depobj): Likewise.
gcc/cp/
* parser.cc (cp_parser_omp_clause_depend): Parse
inoutset depend-kind.
(cp_parser_omp_depobj): Likewise.
* cxx-pretty-print.cc (cxx_pretty_printer::statement): Handle
OMP_CLAUSE_DEPEND_INOUTSET.
gcc/testsuite/
* c-c++-common/gomp/all-memory-1.c (boo): Add test with
inoutset depend-kind.
* c-c++-common/gomp/all-memory-2.c (boo): Likewise.
* c-c++-common/gomp/depobj-1.c (f1): Likewise.
(f2): Adjusted expected diagnostics.
* g++.dg/gomp/depobj-1.C (f4): Adjust expected diagnostics.
include/
* gomp-constants.h (GOMP_DEPEND_INOUTSET): Define.
libgomp/
* libgomp.h (struct gomp_task_depend_entry): Change is_in type
from bool to unsigned char.
* task.c (gomp_task_handle_depend): Handle GOMP_DEPEND_INOUTSET.
Ignore dependencies where
task->depend[i].is_in && task->depend[i].is_in == ent->is_in
rather than just task->depend[i].is_in && ent->is_in. Remember
whether GOMP_DEPEND_IN loop is needed and guard the loop with that
conditional.
(gomp_task_maybe_wait_for_dependencies): Handle GOMP_DEPEND_INOUTSET.
Ignore dependencies where elem.is_in && elem.is_in == ent->is_in
rather than just elem.is_in && ent->is_in.
* testsuite/libgomp.c-c++-common/depend-1.c (test): Add task with
inoutset depend-kind.
* testsuite/libgomp.c-c++-common/depend-2.c (test): Likewise.
* testsuite/libgomp.c-c++-common/depend-3.c (test): Likewise.
* testsuite/libgomp.c-c++-common/depend-inoutset-1.c: New test.
Jonathan Wakely [Tue, 17 May 2022 08:32:36 +0000 (09:32 +0100)]
libstdc++: Skip tests that fail for the versioned namespace
Most tests for the contents of header synopses need to be supressed for
the versioned namespace build, because redeclaring the entities in std
fails when they were originally declared in std::__8.
I added these tests recently without the suppression, so they fail.
libstdc++-v3/ChangeLog:
* testsuite/20_util/expected/synopsis.cc: Skip for versioned
namespace.
* testsuite/27_io/headers/iosfwd/synopsis.cc: Likewise.
Jonathan Wakely [Mon, 16 May 2022 15:54:52 +0000 (16:54 +0100)]
libstdc++: Stop defining C++0x compat symbols for versioned namespace
The src/c++11/compatibility*-c++0x.cc files define symbols that need to
be exported for ancient versions of libstdc++.so.6 due to changes
between C++0x and the final C++11 standard. Those symbols are not needed
in the libstdc++.so.8 library, and we can skip building them entirely.
This also fixes the build failure I introduced last week when making the
versioned namespace config not use the _V2 namespace for compat symbols.
libstdc++-v3/ChangeLog:
* src/Makefile.am [ENABLE_SYMVERS_GNU_NAMESPACE] (cxx11_sources):
Do not build the compatibility*-c++0x.cc objects.
* src/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc [_GLIBCXX_INLINE_VERSION]:
Refuse to build for the versioned namespace.
* src/c++11/compatibility-chrono.cc: Likewise.
* src/c++11/compatibility-condvar.cc: Likewise.
* src/c++11/compatibility-thread-c++0x.cc: Likewise.
* src/c++11/chrono.cc (system_clock, steady_clock):
Use macros to define in inline namespace _V2, matching the
declarations in <system_error>.
* src/c++11/system_error.cc (system_category, generic_category):
Likewise.
Tobias Burnus [Tue, 17 May 2022 10:02:37 +0000 (12:02 +0200)]
libgomp.texi: Add OpenMP 5.2 implementation status
libgomp/
* libgomp.texi (OpenMP Implementation Status): Add 5.2 table.
Jakub Jelinek [Tue, 17 May 2022 10:10:30 +0000 (12:10 +0200)]
i386: Fix up V2DI and V1TI inequality comparisons [PR105613]
The recent r13-458 change to introduce vec_cmpeqv1tiv1ti and
add TARGET_SSE2 support to vec_cmpeqv2div2di works nicely for
equality comparisons, but as the testcase shows doesn't work
for inequality comparisons.
For EQ if we perform comparison with twice as many half-sized elemenets,
the result should be ~0 when both halves are ~0 only (both halves need
to be equal for the whole to be equal), otherwise 0, so AND is the
correct operation for it.
But for NE, the result should be ~0 when either of the halves is ~0
(if either half is not equal, the whole is not equal) and so the right
operation for NE is IOR, not AND.
2022-05-17 Jakub Jelinek <jakub@redhat.com>
PR target/105613
* config/i386/sse.md (vec_cmpeqv2div2di, vec_cmpeqv1tiv1ti): Use
andv4si3 only for EQ, for NE use iorv4si3 instead.
* gcc.c-torture/execute/pr105613.c: New test.
Tobias Burnus [Tue, 17 May 2022 09:01:04 +0000 (11:01 +0200)]
OpenMP: Add omp_all_memory support to Fortran
Fortran part to the C/C++/backend implementation
r13-337-g7f78783dbedca0183d193e475262ca3c489fd365
gcc/fortran/ChangeLog:
* dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory.
* openmp.cc (gfc_match_omp_variable_list, gfc_match_omp_depend_sink,
gfc_match_omp_clauses, resolve_omp_clauses): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj):
Likewise.
* resolve.cc (resolve_symbol): Reject it as symbol.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.1): Set omp_all_memory to 'Y'.
* testsuite/libgomp.fortran/depend-5.f90: New test.
* testsuite/libgomp.fortran/depend-6.f90: New test.
* testsuite/libgomp.fortran/depend-7.f90: New test.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/all-memory-1.f90: New test.
* gfortran.dg/gomp/all-memory-2.f90: New test.
* gfortran.dg/gomp/all-memory-3.f90: New test.
Richard Biener [Tue, 17 May 2022 07:45:02 +0000 (09:45 +0200)]
tree-optimization/105618 - restore load sinking
The PR97330 fix caused some missed sinking of loads out of loops
the following patch re-instantiates.
2022-05-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/105618
* tree-ssa-sink.cc (statement_sink_location): For virtual
PHI uses ignore those defining the used virtual operand.
* gcc.dg/tree-ssa/ssa-sink-19.c: New testcase.
Piotr Trojanek [Wed, 30 Mar 2022 10:00:20 +0000 (12:00 +0200)]
[Ada] Restore defensive guard in checks for volatile actuals
When flagging names of volatile objects occurring in actual parameters
it is safer to guard against identifiers without entity. This is
redundant (because earlier in the resolution of actual parameters we
already guard against actuals with Any_Type), but perhaps such
identifiers will become allowed in constructs like:
Subprogram_Call
(Actual =>
(declare
X : Boolean := ...
with Annotate (GNATprove, ...)));
^^^^^^^^^
which include an identifier that does not denote any entity.
Code cleanup related to handling of volatile components; behaviour is
unaffected.
gcc/ada/
* sem_res.adb (Flag_Effectively_Volatile_Objects): Restore
redundant guard.
Gary Dismukes [Mon, 28 Mar 2022 23:15:30 +0000 (19:15 -0400)]
[Ada] Subprogram renaming fails to hide homograph
The compiler failed to detect an error where the first prefix of an
expanded name given as the renamed subprogram in a subprogram renaming
declaration denotes a unit with the same name as the name given for the
subprogram renaming. Such a unit must be hidden by the renaming itself.
An error check is added to catch this case.
gcc/ada/
* sem_ch8.adb (Analyze_Subprogram_Renaming): Add error check for
the case of a renamed subprogram given by an expanded name whose
outermost prefix names a unit that is hidden by the name of the
renaming.
(Ult_Expanded_Prefix): New local expression function to return
the ultimate prefix of an expanded name.
Ghjuvan Lacambre [Mon, 28 Mar 2022 14:40:46 +0000 (16:40 +0200)]
[Ada] CUDA: remove code performing kernel registration
A previous commit implemented a new kernel registration scheme, using
the binder to generate registration code rather than inserting
registration code in packages. Now that this new approach has had time
to be thoroughly tested, it is time to remove the old approach.
gcc/ada/
* gnat_cuda.ads: Update package-level comments.
(Build_And_Insert_CUDA_Initialization): Remove function.
* gnat_cuda.adb (Build_And_Insert_CUDA_Initialization): Remove
function.
(Expand_CUDA_Package): Remove call to
Build_And_Insert_CUDA_Initialization.
Etienne Servais [Tue, 15 Feb 2022 16:59:10 +0000 (17:59 +0100)]
[Ada] Enhance the warning on C enum with size clause for size /= 32
Improve the warning message and silence warning when size > 32, this is
likely intentional and does not warrant a warning.
gcc/ada/
* freeze.adb (Freeze_Enumeration_Type): Fix comment, enhance
message and silence warning for size > 32.
Yannick Moy [Fri, 11 Mar 2022 10:19:37 +0000 (11:19 +0100)]
[Ada] Allow inlining for proof inside generics
For local subprograms without contracts inside generics, allow their
inlining for proof in GNATprove mode. This requires forbidding the
inlining of subprograms which contain references to object renamings,
which would be replaced in the SPARK expansion and violate assumptions
of the inlining code.
gcc/ada/
* exp_spark.adb (Expand_SPARK_Potential_Renaming): Deal with no
entity case.
* inline.ads (Check_Object_Renaming_In_GNATprove_Mode): New
procedure.
* inline.adb (Check_Object_Renaming_In_GNATprove_Mode): New
procedure.
(Can_Be_Inlined_In_GNATprove_Mode): Remove case forbidding
inlining for subprograms inside generics.
* sem_ch12.adb (Copy_Generic_Node): Preserve global entities
when inlining in GNATprove mode.
* sem_ch6.adb (Analyse_Subprogram_Body_Helper): Remove body to
inline if renaming is detected in GNATprove mode.
Gary Dismukes [Fri, 25 Mar 2022 16:56:24 +0000 (12:56 -0400)]
[Ada] Provide allocation subtype for allocators of a Designated_Storage_Model type
When an allocator is for an access type that has a
Designated_Storage_Model aspect, and the designated type is an
unconstrained record type with discriminants, and the subtype associated
with the allocator is constrained, a dereference of the new access value
can be passed to the designated type's initialization procedure. The
post-front-end phase of the compiler needs to be able to create a
temporary object in the host memory space to pass to the init proc,
which requires creating such an object, but the subtype needed for the
allocation isn't readily available at the point of the dereference. To
make the subtype easily accessible, we set the Actual_Designated_Subtype
of such a dereference to the subtype of the allocated object.
gcc/ada/
* exp_ch4.adb (Expand_N_Allocator): For an allocator with an
unconstrained discriminated designated type, and whose
allocation subtype is constrained, set the
Actual_Designated_Subtype of the dereference passed to the init
proc of the designated type to be the allocation subtype.
* sinfo.ads: Add documentation of new setting of
Actual_Designated_Subtype on a dereference used as an actual
parameter of call to an init proc associated with an allocator.
Also add missing syntax and documentation for the GNAT language
extension that allows an expression as a default for a concrete
generic formal function.
Bob Duff [Fri, 25 Mar 2022 14:23:08 +0000 (10:23 -0400)]
[Ada] Cleanups related to front-end SJLJ
This patch cleans up some code that is left over from the front-end SJLJ
exception handling mechanism, which has been removed.
This is in preparation for fixing a finalization-related bug.
Most importantly:
The documentation is changed: a Handled_Sequence_Of_Statements node
CAN contain both Exception_Handlers and an At_End_Proc.
The assertion contradicting that is removed from
Expand_At_End_Handler.
The From_At_End field is removed.
gcc/ada/
* sinfo.ads: Remove From_At_End. Update comments.
* gen_il-fields.ads, gen_il-gen-gen_nodes.adb, sem_ch11.adb:
Remove From_At_End.
* exp_ch11.adb (Expand_At_End_Handler): Remove assertion.
* fe.h (Exception_Mechanism, Exception_Mechanism_Type, Has_DIC,
Has_Invariants, Is_List_Member, List_Containing): Remove
declarations that are not used in gigi.
* opt.ads (Exception_Mechanism): This is not used in gigi.
* exp_util.ads: Minor comment fix.
Dmitriy Anisimkov [Thu, 24 Mar 2022 06:49:56 +0000 (12:49 +0600)]
[Ada] GNAT.Binary_Search is not internal
Put package GNAT.Binary_Search to predefined units list.
gcc/ada/
* impunit.adb: Add "g-binsea" to Non_Imp_File_Names_95 list.
Yannick Moy [Fri, 18 Mar 2022 16:33:25 +0000 (17:33 +0100)]
[Ada] Fix insertion of declaration inside quantified expression
When the evaluation of the subtype_indication for the
iterator_specification of a quantified_expression leads to the insertion
of a type declaration, this should be done with Insert_Action instead of
Insert_Before.
gcc/ada/
* sem_ch5.adb (Analyze_Iterator_Specification): Use
Insert_Action when possibly inside an expression.
Marc Poulhiès [Tue, 22 Mar 2022 09:08:46 +0000 (10:08 +0100)]
[Ada] Fix Forced sign flag in formatted string
Fix the Forced sign flag that is incorrectly ignored for scientific
notation and shortest representation.
gcc/ada/
* libgnat/g-forstr.adb (Is_Number): Add scientific notation and
shortest representation.
Eric Botcazou [Wed, 23 Mar 2022 22:47:06 +0000 (23:47 +0100)]
[Ada] Fix small glitch in Expand_N_Full_Type_Declaration
The original node is not guaranteed to also be an
N_Full_Type_Declaration, so the code needs to look into the node itself.
gcc/ada/
* exp_ch3.adb (Expand_N_Full_Type_Declaration): Look into N.
Bob Duff [Wed, 23 Mar 2022 18:04:22 +0000 (14:04 -0400)]
[Ada] Requires_Cleanup_Actions and N_Protected_Body
This patch disallows N_Protected_Body from being passed to
Requires_Cleanup_Actions. Protected bodies never need cleanup, and are
never passed to Requires_Cleanup_Actions, which is a good thing, because
it would blow up on Handled_Statement_Sequence, which doesn't exist for
N_Protected_Body.
gcc/ada/
* exp_util.adb (Requires_Cleanup_Actions): Remove
N_Protected_Body from the case statement, so that case will be
covered by "raise Program_Error".
Bob Duff [Wed, 23 Mar 2022 14:27:44 +0000 (10:27 -0400)]
[Ada] Output.w always writes to stderr
There are several debugging procedures called Output.w, and some
output-redirection features. This patch modifies Output.w so their
output is not redirected; it always goes to standard error. Otherwise,
debugging output can get mixed in with some "real" output (perhaps to a
file), which causes confusion and in some cases failure to build.
gcc/ada/
* output.adb (Pop_Output, Set_Output): Unconditionally flush
output when switching from one output destination to another.
Otherwise buffering can cause garbled output.
(w): Push/pop the current settings, and temporarily
Set_Standard_Error during these procedures.
Dmitriy Anisimkov [Wed, 9 Mar 2022 04:31:48 +0000 (10:31 +0600)]
[Ada] Generic binary search implementation
Allows binary search in sorted anonymous array (or array-like
container).
gcc/ada/
* libgnat/g-binsea.ads, libgnat/g-binsea.adb
(GNAT.Binary_Search): New package.
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): New item in list.
* doc/gnat_rm/the_gnat_library.rst (GNAT.Binary_Search): New
package record.
* gnat_rm.texi: Regenerate.
Eric Botcazou [Thu, 17 Mar 2022 18:05:10 +0000 (19:05 +0100)]
[Ada] Fix bogus visibility error with partially parameterized formal package
The problem comes from the special instantiation (abbreviated instantiation
in GNAT parlance) done to check conformance between a formal package and its
corresponding actual in a generic instantiation: the compiler instantiates
the formal package, in the context of the generic instantiation, so that it
can check the conformance of the actual with the result.
More precisely, it occurs with formal packages that are only partially
parameterized, i.e. that have at least one parameter association and an
(others => <>) choice. In this case, RM 12.7(10/2) says that the visible
part of the formal package contains a copy of the formal parameters that
are not explicitly associated.
The analysis of these copies for the abbreviated instantiation is not done
in the correct context when the generic unit is a child generic unit.
gcc/ada/
* sem_ch12.ads (Is_Abbreviated_Instance): Declare.
* sem_ch12.adb (Check_Abbreviated_Instance): Declare.
(Requires_Conformance_Checking): Declare.
(Analyze_Association.Process_Default): Fix subtype of parameter.
(Analyze_Formal_Object_Declaration): Check whether it is in the
visible part of abbreviated instance.
(Analyze_Formal_Subprogram_Declaration): Likewise.
(Analyze_Formal_Type_Declaration): Likewise.
(Analyze_Package_Instantiation): Do not check for a generic child
unit in the case of an abbreviated instance.
(Check_Abbreviated_Instance): New procedure.
(Check_Formal_Packages): Tidy up.
(Copy_Generic_Elist): Fix comment.
(Instantiate_Formal_Package): Tidy up. If the generic unit is a
child unit, copy the qualified name onto the abbreviated instance.
(Is_Abbreviated_Instance): New function.
(Collect_Previous_Instances): Call Is_Abbreviated_Instance.
(Requires_Conformance_Checking): New function.
* sem_ch7.adb (Analyze_Package_Specification): Do not install the
private declarations of the parent for an abbreviated instance.
Etienne Servais [Mon, 21 Feb 2022 15:32:46 +0000 (16:32 +0100)]
[Ada] Take full view of private type
This allows to resolve the following:
type Rec (<>) is private;
type Arr (<>) is private;
private
type Arr is array (Positive range <>) of Natural;
type Rec (L : Natural) is record
F1 : Integer;
F2 : Arr (1 .. L);
end record;
gcc/ada/
* sem_ch3.adb (Analyze_Subtype_Declaration): Use underlying type
of Indic_Typ.
(Constrain_Array): Ditto for T.
Arnaud Charlet [Sun, 20 Mar 2022 09:12:32 +0000 (09:12 +0000)]
[Ada] Allow 'Reduce with -gnat2022
After a period of experimentation, allow 'Reduce in Ada 2022 mode.
gcc/ada/
* sem_attr.adb (Analyze_Attribute [Attribute_Reduce]): Allow
'Reduce for Ada 2022 and above.
* sem_attr.ads (Attribute_Impl_Def): 'Reduce is no longer
implementation defined.
Ghjuvan Lacambre [Tue, 15 Mar 2022 09:57:45 +0000 (10:57 +0100)]
[Ada] Don't create calls to Abort_Undefer when not Abort_Allowed
Prevent creation of references to Abort_Undefer when aborts aren't
allowed. Another solution could have been an early return at
Expand_N_Asynchronous_Select's beginning, but this would break backends
that currently expect trees that do not contain any
N_Asynchronous_Selects in their AST (e.g. CodePeer).
gcc/ada/
* exp_ch9.adb (Expand_N_Asynchronous_Select): Don't generate
Abort_Undefers when not Abort_Allowed.
Marc Poulhiès [Fri, 18 Mar 2022 15:11:41 +0000 (16:11 +0100)]
[Ada] Typo fix in finalization comment
Add missing 's' and reformat the comment block.
gcc/ada/
* exp_ch7.adb: Fix typo.
Etienne Servais [Tue, 26 Oct 2021 15:00:24 +0000 (17:00 +0200)]
[Ada] Initialize Compiler_State to avoid Constraint_Error
When building gnat1 with `-gnatVa` as we do locally, rules like: `gcc -c
-gnatyM79 <any adb file with lines longer than 79>` will throw a
constraint error as `lib.compiler_state` is initialized by par.adb, ie
after scanning. Therefore any error_msg thrown during scanning will
perform this uninitialized read (which raises a Constraint_Error when
the compiler was compiled with `-gnatVa`).
Initialize this flag to `Parsing`.
gcc/ada/
* lib.ads: initialize `Compiler_State` to `Parsing`.
Eric Botcazou [Mon, 21 Mar 2022 07:35:53 +0000 (08:35 +0100)]
[Ada] Deal with derived record types in Has_Compatible_Representation
More precisely, untagged record types, as tagged record types are already
handled by the predicate. If the derived type has not been given its own
representation clause, then the representations are the same.
gcc/ada/
* sem_ch13.adb (Has_Compatible_Representation): Return true for
derived untagged record types without representation clause.
Eric Botcazou [Sun, 20 Mar 2022 17:01:04 +0000 (18:01 +0100)]
[Ada] Streamline implementation of Has_Compatible_Representation
The predicate is only concerned with the internal representation of types
and this representation is shared by the subtypes of a given type, so the
implementation can directly look into the (implementation) base types.
No functional changes.
gcc/ada/
* sem_ch13.ads (Has_Compatible_Representation): Minor tweaks.
* sem_ch13.adb (Has_Compatible_Representation): Look directly into
the (implementation) base types and simplifiy accordingly.
* exp_ch5.adb (Change_Of_Representation): Adjust.
* exp_ch6.adb (Expand_Actuals): Likewise.
Etienne Servais [Thu, 17 Feb 2022 10:40:46 +0000 (11:40 +0100)]
[Ada] Remove superfluous call to Original_Node
The function Same_Object starts by taking the Original_Node of its
arguments.
gcc/ada/
* sem_ch5.adb (Analyze_Assignment): Remove superfluous call to
Original_Node.
Javier Miranda [Sun, 20 Mar 2022 11:36:25 +0000 (11:36 +0000)]
[Ada] Crash freezing declaration that will raise constraint error
When the compiler is built with assertions enabled and processes the
following declarations:
type Vector_Boolean_Array is array (1 .. 10) of Boolean;
O2 : constant Vector_Boolean_Array := [for J in 2 => True];
The expression is rewritten by the frontend with an N_Raise_CE node,
which leads to an assertion error at the freezing point of the object
declaration.
gcc/ada/
* freeze.adb (Freeze_Entity): Protect the call to
Declaration_Node against entities of expressions replaced by the
frontend with an N_Raise_CE node.
Javier Miranda [Fri, 18 Mar 2022 19:28:52 +0000 (19:28 +0000)]
[Ada] Spurious error on subprogram with class-wide preconditions
gcc/ada/
* freeze.adb (Build_DTW_Spec): Do not inherit the not-overriding
indicator because the DTW wrapper overrides its wrapped
subprogram.
* contracts.ads (Make_Class_Precondition_Subps): Adding
documentation.
Eric Botcazou [Fri, 18 Mar 2022 23:23:39 +0000 (00:23 +0100)]
[Ada] Use Actions field of freeze nodes for subprograms
This has a couple of advantages: 1) the actions are analyzed with checks
disabled and 2) they are considered elaboration code by Sem_Elab.
gcc/ada/
* exp_ch13.adb (Expand_N_Freeze_Entity): Delete freeze nodes for
subprograms only if they have no actions.
* exp_ch6.adb (Freeze_Subprogram): Put the actions into the Actions
field of the freeze node instead of inserting them after it.
* sem_elab.adb (Is_SPARK_Semantic_Target): Fix typo in comment.
* gcc-interface/trans.cc (process_freeze_entity): Return early for
freeze nodes of subprograms with Interface_Alias set.
Javier Miranda [Tue, 15 Mar 2022 20:20:24 +0000 (13:20 -0700)]
[Ada] Implement calls to abstract subprograms in class-wide pre/post-conditions
In some special cases involving class-wide pre/post conditions, Ada
allows a non-dispatching call to an abstract function (which is usually
illegal). Fix a bug in the implementation of Ada's rules about the
run-time behavior of such a call. Thanks to Javier Miranda for producing
this patch.
gcc/ada/
* contracts.adb (Build_Call_Helper_Body): Improve handling of
the case of a (legal) non-dispatching call to an abstract
subprogram.
Piotr Trojanek [Wed, 16 Mar 2022 13:42:14 +0000 (14:42 +0100)]
[Ada] Fix documentation of using attribute Loop_Entry in pragmas
Attribute Loop_Entry was initially only allowed to appear in pragmas
Loop_Variant and Loop_Invariant. Then it was also allowed to appear in
pragmas Assert, Assert_And_Cut and Assume, but this change was not
reflected in the GNAT RM.
gcc/ada/
* doc/gnat_rm/implementation_defined_attributes.rst
(Loop_Entry): Mention pragmas Assert, Assert_And_Cut and Assume;
refill.
* gnat_rm.texi: Regenerate.
Etienne Servais [Wed, 16 Mar 2022 16:48:22 +0000 (17:48 +0100)]
[Ada] Check token to be "access", reject it if not
The parser skips the token without verifying it is indeed "access". So
any token is accepted.
gcc/ada/
* par-ch3.adb (P_Access_Type_Definition): Outputs an error if
token is not "access".
Piotr Trojanek [Wed, 16 Mar 2022 20:50:08 +0000 (21:50 +0100)]
[Ada] Enable current value propagation within pragma expressions
This patch fixes an odd incomplete optimization within pragma
expressions. For example, in this code:
X := True;
pragma Assert (X = True);
pragma Assert (X);
the first assertion was eliminated by the frontend (regardless of the
optimization switches), while the second assertion was only eliminated
by the backend and only with switch -O1 or similar.
The problem was that the current value propagation was disabled for
references immediately within pragma argument associations. This was
meant to avoid a crash when such a reference appears in pragma
Inspection_Point, but this wasn't a proper fix. The proper solution is
rather to not expand references in pragma Inspection_Point at all.
Actually, this expansion was enabled to avoid a yet another crash, when
the parameter of pragma Inspection_Point is a prival (i.e. a renaming of
private protected component). It turns out that none of these suspicious
problematic fixes is no longer necessary.
Cleanup related to fixes of current value propagation in expansion of
attribute Loop_Entry.
gcc/ada/
* exp_ch2.adb (Expand_Current_Value): Remove special case for
references immediately within pragma argument associations.
* exp_prag.adb (Expand_Pragma_Inspection_Point): Remove special
case for privals.
Jakub Jelinek [Tue, 17 May 2022 07:06:55 +0000 (09:06 +0200)]
forwprop: Fix a typo and comment formatting
When looking around the spot of the PR105591 fix, I've noticed a typo
and incorrectly formatted comment.
2022-05-17 Jakub Jelinek <jakub@redhat.com>
* tree-ssa-forwprop.cc (simplify_bitfield_ref): Spelling fix:
hanlde -> handle. Fix up comment formatting.
liuhongt [Fri, 13 May 2022 01:59:13 +0000 (09:59 +0800)]
Optimize vpermtiw/b to vpunpcklqdq for certain cases.
Assembly Optimization like:
- vmovq %xmm0, %xmm2
- vmovdqa .LC0(%rip), %xmm0
vmovq %xmm1, %xmm1
- vpermi2w %xmm1, %xmm2, %xmm0
+ vmovq %xmm0, %xmm0
+ vpunpcklqdq %xmm1, %xmm0, %xmm0
...
-.LC0:
- .value 0
- .value 1
- .value 2
- .value 3
- .value 8
- .value 9
- .value 10
- .value 11
gcc/ChangeLog:
PR target/105033
* config/i386/sse.md (*vec_concatv4si): Extend to ..
(*vec_concat<mode>): .. V16QI and V8HImode.
(*vec_concatv16qi_permt2): New pre_reload define_insn_and_split.
(*vec_concatv8hi_permt2): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr105033.c: New test.
liuhongt [Mon, 16 May 2022 01:06:04 +0000 (09:06 +0800)]
Clamp vec_perm_expr index in simplify_bitfield_ref to avoid ICE.
gcc/ChangeLog:
PR tree-optimization/105591
* tree-ssa-forwprop.cc (simplify_bitfield_ref): Clamp
vec_perm_expr index.
gcc/testsuite/ChangeLog:
* gcc.dg/pr105591.c: New test.
GCC Administrator [Tue, 17 May 2022 00:16:28 +0000 (00:16 +0000)]
Daily bump.
Jason Merrill [Thu, 5 May 2022 15:03:44 +0000 (11:03 -0400)]
attribs: fix typedefs in generic code [PR105492]
In my patch for PR100545 I added an assert to check for broken typedefs in
set_underlying_type, and it found one in this case:
rs6000_handle_altivec_attribute had the same problem as
handle_mode_attribute. So let's move the fixup into decl_attributes.
PR c/105492
gcc/ChangeLog:
* attribs.cc (decl_attributes): Fix broken typedefs here.
gcc/c-family/ChangeLog:
* c-attribs.cc (handle_mode_attribute): Don't fix broken typedefs
here.
David Malcolm [Mon, 16 May 2022 19:32:11 +0000 (15:32 -0400)]
analyzer: implement four new warnings for <stdarg.h> misuses [PR105103]
This patch adds support to the analyzer for checking usage of <stdarg.h>,
with four new warnings.
It adds:
(a) a state-machine for tracking "started" and "ended" states on va_list
instances, implementing two new warnings:
-Wanalyzer-va-list-leak
for complaining about missing va_end after a va_start or va_copy
-Wanalyzer-va-list-use-after-va-end:
for complaining about va_arg or va_copy used on a va_list that's had
va_end called on it
(b) interprocedural tracking of variadic parameters, tracking symbolic
values, implementing two new warnings:
-Wanalyzer-va-arg-type-mismatch
for type-checking va_arg usage against the types of the parameters
that were actually passed to the variadic call
-Wanalyzer-va-list-exhausted
for complaining if va_arg is used too many times on a va_list
Here's an LTO example of a type mismatch in a variadic call that
straddles two source files:
stdarg-lto-1-a.c: In function 'called_by_test_type_mismatch_1':
stdarg-lto-1-a.c:19:7: warning: 'va_arg' expected 'const char *' but
received 'int' for variadic argument 1 of 'ap' [-Wanalyzer-va-arg-type-mismatch]
19 | str = va_arg (ap, const char *);
| ^
'test_type_mismatch_1': events 1-2
|
|stdarg-lto-1-b.c:3:6:
| 3 | void test_type_mismatch_1 (void)
| | ^
| | |
| | (1) entry to 'test_type_mismatch_1'
| 4 | {
| 5 | called_by_test_type_mismatch_1 (42, 1066);
| | ~
| | |
| | (2) calling 'called_by_test_type_mismatch_1' from 'test_type_mismatch_1' with 1 variadic argument
|
+--> 'called_by_test_type_mismatch_1': events 3-4
|
|stdarg-lto-1-a.c:12:1:
| 12 | called_by_test_type_mismatch_1 (int placeholder, ...)
| | ^
| | |
| | (3) entry to 'called_by_test_type_mismatch_1'
|......
| 19 | str = va_arg (ap, const char *);
| | ~
| | |
| | (4) 'va_arg' expected 'const char *' but received 'int' for variadic argument 1 of 'ap'
|
gcc/ChangeLog:
PR analyzer/105103
* Makefile.in (ANALYZER_OBJS): Add analyzer/varargs.o.
* doc/invoke.texi: Add -Wanalyzer-va-arg-type-mismatch,
-Wanalyzer-va-list-exhausted, -Wanalyzer-va-list-leak, and
-Wanalyzer-va-list-use-after-va-end.
gcc/analyzer/ChangeLog:
PR analyzer/105103
* analyzer.cc (make_label_text_n): New.
* analyzer.h (class var_arg_region): New forward decl.
(make_label_text_n): New decl.
* analyzer.opt (Wanalyzer-va-arg-type-mismatch): New option.
(Wanalyzer-va-list-exhausted): New option.
(Wanalyzer-va-list-leak): New option.
(Wanalyzer-va-list-use-after-va-end): New option.
* checker-path.cc (call_event::get_desc): Split out decl access
into..
(call_event::get_caller_fndecl): ...this new function and...
(call_event::get_callee_fndecl): ...this new function.
* checker-path.h (call_event::get_desc): Drop "FINAL".
(call_event::get_caller_fndecl): New decl.
(call_event::get_callee_fndecl): New decl.
(class call_event): Make fields protected.
* diagnostic-manager.cc (null_assignment_sm_context::warn): New
overload.
(null_assignment_sm_context::get_new_program_state): New.
(diagnostic_manager::add_events_for_superedge): Move case
SUPEREDGE_CALL to a new pending_diagnostic::add_call_event vfunc.
* engine.cc (impl_sm_context::warn): Implement new override.
(impl_sm_context::get_new_program_state): New.
* pending-diagnostic.cc: Include "analyzer/diagnostic-manager.h",
"cpplib.h", "digraph.h", "ordered-hash-map.h", "cfg.h",
"basic-block.h", "gimple.h", "gimple-iterator.h", "cgraph.h"
"analyzer/supergraph.h", "analyzer/program-state.h",
"alloc-pool.h", "fibonacci_heap.h", "shortest-paths.h",
"sbitmap.h", "analyzer/exploded-graph.h", "diagnostic-path.h",
and "analyzer/checker-path.h".
(ht_ident_eq): New.
(fixup_location_in_macro_p): New.
(pending_diagnostic::fixup_location): New.
(pending_diagnostic::add_call_event): New.
* pending-diagnostic.h (pending_diagnostic::fixup_location): Drop
no-op inline implementation in favor of the more complex
implementation above.
(pending_diagnostic::add_call_event): New vfunc.
* region-model-impl-calls.cc: Include "analyzer/sm.h",
"diagnostic-path.h", and "analyzer/pending-diagnostic.h".
* region-model-manager.cc
(region_model_manager::get_var_arg_region): New.
(region_model_manager::log_stats): Log m_var_arg_regions.
* region-model.cc (region_model::on_call_pre): Handle IFN_VA_ARG,
BUILT_IN_VA_START, and BUILT_IN_VA_COPY.
(region_model::on_call_post): Handle BUILT_IN_VA_END.
(region_model::get_representative_path_var_1): Handle RK_VAR_ARG.
(region_model::push_frame): Push variadic arguments.
* region-model.h (region_model_manager::get_var_arg_region): New
decl.
(region_model_manager::m_var_arg_regions): New field.
(region_model::impl_call_va_start): New decl.
(region_model::impl_call_va_copy): New decl.
(region_model::impl_call_va_arg): New decl.
(region_model::impl_call_va_end): New decl.
* region.cc (alloca_region::dump_to_pp): Dump the id.
(var_arg_region::dump_to_pp): New.
(var_arg_region::get_frame_region): New.
* region.h (enum region_kind): Add RK_VAR_ARG.
(region::dyn_cast_var_arg_region): New.
(class var_arg_region): New.
(is_a_helper <const var_arg_region *>::test): New.
(struct default_hash_traits<var_arg_region::key_t>): New.
* sm.cc (make_checkers): Call make_va_list_state_machine.
* sm.h (sm_context::warn): New vfunc.
(sm_context::get_old_svalue): Drop unused decl.
(sm_context::get_new_program_state): New vfunc.
(make_va_list_state_machine): New decl.
* varargs.cc: New file.
gcc/testsuite/ChangeLog:
PR analyzer/105103
* gcc.dg/analyzer/stdarg-1.c: New test.
* gcc.dg/analyzer/stdarg-2.c: New test.
* gcc.dg/analyzer/stdarg-fmtstring-1.c: New test.
* gcc.dg/analyzer/stdarg-lto-1-a.c: New test.
* gcc.dg/analyzer/stdarg-lto-1-b.c: New test.
* gcc.dg/analyzer/stdarg-lto-1.h: New test.
* gcc.dg/analyzer/stdarg-sentinel-1.c: New test.
* gcc.dg/analyzer/stdarg-types-1.c: New test.
* gcc.dg/analyzer/stdarg-types-2.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Iain Buclaw [Mon, 16 May 2022 16:30:46 +0000 (18:30 +0200)]
d: Merge upstream dmd
60bfa0ee7, druntime
94bd5bcb, phobos
3a1cd9a01.
D front-end changes:
- Import dmd v2.100.0.
- Add bit fields to D, enabled via the -fpreview=bitfields switch.
- Removed the -ftransition=markdown and -frevert=markdown switches.
- Added new trait `__traits(classInstanceAlignment)' to provide the
required data alignment for classes.
- The check for `pragma(crt_constructor)' and `pragma(crt_destructor)'
linkage has been relaxed to allow all `void()' signatures.
- ImportC parser now recognizes the `typeof(...)' operator.
D runtime changes:
- Import druntime v2.100.0.
Phobos changes:
- Import phobos v2.100.0.
- To comply with dip1000, `std.socket.Socket` methods now accept only
`scope' arrays.
- The `fill', `alignSize', `align2', and `align4' methods of
`std.outbuffer.OutBuffer' have been extended to allow specifying a custom
value when pre-filling or padding the buffer.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd
60bfa0ee7.
* dmd/VERSION: Update version to v2.100.0.
* d-builtins.cc (d_init_versions): Update for new front-end interface.
* d-codegen.cc (d_decl_context): Use resolvedLinkage to get
declaration linkage.
(build_struct_literal): Track offset in bits.
* d-gimplify.cc (d_gimplify_modify_expr): Check both operands for a
bit-field reference.
* d-lang.cc (d_handle_option): Handle -fpreview=bitfields, remove
-frevert=markdown and -ftransition=vmarkdown.
(d_post_options): Set flag_rtti and flag_exceptions if -fno-druntime
was seen on command-line.
(d_parse_file): Update for new front-end interface.
(d_type_promotes_to): Use resolvedLinkage to get declaration linkage.
* decl.cc (make_thunk): Likewise.
* expr.cc (ExprVisitor::visit (CatAssignExp *)): Remove lowering for
appending of an element or array to another array.
* lang.opt (fpreview=bitfields): New option.
(frevert=markdown): Remove.
(ftransition=vmarkdown): Remove.
* types.cc (layout_aggregate_members): Ignore anonymous fields in
total count.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime
94bd5bcb.
* libdruntime/Makefile.am (ALL_DRUNTIME_INSTALL_DSOURCES): Add
$(DRUNTIME_DSOURCES_ELF).
(ALL_DRUNTIME_SOURCES): Likewise.
(DRUNTIME_DSOURCES_ELF): New variable.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos
3a1cd9a01.
* testsuite/libphobos.init_fini/custom_gc.d: Update test.
Jonathan Wakely [Mon, 16 May 2022 13:54:07 +0000 (14:54 +0100)]
libstdc++: Fix hyperlink in docs
libstdc++-v3/ChangeLog:
* doc/xml/manual/prerequisites.xml: Fix attributes for external
hyperlink.
* doc/html/manual/setup.html: Regenerate.
Jonathan Wakely [Mon, 16 May 2022 13:44:41 +0000 (14:44 +0100)]
libstdc++: Update C++23 status docs
These are the C++23 proposals supported in the gcc-12 branch.
libstdc++-v3/ChangeLog:
* doc/xml/manual/status_cxx2023.xml: Update with gcc-12 support.
* doc/html/*: Regenerate.
Jonathan Wakely [Mon, 16 May 2022 13:09:05 +0000 (14:09 +0100)]
libstdc++: Add C++23 status docs
These are the C++23 proposals already supported in the gcc-11 branch.
libstdc++-v3/ChangeLog:
* doc/xml/manual/intro.xml: Include new chapter.
* doc/xml/manual/status_cxx2020.xml: Tweak release numbers.
* doc/xml/manual/status_cxx2023.xml: New file.
* doc/html/*: Regenerate.
Jonathan Wakely [Mon, 16 May 2022 12:57:08 +0000 (13:57 +0100)]
libstdc++: Fix status docs for <bit> support
libstdc++-v3/ChangeLog:
* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx2020.xml: Fix supported version for
C++20 bit operations.
Richard Biener [Mon, 16 May 2022 10:39:30 +0000 (12:39 +0200)]
Finish gimple_build API enhancement
This finishes the remaining parts of the gimple_build API enhancement,
converting the remaining workers to receive a gimple_stmt_iterator,
direction and update argument. It also moves the code_helper
receiving functions from gimple-match.h to gimple-fold.h.
2022-05-16 Richard Biener <rguenther@suse.de>
* gimple-match.h (gimple_build): Move code_helper overloads ...
* gimple-fold.h (gimple_build): ... here.
(gimple_build): Transition to new worker API. Provide
overloads from sequence-based API.
(gimple_convert): Likewise.
(gimple_convert_to_ptrofftype): Likewise.
(gimple_build_vector_from_val): Likewise.
(gimple_build_vector): Likewise.
(gimple_build_round_up): Likewise.
* gimple-fold.cc (gimple_build_insert_seq): New helper.
(gimple_build): Use it. Transition combined_fn and code_helper
API parts.
(gimple_convert): Transition to new worker API.
(gimple_convert_to_ptrofftype): Likewise.
(gimple_build_vector_from_val): Likewise.
(gimple_build_vector): Likewise.
(gimple_build_round_up): Likewise.
Richard Biener [Mon, 16 May 2022 10:09:29 +0000 (12:09 +0200)]
Move code_helper to tree.h
tree.h already contains combined_fn handling at the top and moving
code_helper away from gimple-match.h makes improving the gimple_build
API easier.
2022-05-16 Richard Biener <rguenther@suse.de>
* gimple-match.h (code_helper): Move class ...
* tree.h (code_helper): ... here.
Richard Biener [Mon, 16 May 2022 10:07:31 +0000 (12:07 +0200)]
rtl-optimization/105577 - testcase for the PR
2022-05-16 Richard Biener <rguenther@suse.de>
PR rtl-optimization/105577
* g++.dg/torture/pr105577.C: New testcase.
Richard Biener [Mon, 16 May 2022 09:21:06 +0000 (11:21 +0200)]
ipa/105598 - testcase for PR105598
2022-05-16 Richard Biener <rguenther@suse.de>
gcc/testsuite/
* gcc.dg/torture/pr105598.c: New testcase.
Martin Liska [Mon, 16 May 2022 09:07:57 +0000 (11:07 +0200)]
opts-global.cc: document last change
gcc/ChangeLog:
* opts-global.cc (write_langs): Add comment.
Eric Botcazou [Mon, 16 May 2022 08:44:09 +0000 (10:44 +0200)]
Do not use DW_OP_not for TRUTH_NOT_EXPR in conditional expressions
DW_OP_not is a bitwise, not a logical NOT, so it computes the wrong result
in a DWARF conditional expression.
gcc/
* dwarf2out.cc (loc_list_from_tree_1) <TRUTH_NOT_EXPR>: Do a logical
instead of a bitwise negation.
<COND_EXPR>: Swap the operands if the condition is TRUTH_NOT_EXPR.
Eric Botcazou [Wed, 16 Mar 2022 13:50:24 +0000 (14:50 +0100)]
[Ada] Fix fallout of change in equality for untagged record types
The problem is that the resolution of expanded names implicitly assumes
that the visible and private homonyms in a given scope are segregated on
the homonym chain, and this was no longer the case for equality operators
in the specific case at stake.
gcc/ada/
* sem_ch7.adb (Inspect_Untagged_Record_Completion): Also move the
equality operator on the homonym chain if there is another equality
operator in the private part.
Piotr Trojanek [Wed, 16 Mar 2022 12:36:40 +0000 (13:36 +0100)]
[Ada] Fix expansion of attribute Loop_Entry wrt value propagation
When expanding attribute Loop_Entry we create constant object
declarations and put them just before the loop. The current values of
variables at the point of Loop_Entry attribute must not be used when
analysing the initialization expressions of these constants, because
they might be different from the values at the loop entry itself.
gcc/ada/
* exp_attr.adb (Expand_Loop_Entry_Attribute): Disable value
propagation when analysing the constant that holds the
Loop_Entry prefix value.
Piotr Trojanek [Wed, 16 Mar 2022 13:22:42 +0000 (14:22 +0100)]
[Ada] Remove useless code related to current value propagation
The current value propagation applies only to assignable objects and
doesn't make sense for subprogram entities. This was a mistake
introduced when extending the current value propagation years ago.
Cleanup related to fixing interference between expansion of attribute
Loop_Entry and current value propagation.
gcc/ada/
* sem_attr.adb (Address_Checks): Remove call to
Kill_Current_Values for subprogram entities, because this
routine only does something for object entities.
Justin Squirek [Thu, 10 Feb 2022 23:03:00 +0000 (23:03 +0000)]
[Ada] Type invariant or postcondition may cause uninitialized memory reads
This patch corrects an error in the compiler whereby a function
requiring the generation of a postconditions procedure may cause an
uninitialized memory read when the return type
Has_Unconstrained_Elements or is an unconstrained array.
The error occurs because evaluation of postconditions happens within the
"at end" handler when the temporary result object may go out of scope.
The patch modifies expansion in the above cases to evaluate
postconditions at the point of return instead - in order to guarantee
the result object is valid.
Note that these changes have the side effect of introducing a semantic
bug such that functions returning types with unconstrained elements will
have their postconditions/return type invariants evaluated before
finalization. Work is currently being done to introduce wrappers which
will solve this problem and remove technical debt in this area.
gcc/ada/
* exp_ch7.adb (Build_Finalizer): Disable late evaluation of
postconditions for functions returning types which where
Has_Unconstrained_Elements is true or are unconstrained arrays.
Etienne Servais [Mon, 14 Mar 2022 13:35:43 +0000 (14:35 +0100)]
[Ada] Freeze target type on qualified expression expansion
An object declaration (other than a deferred constant declaration)
causes freezing where it occurs (13.14(6)), which means every name
occurring within it causes freezing (13.14(4/1)), and when the name in a
subtype_mark causes freezing, the denoted subtype is frozen (13.14(11)).
Hence, one needs to freeze the target type when expanding a qualified
expression.
gcc/ada/
* exp_ch4.adb (Expand_N_Qualified_Expression): Freeze
Target_Type.
Yannick Moy [Fri, 11 Mar 2022 10:54:53 +0000 (11:54 +0100)]
[Ada] Fix proof of double arithmetic units
Proof of an assertion is not automatic anymore. Add two assertions
before it to guide the prover.
gcc/ada/
* libgnat/s-aridou.adb (Double_Divide): Add intermediate
assertions.
Ghjuvan Lacambre [Mon, 14 Mar 2022 08:58:52 +0000 (09:58 +0100)]
[Ada] Don't crash on ghost packages when emitting CUDA symbols in ALI files
Before this commit, a GNAT compiled with assertions would crash when
attempting to emit CUDA symbols in ALI files for spark_mode/ghost
packages, whose content is a single null statement.
gcc/ada/
* lib-writ.adb (Output_CUDA_Symbols): Check for null packages.
Joel Brobecker [Mon, 14 Mar 2022 03:54:02 +0000 (07:54 +0400)]
[Ada] GNAT.Debug_Pools: Improve documentation of the Stack_Trace_Depth parameter
Setting this parameter to zero when calling the Configure procedure has
the effect of disabling completely the tracking of the biggest memory
users, which wasn't clear from the current documentation. So this patch
enhances the documentation of both the Configure procedure as well as
the Dump procedure to make that explicit.
gcc/ada/
* libgnat/g-debpoo.ads: Improve documentation of the
Stack_Trace_Depth parameter.
Joel Brobecker [Fri, 11 Mar 2022 03:39:53 +0000 (03:39 +0000)]
[Ada] sigaction result not properly checked in __gnat_install_handler (QNX)
The QNX version of __gnat_install_handler calls sigaction for a number
of signals, and then prints an error message when the the call failed.
But unfortunately, except for the first call, we forgot to store
sigaction's return value, so the check that ensues uses a potentially
uninitialized variable, which the compiler does detect (this is how we
found this issue).
This change fixes this by make sure we store the result of each
sigaction call before checking it.
While at it, we noticed a thinko in the error messages all alerting
about the SIGFPE signal, rather than the signal it just tested. Most
likely a copy/paste thinko. Fixed by this change as well.
gcc/ada/
* init.c (__gnat_install_handler) [__QNX__]: Save sigaction's
return value in err before checking err's value. Fix incorrect
signal names in perror messages.
Joel Brobecker [Fri, 11 Mar 2022 04:22:34 +0000 (04:22 +0000)]
[Ada] Fix thinko in QNX's implementation of __gnat_install_handler
On QNX, the sigaction handler is incorrectly installed via the
sa_handler field of struct sigaction, rather than the sa_sigaction
field. This triggers a compilation warning due to a mismatch between the
function's signature and the field's type.
| init.c:2614:18: warning: assignment to 'void (*)(int)'
| from incompatible pointer type 'void (*)(int, siginfo_t *, void *)'
| {aka 'void (*)(int, struct _siginfo *, void *)'}
| [-Wincompatible-pointer-types]
In practice, using the sa_handler field actually works, but only because
those two fields are inside a union:
From target/qnx7/usr/include/signal.h:
| union { \
| __handler_type _sa_handler; \
| __action_type _sa_sigaction; \
| } __sa_un; \
This commit fixes this.
gcc/ada/
* init.c (__gnat_install_handler) [__QNX__]: Set
act.sa_sigaction rather than act.sa_handler.
Joel Brobecker [Fri, 11 Mar 2022 04:22:26 +0000 (04:22 +0000)]
[Ada] Add <stdlib.h> #include in cstreams.c
When building the GNAT runtime for QNX, we get the following warning:
| cstreams.c: In function '__gnat_full_name':
| cstreams.c:209:5: warning: implicit declaration of function 'realpath'
| [-Wimplicit-function-declaration]
| 209 | realpath (nam, buffer);
| | ^~~~~~~~
This commit fixes the warning by adding the corresponding #include
of <stdlib.h>
gcc/ada/
* cstreams.c: Add <stdlib.h> #include.
Joel Brobecker [Fri, 11 Mar 2022 04:22:15 +0000 (04:22 +0000)]
[Ada] replace call to bzero in terminals.c by call to memset
bzero is marked as legacy in POSIX.1-2001, and using it triggers a
deprecation warnings on some systems such as QNX. This change adjusts
the one place where we use it in terminals.c to use memset instead.
This, in turns, allows us to get rid of a hack for HP/UX and Solaris.
gcc/ada/
* terminals.c: Remove bzero #define on HP/UX or Solaris
platforms.
(child_setup_tty): Replace bzero call by equivalent call to
memset.
Gary Dismukes [Tue, 8 Mar 2022 23:21:48 +0000 (18:21 -0500)]
[Ada] Revise Storage_Model_Support operations to do checks and take objects and types
The functions in subpackage Storage_Model_Support (apart from the
Has_*_Aspect functions) are revised to have assertions that will fail
when passed a parameter that doesn't specify the appropriate aspect
(either aspect Storage_Model_Type or Designated_Storage_Model), instead
of returning Empty for bad arguments. Also, various of the functions now
allow either a type with aspect Storage_Model_Type or an object of such
a type.
gcc/ada/
* sem_util.ads (Storage_Model_Support): Revise comments on most
operations within this nested package to reflect that they can
now be passed either a type that has aspect Storage_Model_Type
or an object of such a type. Change the names of the relevant
formals to SM_Obj_Or_Type. Also, add more precise semantic
descriptions in some cases, and declare the subprograms in a
more logical order.
* sem_util.adb (Storage_Model_Support.Storage_Model_Object): Add
an assertion that the type must specify aspect
Designated_Storage_Model, rather than returning Empty when it
doesn't specify that aspect.
(Storage_Model_Support.Storage_Model_Type): Add an assertion
that formal must be an object whose type specifies aspect
Storage_Model_Type, rather than returning Empty for when it
doesn't have such a type (and test Has_Storage_Model_Type_Aspect
rather than Find_Value_Of_Aspect).
(Storage_Model_Support.Get_Storage_Model_Type_Entity): Allow
both objects and types, and add an assertion that the type (or
the type of the object) has a value for aspect
Storage_Model_Type.
Etienne Servais [Tue, 8 Mar 2022 13:49:55 +0000 (14:49 +0100)]
[Ada] Handle case-expression inside if-expression in -gnato2
gcc/ada/
* checks.adb (Apply_Arithmetic_Overflow_Minimized_Eliminated):
Fix condition to return.
Yannick Moy [Fri, 11 Mar 2022 11:55:16 +0000 (12:55 +0100)]
[Ada] Update comment justifying non-inlining for proof inside generics
gcc/ada/
* inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Update comment.
Marc Poulhiès [Mon, 7 Mar 2022 13:02:13 +0000 (14:02 +0100)]
[Ada] Fix iterated element association loop var escaping loop scope
Fix the escaping of the loop variable from the loop scope in both forms
of iterated element associations (i.e. "for J in ..." and "for J of
..."). Create a dedicated scope around the analyses of both loops. Also
create a copy of the Loop_Parameter_Specification instead of analyzing
(and modifying) the original Tree as it will be reanalyzed later.
gcc/ada/
* sem_aggr.adb (Resolve_Iterated_Association): Create scope
around N_Iterated_Element_Association handling. Analyze a copy
of the Loop_Parameter_Specification. Call Analyze instead
Analyze_* to be more homogeneous.
(Sem_Ch5): Remove now unused package.
Eric Botcazou [Wed, 9 Mar 2022 23:31:11 +0000 (00:31 +0100)]
[Ada] Fix internal error on iterated array aggregate
The front-end drops the declaration of a temporary on the floor because
Insert_Actions fails to climb up out of an N_Iterated_Component_Association
when the temporary is created during the analysis of its Discrete_Choices.
gcc/ada/
* exp_util.adb (Insert_Actions) <N_Iterated_Component_Association>:
Climb up out of the node if the actions come from Discrete_Choices.
Javier Miranda [Tue, 8 Mar 2022 22:55:16 +0000 (14:55 -0800)]
[Ada] Accept calls to abstract subprograms in class-wide pre/post-conditions
Fix a regression in the support for Ada 2022's treatment of calls to
abstract subprograms in pre/post-conditions (thanks to Javier Miranda
for producing this patch).
gcc/ada/
* sem_disp.adb (Check_Dispatching_Context): When checking to see
whether an expression occurs in a class-wide pre/post-condition,
also check for the possibility that it occurs in a class-wide
preconditions subprogram that was introduced as part of
expansion. Without this fix, some legal calls occuring in
class-wide preconditions may be incorrectly flagged as violating
the "a call to an abstract subprogram must be dispatching" rule.
Eric Botcazou [Thu, 10 Mar 2022 10:11:32 +0000 (11:11 +0100)]
[Ada] Fix internal error on mix of controlled and protected types
The key is that the protected type is a (limited) private type, which
fools a test in Cleanup_Scopes.
gcc/ada/
* inline.adb (Cleanup_Scopes): Test the underlying type.
Eric Botcazou [Wed, 9 Mar 2022 19:47:00 +0000 (20:47 +0100)]
[Ada] Fix internal error on predicate aspect with iterator
The semantic analysis of predicates involves a fair amount of tree
copying because of both semantic and implementation considerations, and
there is a difficulty with quantified expressions since they declare a
new entity that cannot be shared between the various copies of the tree.
This change implements a specific processing for it in New_Copy_Tree
that subsumes a couple of fixes made earlier for variants of the issue.
gcc/ada/
* sem_util.ads (Is_Entity_Of_Quantified_Expression): Declare.
* sem_util.adb (Is_Entity_Of_Quantified_Expression): New
predicate.
(New_Copy_Tree): Deal with all entities of quantified
expressions.
* sem_ch13.adb (Build_Predicate_Functions): Get rid of
superfluous tree copying and remove obsolete code.
* sem_ch6.adb (Fully_Conformant_Expressions): Deal with all
entities of quantified expressions.
Steve Baird [Thu, 3 Mar 2022 22:35:31 +0000 (14:35 -0800)]
[Ada] Implement component finalization ordering rules for type extensions
Finalization of a record object is required to finalize any components
that have an access discriminant constrained by a per-object expression
before other components. This includes the case of a type extension;
"early finalization" components of the parent type are required to be
finalized before non-early-finalization extension components. This is
implemented in the extension type's finalization procedure by placing
the call to the parent type's finalization procedure between the
finalization of the "early finalization" extension components and the
finalization of the other extension components. Previously that call was
executed after finalizing all of the extension conponents.
gcc/ada/
* exp_ch7.adb (Build_Finalize_Statements): Add Last_POC_Call
variable to keep track of the last "early finalization" call
generated for type extension's finalization procedure. If
non-empty, then this will indicate the point at which to insert
the call to the parent type's finalization procedure. Modify
nested function Process_Component_List_For_Finalize to set this
variable (and avoid setting it during a recursive call). If
Last_POC_Call is empty, then insert the parent finalization call
before, rather than after, the finalization code for the
extension components.
Eric Botcazou [Mon, 28 Feb 2022 14:27:27 +0000 (15:27 +0100)]
[Ada] Fix implementation issues with equality for untagged record types
This moves the implementation of AI12-0101 + AI05-0123 from the expander
to the semantic analyzer and completes the implementation of AI12-0413,
which are both binding interpretations in Ada 2012, fixing a few bugs in
the process and removing a fair amount of duplicated code throughout.
gcc/ada/
* einfo-utils.adb (Remove_Entity): Fix couple of oversights.
* exp_ch3.adb (Is_User_Defined_Equality): Delete.
(User_Defined_Eq): Call Get_User_Defined_Equality.
(Make_Eq_Body): Likewise.
(Predefined_Primitive_Eq_Body): Call Is_User_Defined_Equality.
* exp_ch4.adb (Build_Eq_Call): Call Get_User_Defined_Equality.
(Is_Equality): Delete.
(User_Defined_Primitive_Equality_Op): Likewise.
(Find_Aliased_Equality): Call Is_User_Defined_Equality.
(Expand_N_Op_Eq): Call Underlying_Type unconditionally.
Do not implement AI12-0101 + AI05-0123 here.
(Expand_Set_Membership): Call Resolve_Membership_Equality.
* exp_ch6.adb (Expand_Call_Helper): Remove obsolete code.
* sem_aux.ads (Is_Record_Or_Limited_Type): Delete.
* sem_aux.adb (Is_Record_Or_Limited_Type): Likewise.
* sem_ch4.ads (Nondispatching_Call_To_Abstract_Operation): Declare.
* sem_ch4.adb (Analyze_Call): Call Call_Abstract_Operation.
(Analyze_Membership_Op): Call Resolve_Membership_Equality.
(Nondispatching_Call_To_Abstract_Operation): New procedure.
(Remove_Abstract_Operations): Call it.
* sem_ch6.adb (Check_Untagged_Equality): Remove obsolete error and
call Is_User_Defined_Equality.
* sem_ch7.adb (Inspect_Untagged_Record_Completion): New procedure
implementing AI12-0101 + AI05-0123.
(Analyze_Package_Specification): Call it.
(Declare_Inherited_Private_Subprograms): Minor tweak.
(Uninstall_Declarations): Likewise.
* sem_disp.adb (Check_Direct_Call): Adjust to new implementation
of Is_User_Defined_Equality.
* sem_res.ads (Resolve_Membership_Equality): Declare.
* sem_res.adb (Resolve): Replace direct error handling with call to
Nondispatching_Call_To_Abstract_Operation
(Resolve_Call): Likewise.
(Resolve_Equality_Op): Likewise. mplement AI12-0413.
(Resolve_Membership_Equality): New procedure.
(Resolve_Membership_Op): Call Get_User_Defined_Equality.
* sem_util.ads (Get_User_Defined_Eq): Rename into...
(Get_User_Defined_Equality): ...this.
* sem_util.adb (Get_User_Defined_Eq): Rename into...
(Get_User_Defined_Equality): ...this. Call Is_User_Defined_Equality.
(Is_User_Defined_Equality): Also check the profile but remove tests
on Comes_From_Source and Parent.
* sinfo.ads (Generic_Parent_Type): Adjust field description.
* uintp.ads (Ubool): Invoke user-defined equality in predicate.
Piotr Trojanek [Tue, 8 Mar 2022 16:46:26 +0000 (17:46 +0100)]
[Ada] Remove duplicated detection of user-defined equality
Cleanup related to handling of user-defined equality in GNATprove.
gcc/ada/
* exp_ch3.adb (User_Defined_Eq): Replace duplicated code with a
call to Get_User_Defined_Eq.
Piotr Trojanek [Tue, 8 Mar 2022 16:37:29 +0000 (17:37 +0100)]
[Ada] Improve building of untagged equality
When checking components of a record type for their own user-defined
equality function it is enough to find just one such a component.
Cleanup related to handling of user-defined equality in GNATprove.
gcc/ada/
* exp_ch3.adb (Build_Untagged_Equality): Exit early when the
outcome of a loop is already known.
Olivier Hainque [Fri, 18 Feb 2022 22:57:42 +0000 (22:57 +0000)]
[Ada] Map gnatlib-shared to gnatlib-shared-dual for aarch64-vx7r2
This is an incremental change towards supporting shared libraries
for VxWorks on aarch64.
The aarch64-vx7r2 compiler supports compilation with -fpic/PIC. This
change adds aarch64 to the list of CPUs for which GNATLIB_SHARED maps to
gnatlib-shared-dual for vxworks7r2, so "make gnatlib-shared" actually
builds a shared lib.
While other adjustments will be needed to get the runtime tests to pass,
this one is a necessary step and doesn't impair the rest.
gcc/ada/
* Makefile.rtl: Add aarch64 to the list of CPUs for which
GNATLIB_SHARED maps to gnatlib-shared-dual for vxworks7r2.
Eric Botcazou [Tue, 8 Mar 2022 07:52:10 +0000 (08:52 +0100)]
[Ada] Couple of small consistency tweaks
This aligns Analyze_Negation and Analyze_Unary_Op with the other similar
procedures in Sem_Ch4. No functional changes.
gcc/ada/
* sem_ch4.adb (Analyze_Negation): Minor tweak.
(Analyze_Unary_Op): Likewise.
Eric Botcazou [Thu, 3 Mar 2022 14:57:47 +0000 (15:57 +0100)]
[Ada] Fix spurious error on limited view with incomplete type
The problem is that Install_Limited_With_Clause does not fully implement
AI05-0129, in the case where a regular with clause is processed before a
limited_with clause of the same package: the visible "shadow" entity is
that of the incomplete type, instead of that of the full type per the AI.
This requires adjusting Remove_Limited_With_Unit to match the change in
Install_Limited_With_Clause and also Build_Incomplete_Type_Declaration,
which is responsible for synthesizing incomplete types out of full type
declarations for self-referential types.
A small tweak is also needed in Analyze_Subprogram_Body_Helper to align
it with an equivalent processing for CW types in Find_Type_Name. And the
patch also changes the Incomplete_View field in full type declarations
to point to the entity of the view instead of its declaration.
gcc/ada/
* exp_ch3.adb (Build_Assignment): Adjust to the new definition of
Incomplete_View field.
* sem_ch10.ads (Decorate_Type): Declare.
* sem_ch10.adb (Decorate_Type): Move to library level.
(Install_Limited_With_Clause): In the already analyzed case, also
deal with incomplete type declarations present in the sources and
simplify the replacement code.
(Build_Shadow_Entity): Deal with swapped views in package body.
(Restore_Chain_For_Shadow): Deal with incomplete type declarations
present in the sources.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Adjust to the new
definition of Incomplete_View field.
(Build_Incomplete_Type_Declaration): Small consistency tweak.
Set the incomplete type as the Incomplete_View of the full type.
If the scope is a package with a limited view, build a shadow
entity for the incomplete type.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): When replacing
the limited view of a CW type as designated type of an anonymous
access return type, get to the CW type of the incomplete view of
the tagged type, if any.
(Collect_Primitive_Operations): Adjust to the new definition of
Incomplete_View field.
* sinfo.ads (Incomplete_View): Denote the entity itself instead
of its declaration.
* sem_util.adb: Remove call to Defining_Entity.
Piotr Trojanek [Mon, 7 Mar 2022 14:27:06 +0000 (15:27 +0100)]
[Ada] Pick volatile refinement property of a subtype from its base type
Volatile refinement properties (e.g. Async_Writers), which refine the
Volatile aspect in SPARK, are inherited by subtypes from their base
types. In particular, this patch fixes handling of those properties for
subtypes of private types.
gcc/ada/
* sem_util.adb (Type_Or_Variable_Has_Enabled_Property): Given a
subtype recurse into its base type.
Piotr Trojanek [Mon, 7 Mar 2022 13:07:15 +0000 (14:07 +0100)]
[Ada] Clarify code for detecting volatile refinement properties
Routine Type_Or_Variable_Has_Enabled_Property handles either types or
objects; replace negation with an explicit positive condition.
Cleanup related to handling of volatile refinement aspects in SPARK;
behaviour is unaffected.
gcc/ada/
* sem_util.adb (Type_Or_Variable_Has_Enabled_Property): Clarify.
Piotr Trojanek [Fri, 4 Mar 2022 16:46:30 +0000 (17:46 +0100)]
[Ada] Remove duplicated code for detecting enabled pragmas
Routines Is_Enabled and Is_Enabled_Pragma are identical (except for
comments); remove this duplication.
Cleanup related to handling of volatile refinement aspects in SPARK;
behaviour is unaffected.
gcc/ada/
* sem_util.adb (Is_Enabled): Remove; use Is_Enabled_Pragma
instead.
Martin Liska [Thu, 13 Jan 2022 17:46:26 +0000 (18:46 +0100)]
Use more ARRAY_SIZE.
gcc/ada/ChangeLog:
* locales.c (iso_639_1_to_639_3): Use ARRAY_SIZE.
(language_name_to_639_3): Likewise.
(country_name_to_3166): Likewise.
gcc/analyzer/ChangeLog:
* engine.cc (exploded_node::get_dot_fillcolor): Use ARRAY_SIZE.
* function-set.cc (test_stdio_example): Likewise.
* sm-file.cc (get_file_using_fns): Likewise.
* sm-malloc.cc (malloc_state_machine::unaffected_by_call_p): Likewise.
* sm-signal.cc (get_async_signal_unsafe_fns): Likewise.
gcc/ChangeLog:
* attribs.cc (diag_attr_exclusions): Use ARRAY_SIZE.
(decls_mismatched_attributes): Likewise.
* builtins.cc (c_strlen): Likewise.
* cfg.cc (DEF_BASIC_BLOCK_FLAG): Likewise.
* common/config/aarch64/aarch64-common.cc (aarch64_option_init_struct): Likewise.
* config/aarch64/aarch64-builtins.cc (aarch64_lookup_simd_builtin_type): Likewise.
(aarch64_init_simd_builtin_types): Likewise.
(aarch64_init_builtin_rsqrt): Likewise.
* config/aarch64/aarch64.cc (is_madd_op): Likewise.
* config/arm/arm-builtins.cc (arm_lookup_simd_builtin_type): Likewise.
(arm_init_simd_builtin_types): Likewise.
* config/avr/gen-avr-mmcu-texi.cc (mcus[ARRAY_SIZE): Likewise.
(c_prefix): Likewise.
(main): Likewise.
* config/c6x/c6x.cc (N_SAVE_ORDER): Likewise.
* config/darwin-c.cc (darwin_register_frameworks): Likewise.
* config/gcn/mkoffload.cc (process_obj): Likewise.
* config/i386/i386-builtins.cc (get_builtin_code_for_version): Likewise.
(fold_builtin_cpu): Likewise.
* config/m32c/m32c.cc (PUSHM_N): Likewise.
* config/nvptx/mkoffload.cc (process): Likewise.
* config/rs6000/driver-rs6000.cc (host_detect_local_cpu): Likewise.
* config/s390/s390.cc (NR_C_MODES): Likewise.
* config/tilepro/gen-mul-tables.cc (find_sequences): Likewise.
(create_insn_code_compression_table): Likewise.
* config/vms/vms.cc (NBR_CRTL_NAMES): Likewise.
* diagnostic-format-json.cc (json_from_expanded_location): Likewise.
* dwarf2out.cc (ARRAY_SIZE): Likewise.
* genhooks.cc (emit_documentation): Likewise.
(emit_init_macros): Likewise.
* gimple-ssa-sprintf.cc (format_floating): Likewise.
* gimple-ssa-warn-access.cc (memmodel_name): Likewise.
* godump.cc (keyword_hash_init): Likewise.
* hash-table.cc (hash_table_higher_prime_index): Likewise.
* input.cc (for_each_line_table_case): Likewise.
* ipa-free-lang-data.cc (free_lang_data): Likewise.
* ipa-inline.cc (sanitize_attrs_match_for_inline_p): Likewise.
* optc-save-gen.awk: Likewise.
* spellcheck.cc (test_metric_conditions): Likewise.
* tree-vect-slp-patterns.cc (sizeof): Likewise.
(ARRAY_SIZE): Likewise.
* tree.cc (build_common_tree_nodes): Likewise.
gcc/c-family/ChangeLog:
* c-common.cc (ARRAY_SIZE): Use ARRAY_SIZE.
(c_common_nodes_and_builtins): Likewise.
* c-format.cc (check_tokens): Likewise.
(check_plain): Likewise.
* c-pragma.cc (c_pp_lookup_pragma): Likewise.
(init_pragma): Likewise.
* known-headers.cc (get_string_macro_hint): Likewise.
(get_stdlib_header_for_name): Likewise.
* c-attribs.cc: Likewise.
gcc/c/ChangeLog:
* c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE.
gcc/cp/ChangeLog:
* module.cc (depset::entity_kind_name): Use ARRAY_SIZE.
* name-lookup.cc (get_std_name_hint): Likewise.
* parser.cc (cp_parser_new): Likewise.
gcc/fortran/ChangeLog:
* frontend-passes.cc (gfc_code_walker): Use ARRAY_SIZE.
* openmp.cc (gfc_match_omp_context_selector_specification): Likewise.
* trans-intrinsic.cc (conv_intrinsic_ieee_builtin): Likewise.
* trans-types.cc (gfc_get_array_descr_info): Likewise.
gcc/jit/ChangeLog:
* jit-builtins.cc (find_builtin_by_name): Use ARRAY_SIZE.
(get_string_for_type_id): Likewise.
* jit-recording.cc (recording::context::context): Likewise.
gcc/lto/ChangeLog:
* lto-common.cc (lto_resolution_read): Use ARRAY_SIZE.
* lto-lang.cc (lto_init): Likewise.
Marcel Vollweiler [Mon, 16 May 2022 08:02:50 +0000 (01:02 -0700)]
OpenMP, C++: Add template support for the has_device_addr clause.
This patch adds support for list items in the has_device_addr clause which type
is given by C++ template parameters.
gcc/cp/ChangeLog:
* pt.cc (tsubst_omp_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR.
* semantics.cc (finish_omp_clauses): Added template decl processing.
libgomp/ChangeLog:
* testsuite/libgomp.c++/target-has-device-addr-7.C: New test.
* testsuite/libgomp.c++/target-has-device-addr-8.C: New test.
* testsuite/libgomp.c++/target-has-device-addr-9.C: New test.
Martin Liska [Mon, 16 May 2022 07:48:27 +0000 (09:48 +0200)]
Fix ubsan error in opts-global.cc
Fixes:
opts-global.cc:75:15: runtime error: store to address 0x00000bc9be70 with insufficient space for an object of type 'char'
which happens when mask == 0, len == 0 and we allocate zero elements.
Eventually, result[0] is called which triggers the UBSAN.
gcc/ChangeLog:
* opts-global.cc (write_langs): Allocate at least one byte.
Richard Biener [Fri, 13 May 2022 07:35:30 +0000 (09:35 +0200)]
Add MIN/MAX folding from fold_cond_expr_with_comparison to match.pd
The following adds MIN/MAX folding from fold_cond_expr_with_comparison
to the part GIMPLE of match.pd, leaving the GENERIC part in
fold-const.cc since that's constrainted on frontend specific things
I did not want to carry to match.pd.
The effect becomes appearant when we no longer can rely on GENERIC
folding of COND_EXPRs in gcc.dg/tree-ssa/pr92834.c and
gcc.dg/tree-ssa/pr94786.c.
2022-05-13 Richard Biener <rguenther@suse.de>
* match.pd (A cmp B ? A : B -> min/max): New patterns
carried over from fold_cond_expr_with_comparison.
liuhongt [Fri, 13 May 2022 07:48:01 +0000 (15:48 +0800)]
Fix ICE caused by wrong condition.
When d->perm[i] == d->perm[i-1] + 1 and d->perm[i] == nelt, it's not
continuous. It should fail if there's more than 2 continuous areas.
gcc/ChangeLog:
PR target/105587
* config/i386/i386-expand.cc
(expand_vec_perm_pslldq_psrldq_por): Fail when (d->perm[i] ==
d->perm[i-1] + 1) && d->perm[i] == nelt && start != -1.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr105587.c: New test.
GCC Administrator [Mon, 16 May 2022 00:16:23 +0000 (00:16 +0000)]
Daily bump.
Uros Bizjak [Sun, 15 May 2022 20:07:46 +0000 (22:07 +0200)]
i386: Remove constraints when used with constant integer predicates.
const_int_operand and other const*_operand predicates do not need
constraints when the constraint is inherited from the range of
constant integer predicate. Remove the constraint in case all
alternatives use the same inherited constraint.
2022-05-15 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
* config/i386/i386.md: Remove constraints when used with
const_int_operand, const0_operand, const_1_operand, constm1_operand,
const8_operand, const128_operand, const248_operand, const123_operand,
const2367_operand, const1248_operand, const359_operand,
const_4_or_8_to_11_operand, const48_operand, const_0_to_1_operand,
const_0_to_3_operand, const_0_to_4_operand, const_0_to_5_operand,
const_0_to_7_operand, const_0_to_15_operand, const_0_to_31_operand,
const_0_to_63_operand, const_0_to_127_operand, const_0_to_255_operand,
const_0_to_255_mul_8_operand, const_1_to_31_operand,
const_1_to_63_operand, const_2_to_3_operand, const_4_to_5_operand,
const_4_to_7_operand, const_6_to_7_operand, const_8_to_9_operand,
const_8_to_11_operand, const_8_to_15_operand, const_10_to_11_operand,
const_12_to_13_operand, const_12_to_15_operand, const_14_to_15_operand,
const_16_to_19_operand, const_16_to_31_operand, const_20_to_23_operand,
const_24_to_27_operand and const_28_to_31_operand.
* config/i386/mmx.md: Ditto.
* config/i386/sse.md: Ditto.
* config/i386/subst.md: Ditto.
* config/i386/sync.md: Ditto.
Jason Merrill [Sat, 19 Mar 2022 02:52:32 +0000 (22:52 -0400)]
c++: hidden friend access [DR1699]
It has come up several times that Clang considers hidden friends of a class
to be sufficiently memberly to be covered by a friend declaration naming the
class. This is somewhat unclear in the standard: [class.friend] says
"Declaring a class to be a friend implies that private and protected members
of the class granting friendship can be named in the base-specifiers and
member declarations of the befriended class."
A hidden friend is a syntactic member-declaration, but is it a "member
declaration"? CWG was ambivalent, and referred the question to EWG as a
design choice. But recently Patrick mentioned that the current G++ choice
not to treat it as a "member declaration" was making his library work
significantly more cumbersome, so let's go ahead and vote the other way.
This means that the testcases for 100502 and 58993 are now accepted.
DR1699
PR c++/100502
PR c++/58993
gcc/cp/ChangeLog:
* friend.cc (is_friend): Hidden friends count as members.
* search.cc (friend_accessible_p): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/template/access37.C: Now OK.
* g++.dg/template/friend69.C: Now OK.
* g++.dg/lookup/friend23.C: New test.
Jason Merrill [Fri, 13 May 2022 01:28:47 +0000 (21:28 -0400)]
c++: parsing injected-class-name as template
While I was backporting the patch for PR102300, it occurred to me that it
would be cleaner to look through the injected-class-name earlier in the
function. I don't think this changes any test results.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_template_name): Look through
injected-class-name.
Jason Merrill [Fri, 13 May 2022 20:07:10 +0000 (16:07 -0400)]
c++: array {}-init [PR105589]
My patch for 105191 made us use build_value_init more frequently from
build_vec_init_expr, but build_value_init doesn't like to be called to
initialize a class in a template. That's caused trouble in the past, and
seems like a strange restriction, so let's fix it.
PR c++/105589
PR c++/105191
PR c++/92385
gcc/cp/ChangeLog:
* init.cc (build_value_init): Handle class in template.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-array16.C: New test.
GCC Administrator [Sun, 15 May 2022 00:16:17 +0000 (00:16 +0000)]
Daily bump.