The only preexisting use of GIMPLE_EH_ELSE, for transactional memory
commits, did not allow exceptions to escape from the ELSE path. The
trick it uses to allow the ELSE path to see the propagating exception
does not work very well if the exception cleanup raises further
exceptions: the ELSE block is configured to handle exceptions in
itself. This confuses the heck out of CFG and EH cleanups.
Basing the lowering context for the ELSE block on outer_state, rather
than this_state, gets us the expected enclosing handler.
for gcc/ChangeLog
* tree-eh.c (honor_protect_cleanup_actions): Use outer_
rather than this_state as the lowering context for the ELSE
seq in a GIMPLE_EH_ELSE.
Jonathan Wakely [Fri, 12 Jul 2019 11:43:22 +0000 (12:43 +0100)]
Define __type_identity_t alias and use for string_view
This defines the equivalent of C++2a's std::type_identity_t alias but
for use in C++11 and later. This can be used to replace __detail::__idt
in the string_view headers, which previously used common_type_t because
the one argument specialization of common_type_t was simply the identity
transform (which is no longer true).
* include/experimental/string_view (__detail::__idt): Remove.
(operator==, operator!=, operator<, operator>, operator<=, operator>=):
Use __type_identity_t instead of __detail::__idt;
* include/std/string_view (__detail::__idt): Remove.
(operator==, operator!=, operator<, operator>, operator<=, operator>=):
Use __type_identity_t instead of __detail::__idt;
* include/std/type_traits (__type_identity_t): New alias template.
I'd made it a precondition of vector_builder::elt that the encoding
must have been fully populated and that all implicit elements are
therefore defined. But for one of the AArch64 patches I'm working on,
it'd be convenient to be able to look back at previous elements while
building up the encoding. This patch therefore makes the assert
specific to implicit elements only.
2019-07-12 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* vector-builder.h (vector_builder::elt): Allow already-supplied
elements to be read back before building is complete.
Eric Botcazou [Fri, 12 Jul 2019 10:15:39 +0000 (10:15 +0000)]
re PR rtl-optimization/91136 (incorrect move of instruction to delay slot causes application crash in exception handling)
PR rtl-optimization/91136
* df-core.c (ACCESSING REFS): Fix typos in comment.
* resource.c (mark_target_live_reg): Add artificial defs that occur at
the beginning of the block to the initial set of live registers.
* fold-const.h (get_array_ctor_element_at_index): Adjust.
* fold-const.c (get_array_ctor_element_at_index): Add
ctor_idx output parameter informing the caller where in
the constructor the element was (not) found. Add early exit
for when the ctor is sorted.
* gimple-fold.c (fold_array_ctor_reference): Support constant
folding across multiple array elements.
This patch is part of a series that fixes ambiguous attribute
uses in .md files, i.e. cases in which attributes didn't use
<ITER:ATTR> to specify an iterator, and in which <ATTR> could
have different values depending on the iterator chosen.
No behavioural change except for dropping the unused SVE
divide permutations.
2019-07-12 Richard Sandiford <richard.sandiford@arm.com>
Support multiple operand counts for .md @ patterns
This patch extends the support for "@..." pattern names so that
the patterns can have different numbers of operands. This allows
things like binary and ternary operations to be handled in a
consistent way, a bit like optabs. The generators assert that
the number of operands passed is correct for the underlying
instruction.
Also, replace_operands_with_dups iterated over the old rtx format
even after having decided to do a replacement, which broke with
match_operator.
2019-07-12 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* doc/md.texi: Document that @ patterns can have different
numbers of operands.
* genemit.c (handle_overloaded_gen): Handle this case.
* genopinit.c (handle_overloaded_gen): Likewise.
* gensupport.c (replace_operands_with_dups): Iterate over
the new rtx's format rather than the old one's.
Ian Lance Taylor [Thu, 11 Jul 2019 21:37:33 +0000 (21:37 +0000)]
compiler: ensure evaluation order in type hash/eq functions
The type hash and equality functions are generated after the
order_evaluations pass. They may contain shortcut operators and
Set_and_use_temporary_expressions (e.g. from lowering a
Binary_exprssion) that need to be ordered. Run order_evaluations
and remove_shortcuts on these functions. (The hash functions
may be fine, but to be on the safe side we run on them anyway.
We do need to run on the equality functions.)
A Set_and_use_temporary_expression is effectively an assignment,
so it needs to be ordered. Otherwise if we insert a temporary
statement before it, we may get wrong evaluation order.
Jonathan Wakely [Thu, 11 Jul 2019 19:43:25 +0000 (20:43 +0100)]
Define std::atomic_ref and std::atomic<floating-point> for C++20
This adds the new atomic types from C++2a, as proposed by P0019 and
P0020. To reduce duplication the calls to the compiler's atomic
built-ins are wrapped in new functions in the __atomic_impl namespace.
These functions are currently only used by std::atomic<floating-point>
and std::atomic_ref but could also be used for all other specializations
of std::atomic.
* include/bits/atomic_base.h (__atomic_impl): New namespace for
wrappers around atomic built-ins.
(__atomic_float, __atomic_ref): New class templates for use as base
classes.
* include/std/atomic (atomic<float>, atomic<double>)
(atomic<long double>): New explicit specializations.
(atomic_ref): New class template.
(__cpp_lib_atomic_ref): Define.
* include/std/version (__cpp_lib_atomic_ref): Define.
* testsuite/29_atomics/atomic/60695.cc: Adjust dg-error.
* testsuite/29_atomics/atomic_float/1.cc: New test.
* testsuite/29_atomics/atomic_float/requirements.cc: New test.
* testsuite/29_atomics/atomic_ref/deduction.cc: New test.
* testsuite/29_atomics/atomic_ref/float.cc: New test.
* testsuite/29_atomics/atomic_ref/generic.cc: New test.
* testsuite/29_atomics/atomic_ref/integral.cc: New test.
* testsuite/29_atomics/atomic_ref/pointer.cc: New test.
* testsuite/29_atomics/atomic_ref/requirements.cc: New test.
This patch recognises Modula-2 as language for the traceback table,
fixing the problem shown in
https://gcc.gnu.org/ml/gcc-patches/2019-07/msg00848.html .
[Ada] Avoid spurious errors on dimensionality checking in GNATprove
In the special GNATprove mode of the frontend, automatic inlining is
performed, which may lead to spurious errors on dimensionality checking.
Avoid performing this checking on inlined code, which has already been
checked for dimensionality errors.
There is no impact on compilation.
2019-07-11 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_res.adb (Resolve_Call): Do not perform dimensionality
checking on inlined bodies.
[Ada] Avoid spurious warning on assertions with Loop_Entry
When the Loop_Entry attribute is used inside a loop invariant or another
assertion where it is allowed, it may lead to spurious warnings on
conditions that are detected to be always valid. Now fixed.
2019-07-11 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_eval.adb (Is_Same_Value): Add special case for rewritten
Loop_Entry attribute.
[Ada] Refactor ownership pointer checking in SPARK as a generic
Ownership checking as done in SPARK should be applied only to SPARK
code, which requires GNATprove knowledge of the SPARK_Mode boundary.
Transform the checking unit into a generic to allow passing in the
knowledge from GNATprove to that unit in GNAT sources.
Keeping the code in GNAT sources makes it possible in the future to
adapt it further (or simply instantiate it differently) to be used on
Ada code, independently of GNATprove.
There is no impact on compilation.
2019-07-11 Claire Dross <dross@adacore.com>
gcc/ada/
* gnat1drv.adb: SPARK checking rules for pointer aliasing are
moved to GNATprove backend.
* sem_spark.ads, sem_spark.adb (Sem_SPARK): Is now a generic
unit. Takes as parameters:
- Retysp which is used to query the most underlying type
visible in SPARK. We do not introduce aliasing checks for
types which are not visibly deep.
- Component_Is_Visible_In_SPARK is used to avoid doing pointer
aliasing checks on components which are not visible in SPARK.
- Emit_Messages returns True in the second phase of SPARK
analysis. Error messages for failed aliasing checks are only
output in this case.
Additionally, errors on constructs not supported in SPARK are
removed as duplicates of marking errors. Components are stored
in the permission map using their original component to avoid
inconsistencies between components of different views of the
same type.
(Check_Expression): Handle delta constraints.
(Is_Deep): Exported so that we can check for SPARK restrictions
on deep types inside SPARK semantic checkings.
(Is_Traversal_Function): Exported so that we can check for SPARK
restrictions on traversal functions inside SPARK semantic
checkings.
(Check_Call_Statement, Read_Indexes): Check wether we are
dealing with a subprogram pointer type before querying called
entity.
(Is_Subpath_Expression): Image attribute can appear inside a
path.
(Check_Loop_Statement): Correct order of statements in the loop.
(Check_Node): Ignore raise nodes.
(Check_Statement): Use Last_Non_Pragma to get the object
declaration in an extended return statement.
Patrick Bernardi [Thu, 11 Jul 2019 08:03:04 +0000 (08:03 +0000)]
[Ada] Minimal binder
The new minimal binder option ("-minimal") suppresses the generation of
binder objects that are not strictly required for program operation.
This option is suitable for space constrained applications and comes
with the restriction that programs can no longer be debugged using GDB.
2019-07-11 Patrick Bernardi <bernardi@adacore.com>
gcc/ada/
* bindgen.adb (Gen_Main): Do not generate a reference to
Ada_Main_Program_Name when the Minimal_Binder flag is set.
(Gen_Output_File_Ada): Do not output GNAT_Version and
Ada_Main_Program_Name info if Minimal_Binder flag is set.
* bindusg.adb: Add documentation for new -minimal switch.
* gnatbind.adb (Scan_Bind_Arg): Scan -minimal switch.
* opt.ads: Add new global flag Minimal_Binder to indicate if the
binder should not produce global variables.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Update documentation with new binder -minimal switch.
* gnat_ugn.texi: Regenerate.
Ed Schonberg [Thu, 11 Jul 2019 08:02:53 +0000 (08:02 +0000)]
[Ada] Crash on protected type with self-referential component
This patch fixes a compiler abort on a declarastion for a protected type
PT when one of its private component is of type access PT.
2019-07-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch9.adb (Expand_N_Protected_Type_Declaaration): New
subsidiary routine Replace_Access_Definition, to handle properly
a protected type PT one of whose private components is of type
access PT.
gcc/testsuite/
* gnat.dg/prot8.adb, gnat.dg/prot8.ads: New testcase.
Ed Schonberg [Thu, 11 Jul 2019 08:02:35 +0000 (08:02 +0000)]
[Ada] Remove redundant predicate checks
This patch removes redundant dynamic predicate checks generated by type
conversions in various contexts. The patch also recognizes additional
such checks that can be evaluated statically when applied to constant
values.
No simple test available.
2019-07-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch4.adb (Expand_N_Type_Conversion): If a predicate check
is generated, analyze it with range check suppressed, because
that check has been previously applied.
* exp_ch5.adb (Expand_N_Assignment_Statement): If the RHS is a
type conversion to the type of the LHS, do not apply a predicate
check to the RHS because it will have been generated already
during its expansion.
* exp_ch6.adb (Can_Fold_Predicate_Call): Extend processing to
handle a predicate check on a constant entity whose value is
static.
[Ada] Elaboration order v4.0 and output of dependencies
This patch adds a missing case to the mechanism that outputs the
elaboration order dependencies of units.
------------
-- Source --
------------
-- pack.ads
package Pack is
procedure Force_Body;
end Pack;
-- pack.adb
package body Pack is
procedure Force_Body is null;
end Pack;
-- main.adb
with Pack;
procedure Main is begin null; end Main;
----------------------------
-- Compilation and output --
----------------------------
$ gnatmake -q main.adb -bargs -e
ELABORATION ORDER DEPENDENCIES
unit "pack (spec)" must be elaborated before unit "main (body)"
reason: unit "main (body)" has with clause for unit "pack (spec)"
unit "pack (spec)" must be elaborated before unit "pack (body)"
reason: spec must be elaborated before body
* bindo.adb: Remove the documentation of switch -d_N because it
is no longer in use.
* bindo-graphs.ads, bindo-graphs.adb (Is_Spec_Before_Body_Edge):
New routine.
* bindo-writers.adb (Write_Dependency_Edge): Add the missing
case of a spec-before-body edge.
This patch corrects the generation of protected body declarations so
that instances of pragma Unreferenced applied to formals don't falsly
trigger undefined references.
2019-07-11 Justin Squirek <squirek@adacore.com>
gcc/ada/
* exp_ch9.adb (Build_Private_Protected_Declaration): Add
exception for the moving of pragmas to internally generated
specs for pragma Unreferenced.
Bob Duff [Thu, 11 Jul 2019 08:02:17 +0000 (08:02 +0000)]
[Ada] Fix inconsistent documentation for gnatmetric
One part said all metrics are enabled by default (which is now true),
and another part said the coupling metrics are disabled by default
(which is no longer true).
2019-07-11 Bob Duff <duff@adacore.com>
gcc/ada/
* doc/gnat_ugn/gnat_utility_programs.rst: Fix inconsistent
documentation for gnatmetric.
* gnat_ugn.texi: Regenerate.
* sem_ch8.adb (Analyze_Object_Renaming): Obtain the object being
renamed using routine Get_Object_Name which takes care of
various name forms.
(Get_Object_Name): New routine.
Ed Schonberg [Thu, 11 Jul 2019 08:01:54 +0000 (08:01 +0000)]
[Ada] Compile-time evaluation of predicate checks
This patch recognizes case of dynamic predicates on integer subtypes
that are simple enough to be evaluated statically when the argument is
itself a literal. Even though in many cases such predicate checks will
be removed by the back-end with any level of optimization, it is
preferable to perform this constant folding in the front-end, wich also
cleans up the output of CCG, as well as producing explicit warnings when
the test will fail.
2019-07-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch6.adb (Can_Fold_Predicate_Call): New function,
subsidiary of Expand_Call_Helper, to compute statically a
predicate check when the argument is a static integer.
[Ada] Link error due to negated intrinsic comparison
This patch corrects the resolution of operator "not" when the expression
being negated is an equality operator to prevent the transformation of
an intrinsic equality operator into a function call.
[Ada] Missing finalization of private protected type
This patch updates the analysis of protected types to properly mark the
type as having controlled components when it contains at least one such
component. This in turn marks a potential partial view as requiring
finalization actions.
------------
-- Source --
------------
-- types.ads
with Ada.Finalization; use Ada.Finalization;
package Types is
type Ctrl_Typ is new Controlled with null record;
procedure Finalize (Obj : in out Ctrl_Typ);
type Prot_Typ is limited private;
private
protected type Prot_Typ is
private
Comp : Ctrl_Typ;
end Prot_Typ;
end Types;
-- types.adb
with Ada.Text_IO; use Ada.Text_IO;
package body Types is
procedure Finalize (Obj : in out Ctrl_Typ) is
begin
Put_Line ("finalize");
end Finalize;
protected body Prot_Typ is
end Prot_Typ;
end Types;
-- main.adb
with Types; use Types;
procedure Main is
Obj : Prot_Typ;
begin
null;
end Main;
* exp_util.ads, exp_util.adb (Needs_Finalization): Move to
Sem_Util.
* sem_ch9.adb (Analyze_Protected_Definition): Code cleanup. Mark
the protected type as having controlled components when it
contains at least one such component.
* sem_util.ads, sem_util.adb (Needs_Finalization): New
function.
Eric Botcazou [Thu, 11 Jul 2019 08:01:35 +0000 (08:01 +0000)]
[Ada] New Repinfo.Input unit to read back JSON representation info.
For some time the Repinfo unit has been able to output the
representation information in the JSON data interchange format in
addition to the usual text and binary formats.
The new Repinfo.Input unit makes it possible to read back this
information under this format and make it available to clients, the main
one being ASIS.
The big advantage of using this approach over manipulating a binary blob
is that the writer and the reader of the JSON representation need not be
binary compatible, i.e. in practice need not be the same version of the
compiler or ASIS for the same target.
The patch also adds a -gnatd_j switch to read back the information in
the compiler itself, which makes it easy to keep the writer and the
reader in sync using only one tool, namely the compiler. The typical
usage is:
gcc -c p.ads -gnatR4js
gcc -c p.ads -gnatd_j
to exercise respectively the writer and the reader from the compiler.
2019-07-11 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* alloc.ads (Rep_JSON_Table_Initial): New constant.
(Rep_JSON_Table_Increment): Likewise.
* debug.adb: Document -gnatd_j switch.
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add
repinfo-input.o.
* gnat1drv.adb: Add with clause for Repinfo.Input.
Add with and use clauses for Sinput.
(Read_JSON_Files_For_Repinfo): New procedure.
(Gnat1drv1): Deal with -gnatd_j switch.
* repinfo-input.ad[sb]: New unit.
* snames.ads-tmpl (Name_Discriminant): New constant.
(Name_Operands): Likewise.
[Ada] No warning for guaranteed accessibility check failures
This patch corrects the generation of dynamic accessibility checks which
are guaranteed to trigger errors during run time so as to give the user
proper warning during unit compiliation.
2019-07-11 Justin Squirek <squirek@adacore.com>
gcc/ada/
* checks.adb (Apply_Accessibility_Check): Add check for constant
folded conditions on accessibility checks.
This patch introduces binder switch -d_S which prompts the various
phases of the elaboration order mechanism to output a short message
concerning their commencement and completion. The output is useful when
trying to determine whether a phase is stuck in an infinite loop.
------------
-- Source --
------------
-- main.adb
procedure Main is begin null; end Main;
----------------------------
-- Compilation and output --
----------------------------
* bindo.adb: Update the section of switches and debugging
elaboration issues.
* bindo.ads: Add type Elaboration_Phase.
* bindo-augmentors.adb: Add use clause for
Bindo.Writers.Phase_Writers.
(Augment_Library_Graph): Signal the start and end of the
aubmentation phase.
* bindo-builders.adb: Add with and use clause for Bindo.Writers.
Add use clause for Bindo.Writers.Phase_Writers.
(Build_Invocation_Graph): Signal the start and end of the
invocation graph construction phase.
(Build_Library_Graph): Signal the start and end of the library
graph construction phase.
* bindo-diagnostics.adb: Add use clause for
Bindo.Writers.Phase_Writers.
(Diagnose_Cycle): Signal the start and end of the cycle
diagnostic phase.
* bindo-elaborators.adb: Add use clause for
Bindo.Writers.Phase_Writers.
(Elaborate_Units): Signal the start and end of the unit
elaboration phase.
* bindo-graphs.adb: Add use clause for
Bindo.Writers.Phase_Writers.
(Find_Components): Signal the start and end of the component
discovery phase.
(Find_Cycles): Signal the start and end of the cycle discovery
phase.
* bindo-units.adb: Add with and use clause for Bindo.Writers.
Add use clause for Bindo.Writers.Phase_Writers.
(Collect_Elaborable_Units): Signal the start and end of the unit
collection phase.
* bindo-validators.adb: Add with and use clause for
Bindo.Writers. Add use clause for Bindo.Writers.Phase_Writers.
(Validate_Cycles, Validate_Elaboration_Order,
Validate_Invocation_Graph, Validate_Library_Graph): Signal the
start and end of the libray graph validation phase.
* bindo-writers.ads, bindo-writers.adb: Add new nested package
Phase_Writers.
* debug.adb: Update the documentation of switch d_S.
[Ada] Avoid spurious warning on wrong order of operator call arguments
GNAT issues a warning under -gnatwa when actuals for a call are named
like the formals, but in a different order. This is inappropriate for
calls to operators in infix form, when e.g. Right <= Left is in general
the intended order. Special case calls to operators to avoid that
spurious warning.
2019-07-11 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_res.adb (Check_Argument_Order): Special case calls to
operators.
gcc/testsuite/
* gnat.dg/warn21.adb, gnat.dg/warn21.ads: New testcase.
Richard Biener [Thu, 11 Jul 2019 07:32:04 +0000 (07:32 +0000)]
re PR middle-end/91131 (Bad bitfield coalescing)
2019-07-11 Richard Biener <rguenther@suse.de>
PR middle-end/91131
* gimplify.c (gimplify_compound_literal_expr): Force a temporary
when the object is volatile and we have not cleared it even though
there are no nonzero elements.
2019-07-10 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/predicates.md (cint34_operand): Update
SIGNED_34BIT_OFFSET_P call.
(pcrel_address): Update SIGNED_34BIT_OFFSET_P call.
(pcrel_external_address): Update SIGNED_34BIT_OFFSET_P call.
* config/rs6000/rs6000.c (rs6000_prefixed_address): Update
SIGNED_16BIT_OFFSET_P and SIGNED_34BIT_OFFSET_P calls.
* config/rs6000/rs6000.h (SIGNED_16BIT_OFFSET_P): Remove EXTRA
argument.
(SIGNED_34BIT_OFFSET_P): Remove EXTRA argument.
(SIGNED_16BIT_OFFSET_EXTRA_P): New macro, like
SIGNED_16BIT_OFFSET_P with an EXTRA argument.
(SIGNED_34BIT_OFFSET_EXTRA_P): New macro, like
SIGNED_34BIT_OFFSET_P with an EXTRA argument.
[Darwin, PPC] Collate the system library spec into one expression.
There's no need to redefine this dependent on the target header (that only
works in the case that we have self-hosting which is less and less likely
for the older system versions).
Actually, what we need is for the correct library set to be used based
on the SDK(s) that can target the chosen system.
[arm] Fix BE index for single-var vector initialisers (PR91060)
If a vector constructor has a single nonconstant element,
neon_expand_vector_init loads the constant lanes and then inserts the
nonconstant value. The problem was that it was doing the insertion
using the arm_neon.h neon_vset_lane<mode> patterns, which use
architectural lane numbering rather than GCC lane numbering.
2019-07-10 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR target/91060
* config/arm/iterators.md (V2DI_ONLY): New mode iterator.
* config/arm/neon.md (vec_set<mode>_internal): Add a '@' prefix.
(vec_setv2di_internal): Reexpress as...
(@vec_set<V2DI_ONLY:mode>_internal): ...this.
* config/arm/arm.c (neon_expand_vector_init): Use gen_vec_set_internal
rather than gen_neon_vset_lane<mode>.
Ian Lance Taylor [Wed, 10 Jul 2019 18:12:54 +0000 (18:12 +0000)]
compiler: finalize methods when importing types
This patch changes the compiler to be more aggressive about finalizing
methods on imported types, to avoid problems with interface types that
are imported but remain unreachable until a later stage in the compilation.
The normal pattern prior to this change was that the import process would
leave imported interface types alone, and rely on Gogo::finalize_methods
to locate and finalize all interface types at a later point. This way
of doing things was not working in all cases due to the fact that we can
import an interface type that is only reachable from the body of an
inlinable function, meaning that we can't "find" the type during
the methods finalize phase.
The importer's Import::read_types() now makes a pass over all imported
types to finalize methods on any newly imported type, which takes care
of the issue.
Ian Lance Taylor [Wed, 10 Jul 2019 17:56:40 +0000 (17:56 +0000)]
compiler: add break label in 1,2-case select statement lowering
CL 184998 added optimizations for one- and two-case select
statements. But it didn't handle break statement in the select
case correctly. Specifically, it didn't add the label definition,
so it could result in a dangling goto. This CL fixes this, by
adding the label definition.
[Ada] System.Strings.Stream_Ops: do not depend on Stream_IO
Dependence was only from Ada.Streams.Stream_IO.End_Error exception which
is renaming of the Ada.IO_Exceptions.End_Error. Use
Ada.IO_Exceptions.End_Error directly.
Ed Schonberg [Wed, 10 Jul 2019 09:02:55 +0000 (09:02 +0000)]
[Ada] Spurious run-time error with 64-bit modular types
As a lexical element an integer literal has type Universal_Integer, i.e
is compatible with any integer type. This is semantically consistent and
simplifies type checking and subsequent constant folding when
applicable. An exception is caused by 64-bit modular types, whose upper
bound is not representable in a non-static context that will use 64-bit
integers at run-time. For such cases we need to preserve the information
that the analyzed literal has that modular type. For simplicity we
preseve the information for all integer literals that result from a
modular operation. This happens after prior analysis (or construction)
of the literal, and after type checking and resolution.
2019-07-10 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch2.adb (Analyze_Integer_Literal): Preserve the type of
the literal if prior analysis determined that its type is a
modular integer type.
[Ada] Do not attempt to re-arm guard page on x86_64-vx7(r2)
A change in the API prohibits accessing Tcb fields directly. The bug in
VxWorks7 (failure to re-arm the guard page) now appears to be fixed, so
this is no long necessary.
2019-07-10 Doug Rupp <rupp@adacore.com>
gcc/ada/
* init.c: Do not attempt to re-arm guard page on x86_64-vx7(r2).
Ed Schonberg [Wed, 10 Jul 2019 09:02:47 +0000 (09:02 +0000)]
[Ada] Crash on aggregate for limited type in extended return
This patch fixes a compiler abort on an extended return statement whose
expression is an aggregate (to be built in place) for a discriminated
record with a limited component. The build-in-place mechanism creates an
access type and a renaming declaration through which individual
components are assigned. The renamed object is constrained because it is
limited, and the renaming declaration does not need to create a local
subtype indication for it, which may lead to type mismatches in the
back-end, and is in any case redundant. This patch extends this
optimization to the case of records that are limited only because of a
limitied component, and not because they are explicit declared limited.
2019-07-10 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch8.adb (Check_Constrained_Object): A record that is
limited because of the presence of a limited component is
constrained, and no subtype indiciation needs to be created for
it, just as is the case for declared limited records.
gcc/testsuite/
* gnat.dg/limited3.adb, gnat.dg/limited3_pkg.adb,
gnat.dg/limited3_pkg.ads: New testcase.
[Ada] Fix spurious messages on global variables for SPARK pointer support
Pointer support in GNATprove leads to spurious messages about global
variables, with local variables declared in local packages and protected
components. Now fixed.
There is no impact on compilation.
2019-07-10 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_aux.adb, sem_aux.ads (Is_Protected_Operation): New
function to determine if a subprogram is protected.
* sem_spark.adb (Setup_Protected_Components): New procedure to
add protected components to the environment.
(Check_Callable_Body): Call the new Setup_Protected_Components.
(Check_Package_Spec): Merge local environment with enclosing one
when done.
[Ada] Fix possible crashes in GNATprove analysis of pointers
The new analysis of SPARK pointer rules could crash on some constructs.
Now fixed.
There is no impact on compilation.
2019-07-10 Claire Dross <dross@adacore.com>
gcc/ada/
* sem_spark.adb (Check_Expression): Allow digits constraints as
input.
(Illegal_Global_Usage): Pass in the entity.
(Is_Subpath_Expression): New function to allow different nodes
as inner parts of a path expression.
(Read_Indexes): Allow concatenation and aggregates with box
expressions. Allow attributes Update and Loop_Entry.
(Check_Expression): Allow richer membership test.
(Check_Node): Ignore bodies of generics.
(Get_Root_Object): Allow concatenation and attributes.
[Ada] Spurious error on discriminant of incomplete type
This patch corrects the conformance verification of discriminants to
provide symmetry between the analysis of incomplete and full view
discriminants. As a result, types of discriminants always resolve to the
proper view.
Simon Buist [Wed, 10 Jul 2019 09:02:12 +0000 (09:02 +0000)]
[Ada] Entity names are not unique
This patch updates the Unique_Name procedure in order to prefix the
string "ada___" to child units that have a nested subprogram or package,
so that they do not clash with a parent package of the same name.
This is for GNATprove only and does not affect regular compilation.
2019-07-10 Simon Buist <buist@adacore.com>
gcc/ada/
* sem_util.ads (Child_Prefix): New constant.
* sem_util.adb (Unique_Name): Add a special prefix to child
units that have a nested subprogram or package.
* sem_ch3.adb (Check_Nonoverridable_Aspects): Correct the
spelling in certain error messages.
(Check_Pragma_Implemented): Correct the spelling in certain
error messages.
Eric Botcazou [Wed, 10 Jul 2019 09:01:58 +0000 (09:01 +0000)]
[Ada] Improve support for tuning branch probability heuristics
This adds a new GNAT.Branch_Prediction package to make it possible to
tune the branch probability heuristics more finely. This package
contains the equivalent of __builtin_expect in C/C++ plus a couple of
specializations.
The following program gives a summary of the usage:
package Q is
I : Integer;
pragma Volatile (I);
end Q;
with GNAT.Branch_Prediction; use GNAT.Branch_Prediction;
with Text_IO; use Text_IO;
with Q; use Q;
procedure P is
begin
if Unlikely (I = 0) then
Put_Line ("Zero was passed");
return;
end if;
if Likely (I > 0) then
Put_Line ("A positive number was passed");
else
Put_Line ("A negative number was passed");
end if;
if Expect ((I rem 2) = 0, False) then
Put_Line ("An even number was passed");
else
Put_Line ("An odd number was passed");
end if;
end;
2019-07-10 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-brapre.
* libgnat/g-brapre.ads: New package specification.
* doc/gnat_rm/the_gnat_library.rst: Document it.
* gnat_rm.texi: Regenerate.
For analysis tools that rely on information generated in ALI files, but
do not generate object files, the frontend did not generate the special
extension names like file~2.ali for unit 2 in the file. This is needed
to be able to analyze files with multiple units. Now fixed.
There is no impact on compilation.
2019-07-10 Yannick Moy <moy@adacore.com>
gcc/ada/
* osint-c.adb (Set_File_Name): Always add extension for multiple
units per file mode.
[Ada] sysdep.c: correct include directives ordering
Some VxWorks headers are relying on types that are defined in
`vxWorks.h` but do not include it themselves, we move the include
directive for `vxWorks.h` at the top of the include directives.
2019-07-10 Corentin Gay <gay@adacore.com>
gcc/ada/
* sysdep.c: Put include directive for 'vxWorks.h' before any
other VxWorks headers.
[Ada] Spurious error on case expression with limited result
This patch modifies the expansion of case expressions to prevent a
spurious error caused by the use of assignment statements to capture the
result of the case expression when the associated type is limited.
* exp_ch4.adb (Expand_N_Case_Expression): Mark the generated
assignments to the temporary result as being OK because the
expansion of case expressions is correct by construction.
(Is_Copy_Type): Update the predicate to match the comment
within.
gcc/testsuite/
* gnat.dg/limited2.adb, gnat.dg/limited2_pack_1.adb,
gnat.dg/limited2_pack_1.ads, gnat.dg/limited2_pack_2.adb,
gnat.dg/limited2_pack_2.ads: New testcase.
This patch adds contracts to Ada.Strings libraries, in order to remove
warnings when using these libraries in SPARK.
2019-07-10 Joffrey Huguet <huguet@adacore.com>
gcc/ada/
* libgnat/a-strbou.ads, libgnat/a-strfix.ads,
libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads: Add global
contracts, contract cases, preconditions and postconditions to
procedures and functions.
[Ada] Vxworks7r2 SR0610 coalesced some macro values
SR0600 and SR0610 cannot be differentiated by macro testing (arguably an
oversight in header file version.h) so: The case statement testing for
"file not found" is reformulated into an if/else series of statements to
avoid a problem where two cases have identical values in SR0610, but
different values in SR0600.
2019-07-10 Doug Rupp <rupp@adacore.com>
gcc/ada/
* sysdep.c (__gnat_is_file_not_found_error): Reformulate to also
work for vxworks7r2 SR0610.
[Ada] The environ macro is broken on vxworks7r2 SR0610
In SR0610, the TCB is made private, so the task environ field used by
the environ macro is no longer visible. Arguably this is a bug, however
a more correct approach is to use accessor functions to retrieve this
field and not use the environ macro, thus avoiding the problem.
2019-07-10 Doug Rupp <rupp@adacore.com>
gcc/ada/
* env.c (__gnat_environ): Reformulate to also work for
vxworks7r2 SR0610.
This patch introduces a new cycle detection algorithm which is based on
Tarjan's "Enumeration of the Elementary Circuits of a Directed Graph"
algorithm, with several ideas borrowed from Jonson's "Finding all the
Elementary Circuits of a Directed Graph" algorithm.
No need for a test because the new algorithm improves the performance of
cycle detection only.
* bindo.adb: Update the section on switches.
* bindo-graphs.adb
(Add_Cycle, Add_Vertex_And_Complement): Remove.
(Create): The graph no longer needs a set of recorded cycles
because the cycles are not rediscovered in permuted forms.
(Cycle_End_Vertices): New routine.
(Destroy): The graph no longer needs a set of recorded cycles
because the cycles are not rediscovered in permuted forms.
(Destroy_Library_Graph_Vertex): Move to the library level.
(Find_All_Cycles_Through_Vertex, Find_All_Cycles_With_Edge):
Remove.
(Find_Cycles_From_Successor, Find_Cycles_From_Vertex,
Find_Cycles_In_Component, Has_Elaborate_All_Edge): New routines.
(Insert_And_Sort): Remove.
(Is_Elaborate_Body_Edge): Use predicate
Is_Vertex_With_Elaborate_Body.
(Is_Recorded_Cycle): Remove.
(Is_Vertex_With_Elaborate_Body): New routine.
(Normalize_And_Add_Cycle): Remove.
(Precedence): Rename to xxx_Precedence, where xxx relates to the
input. These versions better reflect the desired input
precedence.
(Record_Cycle): New routine.
(Remove_Vertex_And_Complement, Set_Is_Recorded_Cycle): Remove.
(Trace_xxx): Update all versions to use debug switch -d_t.
(Trace_Component): New routine.
(Trace_Eol): Removed.
(Trace_Vertex): Do not output the component as this information
is already available when the component is traced.
(Unvisit, Visit): New routine.
* bindo-graphs.ads: Add new instance LGV_Lists. Remove instance
RC_Sets. Update the structure of type Library_Graph_Attributes
to remove the set of recorded cycles.
(Destroy_Library_Graph_Vertex): Move to the library level.
* bindo-writers.adb (Write_Component_Vertices): Output
information about the number of vertices.
* debug.adb: Document the use of binder switch -d_t. Update the
use of binder switch -d_T.
Code that violates the conditions for ownership checking should lead to
error messages pointing to the violations instead of crashes.
There is no impact on compilation, only GNATprove.
2019-07-10 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_spark.adb (Get_Root_Object): Replace precondition by error
message.
(Read_Indexes): Replace precondition by error message.
(Check_Callable_Body): Check only traversal function returns an
anonymous access type.
(Check_Expression): Issue error on unexpected expression as
path.
* sem_util.adb (First_Global): Fix access to global on
entry/task.
Javier Miranda [Wed, 10 Jul 2019 09:00:16 +0000 (09:00 +0000)]
[Ada] Missing implicit interface type conversion
The compiler skips adding an implicit type conversion when the interface
type is visible through a limited-with clause.
No small reproducer available.
2019-07-10 Javier Miranda <miranda@adacore.com>
gcc/ada/
* exp_ch6.adb (Is_Class_Wide_Interface_Type): New subprogram.
(Expand_Call_Helper): Handle non-limited views when we check if
any formal is a class-wide interface type.
* exp_disp.adb (Expand_Interface_Actuals): Handle non-limited
views when we look for interface type formals to force "this"
displacement.
Ed Schonberg [Wed, 10 Jul 2019 08:59:55 +0000 (08:59 +0000)]
[Ada] Spurious error on overloaded equality in postcondition
This patch fixes a spurious error in a postcondition in a nested
instantiation when the expression includes an inherited equality and
checks are enabled.
2019-07-10 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_res.adb (Resolve_Equality_Op): Do not replace the resolved
operator by its alias if expander is not active, because the
operand type may not be frozen yet and its inherited operations
have not yet been created.
gcc/testsuite/
* gnat.dg/equal8.adb, gnat.dg/equal8.ads,
gnat.dg/equal8_pkg.ads: New testcase.
This patch adds a missing functionality with respect to elaboration
order v3.0. Units carry an attribute called Elab_Position which among
other things controls the sorting of linker switches by gnatbind.
Setting the proper position ensures the gnatbind will output the linker
switches in an order compatible with what gnatlink expects.
No simple test available as this requires a Windows cross-compiler.
[Ada] Use renamings in GNATprove mode for side-effects extraction
In the GNATprove mode for formal verification, prefer renamings over
declaration of a constant to extract side-effects from expressions,
whenever the constant could be of an owning type, as declaring a
constant of an owning type has an effect on ownership which is
undesirable.
There is no impact on compilation.
2019-07-10 Yannick Moy <moy@adacore.com>
gcc/ada/
* exp_util.adb (Remove_Side_Effects): Prefer renamings for
objects of possible owning type in GNATprove mode.
Paolo Carlini [Wed, 10 Jul 2019 08:24:54 +0000 (08:24 +0000)]
decl.c (get_type_quals, [...]): New.
/cp
2019-07-10 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (get_type_quals,
smallest_type_location (const cp_decl_specifier_seq*)): New.
(check_tag_decl): Use smallest_type_location in error_at about
multiple types in one declaration.
(grokdeclarator): Use locations[ds_complex] in error_at about
complex invalid; use locations[ds_storage_class] in error_at
about static cdtor; use id_loc in error_at about flexible
array member in union; use get_type_quals.
/testsuite
2019-07-10 Paolo Carlini <paolo.carlini@oracle.com>
Jan Hubicka [Wed, 10 Jul 2019 06:08:29 +0000 (08:08 +0200)]
tree-ssa-alias.c (nonoverlapping_component_refs_p_1): Break out from ...; work also on duplicated types.
* tree-ssa-alias.c (nonoverlapping_component_refs_p_1): Break out
from ...; work also on duplicated types.
(nonoverlapping_component_refs_since_match): ... here
(ncr_type_uid): Break out from ...
(ncr_compar): ... here; look for TYPE_UID of canonical type if
available.
(nonoverlapping_component_refs_p): Use same_type_for_tbaa to match
the types and nonoverlapping_component_refs_p_1 to disambiguate.
* g++.dg/lto/alias-3_0.C: New file.
* g++.dg/lto/alias-3_1.c: New file.