This change fixes a compiler crash that would occur in some cases where
an expression involving transient return values of a limited view of a
class-wide interface type occur on the right hand side of a short circuit
operator.
The following compilation must be accepted quietly:
$ gcc -c
This patch corrects the transient object machinery to treat the renamed result
of a controlled function call as a finalizable transient when the context is an
expression with actions. If this was a different context, the lifetime of the
result would be considered extended and not finalized.
This patch modifies the analysis of aspects Abstract_State, Initializes and
Initial_Condition to ensure that they are inserted after pragma SPARK_Mode.
The proper placement allows for SPARK_Mode to be analyzed first and dictate
the mode of the related package.
-- Source --
The warning message pattern given for pragma Warning_As_Error or
for pragma Warnings no longer requires leading and trailing asterisks.
The match can be anywhere in the string without these characters
as shown in this example, compiled with -gnatwa -gnatld7 -gnatj55
Compiling: warnmatch.adb
It is now illegal to use Unrestricted_Access to directly generate a
thin pointer of an unconstrained array type which references a non-
aliased object. This never worked, and we might as well catch it as
illegal, since it is not hard to do so, as shown in the following
example:
1. with
This implements a new warning (on by default, controlled
by -gnatw.z/-gnatw.Z, included in -gnatwa), that warns
if a record type has a specified size and alignment where
the size is not a multiple of the alignment resulting in
an object size greater than the specified size.
The warning is
This patch completes the implementation of Ada 2012 static predicates, by
adding support for case expressions that can be transformed into a statically
evaluable expression on values of the subtype. Compiling:
gcc -c -gnata test_predicate.adb
must yield:
test_predicate.adb:11:20:
This change reorganizes expansion of object initialization statements, which
need to be captured under a single node id. Previously these were represented
as a (malformed) N_Expression_With_Actions with a NULL statement as its
expression. This irregularity is fixed by instead introducing a
When a gnat tool (gnatbind, gnatclean, gnatchop, gnatfind, gnatls,
gnatname, gnatprep or gnatmake) is incorrectly invoked, the usage is
no longer displayed. Instead, this line is displayed:
type gnatxxx --help for help
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-17 Vincent
This change fixes a defect whereby GNAT would fail to generate secondary
stack cleanup code for a scope containing a local object of a limited
discriminated type initialized by a (build-in-place) function call,
thus causing a storage leak.
The following test case must not leak memory for each
This change fixes the circuitry responsible for enforcing the uniqueness
of 'External_Tag attribute values. Previously uniqueness was checked at
type elaboration time only for types that have an explicit External_Tag
attribute definition clause. However we must also account for the fact
that the
This change addresses a missing unlock operation for the case of a call
to a protected function appearing as the expression of a RETURN statement:
the unlock was inserted after the statement containing the protected function
call, which means that in the case of a RETURN statement it would never
This patch updates the finalization machinery to recognize a case where the
result of a class-wide interface function call with multiple actual parameters
that appears in Object.Operation format requires finalization actions.
-- Source --
-- types.ads
with
This patch corrects the transient object machinery to treat the renamed result
of a controlled function call as a finalizable transient when the context is an
expression with actions. If this was a different context, the lifetime of the
result would be considered extended and not finalized.
This patch ensures that all delayed SPARK aspects are analyzed with the proper
SPARK mode of their related construct.
-- Source --
-- modes.ads
package Modes
with SPARK_Mode = On,
Abstract_State = State
is
Var : Integer := 1;
procedure Disabled_1
This corrects a situation in which extra reads of volatile objects
was being done. It was detected in the case of validity checks
being done on case expressions that were volatile, where two
reads were being done, one for the validity check, and one for
the actual case selection. But the problem
This patch clarifies the need of saving and restoring SPARK_Mode in a stack
like fashion. No change in behavior, no test needed.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-17 Hristian Kirtchev kirtc...@adacore.com
* sem_ch6.adb (Analyze_Subprogram_Body_Contract,
This new restriction No_Long_Long_Integer forbids any explicit reference
to type Standard.Long_Long_Integer, and also forbids declaring range
types whose implicit base type is Long_Long_Integer, and modular types
whose size exceeds Long_Integer'Size. The following is compiled with
-gnatl:
1.
This patch allows the renaming and subsequent instantiation of generic
subprograms that are marked Intrinsic, such as the predefined units
Unchecked_Conversion and Unchecked_Deallocation.
The following must execute quietly:
gnatmake -q -gnatws uncrename.adb
uncrename
---
with Mumble;
An optional final named argument [Entity = local_NAME] is allowed
for pragma Annotate to indicate that the annotation is for a particular
entity, and a corresponding Annotate aspect is introduced.
Given the test program:
1. package AspectAnn is
2.Y : constant Integer := 43;
3.
This patch modifies the parser to catch a case where the argument of SPARK
aspect Refined_State is not properly parenthesized.
-- Source --
-- no_parens.ads
package No_Parens
with SPARK_Mode = On,
Abstract_State = State
is
pragma Elaborate_Body;
end
This implements the final definition of the Ada 2012 restriction
No_Standard_Allocators_After_Elaboration. There are two static
cases. First appearence in task body, this one we already had
before (compiled with -gnatj55 -gnatld7)
1. procedure Pmain2 is
2.type P is access all
Add two missing style checks for token spacing for binary operators when
switches -gnatyt, -gnatyy or -gnatyg is used.
Preserve previous behavior with debug switch -gnatd.Q
Test:
$ gcc -c pkg.ads -gnatyt -gnatl -gnatd7
Compiling: pkg.ads
1. package Pkg is
2.One : constant := 1;
the container type is a derived type, the value of the inherited aspect is the
Reference (or Constant_Reference) operation declared for the parent type.
However, Reference is also a primitive operation of the new type, and the
inherited operation has a different signature. It is necessary to
Previously all rep clauses were ignored in -gnatI mode, but in two
cases (enumeration rep clauses and record rep clauses), they were
not removed from the tree, causing trouble with ASIS tools. These
two cases are now consistent, and ASIS tools will see none of the
ignored rep clauses (e.g. gnatpp
The rules for static predicates do not allow the type name to be
parenthesized. This was not checked, but is now fixed, the following
test now gives the error indicated (compiled with -gnatld7 -gnatj55)
(it used to compile without errors).
1. package BadParenSP is
2.subtype r is
Output lines from GNAT.Memory_Dump.Dump can now be prefixed with an offset
relative to the start of the dump, or have no prefix at all, instead of
showing an absolute address.
Test:
$ gnatmake -q dump_test
$ ./dump_test
00: 4C 6F 72 65 6D 20 69 70 73 75 6D 20 64 6F 6C 6F Lorem ipsum dolo
10: 72
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-18 Pascal Obry o...@adacore.com
* s-crtl.ads, i-cstrea.ads (fputwc): New routine.
* a-witeio.adb (Put): On platforms where there is translation
done by the OS output the raw text.
(New_Line): Use Put
In Ada 2012, the formals of a subprogram can be incomplete types, and the
subprogram is a primitive operation of the type. If the type is subsequently
derived, it inherits the operation, and it can be explicitly overridden.
Executing main.adb must yield:
1
2
---
with Prim_Test; use
This reorganizes the handling of predicates, in preparation for proper
implementation of real predicates. Several minor errors are corrected
and we properly reject improper static real predicates. Static string
predicates are now always rejected, in line with latest ARG thinking.
The following
If a constant is defined with a static expression, and the expression
statically fails a static predicate, then the constant is not considered
as being static, as shown by this updated example (see last few lines)
1. package TestSP is
2.subtype F1 is Float with -- OK
3.
An error occurring in a subexpression that is part of some construct in
general suppresses the reporting of further errors on the same construct,
to avoid noisy cascaded messages. This patch ensures that this is also
the case when named associations are present.
The following test case must be
In conversions of prefixed calls involving interfaces, the expression in the
conversion may have a limited view of a type obtained transitively through
several contexts. Use the non-limited view if available, to enable subsequent
interface membership tests.
The following must compile quietly:
This patch ensures that abort-related expansion generates the same amount of
internal entities when aborts are allowed or are being suppressed by pragma
Restriction (No_Abort_Statements).
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-29 Hristian Kirtchev kirtc...@adacore.com
This patch corrects the transient object machinery to disregard aliasing when
the associated context is a Boolean expression with actions. This is because
the Boolean result is always known after the action list has been evaluated,
therefore the transient objects must be finalized at that point.
A new pragma Unevaluated_Use_Of_Old (Error | Warn | Allow) is
implemented which controls the processing of attributes Old and
Loop_Entry. If either of these attributes is used in a potentially
unevaluated expression e.g. the then or else parts of an if
expression), then normally this usage is
This is just an internal cleanup, involving some name changes
and slightly cleaned up testing of flags etc. This is part of
the preparation for implementing static real predicates. No
functional effect.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-29 Robert Dewar de...@adacore.com
This implements static predicates for string and real types,
as defined in the RM. There is one exception, which is that
the RM allows X ABC as being predicate static, but since
ABC ABA is not static, that's peculiar, so we assume
that this is a mistake in the RM, and that string comparisons
Normally the default scalar storage order is the native order of the
target. This pragma, which can be either a configuration pragma, or
appear in a package spec or declarative part, can provide a default
value that overrides this normal default. If used in a package spec
or declarative part, it
The Error option for pragma Unevaluated_Use_Of_Old was not properly
recognized, due to an internal problem with the generation of the
names table for the Snames package. This is now corrected, and
the following program compiles as shown with -gnatld7 -gnatj60:
1. package Uneval_Old is
This patch implements the following set of rules related to shared variables:
1. A volatile representation aspect may only be applied to an
object_declaration or a full_type_declaration.
2. A component of a non-volatile type declaration shall not be volatile.
3. A discriminant
If a procedure or entry has an formal out-parameter of a null-excluding access
type, there is no check applied to the actual before the call. This patch
removes a spurious access check on such parameters on entry calls.
Compiling and executing p.adb must yield;
Procedure version did not
On Linux, s-oscons-tmplt.c needs to define _BSD_SOURCE in order for
CRTSCTS to be visible. Otherwise the macro is undefined, and defaulted
to -1.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-29 Thomas Quinot qui...@adacore.com
PR ada/60652
* s-oscons-tmplt.c: For
For formal verification with GNATprove, frontend inlining can be used to
relieve users from the need to add contracts to local subprograms. Thus,
we adopt here a simple policy for inlining in GNATprove mode, which consists
in inlining all local subprograms which can be inlined, as soon as they
This fix is inspired by ACATS test C324002, which tests that
predicate tests for OUT and IN OUT parameters are properly
applied. They were missed in some cases, and applied when
they should not be to Finalize procedures.
The following three tests (cutdown versions of C324002) compile
and execute
This removes a subprogram which serves no useful purpose and changes the
affected case to use the common code path. No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-29 Eric Botcazou ebotca...@adacore.com
* exp_aggr.adb (Safe_Slice_Assignment): Remove.
Some additional cases of internal routines are now detected and skip
predicate tests on arguments. Not clear if this fixes additional
problems or not, but it is certainly a desirable change. No further
test required.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-30 Robert Dewar
A variable V declared in a project A that is extended by a project B is
now inherited in project B; it can be referenced as V in project B or as
B.V in any other project that imports B.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-30 Vincent Celier cel...@adacore.com
*
This patch makes the compiler generate faster code to reset a large array of
integers to 0 by means of an aggregate with a single Others choice and, more
generally, to set a large array of storage units to a single value by the
same means, for example:
type Arr is array (1 .. 1) of Integer;
The following code:
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Formatted_String; use GNAT.Formatted_String;
procedure Fout is
F : Formatted_String := +%c %% %#08x;
Vc : Character := 'v';
Vi : Integer := 12;
begin
F := F Vc Vi;
Put_Line (-F);
end
This patch modifies the categorization of aspects Async_Readers, Async_Writers,
Effective_Reads and Effective_Writes to no longer require delayed actions. This
in turn ensures that the analysis of their aspect form correctly creates their
pragma counterparts.
-- Source --
In GNATprove, we need to distinguish code form inlined subprograms and code
from generic instances, based on their source locations, to have better
messages. This new query does precisely this.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-07-30 Yannick Moy m...@adacore.com
*
In GNATprove mode, all subprograms are candidates for front-end inlining, to
simplify proofs. This patch extends this transformation to subprogam bodies
that do not have a previous subprogram declaration. In this case the compiler
builds a declaration, transfers aspects, if any, from body to
This patch changes the categorization of SPARK 2014 aspects from delayed to
non-delayed. These aspects are equivalent to source pragmas which appear after
their related constructs. To deal with forward references, the generatd pragmas
are stored in N_Contract nodes and later analyzed at the end of
This patch causes the compiler to print the compilation time in
-gnatv or -gnatl mode (suppressible with debug flag -gnatd7).
It also provides new functions in GNAT.Source_Info to obtain
the compilation date and time (in a form compatible with the
use of the C macros __DATE__ and __TIME__.
This patch implements the following SPARK 2014 rule:
4.4.1 (1) - The box symbol, , may not appear in any expression appearing
in an update expression.
The patch also cleans up the analysis of attribute 'Update.
-- Source --
-- box_update.ads
package Box_Update
The compiler silently skips the generation of code to perform the
conversion of an access type whose designated type is a class-wide
interface type, thus causing unexpected problems at runtime in
dispatching calls to the target object. After this patch the
following test compiles and executes
This change lifts the arbitrary limitation on the number of iterations that
can be executed between loading of the inlined bodies and instantiation of
the generic bodies of external units when inter-unit inlining is activated.
It was previously limited to 1 but this may be not sufficient in some
This change makes is so that Following_Address_Clause is invoked only if this
is really necessary from Analyze_Object_Declaration. This saves about 1% of
the compilation time at low optimization levels. No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-11-20 Eric
An operator that is called in functional notation is rewritten as an operator
so that its operands can be properly resolved. ASIS needs the semantic info
to be available on the original node, so in ASIS mode the resolved operands
are linked back to the original call. This patch takes into account
If the left-hand side of an assignment is an Ada 2012 generalized indexing
with an implicit derenference, the compiler must verify that the type of
the access discriminant that provides the implicit dereference is not an
access_to_constant.
Compiling ada_test.adb must yield:
The following changes are importants:
- It is possible to have multiple tasks waiting for a child process
to terminate.
- When a child terminates, a single wait call will receive the
corresponding process id.
- A call to wait will handle new incoming child processes.
Tested on
The patch modifies the expansion of attributes 'Old and 'Update to ensure that
the tag of a tagged prefix is not modified as a result attribute evaluation.
-- Source --
-- types.ads
package Types is
type Root is tagged record
X : Integer;
end record;
This patch the following SPARK rule (the part about 'Loop_Entry, 'Old, 'Update)
If the Extensions_Visible aspect is False for a subprogram, then certain
restrictions are imposed on the use of any parameter of the subprogram which
is of a specific tagged type. Such a parameter shall not
While the library of formal maps/sets correctly set SPARK_Mode on spec
(On) and private part / body (Off), it was not the case for lists and
vectors, thus causing some errors in GNATprove when instantiating such
formal containers because bodies contain non-SPARK features (e.g. access
types in
Range checks on empty ranges typically correspond to deactivated code
based on a given configuration (say, dead code inside a loop over the
empty range). In GNATprove mode, instead of issuing an error message
(which would stop analysis), enable the range check so that GNATprove
will issue a
Like other similar pragmas, we should disallow duplicate pragma or
aspect Linker_Section for non-overloadable entities (for the case
of overloading, the pragma only applies to previous entities which
do not have such a pragma).
The following should compile with the given error:
1. package
On platform where the switch is allowed, the gcc driver, when called with
-Gnnn (nnn is a non negative number) invokes the compiler (gnat1) with
-G nnn. This patch skips the argument nnn after -G, so that it is not
taken as a source file name.
Tested on x86_64-pc-linux-gnu, committed on trunk
This patch fixes two errors in the handling of extension aggregates for limited
types: Ancestor part of extension aggregate can itself be an extension aggregate
as well as a function call that is rewritten as a reference.
The following must compile quietly:
gcc -c p2.adb
gcc -c
This enables inter-unit inlining of expression functions with -gnatn1, or more
simply with -O1/-O2 -gnatn. These functions are automatically candidates for
inlining, but there were actually inlined across units only with -gnatn2, or
more simply -O3 -gnatn.
The following program must compile
This patch modifies the mechanism which creates a subtype from an arbitrary
expression. The mechanism now captures the bounds of all index constraints
when the expression is of an array type.
-- Source --
-- pack.ads
with Ada.Finalization; use Ada.Finalization;
The compiler suppresses debugging information on predefined units that are
inlined in the code, because stepping into run-time units often complicates
debugging activity. We make an exception for calls that appear in the source,
when the unit is part of the Ada hierarchy, to facilitate monitoring
This patch avoids issuing a warning for a missing component clause
for a discriminant in an unchecked union, and also avoids printing
a line for such a component in the -gnatR2 output.
The following program:
1. with Interfaces;
2. procedure Test_Union is
3. type Test_Type (Flag
Two units, one in a multi-source file and one in another source with
the same base file name do not have the same object file name.
No error during processing of the following project file should be
reported:
project Prj is
package Naming is
for Spec (foo_bar) use foo_bar.ads at 2;
Fixing version number according to new GCC naming scheme.
PR ada/63931
* gnatvsn.ads (Library_Version): Switch to 5.
Index: gnatvsn.ads
===
--- gnatvsn.ads (revision 217874)
+++
This is a minor internal cleanup, to introduce a new primitive
Is_Subprogram_Or_Generic_Subprogram with the obvious meaning.
No external effect, no test required.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-10 Robert Dewar de...@adacore.com
* sem_ch7.adb, einfo.adb,
If one or more objects is compiled in GNATprove mode (either by using
GNATprove directly, or by using -gnatd.F), then the ALI file is marked
and gnatbind will exit with a message as shown here. Given:
1. procedure linkdf is
2. begin
3.null;
4. end;
If we first compile
Illegal Global/Depends contracts should be flagged by frontend in code for
which SPARK_Mode is not specified, as GNATprove relies on contracts being
legal in those cases. The frontend should skip these errors only when
SPARK_Mode is Off. Now fixed, as shown on the following example.
Command:
This patch enforces the same semantics for the handling of loop parameters
in element iterators over formal containers, os those over formal containers:
the loop parameter cannot be assigned to in user code.
Compiling formal_test.adb must yield:
formal_test.adb:15:07: assignment to loop
The string returned by GNAT.Source_Info.Enclosing_Entity did not include
names of operators (e.g. **).
The following program:
1. with Text_IO; use Text_IO;
2. with GNAT.Source_Info; use GNAT.Source_Info;
3. procedure BadEE is
4.type R is new Boolean;
5.RV : R :=
This implements a new configuration pragma
pragma Prefix_Exception_Messages;
which causes messages set using raise x with s to be
prefixed by the expanded name of the enclosing entity if
s is a string literal (if s is more complex, we assume
the program is calculating exactly the message it
This patch fixes an error in the legality checks of aspects that apply
to library units: these aspects are legal on a local instantiation of a
library-level generic unit that carries the aspect pure.
The following must compile quietly:
gcc -c my_buffer.adb
---
package My_Buffer
with
Ada05-019 specifies that freezing a subprogram does not automatically freeze
the profile, i.e. the types of the formals and the return type. In particular
an attribute reference 'Access and its relatives do not freeze the profile.
Compiling bd.ads must yield:
bd.ads:15:34: incorrect
This patch modifies the inheritance of all attributes related to pragma
Default_Initial_Condition to account for a case where the full view of
a private type derives from another private type.
-- Source --
-- parent.ads
package Parent is
type Parent_Typ is private
This is an internal change that does not affect the compiler, but fixes
a problem in which a record comparison was not properly expanded. The
compiler back end handled this, but it blew up codepeer. No further
test required.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-17 Robert
The system unit System.Atomic_Counters which provides an atomic
counter type, along with increment, decrement and test operations,
available to user programs.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-17 Robert Dewar de...@adacore.com
* gnat_rm.texi: Document
Documentation change only, no further test required
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-17 Robert Dewar de...@adacore.com
* gnat_rm.texi: Document that string literal can be used for
pragma Warnings when operating in Ada 83 mode.
Index: gnat_rm.texi
A class-wide type invariant is inherited by a type extension, and incorporated
into the invariant procedure for that type. When the expression for such an
invariant (typically a function call) is first analyzed, we must preserve some
semantic information in it, because the type extension may be
This fixes an error in the handling of attributes where the prefix
raises an exception. This resulted from other errors in the program.
No simple test case has been found, but the correction is clearly
safe.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-17 Robert Dewar
A new mechanism has been implemented that allows specialization of
error messages for missing entities in a configurable run-time.
Instead of just outputting the (sometimes obscure) name of the
entity involved, a more meaningful message can be issued. This
new mechanism is used for a case of
For the purposes of restriction No_Implementation_Identifiers,
Standard.Short_Integer should be considered as being implementation
defined and this was not the case. In addition, this patch fixes
a compiler blow up with a compiler built with assertions in the
test for implementation-defined
This patch improves the error message on an iterator specification whose name
is a function call that does not yield a type that implements an iterator
interface.
Compiling try_containers.adb must yield:
try_containers.adb:17:18: expect object that implements iterator interface
--
with
Directories such as object directories are no longer created for abstract
projects when the builder (gnatmake or gprbuild) is called with -P or
with --subdirs=..., even when there is no explicit indication in the
abstract project that there are no sources in the project.
Tested on
This is an internal clean up to use an existing abstraction
more extensively. No external effect, no test required.
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-10-17 Robert Dewar de...@adacore.com
* gnatcmd.adb, make.adb, prj-part.adb, gnatlink.adb, prj-nmsc.adb,
When expanding a limited aggregate into individual assignments, we create a
transient scope if the type of a component requires it. This must not be done
if the context is an initialization procedure, because the target of the
assignment must be visible outside of the block, and stack cleanup will
Typically an indexing aspect is specified on the private view of a tagged
type. In the unusual case where there is an incomplete view and the aspect
specification appears on the full view, the aspect specification must be
analyzed on the full view rather than the incomplete one, to prevent
This change makes it so that instantiations of generic subprograms marked as
inline are considered for inter-unit inlining. This was not previously the
case because of a technical limitation that was too broadly enforced (unlike
the associated comment which was more accurate) and excluded
The No_Tagged_Streams pragma (and aspect) provides a method for
selectively inhibiting the generation of stream routines for
tagged types. It can be used either in a form naming a specific
tagged type, or in a sequence of declarations to apply to all
subsequent declarations.
The following tests
This patch improves the error recovery for an errant comma or semicolon
after one condition in an expression when more conditions follow, as
shown in this example:
1. procedure BadANDTHEN (X : Integer) is
2. begin
3.if X 10
4. and then X mod 4 = 2;
As shown by this example, the recognition of misspelled aspects is
improved:
1. package UnrecogAs with Prelaborate is
|
Prelaborate is not a valid aspect identifier
possible misspelling of Preelaborate
2.type R is tagged null record;
1 - 100 of 2336 matches
Mail list logo