Skip to content
Snippets Groups Projects
  1. Jun 01, 2022
    • Aldy Hernandez's avatar
      Convert range-op.* to vrange. · cf5bea76
      Aldy Hernandez authored
      This patch provides the infrastructure to make range-ops type agnostic.
      
      First, the range_op_handler function has been replaced with an object
      of the same name.  It's coded in such a way to minimize changes to the
      code base, and to encapsulate the dispatch code.
      
      Instead of:
      
      	range_operator *op = range_op_handler (code, type);
      	if (op)
      	  op->fold_range (...);
      
      We now do:
      	range_op_handler op (code, type);
      	if (op)
      	  op->fold_range (...);
      
      I've folded gimple_range_handler into the range_op_handler class,
      since it's also a query into the range operators.
      
      Instead of:
      
      	range_operator *handler = gimple_range_handler (stmt);
      
      We now do:
      
      	range_op_handler handler (stmt);
      
      This all has the added benefit of moving all the dispatch code into an
      independent class and avoid polluting range_operator (which we'll
      further split later when frange and prange come live).
      
      There's this annoying "using" keyword that's been added to each
      operator due to hiding rules in C++.  The issue is that we will have
      different virtual versions of fold_range() for each combination of
      operands.  For example:
      
      	// Traditional binary op on irange's.
      	fold_range (irange &lhs, const irange &op1, const irange &op2);
      	// For POINTER_DIFF_EXPR:
      	fold_range (irange &lhs, const prange &op1, const prange &op2);
      	// Cast from irange to prange.
      	fold_range (prange &lhs, const irange &op1, const irange &op2);
      
      Overloading virtuals when there are multiple same named methods causes
      hidden virtuals warnings from -Woverloaded-virtual, thus the using
      keyword.  An alternative would be to have different names:
      fold_range_III, fold_range_IPP, fold_range_PII, but that's uglier
      still.
      
      Tested on x86-64 & ppc64le Linux.
      
      gcc/ChangeLog:
      
      	* gimple-range-edge.cc (gimple_outgoing_range_stmt_p): Adjust for
      	vrange and convert range_op_handler function calls to use the
      	identically named object.
      	* gimple-range-fold.cc (gimple_range_operand1): Same.
      	(gimple_range_operand2): Same.
      	(fold_using_range::fold_stmt): Same.
      	(fold_using_range::range_of_range_op): Same.
      	(fold_using_range::range_of_builtin_ubsan_call): Same.
      	(fold_using_range::relation_fold_and_or): Same.
      	(fur_source::register_outgoing_edges): Same.
      	* gimple-range-fold.h (gimple_range_handler): Remove.
      	* gimple-range-gori.cc (gimple_range_calc_op1): Adjust for vrange.
      	(gimple_range_calc_op2): Same.
      	(range_def_chain::get_def_chain): Same.
      	(gori_compute::compute_operand_range): Same.
      	(gori_compute::condexpr_adjust): Same.
      	* gimple-range.cc (gimple_ranger::prefill_name): Same.
      	(gimple_ranger::prefill_stmt_dependencies): Same.
      	* range-op.cc (get_bool_state): Same.
      	(class operator_equal): Add using clause.
      	(class operator_not_equal): Same.
      	(class operator_lt): Same.
      	(class operator_le): Same.
      	(class operator_gt): Same.
      	(class operator_ge): Same.
      	(class operator_plus): Same.
      	(class operator_minus): Same.
      	(class operator_mult): Same.
      	(class operator_exact_divide): Same.
      	(class operator_lshift): Same.
      	(class operator_rshift): Same.
      	(class operator_cast): Same.
      	(class operator_logical_and): Same.
      	(class operator_bitwise_and): Same.
      	(class operator_logical_or): Same.
      	(class operator_bitwise_or): Same.
      	(class operator_bitwise_xor): Same.
      	(class operator_trunc_mod): Same.
      	(class operator_logical_not): Same.
      	(class operator_bitwise_not): Same.
      	(class operator_cst): Same.
      	(class operator_identity): Same.
      	(class operator_unknown): Same.
      	(class operator_abs): Same.
      	(class operator_negate): Same.
      	(class operator_addr_expr): Same.
      	(class pointer_or_operator): Same.
      	(operator_plus::op1_range): Adjust for vrange.
      	(operator_minus::op1_range): Same.
      	(operator_mult::op1_range): Same.
      	(operator_cast::op1_range): Same.
      	(operator_bitwise_not::fold_range): Same.
      	(operator_negate::fold_range): Same.
      	(range_op_handler): Rename to...
      	(get_handler): ...this.
      	(range_op_handler::range_op_handler): New.
      	(range_op_handler::fold_range): New.
      	(range_op_handler::op1_range): New.
      	(range_op_handler::op2_range): New.
      	(range_op_handler::lhs_op1_relation): New.
      	(range_op_handler::lhs_op2_relation): New.
      	(range_op_handler::op1_op2_relation): New.
      	(range_cast): Adjust for vrange.
      	* range-op.h (range_op_handler): Remove function.
      	(range_cast): Adjust for vrange.
      	(class range_op_handler): New.
      	(get_bool_state): Adjust for vrange.
      	(empty_range_varying): Same.
      	(relop_early_resolve): Same.
      	* tree-data-ref.cc (compute_distributive_range): Same.
      	* tree-vrp.cc (get_range_op_handler): Remove.
      	(range_fold_binary_symbolics_p): Use range_op_handler class
      	instead of get_range_op_handler.
      	(range_fold_unary_symbolics_p): Same.
      	(range_fold_binary_expr): Same.
      	(range_fold_unary_expr): Same.
      	* value-query.cc (range_query::get_tree_range): Adjust for vrange.
      cf5bea76
    • Aldy Hernandez's avatar
      Implement generic range temporaries. · 59c8e96d
      Aldy Hernandez authored
      Now that we have generic ranges, we need a way to define generic local
      temporaries on the stack for intermediate calculations in the ranger
      and elsewhere.  We need temporaries analogous to int_range_max, but
      for any of the supported types (currently just integers, but soon
      integers, pointers, and floats).
      
      The Value_Range object is such a temporary.  It is designed to be
      transparently used as a vrange.  It shares vrange's abstract API, and
      implicitly casts itself to a vrange when passed around.
      
      The ultimate name will be value_range, but we need to remove legacy
      first for that to happen.  Until then, Value_Range will do.
      
      Sample usage is as follows.  Instead of:
      
      	extern void foo (vrange &);
      
      	int_range_max t;
      	t.set_nonzero (type);
      	foo (t);
      
      one does:
      
      	Value_Range t (type);
      	t.set_nonzero (type);
      	foo (t);
      
      You can also delay initialization, for use in loops for example:
      
      	Value_Range t;
      	...
      	t.set_type (type);
      	t.set_varying (type);
      
      Creating an supported range type, will result in an unsupported_range
      object being created, which will trap if anything but set_undefined()
      and undefined_p() are called on it.  There's no size penalty for the
      unsupported_range, since its immutable and can be shared across
      instances.
      
      Since supports_type_p() is called at construction time for each
      temporary, I've removed the non-zero check from this function, which
      was mostly unneeded.  I fixed the handful of callers that were
      passing null types, and in the process sped things up a bit.
      
      As more range types come about, the Value_Range class will be augmented
      to support them by adding the relevant bits in the initialization
      code, etc.
      
      Tested on x86-64 & ppc64le Linux.
      
      gcc/ChangeLog:
      
      	* gimple-range-fold.h (gimple_range_type): Check type before
      	calling supports_type_p.
      	* gimple-range-path.cc (path_range_query::range_of_stmt): Same.
      	* value-query.cc (range_query::get_tree_range): Same.
      	* value-range.cc (Value_Range::lower_bound): New.
      	(Value_Range::upper_bound): New.
      	(Value_Range::dump): New.
      	* value-range.h (class Value_Range): New.
      	(irange::supports_type_p): Do not check if type is non-zero.
      59c8e96d
    • Aldy Hernandez's avatar
      Implement abstract vrange class. · 4f1bce19
      Aldy Hernandez authored
      This is a series of patches making ranger type agnostic in preparation
      for contributing support for other types of ranges (pointers and
      floats initially).
      
      The first step in this process is to implement vrange, an abstract
      class that will be exclusively used by ranger, and from which all
      ranges will inherit.  Vrange provides the minimum operations for
      ranger to work.  The current virtual methods are what we've used to
      implement frange (floats) and prange (pointers), but we may restrict
      the virtual methods further as other ranges come about
      (i.e. set_nonnegative() has no meaning for a future string range).
      
      This patchset also provides a mechanism for declaring local type
      agnostic ranges that can transparently hold an irange, frange,
      prange's, etc, and a dispatch mechanism for range-ops to work with
      various range types.  More details in the relevant patches.
      
      FUTURE PLAN
      ===========
      
      The plan after this is to contribute a bare bones implementation for
      floats (frange) that will provide relationals, followed by a
      separation of integers and pointers (irange and prange).  Once this is
      in place, we can further enhance both floats and pointers.  For
      example, pointer tracking, pointer plus optimizations, and keeping
      track of NaN's, etc.
      
      Once frange and prange come live, all ranger clients will immediately
      benefit from these enhancements.  For instance, in our local branch,
      the threader is already float aware with regards to relationals.
      
      We expect to wait a few weeks before starting to contribute further
      enhancements to give the tree a time to stabilize, and Andrew time to
      rebase his upcoming patches  :-P.
      
      NOTES
      =====
      
      In discussions with Andrew, it has become clear that with vrange
      coming about, supports_type_p() is somewhat ambiguous.  Prior to
      vrange it has been used to (a) determine if a type is supported by
      ranger, (b) as a short-cut for checking if a type is pointer or integer,
      as well as (c) to see if a given range can hold a type.  These things
      have had the same meaning in irange, but are slightly different with
      vrange.  I will address this in a follow-up patch.
      
      Speaking of supported types, we now provide an unsupported_range
      for passing around ranges for unsupported types. We've been silently
      doing this for a while, in both vr-values by creating VARYING for
      unsupported types with error_mark_node end points, and in ranger when
      we pass an unsupported range before we realize in range_of_expr that
      it's unsupported.  This class just formalizes what we've already been
      doing in an irange, but making it explicit that you can't do anything
      with these ranges except pass them.  Any other operation traps.
      
      There is no GTY support for vrange yet, as we don't store it long
      term.  When we contribute support for global ranges (think
      SSA_NAME_RANGE_INFO but for generic ranges), we will include it.  There
      was just no need to pollute this patchset with it.
      
      TESTING
      =======
      
      The patchset has been tested on x86-64 Linux as well as ppc64 Linux.
      I have also verified that we fold the same number of conditionals in
      evrp as well as thread the same number of paths.  There should be no
      user visible changes.
      
      We have also benchmarked the work, with the final numbers being an
      *improvement* of 1.92% for evrp, and 0.82% for VRP.  Overall
      compilation has a miniscule improvement.  This is despite the extra
      indirection level.
      
      The improvements are mostly because of small cleanups required for the
      generalization of ranges.  As a sanity check, I stuck kcachegrind on a
      few sample .ii files to see where the time was being gained.  Most of
      the gain came from gimple_range_global() being 19% faster.  This
      function is called a lot, and it was constructing a legacy
      value_range, then returning it by value, which the caller then had to
      convert to an irange.  This is in line with other pending work:
      anytime we get rid of legacy, we gain time.
      
      I will wait a few days before committing to welcome any comments.
      
      gcc/ChangeLog:
      
      	* value-range-equiv.cc (value_range_equiv::set): New.
      	* value-range-equiv.h (class value_range_equiv): Make set method
      	virtual.
      	Remove default bitmap argument from set method.
      	* value-range.cc (vrange::contains_p): New.
      	(vrange::singleton_p): New.
      	(vrange::operator=): New.
      	(vrange::operator==): New.
      	(irange::fits_p): Move to .cc file.
      	(irange::set_nonnegative): New.
      	(unsupported_range::unsupported_range): New.
      	(unsupported_range::set): New.
      	(unsupported_range::type): New.
      	(unsupported_range::set_undefined): New.
      	(unsupported_range::set_varying): New.
      	(unsupported_range::dump): New.
      	(unsupported_range::union_): New.
      	(unsupported_range::intersect): New.
      	(unsupported_range::zero_p): New.
      	(unsupported_range::nonzero_p): New.
      	(unsupported_range::set_nonzero): New.
      	(unsupported_range::set_zero): New.
      	(unsupported_range::set_nonnegative): New.
      	(unsupported_range::fits_p): New.
      	(irange::set): Call irange::set_undefined.
      	(irange::verify_range): Check discriminator field.
      	(irange::dump): Dump [irange] marker.
      	(irange::debug): Move to...
      	(vrange::debug): ...here.
      	(dump_value_range): Accept vrange.
      	(debug): Same.
      	* value-range.h (enum value_range_discriminator): New.
      	(class vrange): New.
      	(class unsupported_range): New.
      	(struct vrange_traits): New.
      	(is_a): New.
      	(as_a): New.
      	(class irange): Inherit from vrange.
      	(dump_value_range): Adjust for vrange.
      	(irange::kind): Rename to...
      	(vrange::kind): ...this.
      	(irange::varying_p): Rename to...
      	(vrange::varying_p): ...this.
      	(irange::undefined_p): Rename to...
      	(vrange::undefined_p): ...this.
      	(irange::irange): Set discriminator.
      	(irange::union_): Convert to irange before passing to irange
      	method.
      	(irange::intersect): Same.
      	(vrange::supports_type_p): New.
      	* vr-values.cc (vr_values::extract_range_from_binary_expr): Pass
      	NULL bitmap argument to value_range_equiv::set.
      	(vr_values::extract_range_basic): Same.
      4f1bce19
    • Yannick Moy's avatar
      [Ada] Allow confirming volatile properties on No_Caching variables · 3e9a6d29
      Yannick Moy authored
      Volatile variables marked with the No_Caching aspect can now have
      confirming aspects for other volatile properties, with a value of
      False.
      
      gcc/ada/
      
      	* contracts.adb (Check_Type_Or_Object_External_Properties): Check
      	the validity of combinations only when No_Caching is not used.
      	* sem_prag.adb (Analyze_External_Property_In_Decl_Part): Check
      	valid combinations with No_Caching.
      3e9a6d29
    • Doug Rupp's avatar
      [Ada] Combine system.ads file - vxworks7 kernel constants. · 6b4239f6
      Doug Rupp authored
      Systemitize Word_Size and Memory_Size declarations rather than hard code
      with numerical values or OS specific Long_Integer size.
      
      gcc/ada/
      
      	* libgnat/system-vxworks7-aarch64.ads (Word_Size): Compute
      	based on Standard'Word_Size. (Memory_Size): Compute based
      	on Word_Size.
      	* libgnat/system-vxworks7-arm.ads: Likewise.
      	* libgnat/system-vxworks7-e500-kernel.ads: Likewise.
      	* libgnat/system-vxworks7-ppc-kernel.ads: Likewise.
      	* libgnat/system-vxworks7-ppc64-kernel.ads: Likewise.
      	* libgnat/system-vxworks7-x86-kernel.ads: Likewise.
      	* libgnat/system-vxworks7-x86_64-kernel.ads: Likewise.
      6b4239f6
    • Doug Rupp's avatar
      [Ada] Combine system.ads files - arm and aarch64 qnx · df014c92
      Doug Rupp authored
      Systemitize Word_Size and Memory_Size declarations rather than hard code
      with numerical values or OS specific Long_Integer size.
      
      gcc/ada/
      
      	* libgnat/system-qnx-arm.ads (Memory_Size): Compute based on
      	Word_Size.
      df014c92
    • Piotr Trojanek's avatar
      [Ada] Fix missing space in error message · d1246541
      Piotr Trojanek authored
      On illegal code like:
      
         type T is new Positive in range 1..5;
      
      the compiler was emitting message:
      
        error: extra "in"ignored
                        ^^
      
      which lacked a space character.
      
      A tiny diagnostic improvement; spotted while mistakenly typing an
      illegal test.
      
      gcc/ada/
      
      	* par-util.adb (Ignore): Add missing space to message string.
      d1246541
    • Yannick Moy's avatar
      [Ada] Fix classification of Subprogram_Variant as assertion pragma · da85f3f2
      Yannick Moy authored
      This pragma was wrongly not recognized as an assertion pragma.  Now
      fixed.
      
      gcc/ada/
      
      	* sem_prag.ads (Assertion_Expression_Pragmas): Fix value for
      	pragma Subprogram_Variant.
      da85f3f2
    • Eric Botcazou's avatar
      [Ada] Rename Returns_On_Secondary_Stack into Needs_Secondary_Stack · 5cfde7a0
      Eric Botcazou authored
      The Returns_On_Secondary_Stack predicate is a misnomer because it must be
      invoked on a type and types do not return; as a matter of fact, the other
      Returns_XXX predicates apply to functions.
      
      gcc/ada/
      
      	* exp_ch6.adb (Caller_Known_Size): Invoke Needs_Secondary_Stack in
      	lieu of Returns_On_Secondary_Stack.
      	(Expand_Call_Helper): Likewise.
      	(Expand_Simple_Function_Return): Likewise.
      	(Needs_BIP_Alloc_Form): Likewise.
      	* exp_ch7.adb (Wrap_Transient_Declaration): Likewise.
      	* sem_res.adb (Resolve_Call): Likewise.
      	(Resolve_Entry_Call): Likewise.
      	* sem_util.ads (Returns_On_Secondary_Stack): Rename into...
      	(Needs_Secondary_Stack): ...this.
      	* sem_util.adb (Returns_On_Secondary_Stack): Rename into...
      	(Needs_Secondary_Stack): ...this.
      	* fe.h (Returns_On_Secondary_Stack): Delete.
      	(Needs_Secondary_Stack): New function.
      	* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Replace call
      	to Returns_On_Secondary_Stack with Needs_Secondary_Stack.
      5cfde7a0
    • Eric Botcazou's avatar
      [Ada] Do not freeze subprogram body without spec too early · 4e8310b3
      Eric Botcazou authored
      This fixes a small oddity whereby a subprogram body declared without a spec
      would be frozen before its entity is fully processed as an overloaded name.
      Now the latter step computes useful information, for example whether the
      body is a (late) primitive of a tagged type, which can be required during
      the freezing process.  The change also adjusts Check_Dispatching_Operation
      accordingly.  No functional changes.
      
      gcc/ada/
      
      	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): For the case where
      	there is no previous declaration, freeze the body entity only after
      	it has been processed as a new overloaded name.
      	Use Was_Expression_Function to recognize expression functions.
      	* sem_disp.adb (Check_Dispatching_Operation): Do not require a body
      	which is the last primitive to be frozen here.
      4e8310b3
    • Julien Bortolussi's avatar
      [Ada] Bug fix in "=" function of formal doubly linked list · ce0bbf28
      Julien Bortolussi authored
      Correction of a typo regarding indexes.
      
      gcc/ada/
      
      	* libgnat/a-cfdlli.adb ("="): Make the function properly loop
      	over the right list.
      ce0bbf28
    • Marc Poulhiès's avatar
      [Ada] Fix predicate check on object declaration · 2977b006
      Marc Poulhiès authored
      When subtype predicate checks are added for object declarations, it
      could lead to a compiler crash or to an incorrect check.
      
      When the subtype for the object being declared is built later by
      Analyze_Object_Declaration, the predicate check can't be applied on the
      object instead of a copy as the call will be incorrect after the subtype
      has been built.
      
      When subtypes for LHS and RHS do not statically match, only checking the
      predicate on the object after it has been initialized may miss a failing
      predicate on the RHS.
      
      In both cases, skip the optimization and check the predicate on a copy.
      
      Rename Should_Build_Subtype into Build_Default_Subtype_OK and move it
      out of sem_ch3 to make it available to other part of the compiler (in
      particular to checks.adb).
      
      gcc/ada/
      
      	* checks.adb (Apply_Predicate_Check): Refine condition for
      	applying optimization.
      	* sem_ch3.adb (Analyze_Component_Declaration): Adjust calls to
      	Should_Build_Subtype.
      	(Analyze_Object_Declaration): Likewise.
      	(Should_Build_Subtype): Rename/move to ...
      	* sem_util.ads (Build_Default_Subtype_OK): ... this.
      	* sem_util.adb (Build_Default_Subtype_OK): Moved from
      	sem_ch3.adb.
      2977b006
    • Doug Rupp's avatar
      [Ada] arm-qnx-7.1: unwind goes wrong after regs restore · 9ba4b38f
      Doug Rupp authored
      Bump the pc +3 total for Thumb mode, the same calculation that as is
      done for arm-linux.
      
      gcc/ada/
      
      	* init.c (__gnat_adjust_context_for_raise) [QNX][__thumb2__]: Bump
      	the pc an extra byte.
      9ba4b38f
    • Ghjuvan Lacambre's avatar
      [Ada] Enable using absolute paths in -fdiagnostics-format=json output · 65818fc9
      Ghjuvan Lacambre authored
      This commit makes GNAT use absolute paths in -fdiagnostics-format=json's
      output when -gnatef is present on the command line. This makes life
      easier for tools that ingest GNAT's output.
      
      gcc/ada/
      
      	* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
      	Document new behavior.
      	* errout.adb (Write_JSON_Location): Output absolute paths when
      	needed.
      	* switch-c.adb (Scan_Front_End_Switches): Update -gnatef
      	comment.
      	* usage.adb (Usage): Update description of -gnatef.
      	* gnat_ugn.texi: Regenerate.
      65818fc9
    • Eric Botcazou's avatar
      [Ada] Fix bad interaction between Inline_Always and -gnateV + -gnata · 66f2a0de
      Eric Botcazou authored
      The combination of pragma/aspect Inline_Always and -gnateV -gnata runs
      afoul of the handling of inlining across units by gigi, which does not
      inline a subprogram that calls nested subprograms if these subprograms
      are not themselves inlined.
      
      This condition does not apply to internally generated subprograms but
      the special _postconditions procedure has Debug_Info_Needed set so it
      is not considered as such and, as a consequence, triggers an error if
      the enclosing subprogram requires inlining by means of Inline_Always.
      
      The _postconditions procedure is already marked inlined when generating
      C code so it makes sense to mark it inlined in the general case as well.
      
      gcc/ada/
      
      	* contracts.adb (Build_Postconditions_Procedure): Set Is_Inlined
      	unconditionnally on the procedure entity.
      66f2a0de
    • Piotr Trojanek's avatar
      [Ada] Propagate null-exclusion to anonymous access types · 2ae98c3a
      Piotr Trojanek authored
      When analyzing an array or record type declaration whose component has a
      constrained access type, e.g.:
      
         type Buffer_Acc is not null access all String;
      
         type Buffer_Rec is record
            Data : Buffer_Acc (1 .. 10);
         end record;
      
         type Buffer_Arr is array (Boolean) of Buffer_Acc (1 .. 10);
      
      we propagated various properties of the unconstrained access type (e.g.
      the designated type, access-to-constant flag), but forgot to propagate
      the null-exclusion.
      
      For GNAT it didn't make a big difference, because the (anonymous)
      component type was never subject to legality checks. The "value
      tracking" optimisation machinery, which also deals with null values,
      only works for entire objects and doesn't care about components.
      However, GNATprove uses this flag when an access-to-component object is
      dereferenced.
      
      gcc/ada/
      
      	* sem_ch3.adb (Constrain_Access): Propagate null-exclusion flag
      	from parent type.
      2ae98c3a
    • Eric Botcazou's avatar
      [Ada] Add a comment about a finalization issue · 8182602c
      Eric Botcazou authored
      gcc/ada/
      
      	* sem_ch5.adb (Analyze_Loop_Statement): Add a comment about
      	a finalization issue.
      8182602c
    • Eric Botcazou's avatar
      [Ada] Get rid of secondary stack for controlled components of limited types · dbb0c80c
      Eric Botcazou authored
      The initial work didn't change anything for limited types because they use
      a specific return mechanism for functions called build-in-place where there
      is no anonymous return object, so the secondary stack was used only for the
      sake of consistency with the nonlimited case.
      
      This change aligns the limited case with the nonlimited case, i.e. either
      they both use the primary stack or they both use the secondary stack.
      
      gcc/ada/
      
      	* exp_ch6.adb (Caller_Known_Size): Call Returns_On_Secondary_Stack
      	instead of Requires_Transient_Scope and tidy up.
      	(Needs_BIP_Alloc_Form): Likewise.
      	* exp_util.adb (Initialized_By_Aliased_BIP_Func_Call): Also return
      	true if the build-in-place function call has no BIPalloc parameter.
      	(Is_Finalizable_Transient): Remove redundant test.
      dbb0c80c
    • Alexandre Oliva's avatar
      [Ada] Note that hardening features are experimental · 7a9800fa
      Alexandre Oliva authored
      Some features haven't got customer feedback or made upstream yet.
      
      gcc/ada/
      
      	* doc/gnat_rm/security_hardening_features.rst: Note that hardening
      	features are experimental.
      	* gnat_rm.texi: Regenerate.
      7a9800fa
    • Steve Baird's avatar
      [Ada] Another case where freezing incorrectly suppresses checks · b1743c7d
      Steve Baird authored
      Avoid improperly suppressing checks for the wrapper subprogram that is
      built when a null type extension inherits (and does not override) a
      function with a controlling result. This is a follow-up to other changes
      already made on this ticket.
      
      gcc/ada/
      
      	* exp_ch3.adb (Make_Controlling_Function_Wrappers): Set the
      	Corresponding_Spec field of a wrapper subprogram body before
      	analyzing the subprogram body; the field will be set (again)
      	during analysis, but we need it to be set earlier.
      	* exp_ch13.adb (Expand_N_Freeze_Entity): Add wrapper subprogram
      	bodies to the list of declarations for which we do not want to
      	suppress checks.
      b1743c7d
    • Eric Botcazou's avatar
      [Ada] Adjust reference in comment · 378523d4
      Eric Botcazou authored
      This is needed after the creation of Returns_On_Secondary_Stack from the
      original Requires_Transient_Scope.
      
      gcc/ada/
      
      	* sem_util.adb (Indirect_Temp_Needed): Adjust reference in comment.
      378523d4
    • Doug Rupp's avatar
      [Ada] QNX shared libraries - arm-qnx build gnatlib .so's · 04b65c9f
      Doug Rupp authored
      Shared libraries now fully supported on arm-qnx.
      
      gcc/ada/
      
      	* Makefile.rtl (GNATLIB_SHARED): Revert disablement for arm-qnx.
      04b65c9f
    • Eric Botcazou's avatar
      [Ada] Fix composability of return on the secondary stack · 12152225
      Eric Botcazou authored
      Having components that need to be returned on the secondary stack would
      not always force a record type to be returned on the secondary stack
      itself.
      
      gcc/ada/
      
      	* sem_util.adb
      	(Returns_On_Secondary_Stack.Caller_Known_Size_Record): Directly
      	check the dependence on discriminants for the variant part, if
      	any, instead of calling the Is_Definite_Subtype predicate.
      12152225
    • Ghjuvan Lacambre's avatar
      [Ada] Fix "formal parameter & is not referenced" not being properly tagged · fdb2f2e6
      Ghjuvan Lacambre authored
      gcc/ada/
      
      	* sem_warn.adb (Warn_On_Unreferenced_Entity): Fix warning tag.
      fdb2f2e6
    • Ghjuvan Lacambre's avatar
      [Ada] Adjust warning switches · 343928a0
      Ghjuvan Lacambre authored
      This makes tagging more accurate.
      
      gcc/ada/
      
      	* sem_warn.adb (Check_References): Adjust conditions under which
      	warning messages should be emitted and their tags as well.
      343928a0
    • Eric Botcazou's avatar
      [Ada] Minor tweaks to dispatching support code · af93b89d
      Eric Botcazou authored
      No functional changes.
      
      gcc/ada/
      
      	* exp_disp.ads (Expand_Interface_Thunk): Change type of Prim.
      	* exp_disp.adb (Expand_Interface_Thunk): Declare Is_Predef_Op
      	earlier, do not initialize Iface_Formal, use No idiom and tweaks
      	comments.
      	(Register_Primitive): Declare L earlier and tweak comments.
      	* sem_disp.adb (Check_Dispatching_Operation): Move tests out of
      	loop.
      af93b89d
    • Steve Baird's avatar
      [Ada] Missing discriminant checks when accessing variant field · eb1091dd
      Steve Baird authored
      In some cases, the compiler would incorrectly fail to generate
      discriminant checks when accessing fields declared in a variant part.
      Correct some such cases; detect the remaining cases and flag them as
      unsupported. The formerly-problematic cases that are now handled
      correctly involve component references occurring in a predicate
      expression (e.g., the expression of a Dynamic_Predicate aspect
      specification) for a type declaration (not for a subtype declaration).
      The cases which are now flagged as unsupported involve expression
      functions declared before the discriminated type in question has been
      frozen.
      
      gcc/ada/
      
      	* exp_ch3.ads: Replace visible Build_Discr_Checking_Funcs (which
      	did not need to be visible - it was not referenced outside this
      	package) with Build_Or_Copy_Discr_Checking_Funcs.
      	* exp_ch3.adb: Refactor existing code into 3 procedures -
      	Build_Discr_Checking_Funcs, Copy_Discr_Checking_Funcs, and
      	Build_Or_Copy_Discr_Checking_Funcs. This refactoring is intended
      	to be semantics-preserving.
      	* exp_ch4.adb (Expand_N_Selected_Component): Detect case where a
      	call should be generated to the Discriminant_Checking_Func for
      	the component in question, but that subprogram does not yet
      	exist.
      	* sem_ch13.adb (Freeze_Entity_Checks): Immediately before
      	calling Build_Predicate_Function, add a call to
      	Exp_Ch3.Build_Or_Copy_Discr_Checking_Funcs in order to ensure
      	that Discriminant_Checking_Func attributes are already set when
      	Build_Predicate_Function is called.
      	* sem_ch6.adb (Analyze_Expression_Function): If the expression
      	of a static expression function has been transformed into an
      	N_Raise_xxx_Error node, then we need to copy the original
      	expression in order to check the requirement that the expression
      	must be a potentially static expression. We also want to set
      	aside a copy the untransformed expression for later use in
      	checking calls to the expression function via
      	Inline_Static_Function_Call.  So introduce a new function,
      	Make_Expr_Copy, for use in these situations.
      	* sem_res.adb (Preanalyze_And_Resolve): When analyzing certain
      	expressions (e.g., a default parameter expression in a
      	subprogram declaration) we want to suppress checks. However, we
      	do not want to suppress checks for the expression of an
      	expression function.
      eb1091dd
    • Bob Duff's avatar
      [Ada] Fix search for "for ... of" loop subprograms · 3c2674cc
      Bob Duff authored
      This patch makes the search for Get_Element_Access, Step (Next/Prev),
      Reference_Control_Type, and Pseudo_Reference (for optimized "for ... of"
      loops) more robust.  In particular, we have a new Next procedure in Ada
      2022, and we need to pick the right one.
      
      We have not yet added the new Next and other subprograms.
      
      gcc/ada/
      
      	* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): For each
      	subprogram found, assert that the variable is Empty, so we can
      	detect bugs where we find two or more things with the same name.
      	Without this patch, that bug would happen when we add the new
      	Next procedure.  For Step, make sure we pick the right one, by
      	checking name and number of parameters.  For Get_Element_Access,
      	check that we're picking a function.  That's not really
      	necessary, because there is no procedure with that name, but it
      	seems cleaner this way.
      	* rtsfind.ads: Minor comment improvement. It seems kind of odd
      	to say "under no circumstances", and then immediately contradict
      	that with "The one exception is...".
      3c2674cc
    • Doug Rupp's avatar
      [Ada] arm-qnx-7.1: unwind goes wrong after regs restore · c97f3a7d
      Doug Rupp authored
      The usual increment of the pc to pc+2 for ARM is needed.
      
      gcc/ada/
      
      	* init.c (QNX): __gnat_adjust_context_for_raise: New
      	implementation for arm-qnx.
      c97f3a7d
    • Julien Bortolussi's avatar
      [Ada] Add reference counting in functional containers · f3949a2e
      Julien Bortolussi authored
      This patch adds reference counting to dynamically allocated pointers
      on arrays and elements used by the functional container. This is done
      by making both the arrays and the elements controlled.
      
      gcc/ada/
      
      	* libgnat/a-cofuba.ads, libgnat/a-cofuba.adb: Add reference
      	counting.
      f3949a2e
    • Yannick Moy's avatar
      [Ada] Issue a warning on entity hidden in use_clause with -gnatwh · e1379eee
      Yannick Moy authored
      Augment the warnings issued with switch -gnatwh, so that a warning is
      also issued when an entity from the package of a use_clause ends up
      hidden due to an existing visible homonym.
      
      gcc/ada/
      
      	* sem_ch8.adb (Use_One_Package): Possibly warn.
      	* sem_util.adb (Enter_Name): Factor out warning on hidden entity.
      	(Warn_On_Hiding_Entity): Extract warning logic from Enter_Name and
      	generalize it to be applied also on use_clause.
      	* sem_util.ads (Warn_On_Hiding_Entity): Add new procedure.
      e1379eee
    • Yannick Moy's avatar
      [Ada] Issue better error message for out-of-order keywords in record def · 94e416d2
      Yannick Moy authored
      Various cases of out-of-order keywords in the definition of a record
      were already detected. This adds a similar detection after NULL and
      RECORD keywords.
      
      gcc/ada/
      
      	* par-ch3.adb (P_Known_Discriminant_Part_Opt): Reword error
      	message to benefit from existing codefix.
      	(P_Record_Definition): Detect out-of-order keywords in record
      	definition and issue appropriate messages. Other cases are
      	already caught at appropriate places.
      94e416d2
    • Eric Botcazou's avatar
      [Ada] Use Actions field of freeze nodes for subprograms (continued) · 73514ab7
      Eric Botcazou authored
      This case was missed in the previous change.
      
      gcc/ada/
      
      	* exp_ch6.adb (Freeze_Subprogram.Register_Predefined_DT_Entry): Put
      	the actions into the Actions field of the freeze node instead of
      	inserting them after it.
      73514ab7
    • Marc Poulhiès's avatar
      [Ada] Add inline documentation for Is_{Parenthesis,Enum_Array}_Aggregate · 64f72fae
      Marc Poulhiès authored
      Both flags were added when square brackets for array/container
      aggregates have been enabled with -gnat2022 without their corresponding
      inline documentation. This change adds the missing documention.
      
      gcc/ada/
      
      	* sinfo.ads: Add inline documention for Is_Parenthesis_Aggregate
      	and Is_Enum_Array_Aggregate.
      64f72fae
    • Bob Duff's avatar
      [Ada] Incorrect code for anonymous access-to-function with convention C · 5512eabc
      Bob Duff authored
      This patch fixes a bug where the compiler generates incorrect code for a
      call via an object with convention C, whose type is an anonymous
      access-to-function type.
      
      gcc/ada/
      
      	* einfo-utils.adb (Set_Convention): Call Set_Convention
      	recursively, so that Set_Can_Use_Internal_Rep is called (if
      	appropriate) on the anonymous access type of the object, and its
      	designated subprogram type.
      	* sem_ch3.adb (Access_Definition): Remove redundant call to
      	Set_Can_Use_Internal_Rep.
      5512eabc
    • Bob Duff's avatar
      [Ada] Suppress warnings on membership test of ranges · 3cd52053
      Bob Duff authored
      For a membership test "X in A .. B", the compiler used to warn if it
      could prove that X is within one of the bounds.  For example, if we know
      at compile time that X >= A, then the above could be replaced by "X <=
      B".
      
      This patch suppresses that warning, because there is really
      nothing wrong with the membership test, and programmers sometimes
      find it annoying.
      
      gcc/ada/
      
      	* exp_ch4.adb (Expand_N_In): Do not warn in the above-mentioned
      	cases.
      	* fe.h (Assume_No_Invalid_Values): Remove from fe.h, because
      	this is not used in gigi.
      	* opt.ads (Assume_No_Invalid_Values): Improve the comment. We
      	don't need to "clearly prove"; we can just "prove". Remove the
      	comment about fe.h, which is no longer true.
      3cd52053
    • Richard Biener's avatar
      tree-optimization/105763 - avoid abnormals with ranger queries · ae575e93
      Richard Biener authored
      In unswitching we use ranger to simplify switch statements so we
      have to avoid doing anything for abnormals.
      
      2022-05-30  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/105763
      	* tree-ssa-loop-unswitch.cc (find_unswitching_predicates_for_bb):
      	Check gimple_range_ssa_p.
      
      	* gcc.dg/pr105763.c: New testcase.
      ae575e93
    • GCC Administrator's avatar
      Daily bump. · 820ead45
      GCC Administrator authored
      820ead45
  2. May 31, 2022
    • Patrick Palka's avatar
      c++: non-dep call with empty TYPE_BINFO [PR105758] · 4f84f120
      Patrick Palka authored
      Here the out-of-line definition of Z<T>::z causes duplicate_decls to
      change z's type from using the primary template type Z<T> (which is also
      the type of the injected class name) to the implicit instantiation Z<T>,
      and this latter type lacks a TYPE_BINFO (although its TYPE_CANONICAL was
      set by a special case in lookup_template_class to point to the former).
      
      Later, when processing the non-dependent call z->foo(0), build_over_call
      relies on the object argument's TYPE_BINFO to build the templated form
      for this call, which fails because the object argument type has empty
      TYPE_BINFO due to the above.
      
      It seems weird that the implicit instantiation Z<T> doesn't have the
      same TYPE_BINFO as the primary template type Z<T>, despite them being
      proclaimed equivalent via TYPE_CANONICAL.  So I tried also setting
      TYPE_BINFO in the special case in lookup_template_class, but that led to
      some problems with constrained partial specializations of the form Z<T>.
      I'm not sure what, if anything, we ought to do about the subtle
      differences between these two versions of the same type.
      
      Fortunately it seems we don't need to rely on TYPE_BINFO at all in
      build_over_call here -- the z_candidate struct already contains the
      exact binfos we need to rebuild the BASELINK for the templated form.
      
      	PR c++/105758
      
      gcc/cp/ChangeLog:
      
      	* call.cc (build_over_call): Use z_candidate::conversion_path
      	and ::access_path instead of TYPE_BINFO when building the
      	BASELINK for the templated form.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/template/non-dependent24.C: New test.
      4f84f120
    • Patrick Palka's avatar
      c++: use auto_timevar instead of timevar_push/pop · 3f7daf7e
      Patrick Palka authored
      r12-5487-g9bf69a8558638c replaced uses of timevar_cond_push/pop with
      auto_cond_timevar and removed now unnecessary wrapper functions.  This
      patch does the same with timevar_push/pop and auto_timevar.
      
      gcc/cp/ChangeLog:
      
      	* parser.cc: Use auto_timevar instead of timevar_push/pop.
      	Remove wrapper functions.
      	* pt.cc: Likewise.
      3f7daf7e
Loading