Martin Liska [Thu, 4 Jul 2019 15:59:19 +0000 (17:59 +0200)]
Support __builtin_expect_with_probability for analysis of # of loop iterations.
2019-07-04 Martin Liska <mliska@suse.cz>
* tree-ssa-loop-niter.c (get_upper_bound_based_on_builtin_expr_with_prob):
New function.
(estimate_numbers_of_iterations):
Support __builtin_expect_with_probability for analysis
of # of loop iterations.
Andrea Corallo [Thu, 4 Jul 2019 15:46:00 +0000 (15:46 +0000)]
introduce gcc_jit_context_new_bitfield
gcc/jit/ChangeLog:
2019-07-04 Andrea Corallo <andrea.corallo@arm.com>
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_12): New ABI tag.
* docs/topics/types.rst: Add gcc_jit_context_new_bitfield.
* jit-common.h (namespace recording): Add class bitfield.
* jit-playback.c:
(DECL_C_BIT_FIELD, SET_DECL_C_BIT_FIELD): Add macros.
(playback::context::new_bitfield): New method.
(playback::compound_type::set_fields): Add bitfield support.
(playback::lvalue::mark_addressable): Was jit_mark_addressable make this
a method of lvalue plus return a bool to communicate success.
(playback::lvalue::get_address): Check for jit_mark_addressable return
value.
* jit-playback.h (new_bitfield): New method.
(class bitfield): New class.
(class lvalue): Add jit_mark_addressable method.
* jit-recording.c (recording::context::new_bitfield): New method.
(recording::bitfield::replay_into): New method.
(recording::bitfield::write_to_dump): Likewise.
(recording::bitfield::make_debug_string): Likewise.
(recording::bitfield::write_reproducer): Likewise.
* jit-recording.h (class context): Add new_bitfield method.
(class field): Make it derivable by class bitfield.
(class bitfield): Add new class.
* libgccjit++.h (class context): Add new_bitfield method.
* libgccjit.c (struct gcc_jit_bitfield): New structure.
(gcc_jit_context_new_bitfield): New function.
* libgccjit.h
(LIBGCCJIT_HAVE_gcc_jit_context_new_bitfield) New macro.
(gcc_jit_context_new_bitfield): New function.
* libgccjit.map (LIBGCCJIT_ABI_12) New ABI tag.
gcc/testsuite/ChangeLog:
2019-07-04 Andrea Corallo <andrea.corallo@arm.com>
I found GIMPLE_EH_ELSE offered exactly the semantics I needed for some
Ada changes yet to be contributed, but GIMPLE_EH_ELSE was only built
by GIMPLE passes, and I needed to build earlier something that
eventually became GIMPLE_EH_ELSE.
This patch does that, introducing an EH_ELSE_EXPR tree, and logic to
dump it and to gimplify it.
for gcc/ChangeLog
* doc/generic.texi (Cleanups): Document EH_ELSE_EXPR.
* except.c: Likewise.
* expr.c (expand_expr_real_1): Reject it.
* gimplify.c (gimplify_expr): Gimplify it, within
TRY_FINALLY_EXPR.
* tree-dump.c (dequeue_and_dump): Dump it.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree.c (block_may_fallthru): Handle it.
* tree.def (EH_ELSE_EXPR): Introduce it.
* gimple-pretty-print.c (dump_gimple_try): Dump TRY_FINALLY
with GIMPLE_EH_ELSE as try/finally/else.
Richard Biener [Thu, 4 Jul 2019 13:56:12 +0000 (13:56 +0000)]
re PR ipa/91062 (gcc.dg/ipa/ipa-pta-1.c dump contains garbage when gcc was configured with --enable-checking=all)
2019-07-04 Richard Biener <rguenther@suse.de>
PR ipa/91062
* tree-pass.h (execute_all_ipa_transforms): Add a flag
parameter whether to disable GC collection.
* passes.c (execute_one_ipa_transform_pass): Likewise, and
honor it.
(execute_all_ipa_transforms): Likewise and pass it down.
* cgraph.c (cgraph_node::get_body): Do not invoke garbage
collection from applying IPA transforms.
* cgraphunit.c (cgraph_node::expand): Allow garbage collection
from applying IPA transforms.
Richard Biener [Thu, 4 Jul 2019 13:55:15 +0000 (13:55 +0000)]
re PR tree-optimization/90911 (456.hmmer regression with r272239)
2019-07-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/90911
* tree-vectorizer.h (_loop_vec_info::scalar_loop_scaling): New field.
(LOOP_VINFO_SCALAR_LOOP_SCALING): new.
* tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Initialize
scalar_loop_scaling.
(vect_transform_loop): Scale scalar loop profile if needed.
* tree-vect-loop-manip.c (vect_loop_versioning): When re-using
the loop copy from if-conversion adjust edge probabilities
and scale the vectorized loop body profile, queue the scalar
profile for updating after peeling.
Jan Hubicka [Thu, 4 Jul 2019 12:52:22 +0000 (14:52 +0200)]
tree-ssa-alias.c (decl_refs_may_alias_p): Add size1 and size2 parameters; return early for must-alias.
* tree-ssa-alias.c (decl_refs_may_alias_p): Add size1 and size2
parameters; return early for must-alias.
(indirect_ref_may_alias_decl_p): Likewise; when establishing
outer types match, try nonoverlapping_component_refs
if must-alias is not obvious.
(indirect_refs_may_alias_p): Likewise.
(refs_may_alias_p_2): Likewise.
* gcc.dg/tree-ssa/alias-access-path-3.c: New testcase.
* gcc.dg/tree-ssa/alias-access-path-8.c: New testcase.
Eric Botcazou [Thu, 4 Jul 2019 08:07:19 +0000 (08:07 +0000)]
[Ada] Clean up support for validity checks in the compiler
This removes old code in the parser that serves no useful purpose and
fixes minor issues in the Validsw package. No functional changes.
2019-07-04 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gnat1drv.adb (Adjust_Global_Switches): Use proper interface to
set the validity settings in CodePeer mode.
* par-load.adb (Load): Remove all code dealing with validity
settings.
* validsw.ads (Validity_Check_Copies): Alphabetize.
* validsw.adb (Reset_Validity_Check_Options): Set all options to
off.
(Save_Validity_Check_Options): Save all options.
Ed Schonberg [Thu, 4 Jul 2019 08:07:00 +0000 (08:07 +0000)]
[Ada] Spurious error on instantiation and limited_with_clause
This patch fixes a spurious error during the construction of an instance
body in the inlining phase of the frontend, when the package declaration
for the main unit has a limited_with_clause on some unit P, and the main
unit itself does not have a corresponding regular with_clause, but some
other unit in the context has with_clause that has compiled P. P must
be removed from visibility to prevent conflicts with homonyms in the
generic body to be instantiated.
The following must compile quietly:
gcc -c gpr2-project-view.adb
----
package GNATCOLL is
end GNATCOLL;
package GNATCOLL.Refcount is
generic
type Element_Type (<>) is private;
package Shared_Pointers is
type Ref is tagged private;
type Element_Access is access all Element_Type;
type Reference_Type (Element : access Element_Type)
is limited null record;
function Unchecked_Get (Self : Ref'Class) return Element_Access;
function Get (Self : Ref'Class) return Reference_Type
is ((Element => Unchecked_Get (Self)));
private
type Ref is tagged null record;
end Shared_Pointers;
type Refcounted is abstract tagged null record;
generic
type Encapsulated is abstract new Refcounted with private;
package Smart_Pointers is
type Encapsulated_Access is access all Encapsulated'Class;
type Ref is tagged private;
procedure Set (Self : in out Ref; Data : Encapsulated'Class);
procedure Set (Self : in out Ref; Data : access Encapsulated'Class);
private
type Ref is tagged null record;
end Smart_Pointers;
end GNATCOLL.Refcount;
----
package body GNATCOLL.Refcount is
package body Shared_Pointers is
function Unchecked_Get (Self : Ref'Class) return Element_Access is
begin
return null;
end Unchecked_Get;
end Shared_Pointers;
package body Smart_Pointers is
procedure Set (Self : in out Ref; Data : access Encapsulated'Class) is
begin
null;
end Set;
procedure Set (Self : in out Ref; Data : Encapsulated'Class) is
Tmp : constant Encapsulated_Access := new Encapsulated'Class'(Data);
begin
Set (Self, Tmp);
end Set;
end Smart_Pointers;
end GNATCOLL.Refcount;
----
package GPR2 is
end GPR2;
----
package GPR2.Parser is
end GPR2.Parser;
----
with GPR_Parser.Analysis;
package GPR2.Parser.Project is
end GPR2.Parser.Project;
----
package GPR2.Project is
end GPR2.Project;
----
with GPR2.Parser.Project;
package GPR2.Project.Configuration is
end GPR2.Project.Configuration;
----
with GPR2.Project.Configuration;
with GPR2.Unit.Set;
package GPR2.Project.Definition is
end GPR2.Project.Definition;
----
limited with GPR2.Unit.Set;
package GPR2.Project.View is
procedure Require_Body;
end GPR2.Project.View;
----
with GPR2.Project.Definition;
package body GPR2.Project.View is
procedure Require_Body is null;
end GPR2.Project.View;
----
package GPR2.Unit is
end GPR2.Unit;
package GPR2.Unit.Set is
end GPR2.Unit.Set;
...
package GPR_Parser is
end GPR_Parser;
----
with GNATCOLL.Refcount;
package GPR_Parser.Analysis is
type Unit_Provider_Interface is null record;
package Unit_Provider_References is new GNATCOLL.Refcount.Shared_Pointers
(Unit_Provider_Interface);
end GPR_Parser.Analysis;
2019-07-04 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch10.adb (Remove_Context_Clauses): Handle properly the
removal of a limited_with_clause which appears in the library
unit oF the main unit, when some other unit in the context has a
regular with_clause on the same unit, to prevent spurious
visibility errors in the subsequent analysis of pending instance
bodies.
[Ada] Management of internal data structures in Sem_Elab
This patch modifies the timing of Sem_Elab's internal data structure
creation and destruction, and adds the concept of "active" elaboration
compiler phase.
The elaboration phase of the compiler is active after the frontend
initializes Sem_Elab. It is at this point that all internal data
structures of Sem_Elab are created and become ready to accept data.
The elaboration phase of the compiler is completed after all elaboration
scenarios are examined, all ABE checks are intalled, and diagnostics are
emitted. It is at this point that all internal data structures of
Sem_Elab are destroyed. Further attempts to reintroduce data into
Sem_Elab by subsequent compiler phases are cut off.
* sem_elab.adb: Add new type Elaboration_Phase_Status along with
a global to keep track of the elaboration phase status.
Initialize all internal data structures to Nil for services
Elaborated_Units, Internal_Representation, and Scenario_Storage.
(Build_Call_Marker): Do not create a call marker when the
elaboration phase is not active.
(Build_Variable_Reference_Marker): Do not create a call marker
when the elaboration phase is not active.
(Check_Elaboration_Scenarios): Destroy all internal structures
when the elaboration phase does not have to run. Do not execute
when the elaboration phase is not active.
(Elaboration_Phase_Active): New routine.
(Finalize_All_Data_Structures): New routine.
(Initialize): Initialize all internal data structures and signal
that the elaboration phase has started.
(Initialize_All_Data_Structures): New routine.
(Initialize_Elaborated_Units): Initialize all internal data
structures.
(Initialize_Internal_Representation): Initialize all internal
data structures.
(Initialize_Scenario_Storage): Initialize all internal data
structures.
(Kill_Elaboration_Scenario): Do not execute when the elaboration
phase is not active.
(Set_Elaboration_Phase): New routine.
(Update_Elaboration_Scenario): Do not execute when the
elaboration phase is not active.
Gary Dismukes [Thu, 4 Jul 2019 08:06:49 +0000 (08:06 +0000)]
[Ada] Expr. func. with private formal rejected in nested Ghost package
The compiler prematurely freezes a private type that is the type of a
formal parameter of an expression function declared within a nested,
inactivated Ghost package, resulting is an error complaining that the
private type must be fully defined at that point. This is fixed by
testing for Ignored_Ghost_Entity in the condition guarding the code that
performs Mask_Unfrozen_Types for an expression function without a
separate declaration, ensuring that the expression function's profile
isn't frozen prematurely.
2019-07-04 Gary Dismukes <dismukes@adacore.com>
gcc/ada/
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): The special
treatment of calling Mask_Unfrozen_Types must also be done in
the case of an Ignored_Ghost_Entity, because Expander_Active is
False in that case.
gcc/testsuite/
* gnat.dg/ghost5.adb, gnat.dg/ghost5.ads,
gnat.dg/ghost5_parent.ads: New testcase.
[Ada] Spurious error on incomplete tagged formal parameter
This patch fixes an issue whereby a check for competing controlling
formals led to a spurious dispatching error due to an incomplete type
being used within a subprogram specification.
2019-07-04 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_disp.adb (Check_Controlling_Formals): Obtain the full view
before type comparison.
gcc/testsuite/
* gnat.dg/tagged2.adb, gnat.dg/tagged2.ads: New testcase.
Ed Schonberg [Thu, 4 Jul 2019 08:06:35 +0000 (08:06 +0000)]
[Ada] Bug in composition of equality for variant records
This patch fixes an omission in the construction of equality routines
for variant records, to take into account user-defined equality
functions for components of the record. Previously the constructed
equality routine for variant records used the predefined equality for
all components, When composavility of equality was introduced for
untagged records, expansion of record equality was modified properly,
but not for the case of variant records, which use a different and more
complex process to build the equality function.
2019-07-04 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* exp_ch4.ads, exp_ch4.adb (Build_Eq_Call): New visible
subprogram, extracted from Expand_Composite_Equality, to handle
properly the composition of equality for variant record types.
* exp_ch3.adb (MAke_Eq_If): Use Build_Eq_Call for each
component, to handle properly the case of a component with a
user-defined equality. Revert to predefined equality if the
user-defined operation is abstract, to maintain compatibility
with older versions,
gcc/testsuite/
* gnat.dg/equal6.adb, gnat.dg/equal6_types.adb,
gnat.dg/equal6_types.ads: New testcase.
[Ada] Missing actual for generated initialization procedure
This patch fixes an issue whereby the use of an allocator with a
composite type containing null-excluding components may lead to a
compile time error due to incorrect code generation.
2019-07-04 Justin Squirek <squirek@adacore.com>
gcc/ada/
* exp_ch3.adb (Build_Initialization_Call): Fixup
*_skip_null_excluding_check argument to handle new default.
(Init_Formals): Make *_skip_null_excluding_check formal default
to False
* exp_ch4.adb (Expand_N_Allocator): Add comment to note heavy
code duplication
[Ada] Assertion failure on Default_Initial_Condition
This patch prevents the association of a Default_Initial_Condition with
an incomplete type whose full view is the private type or private
extension subject to the aspect/pragma.
Ed Schonberg [Thu, 4 Jul 2019 08:06:14 +0000 (08:06 +0000)]
[Ada] Spurious error on 'First in a generic context
This patch fixes a spurious error on an attribute reference within an
aspect specification for an unconstrained array type when the
corresponding type declaration appears within a generic unit.
2019-07-04 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_attr.adb (Check_Array_Type): An array type attribute such
as 'First can be applied to an unconstrained array tyope when
the attribute reference appears within an aspect specification
and the prefix is a current instance, given that the prefix of
the attribute will become a formal of the subprogram that
implements the aspect (typically a predicate check).
gcc/testsuite/
* gnat.dg/aspect2.adb, gnat.dg/aspect2.ads: New testcase.
[Ada] Hang on expansion of library-level instantiation
This patch fixes an issue whereby instantiation of a generic at the
library-level may cause a hang or crash during compilation due to
inappropriate expansion of generic actuals.
2019-07-04 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_ch12.adb (Perform_Appropriate_Analysis): Added for
selecting which type of analysis based on wheither the
instantiation is a generic at the library-level. In which case
expansion during analysis.
(Preanalyze_Actuals): Modify calls to Analyze to use the new
routine.
gcc/testsuite/
* gnat.dg/generic_inst4.adb, gnat.dg/generic_inst4_gen.ads,
gnat.dg/generic_inst4_inst.ads, gnat.dg/generic_inst4_typ.ads:
New testcase.
[Ada] Better error messages for ownership errors in SPARK
When SPARK code does not follow the ownership rules of SPARK RM 3.10,
the error message now points to a location explaining why the object has
a more restricted permission than the expected one.
There is no impact on compilation.
2019-07-04 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_spark.adb (Explanation, Get_Expl): New functions to get
the explanation for a permission mismatch.
(Perm_Error, Perm_Mismatch, Perm_Error_Loop_Exit): Take
explanation into account for issuing a more precise error
message.
(Set_Perm_Prefixes, Set_Perm_Extensions,
Set_Perm_Extensions_Move): Pass suitable argument for the
explanation node.
* exp_aggr.adb (In_Place_Assign_OK): Moved to top level and add
support for record aggregates.
(Component_Check): Use Is_CCG_Supported_Aggregate instead of a
similar local predicate.
(Convert_To_Assignments): Take advantage of In_Place_Assign_OK
predicate when possible.
(Is_CCG_Supported_Aggregate): Return False for records with
representation clauses and fix the logic for dealing with nested
aggregates.
Piotr Trojanek [Thu, 4 Jul 2019 08:05:27 +0000 (08:05 +0000)]
[Ada] Keep assertions in internal units enabled for GNATprove
In GNATprove mode the assertion policy is now always enabled, even when
analysing internal units. Otherwise, assertion expressions (e.g.
Default_Initial_Condition) in internal units (e.g. Ada.Text_IO)
disappear in the semantic analysis phase of the frontend and the
GNATprove backend can't see them.
No frontend test provided, because only the GNATprove backend is
affected (and there appear to be no difference in the output with -gnatG
switch, because the expansion of Default_Initial_Condition is not
attached to the AST).
2019-07-04 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* opt.adb (Set_Config_Switches): Keep assertions policy as
enabled when analysing internal units in GNATprove mode.
* doc/gnat_ugn/platform_specific_information.rst: Document
Windows socket timeout particularity.
* gnat_ugn.texi: Regenerate.
* gsocket.h: Include versionhelpers.h.
* socket.c (__gnat_minus_500ms): New function.
* libgnat/g-sothco.ads (Minus_500ms_Windows_Timeout): New
imported function.
* libgnat/g-socket.adb (Set_Socket_Option): Refactor to remove
500ms from the requested timeout only on old Windows version.
Ed Schonberg [Thu, 4 Jul 2019 08:05:03 +0000 (08:05 +0000)]
[Ada] Spurious dimensionality error on aggregate with "others" assoc.
This patch fixes a spurious dimensionality error on an array aggregate
with a single "others' clause whose expression is a dimensioned entity,
The expansion of the aggregate may create copies of the expression, and
the dimensionality check must use the type of the expression to retrieve
the proper dimension information to check against the dimensions of the
array component type.
2019-07-04 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_dim.adb (Analyze_Dimension_Array_Aggregate): If the
component is an entity name, its dimensions are those of its
type.
gcc/testsuite/
* gnat.dg/dimensions2.adb, gnat.dg/dimensions2_phys.ads,
gnat.dg/dimensions2_real_numbers.ads: New testcase.
PR target/88833
* fwprop.c (reg_single_def_p): New function.
(propagate_rtx_1): Add unconditional else inside RTX_EXTRA case.
(forward_propagate_into): New parameter reg_prop_only
with default value false.
Propagate def's src into loop only if SET_SRC and SET_DEST
of def_set have single definitions.
Likewise if reg_prop_only is set to true.
(fwprop): New param fwprop_addr_p.
Integrate fwprop_addr into fwprop.
(fwprop_addr): Remove.
(pass_rtl_fwprop_addr::execute): Call fwprop with arg set
to true.
(pass_rtl_fwprop::execute): Call fwprop with arg set to false.
* simplify-rtx.c (simplify_subreg): Add case for vector comparison.
* config/i386/sse.md (UNSPEC_BLENDV): Adjust pattern.
Jakub Jelinek [Thu, 4 Jul 2019 05:10:52 +0000 (07:10 +0200)]
re PR tree-optimization/91069 (Miscompare of 453.povray since r272843)
PR middle-end/91069
* gcc.dg/pr91069.c (v2df): Use 2 * sizeof (double) instead of
hardcoded 16 for better portability.
(v2di): Change from long vector to long long vector. Use
2 * sizeof (long long) instead of hardcoded 16.
For a select statement with zero-, one-, or two-case with a
default case, we can generate simpler code instead of calling the
generic selectgo. A zero-case select is just blocking the
execution. A one-case select is mostly just executing the case. A
two-case select with a default case is a non-blocking send or
receive. We add these special cases for lowering a select
statement.
compiler: set varargs lowered for imported call expressions
Fix compiler buglet: varargs lowering happens before inlinable
function bodies are written out to export data, so set the "varargs
lowered" flag on call expressions that we import.
Jonathan Wakely [Wed, 3 Jul 2019 21:06:25 +0000 (22:06 +0100)]
PR libstdc++/91067 fix missing exports for filesystem iterators
The copy assignment operator for recursive_directory_iterator was not
exported despite being needed. The __shared_ptr default constructors are
not needed when compiling with GCC but Clang requires them for -O1.
PR libstdc++/91067
* acinclude.m4 (libtool_VERSION): Bump to 6:27:0.
* configure: Regenerate.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.27): Add new version. Export
missing symbols.
* testsuite/27_io/filesystem/iterators/91067.cc: New test.
* testsuite/util/testsuite_abi.cc: Add new symbol version.
Dennis Zhang [Wed, 3 Jul 2019 19:52:04 +0000 (19:52 +0000)]
[AArch64] Remove constraint strings from define_expand constructs
A number of AArch64 define_expand patterns have specified constraints
for their operands. But the constraint strings are ignored at expand
time and are therefore redundant/useless. We now avoid specifying
constraints in new define_expands, but we should clean up the existing
define_expand definitions.
For example, the constraint "=w" is removed in the following case:
(define_expand "sqrt<mode>2"
[(set (match_operand:GPF_F16 0 "register_operand" "=w")
The "" marks with an empty constraint in define_expand are removed as well.
2019-07-03 Dennis Zhang <dennis.zhang@arm.com>
gcc/
* config/aarch64/aarch64.md: Remove redundant constraints from
define_expand but keep some patterns untouched if they are
specially selected by TARGET_SECONDARY_RELOAD hook.
* config/aarch64/aarch64-sve.md: Likewise.
* config/aarch64/atomics.md: Remove redundant constraints from
define_expand.
* config/aarch64/aarch64-simd.md: Likewise.
[Darwin] Revise pie,no-pie and rdynamic driver specs.
Processing these early and pushing the corresponding Xlinker lines
has the effect that the driver then supposes that there are linker
inputs, and causes a link line to be created when it is not needed
The solution is to place these drive specs into the link spec and
claim them at the end of that.
2019-07-03 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.h (DRIVER_SELF_SPECS): Remove the linker cases.
(RDYNAMIC): Rename to, DARWIN_RDYNAMIC.
(DARWIN_PIE_SPEC, DARWIN_NOPIE_SPEC): Adjust to remove the Xlinker
clauses.
(LINK_COMMAND_SPEC_A): Add DARWIN_RDYNAMIC, DARWIN_PIE_SPEC and
DARWIN_NOPIE_SPEC.
The library handling and some of the options for creating the crts for
the older PPC Darwin versions had bit-rotted somewhat. This adjusts the
build criteria for the crts to avoid newer ld64 versions warnings about
mismatches in build and object versions.
Added to some of the comments that it's documented why the specs are as
they are.
2019-07-03 Iain Sandoe <iain@sandoe.co.uk>
gcc/
* config/darwin.h (REAL_LIBGCC_SPEC): Adjust for earlier Darwin.
(STARTFILE_SPEC): Split crt3 into a separate spec.
(DARWIN_EXTRA_SPECS): Add crt2 and crt3 spec.
(DARWIN_CRT2_SPEC): New.
(DARWIN_CRT3_SPEC): New.
(MIN_LD64_OMIT_STUBS): Revise to 62.1.
* config/rs6000/darwin.h (DARWIN_CRT2_SPEC): Revise conditions.
(DARWIN_CRT3_SPEC): New.
libgcc/
2019-07-03 Iain Sandoe <iain@sandoe.co.uk>
* config.host (powerpc-*-darwin*,powerpc64-*-darwin*): Revise crt
list.
* config/rs6000/t-darwin: Build crt3_2 for older systems. Revise
mmacosx-version-min for crts to run across all system versions.
* config/rs6000/t-darwin64 (LIB2ADD): Remove.
* config/t-darwin: Revise mmacosx-version-min for crts to run across
system versions >= 10.4.
Fix the failing store merging test on Arm. Aligning variables fixes a
few cases, otherwise disable the test on Arm. All store merging tests
now pass. Committed as obvious.
testsuite/
* gcc.dg/store_merging_27.c: Fix test for Arm.
* gcc.dg/store_merging_28.c: Likewise.
* gcc.dg/store_merging_29.c: Likewise.
* gcc.dg/tree-ssa/dump-6.c: Likewise.
compiler: include transitive imports in the type descriptor list
In CL 179598, we were using Gogo::packages_, when compiling the
main package, as the list of packages of which we need to
register the type descriptors. This is not complete. It only
includes main's direct import and one-level indirect imports. It
does not include all the packages transitively imported.
To fix that, we need to track all the transitive imports. We
have almost already done that, for init functions. However, there
may be packages that don't need init functions but do need to
register type descriptors. For them, we add a dummy init function
to its export data. So when we compile the main package we will
see all the transitive imports. The dummy init functions are not
real functions and are not called.
Even if there was no, or an empty address list we would try to generate
a header for the .debug_addr section with -gdwarf-5 and -gsplit-dwarf.
The skeleton DIE would also get a (dangling) DW_AT_addr_base in that case.
PR debug/90981
* dwarf2out.c (add_top_level_skeleton_die_attrs): Only add
DW_AT_addr_base if there is actually a .debug_addr section with
addresses.
(output_addr_table): Add DWARF5 table header generation here after
checking there are actually any addresses from...
(dwarf2out_finish): ...here.
* testsuite/g++.dg/pr90981.C: New test.
Sylvia Taylor [Wed, 3 Jul 2019 10:57:28 +0000 (10:57 +0000)]
[aarch64]: force frame pointer setup before tlsdesc call
The operation that sets up the tlsdesc register is really a function
call; as such, the frame pointer should really be correctly set up
before this happens. However, because it does not appear as a
call_insn in the RTL the normal dependencies are not added
automatically. We fix this by adding a USE of FP_REGNUM to prevent
migration of the frame-pointer setup past the call by the scheduler.
If a frame pointer is not being used, this is harmless since it only
represents a scheduling constraint.
2019-07-03 Sylvia Taylor <sylvia.taylor@arm.com>
* config/aarch64/aarch64.md (FP_REGNUM): New constant.
(tlsdesc_small_advsimd_<mode>): Add use of FP_REGNUM.
(tlsdesc_small_sve_<mode>): Likewise.
Martin Liska [Wed, 3 Jul 2019 08:36:54 +0000 (10:36 +0200)]
Add zstd support for LTO bytecode compression.
2019-07-03 Martin Liska <mliska@suse.cz>
* Makefile.in: Define ZSTD_LIB.
* common.opt: Adjust compression level
to support also zstd levels.
* config.in: Regenerate.
* configure: Likewise.
* configure.ac: Add --with-zstd and --with-zstd-include options
and detect ZSTD.
* doc/install.texi: Mention zstd dependency.
* gcc.c: Print supported LTO compression algorithms.
* lto-compress.c (lto_normalized_zstd_level): Likewise.
(lto_compression_zstd): Likewise.
(lto_uncompression_zstd): Likewise.
(lto_end_compression): Dispatch in between zlib and zstd.
(lto_compression_zlib): Mark with ATTRIBUTE_UNUSED.
(lto_uncompression_zlib): Make it static.
* lto-compress.h (lto_end_uncompression): Fix GNU coding style.
* lto-section-in.c (lto_get_section_data): Pass info
about used compression.
* lto-streamer-out.c: By default use zstd when possible.
* timevar.def (TV_IPA_LTO_DECOMPRESS): Rename to decompression
(TV_IPA_LTO_COMPRESS): Likewise for compression.
Martin Liska [Wed, 3 Jul 2019 08:36:35 +0000 (10:36 +0200)]
Add .gnu.lto_.lto section.
2019-07-03 Martin Liska <mliska@suse.cz>
* lto-section-in.c (lto_get_section_data): Add "lto" section.
* lto-section-out.c (lto_destroy_simple_output_block): Never
compress LTO_section_lto section.
* lto-streamer-out.c (produce_asm): Do not set major_version
and minor_version.
(lto_output_toplevel_asms): Likewise.
(produce_lto_section): New function.
(lto_output): Call produce_lto_section.
(lto_write_mode_table): Do not set major_version and
minor_version.
(produce_asm_for_decls): Likewise.
* lto-streamer.h (enum lto_section_type): Add LTO_section_lto
type.
(struct lto_header): Remove.
(struct lto_section): New struct.
(struct lto_simple_header): Do not inherit from lto_header.
(struct lto_file_decl_data): Add lto_section_header field.
2019-07-03 Martin Liska <mliska@suse.cz>
* lto-common.c: Read LTO section and verify header.
Martin Liska [Wed, 3 Jul 2019 08:29:48 +0000 (10:29 +0200)]
Fix use-after-scope in host-mingw32.c (PR target/88056).
2019-07-03 Martin Liska <mliska@suse.cz>
PR target/88056
* config/i386/host-mingw32.c (mingw32_gt_pch_use_address):
Define local_object_name in outer scope in order to handle
use-after-scope issue.
* binde.adb: Remove with clause for System.OS_Lib.
(Force_Elab_Order): Refactor the majority of the code in Butil.
Use the new forced units iterator to obtain unit names.
* bindo-builders.adb: Add with and use clauses for Binderr,
Butil, Opt, Output, Types, GNAT, and GNAT.Dynamic_HTables. Add
a hash table which maps units to line number in the forced
elaboration order file.
(Add_Unit): New routine.
(Build_Library_Graph): Create forced edges between pairs of
units listed in the forced elaboration order file.
(Create_Forced_Edge, Create_Forced_Edges, Destroy_Line_Number,
Duplicate_Unit_Error, Hash_Unit, Internal_Unit_Info,
Is_Duplicate_Unit, Missing_Unit_Info): New routines.
* bindo-graphs.adb (Is_Internal_Unit, Is_Predefined_Unit):
Refactor some of the behavior to Bindo-Units.
* bindo-graphs.ads: Enable the enumeration literal for forced
edges.
* bindo-units.adb, bindo-units.ads (Is_Internal_Unit,
Is_Predefined_Unit): New routines.
* butil.adb: Add with and use clauses for Opt, GNAT, and
System.OS_Lib. Add with clause for Unchecked_Deallocation.
(Has_Next, Iterate_Forced_Units, Next, Parse_Next_Unit_Name,
Read_Forced_Elab_Order_File): New routines.
* butil.ads: Add with and use clauses for Types. Add new
iterator over the units listed in the forced elaboration order
file.
(Has_Next, Iterate_Forced_Units, Next): New routine.
* namet.adb, namet.ads (Present): New routine.
Bob Duff [Wed, 3 Jul 2019 08:16:24 +0000 (08:16 +0000)]
[Ada] Crash on anonymous access-to-class-wide with tasks
This patch fixes a bug in which if an object declaration is of an
anonymous access type whose designated type is a limited class-wide type
(but not an interface), and the object is initialized with an allocator,
and the designated type of the allocator contains tasks, the compiler
would crash.
2019-07-03 Bob Duff <duff@adacore.com>
gcc/ada/
* sem_ch3.adb (Access_Definition): The code was creating a
master in the case where the designated type is a class-wide
interface type. Create a master in the noninterface case as
well. That is, create a master for all limited class-wide types.
gcc/testsuite/
* gnat.dg/task2.adb, gnat.dg/task2_pkg.adb,
gnat.dg/task2_pkg.ads: New testcase.
[Ada] Suppress warnings in generic instantiations with pragma Warnings
Warnings issued by GNAT or GNATprove inside generic instantiations can
now be suppressed by using pragma Warnings Off/On around the instance.
This has mostly an effect on GNATprove, since GNAT typically does not
issue warnings on instantiations, only on the generic code itself.
2019-07-03 Yannick Moy <moy@adacore.com>
gcc/ada/
* erroutc.adb (Sloc_In_Range): New function to determine whether
the range of a pragma Warnings covers a location, taking
instantiations into account.
Ed Schonberg [Wed, 3 Jul 2019 08:16:11 +0000 (08:16 +0000)]
[Ada] Crash on front-end inlining of subp. with aspect specifications
This patch fixes a gap in the handling of formals when inlining a call
to a subprogram marked Inline_Always. For the inlining, the formals are
replaced by the actuals in the block constructed for inlining, The
traversal that performs this replacement does not apply to aspect
specifications that may appear in the original body, because these
aspects are only indirectly reachable from the nodes to which they
apply: a separate traversal is required to perform the replacement in
the expressions for any aspect specification present in the source.
2019-07-03 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* inline.adb (Process_Formals_In_Aspects): New procedure within
Expand_Inlined_Call, to perform a replacement of references to
formals that appear in aspect specifications within the body
being inlined.
gcc/testsuite/
* gnat.dg/inline16.adb, gnat.dg/inline16_gen.adb,
gnat.dg/inline16_gen.ads, gnat.dg/inline16_types.ads: New
testcase.
[Ada] Incorrect expansion on renamings of formal parameters
This patch fixes an issue whereby a renaming of an unconstrained formal
parameter leads to spurious runtime errors; manifesting either as a
storage or constraint error due to incorrect bounds being assumed.
This issue also occurs when the renamings are implicit such as through
generic instantiations.
2019-07-03 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_ch8.adb (Analyze_Object_Renaming): Add call to search for
the appropriate actual subtype of the object renaming being
analyzed.
(Check_Constrained_Object): Minor cleanup.
gcc/testsuite/
* gnat.dg/renaming13.adb, gnat.dg/renaming14.adb: New testcases.
Refine the implementation of pointer support for SPARK analysis.
There is no impact on compilation.
2019-07-03 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_spark.adb (Get_Observed_Or_Borrowed_Expr): New function to
return go through traversal function call.
(Check_Type): Consistently use underlying type.
(Get_Perm): Adapt for case of elaboration code where variables
are not declared in the environment. Remove incorrect handling
of borrow and observe.
[Ada] Spurious visibility error in inlined function
This patch corrects the use of tree replication when inlining a function
that returns an unconstrained result, and its sole statement is an
extended return statement. The use of New_Copy_Tree ensires that global
references saved in a generic template are properly carried over when
the function is instantiated and inlined.
* inline.adb (Build_Return_Object_Formal): New routine.
(Can_Split_Unconstrained_Function): Code clean up.
(Copy_Formals,Copy_Return_Object): New routines.
(Split_Unconstrained_Function): Code clean up and refactoring.
gcc/testsuite/
* gnat.dg/inline15.adb, gnat.dg/inline15_gen.adb,
gnat.dg/inline15_gen.ads, gnat.dg/inline15_types.ads: New
testcase.
Bob Duff [Wed, 3 Jul 2019 08:15:28 +0000 (08:15 +0000)]
[Ada] Improve warnings about infinite loops
The compiler now has fewer false alarms when warning about infinite
loops. For example, a loop of the form "for X of A ...", where A is an
array, cannot be infinite. The compiler no longer warns in this case.
2019-07-03 Bob Duff <duff@adacore.com>
gcc/ada/
* sem_warn.adb (Check_Infinite_Loop_Warning): Avoid the warning
if an Iterator_Specification is present.
gcc/testsuite/
* gnat.dg/warn20.adb, gnat.dg/warn20_pkg.adb,
gnat.dg/warn20_pkg.ads: New testcase.
The dynamic ABE checks model now emits the same diagnostics as those of the
static ABE checks model.
The ABE checks mechanism has been redesigned and refactored in the face of
increasing requirements. Most of the functionality can now be toggled, thus
allowing for various combinations of behavior. The combinations are defined
as "initial states" and may be further altered.
Scenarios and targets have been distinctly separated at the higher level,
instead of directly working with nodes and entitites. Scenarios and targets
now carry a representation which removes the need to constantly recompute
relevant attributes, and offers a common interface for the various processors.
Most processing has now been refactored into "services" which perform a single
ABE-related function.
-----------------------
-- Elaboration order --
-----------------------
A new elaboration order mechanism based on the use of an invocation graph to
provide extra information about the flow of execution at elaboration time has
been introduced.
The ABE checks mechanism has been altered to encode pieces of the invocation
graph in the associated ALI files of units.
The new elaboration order mechanism reconstructs the full invocation graph at
bind time, and coupled with the library item graph, determines the elaboration
order of units.
The new elaboration order mechanism is currently inaccessible.
------------
-- Source --
------------
-- pack.ads
package Pack is
procedure ABE_Proc;
procedure Safe_Proc;
end Pack;
-- pack.adb
with Ada.Text_IO; use Ada.Text_IO;
package body Pack is
function Call_Proc (ABE : Boolean) return Integer;
procedure Safe_Proc is
begin
Put_Line ("safe");
end Safe_Proc;
function Call_Proc (ABE : Boolean) return Integer is
begin
if ABE then
ABE_Proc;
else
Safe_Proc;
end if;
procedure ABE_Proc is
begin
Put_Line ("ABE");
end ABE_Proc;
end Pack;
-- main.adb
with Pack;
procedure Main is begin null; end Main;
----------------------------
-- Compilation and output --
----------------------------
$ gnatmake -f -q -gnatE main.adb
$ ./main
$ gnatmake -f -q -gnatE main.adb -gnatDG -gnatwL
$ grep -c "safeE" pack.adb.dg
pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen
pack.adb:14:10: warning: Program_Error may be raised at run time
pack.adb:14:10: warning: body of unit "Pack" elaborated
pack.adb:14:10: warning: function "Call_Proc" called at line 22
pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14
pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen
pack.adb:14:10: warning: Program_Error may be raised at run time
pack.adb:14:10: warning: body of unit "Pack" elaborated
pack.adb:14:10: warning: function "Call_Proc" called at line 23
pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14
safe
raised PROGRAM_ERROR : pack.adb:14 access before elaboration
0
* ali.adb: Add with and use clauses for GNAT,
GNAT.Dynamic_HTables, and Snames. Add a map from invocation
signature records to invocation signature ids. Add various
encodings of invocation-related attributes. Sort and update
table Known_ALI_Lines.
(Add_Invocation_Construct, Add_Invocation_Relation,
Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind,
Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind,
Code_To_Invocation_Graph_Line_Kind, Destroy, Hash): New
routines.
(Initialize_ALI): Sort the initialization sequence. Add
initialization for all invocation-related tables.
(Invocation_Construct_Kind_To_Code,
Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code,
Invocation_Signature_Of, Present): New routines.
(Scan_ALI): Add the default values for invocation-related ids.
Scan invocation graph lines.
(Scan_Invocation_Graph_Line): New routine.
* ali.ads: Add with clause for GNAT.Dynamic_Tables. Add types
for invocation constructs, relations, and signatures. Add
tables for invocation constructs, relations, and signatures.
Update Unit_Record to capture invocation-related ids. Relocate
table Unit_Id_Tables and subtypes Unit_Id_Table, Unit_Id_Array
from Binde.
(Add_Invocation_Construct, Add_Invocation_Relation,
Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind,
Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind,
Code_To_Invocation_Graph_Line_Kind,
Invocation_Construct_Kind_To_Code,
Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code,
Invocation_Signature_Of, Present): New routines.
* binde.adb: Add with and use clause for Types. Add use clause
for ALI.Unit_Id_Tables;
* binde.ads: Relocate table Unit_Id_Tables and subtypes
Unit_Id_Table, Unit_Id_Array to ALI.
* bindgen.adb: Remove with and use clause for ALI.
* bindgen.ads: Remove with and use clause for Binde. Add with
and use clause for ALI.
* bindo.adb, bindo.ads, bindo-augmentors.adb,
bindo-augmentors.ads, bindo-builders.adb, bindo-builders.ads,
bindo-diagnostics.adb, bindo-diagnostics.ads,
bindo-elaborators.adb, bindo-elaborators.ads, bindo-graphs.adb,
bindo-graphs.ads, bindo-units.adb, bindo-units.ads,
bindo-validators.adb, bindo-validators.ads, bindo-writers.adb,
bindo-writers.ads: New units.
* debug.adb: Use and describe GNAT debug switches -gnatd_F and
-gnatd_G. Add GNATbind debug switches in the ranges dA .. dZ,
d.a .. d.z, d.A .. d.Z, d.1 .. d.9, d_a .. d_z, d_A .. d_Z, and
d_1 .. d_9. Use and describe GNATbind debug switches -d_A,
-d_I, -d_L, -d_N, -d_O, -d_T, and -d_V.
* exp_util.adb, exp_util.ads (Exceptions_OK): Relocate to
Sem_Util.
* gnatbind.adb: Add with and use clause for Bindo. Use the new
Bindo elaboration order only when -d_N is in effect.
* lib-writ.adb
(Column, Extra, Invoker, Kind, Line, Locations, Name, Placement,
Scope, Signature, Target): New routines.
(Write_ALI): Output all invocation-related data.
(Write_Invocation_Graph): New routine.
* lib-writ.ads: Document the invocation graph ALI line.
* namet.adb, namet.ads (Present): New routines.
* sem_ch8.adb (Find_Direct_Name): Capture the status of
elaboration checks and warnings of an identifier.
(Find_Expanded_Name): Capture the status of elaboration checks
and warnings of an expanded name.
* sem_ch12.adb (Analyze_Generic_Package_Declaration): Ensure
that invocation graph-related data within the body of the main
unit is encoded in the ALI file.
(Analyze_Generic_Subprogram_Declaration): Ensure that invocation
graph-related data within the body of the main unit is encoded
in the ALI file.
(Analyze_Package_Instantiation): Perform minimal decoration of
the instance entity.
(Analyze_Subprogram_Instantiation): Perform minimal decoration
of the instance entity.
* sem_elab.adb: Perform heavy refactoring of all code. The unit
is now split into "services" which specialize in one area of ABE
checks. Add processing in order to capture invocation-graph
related attributes of the main unit, and encode them in the ALI
file. The Processing phase can now operate in multiple modes,
all described by type Processing_Kind. Scenarios and targets
are now distinct at the higher level, and carry their own
representations. This eliminates the need to constantly
recompute their attributes, and offers the various processors a
uniform interface. The various initial states of the Processing
phase are now encoded using type Processing_In_State, and
xxx_State constants.
* sem_elab.ads: Update the literals of type
Enclosing_Level_Kind. Add Inline pragmas on several routines.
* sem_prag.adb (Process_Inline): Ensure that invocation
graph-related data within the body of the main unit is encoded
in the ALI file.
* sem_util.adb (Enclosing_Generic_Body, Enclosing_Generic_Unit):
Code clean up.
(Exceptions_OK): Relocated from Sem_Util.
(Mark_Save_Invocation_Graph_Of_Body): New routine.
* sem_util.ads (Exceptions_OK): Relocated from Sem_Util.
(Mark_Save_Invocation_Graph_Of_Body): New routine.
* sinfo.adb (Is_Elaboration_Checks_OK_Node): Now applicable to
N_Variable_Reference_Marker.
(Is_Elaboration_Warnings_OK_Node): Now applicable to
N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker.
(Is_Read): Use Flag4.
(Is_SPARK_Mode_On_Node): New applicable to
N_Variable_Reference_Marker.
(Is_Write): Use Flag5.
(Save_Invocation_Graph_Of_Body): New routine.
(Set_Is_Elaboration_Checks_OK_Node): Now applicable to
N_Variable_Reference_Marker.
(Set_Is_Elaboration_Warnings_OK_Node): Now applicable to
N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker.
(Set_Is_SPARK_Mode_On_Node): New applicable to
N_Variable_Reference_Marker.
(Set_Save_Invocation_Graph_Of_Body): New routine.
* sinfo.ads: Update the documentation of attributes
Is_Elaboration_Checks_OK_Node, Is_Elaboration_Warnings_OK_Node,
Is_SPARK_Mode_On_Node. Update the flag usage of attributes
Is_Read, Is_Write. Add attribute Save_Invocation_Graph_Of_Body
and update its occurrence in nodes.
(Save_Invocation_Graph_Of_Body): New routine along with pragma
Inline.
(Set_Save_Invocation_Graph_Of_Body): New routine along with
pragma Inline.
* switch-b.adb (Scan_Binder_Switches): Refactor the scanning of
debug switches.
(Scan_Debug_Switches): New routine.
* libgnat/g-dynhta.adb, libgnat/g-dynhta.ads (Contains): New routine.
* libgnat/g-graphs.adb (Associate_Vertices): Update the use of
Component_Vertex_Iterator.
(Contains_Component, Contains_Edge, Contains_Vertex, Has_Next):
Reimplemented.
(Iterate_Component_Vertices): New routine.
(Iterate_Vertices): Removed.
(Next): Update the parameter profile.
(Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New
routines.
* libgnat/g-graphs.ads: Update the initialization of
No_Component. Add type Component_Vertex_Iterator. Remove type
Vertex_Iterator.
(Has_Next): Add new versions and remove old ones.
(Iterate_Component_Vertices): New routine.
(Iterate_Vertices): Removed.
(Next): Add new versions and remove old ones.
(Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New
routines.
* libgnat/g-sets.adb (Contains): Reimplemented.
* gcc-interface/Make-lang.in (GNATBIND_OBJS): Add
GNAT.Dynamic_HTables, GNAT.Graphs and Bindo units.
* rtsfind.ads: Remove extra space.
[Ada] SPARK pointer support extended to local borrowers and observers
SPARK rules allow local borrowers and observers to be declared. During
their lifetime, the access to the borrowed/observed object is
restricted.
There is no impact on compilation.
2019-07-03 Yannick Moy <moy@adacore.com>
gcc/ada/
* sem_spark.adb: Add support for locally borrowing and observing
a path.
(Get_Root_Object): Add parameter Through_Traversal to denote
when we are interesting in getting to the traversed parameter.
(Is_Prefix_Or_Almost): New function to support detection of
illegal access to borrowed or observed paths.
(Check_Pragma): Add analysis of assertion pragmas.
Ed Schonberg [Wed, 3 Jul 2019 08:14:47 +0000 (08:14 +0000)]
[Ada] Spurious error with static predicate in generic unit
This patch fixes a spurious error in a generic unit that invludes a
subtype with a static predicate, when the type is used in a case
expression.
2019-07-03 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch13.adb (Build_Predicate_Functions): In a generic context
we do not build the bodies of predicate fuctions, but the
expression in a static predicate must be elaborated to allow
case coverage checking within the generic unit.
(Build_Discrete_Static_Predicate): In a generic context, return
without building function body once the
Static_Discrete_Predicate expression for the type has been
constructed.
gcc/testsuite/
* gnat.dg/predicate6.adb, gnat.dg/predicate6.ads: New testcase.
* gnat.dg/static_pred1.adb: Remove expected error.
Bob Duff [Wed, 3 Jul 2019 08:14:38 +0000 (08:14 +0000)]
[Ada] Style check for mixed-case identifiers
This patch implements a new switch, -gnatyD, enables a style check that
requires defining identifiers to be in mixed case.
2019-07-03 Bob Duff <duff@adacore.com>
gcc/ada/
* par-ch3.adb (P_Defining_Identifier): Call
Check_Defining_Identifier_Casing.
* style.ads, styleg.ads, styleg.adb
(Check_Defining_Identifier_Casing): New procedure to check for
mixed-case defining identifiers.
* stylesw.ads, stylesw.adb (Style_Check_Mixed_Case_Decls): New
flag for checking for mixed-case defining identifiers.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new feature.
* gnat_ugn.texi: Regenerate.
Eric Botcazou [Wed, 3 Jul 2019 08:14:33 +0000 (08:14 +0000)]
[Ada] Extend -gnatw.z warning to array types
The -gnatw.z switch causes the compiler to issue a warning on record
types subject to both an alignment clause and a size clause, when the
specified size is not a multiple of the alignment in bits, because this
means that the Object_Size will be strictly larger than the specified
size.
It makes sense to extend this warning to array types, but not to the
cases of bit-packed arrays where the size is not a multiple of storage
unit and the specified alignment is the minimum one, because there would
be no way to get rid of it apart from explicitly silencing it.
The compiler must issue the warning:
p.ads:5:03: warning: size is not a multiple of alignment for "Triplet"
p.ads:5:03: warning: size of 24 specified at line 4
p.ads:5:03: warning: Object_Size will be increased to 32
on the following package:
package P is
type Triplet is new String (1 .. 3);
for Triplet'Size use 24;
for Triplet'Alignment use 4;
type Arr is array (1 .. 7) of Boolean;
pragma Pack (Arr);
for Arr'Size use 7;
for Arr'Alignment use 1;
end P;
2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(Warning message control): Document that -gnatw.z/Z apply to
array types.
* freeze.adb (Freeze_Entity): Give -gnatw.z warning for array
types as well, but not if the specified alignment is the minimum
one.
* gnat_ugn.texi: Regenerate.
Ed Schonberg [Wed, 3 Jul 2019 08:14:24 +0000 (08:14 +0000)]
[Ada] Spurious error on dynamic predicate in a generic context
This patch fixes a spurious error on the conformance checking between
the expression for an aspect analyzed at the freeze point of the type,
and the analysis of a copy of the expression performed at the end of the
enclosing list of declarationss. In a generic context the first may not
have been analyzed yet and this must be done before the conformance
check.
2019-07-03 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): No error
message on attribute applied to a renaming when the renamed
object is an aggregate (from code reading).
(Check_Aspect_At_End_Of_Declarations): In a generic context
where freeze nodes are not generated, the original expression
for an aspect may need to be analyzed to precent spurious
conformance errors when compared with the expression that is
anakyzed at the end of the current declarative list.
gcc/testsuite/
* gnat.dg/predicate5.adb, gnat.dg/predicate5.ads: New testcase.
Ed Schonberg [Wed, 3 Jul 2019 08:14:10 +0000 (08:14 +0000)]
[Ada] Make loop labels unique for front-end inlined calls
This patch transforms loop labels in the body of subprograms that are to
be inlined by the front-end, to prevent accidental duplication of loop
labels, which might make the resulting source illegal.
----
Source program:
----
package P is
procedure Get_Rom_Addr_Offset
with Inline_Always;
end P;
----
package body P is
procedure Get_Rom_Addr_Offset is
X : Integer;
begin
Main_Block :
for I in 1 .. 10 loop
X := 2;
exit Main_Block when I > 4;
other_loop:
for J in character'('a') .. 'z' loop
if I < 5 then
exit Main_Block when J = 'k';
else
Exit Other_Loop;
end if;
end loop other_loop;
end loop Main_Block;
end Get_Rom_Addr_Offset;
procedure P2 is
begin
Main_Block :
for I in 1 .. 1 loop
Get_Rom_Addr_Offset;
end loop Main_Block;
end P2;
end P;
----
Command:
gcc -c -gnatN -gnatd.u -gnatDG p.adb
----
Output
----
package body p is
procedure p__get_rom_addr_offset is
x : integer;
other_loop : label
main_block : label
begin
main_block : for i in 1 .. 10 loop
x := 2;
exit main_block when i > 4;
other_loop : for j in 'a' .. 'z' loop
if i < 5 then
exit main_block when j = 'k';
else
exit other_loop;
end if;
end loop other_loop;
end loop main_block;
return;
end p__get_rom_addr_offset;
procedure p__p2 is
main_block : label
begin
main_block : for i in 1 .. 1 loop
B6b : declare
x : integer;
other_loopL10b : label
main_blockL9b : label
begin
main_blockL9b : for i in 1 .. 10 loop
x := 2;
exit main_blockL9b when i > 4;
other_loopL10b : for j in 'a' .. 'z' loop
if i < 5 then
exit main_blockL9b when j = 'k';
else
exit other_loopL10b;
end if;
end loop other_loopL10b;
end loop main_blockL9b;
end B6b;
end loop main_block;
return;
end p__p2;
begin
null;
end p;
2019-07-03 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* inline.adb (Make_Loop_Labels_Unique): New procedure to modify
the source code of subprograms that are inlined by the
front-end, to prevent accidental duplication between loop labels
in the inlined code and the code surrounding the inlined call.
* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Update
the section on resolving elaboration circularities to eliminate
certain combinations of switches which together do not produce
the desired effect and confuse users.
* gnat_ugn.texi: Regenerate.
* bindgen.adb (Gen_Main): Disable generation of reference to
Ada_Main_Program_Name for CCG.
* bindusg.adb (Display): Add -G to the command-line usage for
gnatbind.
* opt.ads (Generate_C_Code): Update comment.
* switch-b.adb (Scan_Binder_Switches): Add handling for -G.