Skip to content
Snippets Groups Projects
  1. Jan 07, 2025
    • Paul-Antoine Arras's avatar
      Only apply adjust_args in OpenMP dispatch if variant substitution occurs · aa688dd6
      Paul-Antoine Arras authored
      This is a followup to
      084ea8ad OpenMP: middle-end support for dispatch + adjust_args.
      
      This patch fixes a bug that caused arguments in an OpenMP dispatch call to be
      modified even when no variant substitution occurred.
      
      gcc/ChangeLog:
      
      	* gimplify.cc (gimplify_call_expr): Create variable
      	variant_substituted_p to control whether adjust_args applies.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/adjust-args-4.c: New test.
      aa688dd6
    • Tamar Christina's avatar
      perform affine fold to unsigned on non address expressions. [PR114932] · 405c99c1
      Tamar Christina authored
      When the patch for PR114074 was applied we saw a good boost in exchange2.
      
      This boost was partially caused by a simplification of the addressing modes.
      With the patch applied IV opts saw the following form for the base addressing;
      
        Base: (integer(kind=4) *) &block + ((sizetype) ((unsigned long) l0_19(D) *
      324) + 36)
      
      vs what we normally get:
      
        Base: (integer(kind=4) *) &block + ((sizetype) ((integer(kind=8)) l0_19(D)
      * 81) + 9) * 4
      
      This is because the patch promoted multiplies where one operand is a constant
      from a signed multiply to an unsigned one, to attempt to fold away the constant.
      
      This patch attempts the same but due to the various problems with SCEV and
      niters not being able to analyze the resulting forms (i.e. PR114322) we can't
      do it during SCEV or in the general form like in fold-const like extract_muldiv
      attempts.
      
      Instead this applies the simplification during IVopts initialization when we
      create the IV. This allows IV opts to see the simplified form without
      influencing the rest of the compiler.
      
      as mentioned in PR114074 it would be good to fix the missed optimization in the
      other passes so we can perform this in general.
      
      The reason this has a big impact on Fortran code is that Fortran doesn't seem to
      have unsigned integer types.  As such all it's addressing are created with
      signed types and folding does not happen on them due to the possible overflow.
      
      concretely on AArch64 this changes the results from generation:
      
              mov     x27, -108
              mov     x24, -72
              mov     x23, -36
              add     x21, x1, x0, lsl 2
              add     x19, x20, x22
      .L5:
              add     x0, x22, x19
              add     x19, x19, 324
              ldr     d1, [x0, x27]
              add     v1.2s, v1.2s, v15.2s
              str     d1, [x20, 216]
              ldr     d0, [x0, x24]
              add     v0.2s, v0.2s, v15.2s
              str     d0, [x20, 252]
              ldr     d31, [x0, x23]
              add     v31.2s, v31.2s, v15.2s
              str     d31, [x20, 288]
              bl      digits_20_
              cmp     x21, x19
              bne     .L5
      
      into:
      
      .L5:
              ldr     d1, [x19, -108]
              add     v1.2s, v1.2s, v15.2s
              str     d1, [x20, 216]
              ldr     d0, [x19, -72]
              add     v0.2s, v0.2s, v15.2s
              str     d0, [x20, 252]
              ldr     d31, [x19, -36]
              add     x19, x19, 324
              add     v31.2s, v31.2s, v15.2s
              str     d31, [x20, 288]
              bl      digits_20_
              cmp     x21, x19
              bne     .L5
      
      The two patches together results in a 10% performance increase in exchange2 in
      SPECCPU 2017 and a 4% reduction in binary size and a 5% improvement in compile
      time. There's also a 5% performance improvement in fotonik3d and similar
      reduction in binary size.
      
      The patch folds every IV to unsigned to canonicalize them.  At the end of the
      pass we match.pd will then remove unneeded conversions.
      
      Note that we cannot force everything to unsigned, IVops requires that array
      address expressions remain as such.  Folding them results in them becoming
      pointer expressions for which some optimizations in IVopts do not run.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/114932
      	* tree-ssa-loop-ivopts.cc (alloc_iv): Perform affine unsigned fold.
      
      gcc/testsuite/ChangeLog:
      
      	PR tree-optimization/114932
      	* gcc.dg/tree-ssa/pr64705.c: Update dump file scan.
      	* gcc.target/i386/pr115462.c: The testcase shares 3 IVs which calculates
      	the same thing but with a slightly different increment offset.  The test
      	checks for 3 complex addressing loads, one for each IV.  But with this
      	change they now all share one IV.  That is the loop now only has one
      	complex addressing.  This is ultimately driven by the backend costing
      	and the current costing says this is preferred so updating the testcase.
      	* gfortran.dg/addressing-modes_1.f90: New test.
      405c99c1
    • Andrew Pinski's avatar
      cfgexpand: Handle integral vector types and constructors for scope conflicts [PR105769] · 4f4722b0
      Andrew Pinski authored
      
      This is an expansion of the last patch to also track pointers via vector types and the
      constructor that are used with vector types.
      In this case we had:
      ```
      _15 = (long unsigned int) &bias;
      _10 = (long unsigned int) &cov_jn;
      _12 = {_10, _15};
      ...
      
      MEM[(struct vec *)&cov_jn] ={v} {CLOBBER(bob)};
      bias ={v} {CLOBBER(bob)};
      MEM[(struct function *)&D.6156] ={v} {CLOBBER(bob)};
      
      ...
      MEM <vector(2) long unsigned int> [(void *)&D.6172 + 32B] = _12;
      MEM[(struct function *)&D.6157] ={v} {CLOBBER(bob)};
      ```
      
      Anyways tracking the pointers via vector types to say they are alive
      at the point where the store of the vector happens fixes the bug by saying
      it is alive at the same time as another variable is alive.
      
      Bootstrapped and tested on x86_64-linux-gnu.
      
      	PR tree-optimization/105769
      
      gcc/ChangeLog:
      
      	* cfgexpand.cc (vars_ssa_cache::operator()): For constructors
      	walk over the elements.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/torture/pr105769-1.C: New test.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      4f4722b0
    • Andrew Pinski's avatar
      cfgexpand: Rewrite add_scope_conflicts_2 to use cache and look back further [PR111422] · 0014a858
      Andrew Pinski authored
      
      After fixing loop-im to do the correct overflow rewriting
      for pointer types too. We end up with code like:
      ```
      _9 = (unsigned long) &g;
      _84 = _9 + 18446744073709551615;
      _11 = _42 + _84;
      _44 = (signed char *) _11;
      ...
      *_44 = 10;
      g ={v} {CLOBBER(eos)};
      ...
      n[0] = &f;
      *_44 = 8;
      g ={v} {CLOBBER(eos)};
      ```
      
      Which was not being recongized by the scope conflicts code.
      This was because it only handled one level walk backs rather than multiple ones.
      This fixes the issue by having a cache which records all references to addresses
      of stack variables.
      
      Unlike the previous patch, this only records and looks at addresses of stack variables.
      The cache uses a bitmap and uses the index as the bit to look at.
      
      	PR middle-end/117426
      	PR middle-end/111422
      gcc/ChangeLog:
      
      	* cfgexpand.cc (struct vars_ssa_cache): New class.
      	(vars_ssa_cache::vars_ssa_cache): New constructor.
      	(vars_ssa_cache::~vars_ssa_cache): New deconstructor.
      	(vars_ssa_cache::create): New method.
      	(vars_ssa_cache::exists): New method.
      	(vars_ssa_cache::add_one): New method.
      	(vars_ssa_cache::update): New method.
      	(vars_ssa_cache::dump): New method.
      	(add_scope_conflicts_2): Factor mostly out to
      	vars_ssa_cache::operator(). New cache argument.
      	Walk the bitmap cache for the stack variables addresses.
      	(vars_ssa_cache::operator()): New method factored out from
      	add_scope_conflicts_2. Rewrite to be a full walk of all operands
      	and use a worklist.
      	(add_scope_conflicts_1): Add cache new argument for the addr cache.
      	Just call add_scope_conflicts_2 for the phi result instead of calling
      	for the uses and don't call walk_stmt_load_store_addr_ops for phis.
      	Update call to add_scope_conflicts_2 to add cache argument.
      	(add_scope_conflicts): Add cache argument and update calls to
      	add_scope_conflicts_1.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/torture/pr117426-1.c: New test.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      0014a858
    • Andrew Pinski's avatar
      cfgexpand: Factor out getting the stack decl index · 4b1a2878
      Andrew Pinski authored
      
      This is the first patch in improving this code.
      Since there are a few places which get the index and they
      check the same thing, let's factor that out into one function.
      
      Bootstrapped and tested on x86_64-linux-gnu.
      
      gcc/ChangeLog:
      
      	* cfgexpand.cc (INVALID_STACK_INDEX): New defined.
      	(decl_stack_index): New function.
      	(visit_op): Use decl_stack_index.
      	(visit_conflict): Likewise.
      	(add_scope_conflicts_1): Likewise.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      4b1a2878
    • Jeff Law's avatar
      [PR testsuite/118055] Trivial testsuite adjustment for m68k target · a856b4d9
      Jeff Law authored
      After a bit of a prod from Hans...
      
      Make the obvious change to these tests to get them passing again on m68k.
      
      	PR testsuite/118055
      
      gcc/testsuite
      
      	* gcc.dg/tree-ssa/pr83403-1.c: Add m68k*-*-* to targets needing
      	additional arguments for peeling.
      	* gcc.dg/tree-ssa/pr83403-2.c: Similarly.
      a856b4d9
    • Richard Biener's avatar
      rtl-optimization/118298 - constant iteration loops and #pragma unroll · 34501ef4
      Richard Biener authored
      When the RTL unroller handles constant iteration loops it bails out
      prematurely when heuristics wouldn't apply any unrolling before
      checking #pragma unroll.
      
      	PR rtl-optimization/118298
      	* loop-unroll.cc (decide_unroll_constant_iterations): Honor
      	loop->unroll even if the loop is too big for heuristics.
      34501ef4
    • Richard Biener's avatar
      Fixup convert-dfp*.c · cda313ba
      Richard Biener authored
      The testcases use -save-temps which doesn't play nice with -flto
      and multilib testing resulting in spurious UNRESOLVED like
      
      /usr/lib64/gcc/x86_64-suse-linux/14/../../../../x86_64-suse-linux/bin/ld: i386:x86-64 architecture of input file `./convert-dfp-2.ltrans0.ltrans.o' is incompatible with i386 output
      
      The following skips the testcases when using -flto.
      
      	* gcc.dg/torture/convert-dfp-2.c: Skip with -flto.
      	* gcc.dg/torture/convert-dfp.c: Likewise.
      cda313ba
    • Tsung Chun Lin's avatar
      RISC-V: Add missing dg-runtest to run the testcase under gcc.target/riscv/rvv/ · bacaf016
      Tsung Chun Lin authored
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/rvv.exp: Add dg-runtest to run the
      	testcase under gcc.target/riscv/rvv/.
      bacaf016
    • Marc Poulhiès's avatar
      Update copyright years. · 0c28cf56
      Marc Poulhiès authored
      0c28cf56
    • Marc Poulhiès's avatar
      ada: Adjust pragma obsolescent message · edec3538
      Marc Poulhiès authored
      Do not mention an explicit version.
      
      gcc/ada/ChangeLog:
      
      	* libgnat/a-calcon.ads: Adjust.
      	* libgnat/a-calend.ads: Adjust.
      edec3538
    • Alexandre Oliva's avatar
      ada: Drop g-cpp* units not needed by the compiler · 5f5022a9
      Alexandre Oliva authored
      Having moved __gnat_convert_caught_object to g-cstyin.o, we can drop
      other g-cpp* units that are now needed by programs that actually use
      their APIs to get more information about C++ exceptions and type_info
      objects.
      
      gcc/ada/ChangeLog:
      
      	* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS):
      	Drop g-cpp, g-cppexc and g-cppstd.
      5f5022a9
    • Eric Botcazou's avatar
      ada: Do not create temporaries for initialization statements · 980415be
      Eric Botcazou authored
      Assignment statements marked with the No_Ctrl_Actions or No_Finalize_Actions
      flag are initialization statements and, therefore, no temporaries are needed
      to hold the value of the right-hand side for them.
      
      gcc/ada/ChangeLog:
      
      	* gcc-interface/trans.cc (Call_to_gnu): Always use the return slot
      	optimization if the parent node is an initialization statement.
      	(gnat_to_gnu) <N_Assignment_Statement>: Build an INIT_EXPR instead
      	of a MODIFY_EXPR if this is an initialization statement.
      980415be
    • Piotr Trojanek's avatar
      ada: Remove unused AST flag Address_Warning_Posted · a80bb352
      Piotr Trojanek authored
      Flag Address_Warning_Posted was only read and never written, so it can be
      safely removed.
      
      gcc/ada/ChangeLog:
      
      	* gen_il-fields.ads (Opt_Field_Enum): Remove flag.
      	* gen_il-gen-gen_nodes.adb (N_Attribute_Definition_Clause): Remove
      	field.
      	* sem_ch13.adb (Validate_Address_Clauses): Remove read of the flag.
      	* sinfo.ads (Address_Warning_Posted): Remove flag description.
      a80bb352
    • Eric Botcazou's avatar
      ada: Do not raise exceptions from Exp_Aggr.Packed_Array_Aggregate_Handled · 0f1bc0d5
      Eric Botcazou authored
      An exception is now raised during bootstrap and this causes compatibility
      issues with older compilers.
      
      gcc/ada/ChangeLog:
      
      	* exp_aggr.adb (Packed_Array_Aggregate_Handled): Remove declaration
      	and handler for Not_Handled local exception. Check the return value
      	of Get_Component_Val instead.
      	(Get_Component_Val): Return No_Uint instead of raising Not_Handled.
      0f1bc0d5
    • Javier Miranda's avatar
      ada: Cleanup preanalysis of static expressions (part 2) · 360cd354
      Javier Miranda authored
      According to RM 13.14(8/4), a static expression in an aspect specification
      does not cause freezing; however, the frontend performs many calls to
      Preanalyze_Spec_Expression made during the analysis of aspects. This
      patch, suggested by Eric Botcazou, takes care of this additional code
      cleanup which requires also replacing many occurrences of the global
      variable In_Spec_Expression by calls to Preanalysis_Active.
      
      gcc/ada/ChangeLog:
      
      	* exp_util.adb (Insert_Actions): Document behavior under strict
      	preanalysis.
      	* sem.ads (In_Strict_Preanalysis): New subprogram.
      	(Preanalysis_Active): Replace 'and' operator by 'and then'.
      	* sem.adb (In_Strict_Preanalysis): Ditto.
      	* sem_attr.adb (Check_Dereference): Replace In_Spec_Expression
      	occurrence by call to Preanalysis_Active, and document it.
      	(Resolve_Attribute [Atribute_Access]): Ditto.
      	(Eval_Attribute): No evaluation under strict preanalysis.
      	(Validate_Static_Object_Name): No action under strict preanalysis.
      	* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Replace
      	calls to Preanalyze_Spec_Expression by calls to Preanalyze_And_Resolve.
      	(Check_Aspect_At_Freeze_Point): Ditto.
      	(Resolve_Aspect_Expressions [Dynamic/Static/Predicate aspects]): Code
      	cleanup adjusting the code to emulate Preanalyze_And_Resolve, instead
      	of Preanalyze_Spec_Expression.
      	(Resolve_Aspect_Expressions [CPU/Interrupt_Priority/Priority/
      	Storage_Size aspects]): Replace calls to Preanalyze_Spec_Expression
      	by call to Preanalyze_And _Resolve.
      	* sem_ch3.adb (Analyze_Object_Declaration): Replace In_Spec_Expression
      	occurrence by call to Preanalysis_Active.
      	(Find_Type_Of_Object): Add documentation.
      	* sem_ch4.adb (Analyze_Case_Expression): Replace In_Spec_Expression
      	occurrence by call to Preanalysis_Active.
      	* sem_ch6.adb (Analyze_Expression_Function): Minor code reorganization
      	moving the code preanalyzing the expression after the new body has
      	been inserted in the tree to ensure that its Parent attribute is
      	available for preanalysis.
      	* sem_cat.adb (Validate_Static_Object_Name): No action under strict
      	preanalysis.
      	* sem_elab.adb (Check_For_Eliminated_Subprogram): Replace In_Spec_Expression
      	occurrence by call to Preanalysis_Active.
      	* sem_eval.adb (Eval_Intrinsic_Call [Name_Enclosing_Entity]): Ditto.
      	* sem_elim.adb (Check_For_Eliminated_Subprogram): Ditto.
      	* sem_res.adb (Resolve_Entity_Name): Ditto.
      360cd354
    • Piotr Trojanek's avatar
      ada: Fix constants overlayed by variables · d0f0f9fb
      Piotr Trojanek authored
      Code cleanup suggested by GNATcheck rule Constant_Overlays.
      
      gcc/ada/ChangeLog:
      
      	* repinfo-input.adb (Decode_Name, Read_Name_With_Prefix): Use constant
      	overlay with pragma Import.
      d0f0f9fb
    • Piotr Trojanek's avatar
      ada: Improve protection against wrong use from GDB · 0a71f5b5
      Piotr Trojanek authored
      A code cleanup in routine intended to be used from DGB, suggested by running
      GNATcheck rule Boolean_Negations. However, this code can be tuned to protect
      against more illegal uses.
      
      gcc/ada/ChangeLog:
      
      	* exp_disp.adb (Write_DT): Add guards that prevent crashes on illegal
      	node numbers.
      0a71f5b5
    • Piotr Trojanek's avatar
      ada: Fix violations of GNAT-specific GNATcheck rules · e8aadcb3
      Piotr Trojanek authored
      Code cleanup; semantics is unaffected.
      
      gcc/ada/ChangeLog:
      
      	* diagnostics-pretty_emitter.adb (Get_Last_Line_Char): Fix whitespace.
      	* sem_aggr.adb (Resolve_Array_Aggregate): Fix style.
      e8aadcb3
    • Piotr Trojanek's avatar
      ada: Remove dead code in detection of null record definitions · 67217576
      Piotr Trojanek authored
      Code cleanup; behavior is unaffected.
      
      gcc/ada/ChangeLog:
      
      	* sem_util.adb (Is_Null_Record_Definition): Remove check for
      	Component_List being present after using it; replace check for
      	component item being a component declaration with an assertion;
      	fix style in comment.
      67217576
    • Ronan Desplanques's avatar
      ada: Fix abort deferral for finally parts · ec62ba1e
      Ronan Desplanques authored
      This patch fixes two problems with how abort was deferred in finally
      parts. First, calls to runtime subprograms are now omitted when
      aborting is disallowed by active restrictions. Second, Abort_Undefer is
      now correctly called when the finally part propagates an exception.
      
      gcc/ada/ChangeLog:
      
      	* exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Fix abort
      	deferral.
      ec62ba1e
    • Steve Baird's avatar
      ada: Improved checking of uses of package renamings · 71078911
      Steve Baird authored
      In some cases, the RM 8.5.1(3.1) legality rule about uses of renamings of
      limited views of packages was implemented incorrectly, resulting in rejecting
      legal uses.
      
      gcc/ada/ChangeLog:
      
      	* gen_il-fields.ads: add new Renames_Limited_View field.
      	* gen_il-gen-gen_entities.adb: add Renames_Limited_View flag for
      	packages.
      	* einfo.ads: add comment documenting Renames_Limited_View flag.
      	* sem_ch8.adb (Analyze_Package_Renaming): Set new Renames_Limited_View
      	flag. Test new Renames_Limited_View flag instead of calling
      	Has_Limited_With. If Has_Limited_With is True, that just means
      	that somebody, sometime during this compilation needed to
      	reference the limited view of the package; so that function
      	returns True too often to be used here.
      	(Find_Expanded_Name): Test new Renames_Limited_View flag instead of
      	calling Has_Limited_With.
      71078911
    • Piotr Trojanek's avatar
      ada: Remove flag Is_Inherited_Pragma which is only set and never used · 4b64d6d6
      Piotr Trojanek authored
      Code cleanup; behavior is unaffected. Flag Is_Inherited_Pragma is only set in
      GNAT, but is not actually used, neither by the compiler nor by any backend.
      
      gcc/ada/ChangeLog:
      
      	* contracts.adb (Inherit_Pragma): Don't set flag Is_Inherited_Pragma.
      	* gen_il-fields.ads (Opt_Field_Enum): Remove field identifier.
      	* gen_il-gen-gen_nodes.adb (N_Pragma): Remove field from node.
      	* sinfo.ads (Is_Inherited_Pragma): Remove field description.
      	(N_Pragma): Remove field reference.
      4b64d6d6
    • Piotr Trojanek's avatar
      ada: Avoid conversion from String to Name_Id at runtime · 8f4194d6
      Piotr Trojanek authored
      Code cleanup.
      
      gcc/ada/ChangeLog:
      
      	* sem_prag.adb (Analyze_Attribute): Replace runtime conversion
      	with existing constant.
      8f4194d6
    • Piotr Trojanek's avatar
      ada: Untangle check for restriction No_Implementation_Attributes · b014d250
      Piotr Trojanek authored
      Code cleanup; given that no attribute is both defined by Ada 83 and specific to
      GNAT, the semantics is unaffected.
      
      gcc/ada/ChangeLog:
      
      	* sem_attr.adb (Analyze_Attribute): Simplify logic.
      b014d250
    • Piotr Trojanek's avatar
      ada: Handle attributes related to Ada 2012 iterators as internal · a1b92ccf
      Piotr Trojanek authored
      Use existing machinery for internal attributes to handle attributes
      related to Ada 2012 iterators. All these attributes exist exclusively
      as a mean to delay processing.
      
      Code cleanup. The only change in behavior is the wording of error
      emitted when one of the internal attributes appears in source code:
      from "illegal attribute" (which used to be emitted in the analysis)
      to "unrecognized attribute (which is emitted by the parser).
      
      gcc/ada/ChangeLog:
      
      	* exp_attr.adb (Expand_N_Attribute_Reference): Remove explicit
      	handling of attributes related to Ada 2012 iterators.
      	* sem_attr.adb (Analyze_Attribute, Eval_Attribute): Likewise;
      	move attribute Reduce according to alphabetic order.
      	* snames.adb-tmpl (Get_Attribute_Id): Add support for new internal
      	attributes.
      	* snames.ads-tmpl: Recognize names of new internal attributes.
      	(Attribute_Id): Recognize new internal attributes.
      	(Internal_Attribute_Id): Likewise.
      	(Is_Internal_Attribute_Name): Avoid duplication in comment.
      a1b92ccf
    • Piotr Trojanek's avatar
      ada: Remove unnecessary qualifiers for First/Next list operations · 69dfa02b
      Piotr Trojanek authored
      Code cleanup related to work on expression functions for GNATprove
      (which require accessibility checks even when they are not expanded
      and thus have no explicit return statements).
      
      gcc/ada/ChangeLog:
      
      	* accessibility.adb (First_Selector): Remove redundant and locally
      	inconsistent parenthesis.
      	(Check_Return_Construct_Accessibility): Remove qualifier from list
      	operation.
      	* sem_util.adb (Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post):
      	Likewise.
      69dfa02b
    • Eric Botcazou's avatar
      ada: Fix internal error on container aggregate for bounded vectors · ce13a3a4
      Eric Botcazou authored
      The problem is that we analyze references to an object before the actual
      subtype of the object is established, thus creating a type mismatch that
      is flagged by the code generator.
      
      gcc/ada/ChangeLog:
      
      	* exp_ch7.ads (Store_After_Actions_In_Scope_Without_Analysis): New
      	procedure declaration.
      	* exp_ch7.adb (Store_New_Actions_In_Scope): New procedure.
      	(Store_Actions_In_Scope): Call Store_New_Actions_In_Scope when the
      	target list is empty.
      	(Store_After_Actions_In_Scope_Without_Analysis): New procedure body.
      	* exp_aggr.adb (Expand_Container_Aggregate): For a declaration that
      	is wrapped in a transient scope, also defer the analysis of the new
      	code until after the declaration is analyzed.
      ce13a3a4
    • Eric Botcazou's avatar
      ada: Add guard to System.Val_Real.Large_Powfive against pathological input · c7799a81
      Eric Botcazou authored
      There is no need to keep multiplying the result once it saturates to +Inf.
      
      gcc/ada/ChangeLog:
      
      	* libgnat/s-powflt.ads (Maxpow_Exact): Minor comment fix.
      	* libgnat/s-powlfl.ads (Maxpow_Exact): Likewise.
      	* libgnat/s-powllf.ads (Maxpow_Exact): Likewise.
      	* libgnat/s-valrea.adb (Large_Powfive) [1 parameter]: Exit the loop
      	as soon as the result saturates to +Inf.
      	(Large_Powfive) [2 parameters]: Likewise.
      c7799a81
    • Alexandre Oliva's avatar
      ada: Drop vxworks-smp-ppc-link.spec · 0f83183d
      Alexandre Oliva authored
      Adding -msmp to linker options in system-vxworks-ppc-rtp-smp.ads
      obviated vxworks-smp-ppc-link.spec.  Drop it.
      
      gcc/ada/ChangeLog:
      
      	* libgnat/system-vxworks-ppc-rtp-smp.ads: Drop
      	--specs=vxworks-ppc-link.spec from Linker_Options.
      	* vxworks-smp-ppc-link.spec: Delete.
      0f83183d
    • Ronan Desplanques's avatar
      ada: Add "finally" GNAT extension · 5697da32
      Ronan Desplanques authored
      This patch adds a new reserved word, "finally", and accompanying new
      syntax that's similar to the Java equivalent.
      
      gcc/ada/ChangeLog:
      
      	* atree.adb (Parent_Or_List_Containing): New function.
      	* atree.ads (Parent_Or_List_Containing): Likewise.
      	* gen_il-fields.ads: Add new field.
      	* gen_il-gen-gen_nodes.adb (Gen_Nodes): Extend handled sequence of
      	statements node.
      	* par-ch11.adb (P_Handled_Sequence_Of_Statements, P_Exception_Handler):
      	Add new syntactic construct.
      	* par-ch5.adb (P_Sequence_Of_Statements): Likewise.
      	* par.adb: Likewise.
      	* par-util.adb (Check_Future_Keyword): Warn that "finally" becomes a
      	reserved word with extensions.
      	* scans.adb (Initialize_Ada_Keywords): Add new reserved word.
      	* snames.adb-tmpl: Likewise.
      	* snames.ads-tmpl: Likewise.
      	* scans.ads: Likewise.
      	* sem_ch11.adb (Analyze_Handled_Statements): Adapt to new node field.
      	* sem_ch5.adb (Analyze_Exit_Statement): Add legality check.
      	(Analyze_Goto_Statement): Likewise.
      	* sem_ch6.adb (Analyze_Return_Statement): Likewise.
      	* sinfo-utils.adb (Lowest_Common_Ancestor, Destroy_Element): New
      	subprograms.
      	* sinfo-utils.ads (Lowest_Common_Ancestor): New function.
      	* sinfo.ads: Add documentation for new field.
      	* xsnamest.adb: Fix typo in comment.
      	* doc/gnat_rm/gnat_language_extensions.rst: Document new extension.
      	* warnsw.adb: Add new option.
      	* warnsw.ads: Likewise.
      	* exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Add abort
      	deferral to finally part.
      	* gnat_rm.texi: Regenerate.
      	* gnat_ugn.texi: Regenerate.
      	* gcc-interface/trans.cc (Handled_Sequence_Of_Statements_to_gnu):
      	Handle finally statements.
      5697da32
    • Eric Botcazou's avatar
      ada: Elide the copy for bit-packed aggregates in (safe) assignments · a47c6d8a
      Eric Botcazou authored
      The in-place expansion has been historically disabled for them, but there
      does not seem to be any good reason left for this.
      
      gcc/ada/ChangeLog:
      
      	* exp_aggr.adb (Expand_Array_Aggregate): Do not exclude aggregates
      	of bit-packed array types in assignments from in-place expansion.
      a47c6d8a
    • Piotr Trojanek's avatar
      ada: Reject references to attribute Result in Exceptional_Cases · eccfadd5
      Piotr Trojanek authored
      Functions with aspect Side_Effects should not reference attribute Result in
      consequences of their aspect Exceptional_Cases.
      
      gcc/ada/ChangeLog:
      
      	* sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Reject
      	references to attribute Result.
      eccfadd5
    • Piotr Trojanek's avatar
      ada: Move checks for consequences of Exceptional_Cases to GNAT · 0307abc8
      Piotr Trojanek authored
      Previously checks for consequence expressions of Exceptional_Cases aspects were
      done in GNATprove backend. However, we can do them in the frontend, where they
      will apply to all subprograms, regardless of the SPARK_Mode aspect.
      
      gcc/ada/ChangeLog:
      
      	* sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Move check
      	from GNATprove backend to GNAT frontend.
      0307abc8
    • Piotr Trojanek's avatar
      ada: Fix comments about Subprogram_Variant and Exceptional_Cases · d734902a
      Piotr Trojanek authored
      The comment about Subprogram_Variant was outdated after more types have been
      allowed by the corresponding SPARK RM rule; the comment about Exceptional_Cases
      was incorrect, after being copy-pasted.
      
      gcc/ada/ChangeLog:
      
      	* sem_prag.adb (Analyze_Exceptional_Contract, Analyze_Variant): Fix
      	comments.
      d734902a
    • Steve Baird's avatar
      ada: Put_Image spec incorrectly ignored for Fixed_Point_Type'Base'Image call. · 67e3db71
      Steve Baird authored
      If a Put_Image aspect specification (introduced in Ada 2022) is given for a
      fixed point type Fx, then in some cases a call to Fx'Base'Image would
      incorrectly ignore the aspect specification and would instead return the
      pre-Ada2022 version of the image. However, a call to Fx'Image would do the
      right thing.
      
      gcc/ada/ChangeLog:
      
      	* exp_put_image.adb (Image_Should_Call_Put_Image): Cope with the case
      	where the attribute prefix for an Image attribute reference
      	denotes an Itype constructed for a fixed point type. Calling
      	Has_Aspect with such an Itype misses applicable aspect
      	specifications; we need to look on the right list. This comes up
      	if the prefix of the attribute reference is
      	Some_Fixed_Point_Type'Base.
      67e3db71
    • Gary Dismukes's avatar
      ada: Error on instantiation with defaulted formal type referencing other formal type · f409c452
      Gary Dismukes authored
      The compiler wasn't accounting for default subtypes on generic formal types
      that reference other formal types of the same generic, leading to errors
      about invalid subtypes. Several other problems that could lead to blowups
      or incorrect errors were noticed through testing related cases and fixed
      along the way.
      
      gcc/ada/ChangeLog:
      
      	* sem_ch12.adb (Analyze_One_Association): In the case of a formal type
      	that has a Default_Subtype_Mark that does not have its Entity field set,
      	this means the default refers to another formal type of the same generic
      	formal part, so locate the matching subtype in the Result_Renamings and
      	set Match's Entity to that subtype prior to the call to Instantiate_Type.
      	(Validate_Formal_TypeDefault.Reference_Formal): Add test of Entity being
      	Present, to prevent blowups on End_Label ids (which don't have Entity set).
      	(Validate_Formal_Type_Default.Validate_Derived_Type_Default): Apply
      	Base_Type to Formal.
      	(Validate_Formal_Type_Default): Guard interface-related semantic checks
      	with a test of Is_Tagged_Type.
      f409c452
    • Eric Botcazou's avatar
      ada: Use the syntax of Ada 2012 if-expression in -gnatR3 output · 90f504df
      Eric Botcazou authored
      This uses the syntax of Ada 2012 if-expression in the output produced by the
      -gnatR3 switch for dynamic expressions.
      
      gcc/ada/ChangeLog:
      
      	* repinfo.adb (List_GCC_Expression.Print_Expr) <Cond_Expr>: Do not
      	output the final "end".
      90f504df
    • Johannes Kanig's avatar
      ada: Preserve Warning_Doc_Switch in gnatprove invocation · c5ce2451
      Johannes Kanig authored
      When invoked by gnat2why, the Warning_Doc_Switch was unintenionally
      reset.
      
      gcc/ada/ChangeLog:
      
      	* gnat1drv.adb: (SPARK_Library_Warning): preserve Warning_Doc_Switch
      c5ce2451
    • Eric Botcazou's avatar
      ada: Restrict previous change made to expansion of allocators · bd1df4e8
      Eric Botcazou authored
      There is no need to build a cleanup if exceptions cannot be propagated.
      
      gcc/ada/ChangeLog:
      
      	* exp_ch4.adb (Expand_Allocator_Expression): Do not build a cleanup
      	if restriction No_Exception_Propagation is active.
      	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
      bd1df4e8
Loading