aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-06-21sh: Make *minus_plus_one work after RARichard Sandiford1-3/+3
*minus_plus_one had no constraints, which meant that it could be matched after RA with operands 0, 1 and 2 all being different. The associated split instead requires operand 0 to be tied to operand 1. gcc/ * config/sh/sh.md (*minus_plus_one): Add constraints.
2024-06-21ada: Fix internal error on protected type with -gnatc -gnatREric Botcazou1-0/+6
It occurs when the body of a protected subprogram is processed, because the references to the components of the type have not been properly expanded. gcc/ada/ * gcc-interface/trans.cc (Subprogram_Body_to_gnu): Also return early for a protected subprogram in -gnatc mode.
2024-06-21ada: Fix bogus Address Sanitizer stack-buffer-overflow on packed array copyEric Botcazou2-2/+17
The Address Sanitizer considers that the padding at the end of a justified modular type may be accessed through the object, but it is never accessed and therefore can always be reused. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <discrete_type>: Set the TYPE_JUSTIFIED_MODULAR_P flag earlier. * gcc-interface/misc.cc (gnat_unit_size_without_reusable_padding): New function. (LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING): Redefine to above function.
2024-06-21ada: Fix bogus Address Sanitizer stack-buffer-overflow on packed record equalityEric Botcazou1-7/+19
We set DECL_BIT_FIELD optimistically during the translation of record types and clear it afterward if needed, but fail to clear other attributes in the latter case, which fools the logic of the Address Sanitizer. gcc/ada/ * gcc-interface/utils.cc (clear_decl_bit_field): New function. (finish_record_type): Call clear_decl_bit_field instead of clearing DECL_BIT_FIELD manually.
2024-06-21ada: Implement fast modulo reduction for nonbinary modular multiplicationEric Botcazou2-6/+8
This adds the missing guard to prevent the reduction from being used when the target does not provide or cannot synthesize a high-part multiply. gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Mod>: Fix formatting. * gcc-interface/utils2.cc: Include optabs-query.h. (fast_modulo_reduction): Call can_mult_highpart_p on the TYPE_MODE before generating a high-part multiply. Fix formatting.
2024-06-21ada: Implement fast modulo reduction for nonbinary modular multiplicationEric Botcazou3-3/+121
This implements modulo reduction for nonbinary modular multiplication with small moduli by means of the standard division-free algorithm also used in the optimizer, but with fewer constraints and therefore better results. For the sake of consistency, it is also used for the 'Mod attribute of the same modular types and, more generally, for the Mod (and Rem) operators of unsigned types if the second operand is static and not a power of two. gcc/ada/ * gcc-interface/gigi.h (fast_modulo_reduction): Declare. * gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Mod>: In the unsigned case, call fast_modulo_reduction for {FLOOR,TRUNC}_MOD_EXPR if the RHS is a constant and not a power of two, and the precision is not larger than the word size. * gcc-interface/utils2.cc: Include expmed.h. (fast_modulo_reduction): New function. (nonbinary_modular_operation): Call fast_modulo_reduction for the multiplication if the precision is not larger than the word size.
2024-06-21ada: Reject ambiguous function calls in interpolated string expressionsJavier Miranda1-0/+10
When the interpolated expression is a call to an ambiguous call the frontend does not reject it; erroneously accepts the call and generates code that calls to one of them. gcc/ada/ * sem_ch2.adb (Analyze_Interpolated_String_Literal): Reject ambiguous function calls.
2024-06-21ada: Apply fixes to Examine_Array_BoundsRonan Desplanques1-1/+3
gcc/ada/ * sem_util.adb (Examine_Array_Bounds): Add missing return statements. Fix criterion for a string literal being empty.
2024-06-21ada: Fix crash in GNATbind during error reportingEric Botcazou1-3/+7
This is the minimal fix to avoid the crash. gcc/ada/ * bcheck.adb (Check_Consistency_Of_Sdep): Guard against path to ALI file not found.
2024-06-21ada: Crash when using user defined string literalsJavier Miranda1-1/+7
When a non-overridable aspect is explicitly specified for a non-tagged derived type, the compiler blows up processing an object declaration of an object of such type. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Fix code locating the entity of the parent type.
2024-06-21ada: Change error message on invalid RTS pathMarc Poulhiès3-13/+27
Include the invalid path in the error message. gcc/ada/ * make.adb (Scan_Make_Arg): Adjust error message. * gnatls.adb (Search_RTS): Likewise. * switch-b.adb (Scan_Debug_Switches): Likewise.
2024-06-21ada: Small cleanup in processing of primitive operationsEric Botcazou6-67/+55
The processing of primitive operations is now always uniform for tagged and untagged types, but the code contains left-overs from the time where it was specific to tagged types, in particular for the handling of subtypes. gcc/ada/ * einfo.ads (Direct_Primitive_Operations): Mention concurrent types as well as GNAT extensions instead of implementation details. (Primitive_Operations): Document that Direct_Primitive_Operations is also used for concurrent types as a fallback. * einfo-utils.adb (Primitive_Operations): Tweak formatting. * exp_util.ads (Find_Prim_Op): Adjust description. * exp_util.adb (Make_Subtype_From_Expr): In the private case with unknown discriminants, always copy Direct_Primitive_Operations and do not overwrite the Class_Wide_Type of the expression's base type. * sem_ch3.adb (Analyze_Incomplete_Type_Decl): Tweak comment. (Analyze_Subtype_Declaration): Remove older and now dead calls to Set_Direct_Primitive_Operations. Tweak comment. (Build_Derived_Private_Type): Likewise. (Build_Derived_Record_Type): Likewise. (Build_Discriminated_Subtype): Set Direct_Primitive_Operations in all cases instead of just for tagged types. (Complete_Private_Subtype): Likewise. (Derived_Type_Declaration): Tweak comment. * sem_ch4.ads (Try_Object_Operation): Adjust description.
2024-06-21ada: Revert conditional installation of signal handlers on VxWorksDoug Rupp1-8/+4
The conditional installation resulted in a semantic change, and although it is likely what is ultimately wanted (since HW interrupts are being reworked on VxWorks). However it must be done in concert with other modifications for the new formulation of HW interrupts and not in isolation. gcc/ada/ * init.c [vxworks] (__gnat_install_handler): Revert to installing signal handlers without regard to interrupt_state.
2024-06-21ada: Cannot override inherited function with controlling resultJavier Miranda1-2/+4
When a package has the declaration of a derived tagged type T with private null extension that inherits a public function F with controlling result, and a derivation of T is declared in the public part of another package, overriding function F may be rejected by the compiler. gcc/ada/ * sem_disp.adb (Find_Hidden_Overridden_Primitive): Check public dispatching primitives of ancestors; previously, only immediately-visible primitives were checked.
2024-06-21ada: Fix missing index check with declare expressionEric Botcazou1-10/+26
The Do_Range_Check flag is properly set on the Expression of the EWA node built for the declare expression, so this instructs Generate_Index_Checks to look into this Expression. gcc/ada/ * checks.adb (Generate_Index_Checks): Add specific treatment for index expressions that are N_Expression_With_Actions nodes.
2024-06-21ada: Fix internal error on case expression used as index of array componentEric Botcazou1-35/+73
This occurs when the bounds of the array component depend on a discriminant and the component reference is not nested, that is to say the component is not (referenced as) a subcomponent of a larger record. In this case, Analyze_Selected_Component does not build the actual subtype for the component, but it turns out to be required for constructs generated during the analysis of the case expression. The change causes this actual subtype to be built, and also renames a local variable used to hold the prefix of the selected component. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Rename Name into Pref and use Sel local variable consistently. (Is_Simple_Indexed_Component): New predicate. Call Is_Simple_Indexed_Component to determine whether to build an actual subtype for the component.
2024-06-21ada: Fix incorrect handling of packed array with aliased composite componentsEric Botcazou2-101/+93
The problem is that the handling of the interaction between packing and aliased/atomic/independent components of an array type is tied to that of the interaction between a component clause and aliased/atomic/independent components, although the semantics are different: packing is a best effort thing, whereas a component clause must be honored or else an error be given. This decouples the two handlings, but retrofits the separate processing of independent components done in both cases into the common code and changes the error message from "minimum allowed is" to "minimum allowed value is" for the sake of consistency with the aliased/atomic processing. gcc/ada/ * freeze.adb (Freeze_Array_Type): Decouple the handling of the interaction between packing and aliased/atomic components from that of the interaction between a component clause and aliased/ atomic components, and retrofit the processing of the interaction between the two characteristics and independent components into the common processing. gcc/testsuite/ChangeLog: * gnat.dg/atomic10.adb: Adjust.
2024-06-21ada: Generic formal/actual matching -- misc cleanupBob Duff7-44/+59
The only substantive change is to remove Activation_Chain_Entity from N_Generic_Package_Declaration. The comment in sinfo.ads suggesting this change was written in 1993! Various pieces of missing documentation are added to Sinfo and Einfo. Also other minor cleanups. gcc/ada/ * gen_il-gen-gen_nodes.adb (N_Generic_Package_Declaration): Remove Activation_Chain_Entity. * sinfo.ads: Comment improvements. Add missing doc. Remove obsolete comment about Activation_Chain_Entity. * einfo.ads: Comment improvements. Add missing doc. * einfo-utils.adb (Base_Type): Add Assert (disabled for now). (Next_Index): Minor cleanup. * aspects.ads: Minor comment fix. * exp_ch6.adb: Likewise. * sem_ch3.adb: Likewise.
2024-06-21ada: Fix gnatcheck violation reported after a recent cleanupPiotr Trojanek1-1/+1
Code cleanup; semantics is unaffected. gcc/ada/ * sem_ch3.adb (Add_Interface_Tag_Components): Simplify with No.
2024-06-21ada: Predefined arithmetic operators incorrectly treated as directly visibleSteve Baird1-1/+21
In some cases, a predefined operator (e.g., the "+" operator for an integer type) is incorrectly treated as being directly visible when it is not. This can lead to both accepting operator uses that should be rejected and also to incorrectly rejecting legal constructs as ambiguous (for example, an expression "Foo + 1" where Foo is an overloaded function and the "+" operator is directly visible for the result type of only one of the possible callees). gcc/ada/ * sem_ch4.adb (Is_Effectively_Visible_Operator): A new function. (Check_Arithmetic_Pair): In paths where Add_One_Interp was previously called unconditionally, instead call only if Is_Effectively_Visible_Operator returns True. (Check_Boolean_Pair): Likewise. (Find_Unary_Types): Likewise.
2024-06-21ada: Fix assertion failure on predicate involving access parameterEric Botcazou1-1/+12
The assertion fails because the Original_Node of the expression has no Etype since its an unanalyzed identifier. gcc/ada/ * accessibility.adb (Accessibility_Level): Apply the processing to Expr when its Original_Node is an unanalyzed identifier.
2024-06-21ada: Fix for Default_Component_Value with declare expressionsPiotr Trojanek2-3/+13
When the expression of aspect Default_Component_Value includes a declare expression with current type instance, we attempted to recursively froze that type, which itself caused an infinite recursion, because we didn't properly manage the scope of declare expression. This patch fixes both the detection of the current type instance and analysis of the expression that caused recursive freezing. gcc/ada/ * sem_attr.adb (In_Aspect_Specification): Use the standard condition that works correctly with declare expressions. * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Replace ordinary analysis with preanalysis of spec expressions.
2024-06-21ada: Spurious style error with mutiple square bracketsJustin Squirek3-20/+43
This patch fixes a spurious error in the compiler when checking for style for token separation where two square brackets are next to each other. gcc/ada/ * csets.ads (Identifier_Char): New function - replacing table. * csets.adb (Identifier_Char): Rename and move table for static values. (Initialize): Remove dynamic calculations. (Identifier_Char): New function to calculate dynamic values. * opt.adb (Set_Config_Switches): Remove setting of Identifier_Char.
2024-06-20complex-lowering: Better handling of PAREN_EXPR [PR68855]Andrew Pinski3-2/+60
When PAREN_EXPR tree code was added in r0-85884-gdedd42d511b6e4, a simplified handling was added to complex lowering. Which means we would get: ``` _9 = COMPLEX_EXPR <_15, _14>; _11 = ((_9)); _19 = REALPART_EXPR <_11>; _20 = IMAGPART_EXPR <_11>; ``` In many cases instead of just simply: ``` _19 = ((_15)); _20 = ((_14)); ``` So this adds full support for PAREN_EXPR to complex lowering. It is handled very similar as NEGATE_EXPR; except creating PAREN_EXPR instead of NEGATE_EXPR for the real/imag parts. This allows for more optimizations including vectorization, especially with -ffast-math. gfortran.dg/vect/pr68855.f90 is an example where this could show up. It also shows up in SPEC CPU 2006's 465.tonto; though I have not done any benchmarking there. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR tree-optimization/68855 * tree-complex.cc (init_dont_simulate_again): Handle PAREN_EXPR like NEGATE_EXPR. (complex_propagate::visit_stmt): Likewise. (expand_complex_move): Don't handle PAREN_EXPR. (expand_complex_paren): New function. (expand_complex_operations_1): Handle PAREN_EXPR like NEGATE_EXPR. And call expand_complex_paren for PAREN_EXPR. gcc/testsuite/ChangeLog: * gcc.dg/vect/pr68855.c: New test. * gfortran.dg/vect/pr68855.f90: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-06-21Remove outdated info from passes.texiRichard Biener1-61/+9
This applies some maintainance to passes.texi by removing references to no longer existing passes. It also fixes a few minor things but doesn't fill the gaps that meanwhile exist. * doc/passes.texi: Remove references to no longer existing passes.
2024-06-21Build: Set gcc_cv_as_mips_explicit_relocs if ↵YunQiang Su2-0/+4
gcc_cv_as_mips_explicit_relocs_pcrel We check gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel only, while gcc_cv_as_mips_explicit_relocs is used by later code. Maybe, it is time for use to set gcc_cv_as_mips_explicit_relocs always now, as it has been in Binutils for more than 20 years. gcc * configure.ac: Set gcc_cv_as_mips_explicit_relocs if gcc_cv_as_mips_explicit_relocs_pcrel. * configure: Regenerate.
2024-06-21MIPS: Set condmove cost to SET(REG, REG)YunQiang Su3-4/+42
On most uarch, the cost condmove is same as other noraml integer, and it should be COSTS_N_INSNS(1). In GCC12 or previous, the condmove is always enabled, and from GCC13, we start to compare the cost. The generic rtx_cost give the result of COSTS_N_INSN(2). Let's define it to COSTS_N_INSN(1) in mips_rtx_costs. gcc * config/mips/mips.cc(mips_rtx_costs): Set condmove cost. * config/mips/mips.md(mov<GPR:mode>_on_<MOVECC:mode>, mov<GPR:mode>_on_<MOVECC:mode>_mips16e2, mov<GPR:mode>_on_<GPR2:mode>_ne mov<GPR:mode>_on_<GPR2:mode>_ne_mips16e2): Define name by remove starting *, so that we can use CODE_FOR_. gcc/testsuite * gcc.target/mips/movcc-2.c: Add k?100:1000 test.
2024-06-20rs6000: Fix wrong RTL patterns for vector merge high/low word on LEKewen Lin5-40/+232
Commit r12-4496 changes some define_expands and define_insns for vector merge high/low word, which are altivec_vmrg[hl]w, vsx_xxmrg[hl]w_<VSX_W:mode>. These defines are mainly for built-in function vec_merge{h,l}, __builtin_vsx_xxmrghw, __builtin_vsx_xxmrghw_4si and some internal gen function needs. These functions should consider endianness, taking vec_mergeh as example, as PVIPR defines, vec_mergeh "Merges the first halves (in element order) of two vectors", it does note it's in element order. So it's mapped into vmrghw on BE while vmrglw on LE respectively. Although the mapped insns are different, as the discussion in PR106069, the RTL pattern should be still the same, it is conformed before commit r12-4496, define_expand altivec_vmrghw got expanded into: (vec_select:VSX_W (vec_concat:<VS_double> (match_operand:VSX_W 1 "register_operand" "wa,v") (match_operand:VSX_W 2 "register_operand" "wa,v")) (parallel [(const_int 0) (const_int 4) (const_int 1) (const_int 5)])))] on both BE and LE then. But commit r12-4496 changed it to expand into: (vec_select:VSX_W (vec_concat:<VS_double> (match_operand:VSX_W 1 "register_operand" "wa,v") (match_operand:VSX_W 2 "register_operand" "wa,v")) (parallel [(const_int 0) (const_int 4) (const_int 1) (const_int 5)])))] on BE, and (vec_select:VSX_W (vec_concat:<VS_double> (match_operand:VSX_W 1 "register_operand" "wa,v") (match_operand:VSX_W 2 "register_operand" "wa,v")) (parallel [(const_int 2) (const_int 6) (const_int 3) (const_int 7)])))] on LE, although the mapped insn are still vmrghw on BE and vmrglw on LE, the associated RTL pattern is completely wrong and inconsistent with the mapped insn. If optimization passes leave this pattern alone, even if its pattern doesn't represent its mapped insn, it's still fine, that's why simple testing on bif doesn't expose this issue. But once some optimization pass such as combine does some changes basing on this wrong pattern, because the pattern doesn't match the semantics that the expanded insn is intended to represent, it would cause the unexpected result. So this patch is to fix the wrong RTL pattern, ensure the associated RTL patterns become the same as before which can have the same semantic as their mapped insns. With the proposed patch, the expanders like altivec_vmrghw expands into altivec_vmrghb_direct_be or altivec_vmrglb_direct_le depending on endianness, "direct" can easily show which insn would be generated, _be and _le are mainly for the different RTL patterns as endianness. Co-authored-by: Xionghu Luo <xionghuluo@tencent.com> PR target/106069 PR target/115355 gcc/ChangeLog: * config/rs6000/altivec.md (altivec_vmrghw_direct_<VSX_W:mode>): Rename to ... (altivec_vmrghw_direct_<VSX_W:mode>_be): ... this. Add the condition BYTES_BIG_ENDIAN. (altivec_vmrghw_direct_<VSX_W:mode>_le): New define_insn. (altivec_vmrglw_direct_<VSX_W:mode>): Rename to ... (altivec_vmrglw_direct_<VSX_W:mode>_be): ... this. Add the condition BYTES_BIG_ENDIAN. (altivec_vmrglw_direct_<VSX_W:mode>_le): New define_insn. (altivec_vmrghw): Adjust by calling gen_altivec_vmrghw_direct_v4si_be for BE and gen_altivec_vmrglw_direct_v4si_le for LE. (altivec_vmrglw): Adjust by calling gen_altivec_vmrglw_direct_v4si_be for BE and gen_altivec_vmrghw_direct_v4si_le for LE. (vec_widen_umult_hi_v8hi): Adjust the call to gen_altivec_vmrghw_direct_v4si by gen_altivec_vmrghw for BE and by gen_altivec_vmrglw for LE. (vec_widen_smult_hi_v8hi): Likewise. (vec_widen_umult_lo_v8hi): Adjust the call to gen_altivec_vmrglw_direct_v4si by gen_altivec_vmrglw for BE and by gen_altivec_vmrghw for LE (vec_widen_smult_lo_v8hi): Likewise. * config/rs6000/rs6000.cc (altivec_expand_vec_perm_const): Replace CODE_FOR_altivec_vmrghw_direct_v4si by CODE_FOR_altivec_vmrghw_direct_v4si_be for BE and CODE_FOR_altivec_vmrghw_direct_v4si_le for LE. And replace CODE_FOR_altivec_vmrglw_direct_v4si by CODE_FOR_altivec_vmrglw_direct_v4si_be for BE and CODE_FOR_altivec_vmrglw_direct_v4si_le for LE. * config/rs6000/vsx.md (vsx_xxmrghw_<VSX_W:mode>): Adjust by calling gen_altivec_vmrghw_direct_v4si_be for BE and gen_altivec_vmrglw_direct_v4si_le for LE. (vsx_xxmrglw_<VSX_W:mode>): Adjust by calling gen_altivec_vmrglw_direct_v4si_be for BE and gen_altivec_vmrghw_direct_v4si_le for LE. gcc/testsuite/ChangeLog: * g++.target/powerpc/pr106069.C: New test. * gcc.target/powerpc/pr115355.c: New test.
2024-06-21Daily bump.GCC Administrator7-1/+429
2024-06-20i386: Allow all register_operand SUBREGs in x86_ternlog_idx.Roger Sayle1-9/+8
This patch tweaks ix86_ternlog_idx to allow any SUBREG that matches the register_operand predicate, and is split out as an independent piece of a patch that I have to clean-up redundant ternlog patterns in sse.md. It turns out that some of these patterns aren't (yet) sufficiently redundant to be obsolete. The problem is that the "new" ternlog pattern has the restriction that it allows SUBREGs, but only those where the inner and outer modes are the same size, where regular patterns use "register_operand" which allows arbitrary including paradoxical SUBREGs. A motivating example is f2 in gcc.target/i386/avx512dq-abs-copysign-1.c void f2 (float x, float y) { register float a __asm ("xmm16"), b __asm ("xmm17"); a = x; b = y; asm volatile ("" : "+v" (a), "+v" (b)); a = __builtin_copysignf (a, b); asm volatile ("" : "+v" (a)); } for which combine tries: (set (subreg:V4SF (reg:SF 100 [ _3 ]) 0) (ior:V4SF (and:V4SF (not:V4SF (reg:V4SF 104)) (subreg:V4SF (reg:SF 110) 0)) (reg:V4SF 106))) where the SUBREG is paradoxical, with inner mode SF and outer mode V4SF. This patch allows the recently added ternlog_operand to accept this case. 2024-06-20 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386-expand.cc (ix86_ternlog_idx): Allow any SUBREG that matches register_operand. Use rtx_equal_p to compare REG or SUBREG "leaf" operands.
2024-06-20[RISC-V] Minor cleanup/improvement to bset/binv patternsJeff Law2-37/+25
Changes since V1: Whitespace fixes noted by the linter Missed using the iterator for the output template in <bit_optab><mode>_mask pattern! -- This patch introduces a bit_optab iterator that maps IOR/XOR to bset and binv (and one day bclr if we need it). That allows us to combine some patterns that only differed in the RTL opcode (IOR vs XOR) and in the name/assembly (bset vs binv). Additionally this also allow us to use the iterator in the bset<mode>mask and bsetidisi patterns thus potentially fixing a missed optimization. This has gone through my tester. I'll wait for a verdict from pre-commit CI before moving forward. gcc/ * config/riscv/bitmanip.md (<bit_optab><mode>): New unified pattern for bset/binv using a code iterator. (<bit_optab>i<mode>): Likewise. (<bit_optab><mode>_mask): Likewise. Support XOR via any_or. (<bit_optab>isidi): Likewise. * config/riscv/iterators.md (bit_optab): New iterator.
2024-06-20libstdc++: Fix find_last_set(simd_mask) to ignore padding bitsMatthias Kretz2-13/+62
With the change to the AVX512 find_last_set implementation, the change to AVX512 operator!= is unnecessary. However, the latter was not producing optimal code and unnecessarily set the padding bits. In theory, the compiler could determine that with the new != implementation, the bit operation for clearing the padding bits is a no-op and can be elided. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/115454 * include/experimental/bits/simd_x86.h (_S_not_equal_to): Use neq comparison instead of bitwise negation after eq. (_S_find_last_set): Clear unused high bits before computing bit_width. * testsuite/experimental/simd/pr115454_find_last_set.cc: New test.
2024-06-20ada: Reference to nonexistent operator in reduction expression acceptedSteve Baird1-27/+83
In some cases, a reduction expression that references the (nonexistent) "+" operator of a generic formal private type is incorrectly accepted. gcc/ada/ * sem_attr.adb (Resolve_Attribute.Proper_Op): When resolving the name of the reducer subprogram in a reduction expression, Proper_Op treats references to operators defined in Standard specially. Disable this special treatment if the type of the reduction expression is not the right class of type for the operator, or if a new Boolean parameter (named "Strict") is True. (Resolve_Attribute): In the overloaded case, iterate over the reducer subprogram candidates twice. First with Strict => True and then, if no good intepretation is found, with Strict => False.
2024-06-20ada: Fix checking of SPARK RM on ghost with concurrent partYannick Moy1-2/+6
SPARK RM 6.9(21) forbids a ghost type to have concurrent parts. This was not enforced, instead only the type itself was checked to be concurrent. Now fixed. gcc/ada/ * ghost.adb (Check_Ghost_Type): Fix checking.
2024-06-20ada: Rewrite generic formal/actual matchingBob Duff6-1183/+1485
...in preparation for implementing type inference for generic parameters. The main change is to do the "matching" computation early, and produce a *constant* data structure (Gen_Assocs_Rec) to represent the matching between each triple of unanalyzed formal, analyzed formal, and corresponding actual. This will allow us to look at that data structure more than once, which will be necessary for type inference. Matching_Actual is removed; Match_Assocs is added. Other changes include removal of global variables, splitting out processing into subprograms, adding assertions, comment corrections, and other general cleanups. gcc/ada/ * expander.ads: Minor comment fixes. * nlists.ads: Misc comment improvements. * sem_aux.ads (First_Discriminant): Improve comment. * sem_ch12.adb: Misc cleanups. (Associations): New package containing type Gen_Assocs_Rec to represent matchings, and function Match_Assocs to create the Gen_Assocs_Rec constant. (Analyze_Associations): Call Match_Assocs, and other major changes related to that. * sem_ch12.ads: Minor comment fixes. * sem_ch3.adb: Minor comment fixes.
2024-06-20ada: Replace "All" argument to Extensions_Allowed pragma with "All_Extensions"Steve Baird7-30/+36
The argument to pragma Extensions_Allowed to enable all extensions is no longer "All", but instead "All_Extensions". gcc/ada/ * doc/gnat_rm/gnat_language_extensions.rst: Update documentation. * doc/gnat_rm/implementation_defined_pragmas.rst: Update documentation. * errout.adb (Error_Msg_GNAT_Extension): Update error message text. * par-prag.adb: Update pragma parsing. This includes changing the the name of the Check_Arg_Is_On_Or_Off formal parameter All_OK_Too to All_Extensions_OK_Too. * sem_prag.adb (Analyze_Pragma): In analyzing an Extensions_Allowed pragma, replace uses of Name_All with Name_All_Extensions; update a comment to reflect this. * snames.ads-tmpl: Add Name_All_Extensions declaration. * gnat_rm.texi: Regenerate.
2024-06-20ada: Crash on selected component of formal derived type in generic instanceGary Dismukes1-18/+19
The compiler crashes on an instantiation of a generic child unit G1.GC that has a formal private extension P_Ext of a private type P declared in the parent G1 whose full type has a component C, when analyzing a selected component ACC.C whose prefix is of an access type coming from an instantiation of another generic G2 where the designated type is the formal type P_Ext (coming in from a formal type of G2). gcc/ada/ * sem_ch4.adb (Try_Selected_Component_In_Instance): Reverse if_statement clauses so that the testing for the special case of extensions of private types in instance bodies is done first, followed by the testing for the case of a parent type that's a generic actual type. In the extension case, apply Base_Type to the type actual in the test of Used_As_Generic_Actual, and add a test of Present (Parent_Subtype (Typ)).
2024-06-20ada: Fix inlining of fixed-lower-bound array for GNATproveYannick Moy2-5/+17
Inlining in GNATprove may fail on a call to a subprogram with a formal of an array type with fixed lower bound (a GNAT extension), because the appropriate conversion is not used. Fix it. Also fix the function that inserts an unchecked conversion, in cases where it could skip sliding due to the target type having fixed lower bound. gcc/ada/ * inline.adb (Establish_Actual_Mapping_For_Inlined_Call): In the case of formal with a fixed lower bounds, insert appropriate conversion like in the case of a constrained type. * tbuild.adb (Unchecked_Convert_To): Do not skip the conversion when it may involve sliding due to a type with fixed lower bound.
2024-06-20ada: Fix assertion failure during analysis of instantiation of formal packageEric Botcazou1-1/+2
It's an assertion on the name of an instance of a generic child unit and it needs to cope with a renaming of the unit. gcc/ada/ * sem_ch12.adb (Instantiate_Formal_Package): Accept renamings of a generic parent that is a child unit for the abbreviated instance.
2024-06-20ada: Fix composition of primitive equality for untagged records with variant ↵Eric Botcazou1-28/+22
part In Ada 2012, primitive equality operators of untagged record types compose like those of tagged record types, but this has never been implemented for untagged record types with a variant part. gcc/ada/ * exp_ch4.adb (Expand_Composite_Equality): In the untagged record case, always look for a user-defined equality operator in Ada 2012.
2024-06-20ada: New pragma to default all interrupts to system.Doug Rupp15-779/+904
New pragma Interrupts_System_By_Default defaults all interrupts/signals to system (which will inhibit the installation of default signal handlers). Note this changes the ALI format: it optionally adds an identifier to the 'P' line (similar to pragma Unreserve_All_Interrupts). As per comment in lib-writ spec regarding new modifiers, adding modifiers to the P line is always safe. Also note this does not introduce a bootstrap problem because the compiler and binder do not set the underlying _gl global nor do they use this pragma. gcc/ada/ * ali.ads (Interrupts_Default_To_System): New boolean. (Interrupts_Default_To_System_Specified): New boolean. * ali.adb (Interrupts_Default_To_System_Specified): Initialize. (Interrupts_Default_To_System): Initialize. (Scan_ALI): Processing for "ID". * bindgen.adb: Coallesce comments on interrupt settings to ... (Gen_Adainit): Import Interrupts_Default_To_System flag and set if pragma specified. (Gen_Output_File_Ada): Generate Local_Interrupt_States according to pragma. * init.c: ... here. [vxworks] (__gnat_install_handler): Test for interrupt_state. (__gl_interrupts_default_to_system): New global flag. (__gnat_get_interrupt_State): return interrupt state according to new global flag. * lib-writ.ads: Document "ID". * lib-writ.adb: Write out "ID". * opt.ads (Interrupts_System_By_Default): New boolean, defaulted to False. * par-prag.adb (Pragma_Interrupts_System_By_Default): New. * sem_prag.adb (Pragma_Interrupts_System_By_Default): Handle it. (Pragma_Interrupts_System_By_Default): Default it. * snames.ads-tmpl (Name_Interrupts_System_By_Default): New name. (Pragma_Interrupts_System_By_Default): New * libgnarl/s-intman__posix.adb (Initialize): Ensure the Keep_Unmasked signal is sigset-able. * doc/gnat_rm/implementation_defined_pragmas.rst: Document pragma Interrupts_System_By_Default. * doc/gnat_ugn/the_gnat_compilation_model.rst (Configuration pragmas): Add Interrupts_System_By_Default. (Partition-Wide Settings): Mention pragma Interrupts_System_By_Default. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-06-20ada: Fix bogus error with "=" operator on array of private unchecked unionEric Botcazou2-20/+14
The code is legal and, therefore, must be accepted by the compiler, but it must raise Program_Error at run time due to operands not having inferable discriminants and a warning be given at compile time (RM B.3.3(22-23)). gcc/ada/ * exp_ch4.adb (Expand_Array_Equality.Component_Equality): Copy the Comes_From_Source flag from the original test to the new one, and remove obsolete code dealing with unchecked unions. * sem_util.adb (Has_Inferable_Discriminants): Return False for an incomplete or private nominal subtype.
2024-06-20ada: Fix crash on real literal in declare expression of expression functionEric Botcazou1-2/+3
The problem is that the freeze node of the type to which the real literal is resolved is placed inside the expression function instead of outside. gcc/ada/ * freeze.adb (Freeze_Expression): Also attach pending freeze nodes to the parent in the case of an internal block in a spec expression.
2024-06-20ada: Enforce strict alignment for array types with aliased componentEric Botcazou2-13/+22
This was initially implemented as part of AI12-001 but immediately disabled because it breaks Florist on 32-bit platforms. However, it is possible to reenable it in almost all cases without affecting Florist, and the -gnatd_l switch can now be used to disable it again. gcc/ada/ * debug.adb (d_l): Document new usage for the compiler. * freeze.adb (Check_Strict_Alignment): Set the Strict_Alignment flag on array types with aliased component, except if the component size is equal to the storage unit or the -gnatd_l switch is specified.
2024-06-20ada: Update Bit Ordering references in GNAT Reference ManualEric Botcazou4-28/+24
They are still tailored to Ada 95 while the level of recommended support for Bit Ordering was changed in Ada 2005. gcc/ada/ * doc/gnat_rm/implementation_advice.rst (Representation Clauses): Remove >> marker and add end of sentence after code-block directive. (RM 13.5.3(7-8)): Update to Ada 2005 wording. * doc/gnat_rm/implementation_defined_characteristics.rst (RM 13.5.3(5)): Likewise. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-06-20ada: Add documentation for Subprogram_Variant aspect and pragmaPiotr Trojanek4-655/+738
For completeness, the GNAT Reference Manual should document aspects and pragmas that are specific to SPARK and described in the SPARK User's Guide. gcc/ada/ * doc/gnat_rm/implementation_defined_aspects.rst (Aspect Subprogram_Variant): Refer to SPARK User's Guide. * doc/gnat_rm/implementation_defined_pragmas.rst (Pragma Subprogram_Variant): Document syntax to satisfy the convention; refer to SPARK User's Guide for semantics. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2024-06-20ada: Streamline propagation of controlled flags on typesEric Botcazou7-101/+113
The front-end maintains a set of 4 flags on (base) types that are used to parameterize the implementation of controlled operations, and these flags need to be propagated through composition and derivation. This is done on a per-flag basis in the current implementation with a few loopholes. This introduces a Propagate_Controlled_Flags routine to that effect, which is modeled on the existing Propagate_Concurrent_Flags routine, and is used in most cases to do the propagation. This also removes the handling of the Finalize_Storage_Only flag from Inherit_Aspects_At_Freeze_Point, since the associated aspect does not exist (only the pragma does). gcc/ada/ * freeze.adb (Freeze_Array_Type): Call Propagate_Controlled_Flags to propagate the controlled flags from the component to the array. (Freeze_Record_Type): Propagate the Finalize_Storage_Only flag from the components to the record. * sem_ch3.adb (Analyze_Private_Extension_Declaration): Do not call Propagate_Concurrent_Flags here but... (Array_Type_Declaration): Tidy and call Propagate_Controlled_Flags to propagate the controlled flags from the component to the array. (Build_Derived_Private_Type): Do not propagate the controlled flags manually here but... (Build_Derived_Record_Type): ...call Propagate_Controlled_Flags to propagate the controlled flags from parent to derived type. (Build_Derived_Type): Likewise. (Copy_Array_Base_Type_Attributes): Call Propagate_Controlled_Flags to copy the controlled flags. (Record_Type_Definition): Streamline the propagation of the Finalize_Storage_Only flag from the components to the record. * sem_ch7.adb (Preserve_Full_Attributes): Use Full_Base and call Propagate_Controlled_Flags to copy the controlled flags. * sem_ch9.adb (Analyze_Protected_Definition): Use canonical idiom to compute Has_Controlled_Component. (Analyze_Protected_Type_Declaration): Minor tweak. * sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): Do not deal with Finalize_Storage_Only here. * sem_util.ads (Propagate_Controlled_Flags): New declaration. * sem_util.adb (Propagate_Controlled_Flags): New procedure.
2024-06-20ada: Remove redundant conditions from freezing codePiotr Trojanek2-8/+7
Code cleanup; behavior is unaffected. gcc/ada/ * freeze.adb (Check_Current_Instance): This routine is only called with parameter E being a type entity, so there is no need to check for types just before the equality with E. * sem_ch13.adb (Analyze_Aspect_Specifications): Regroup condition to avoid unnecessary evaluation. (Check_Aspect_At_End_Of_Declarations): If In_Instance is true, then the routine exits early.
2024-06-20ada: Fix style in freezing codePiotr Trojanek2-8/+6
Code cleanup; semantics is unaffected. gcc/ada/ * freeze.adb (Find_Aspect_No_Parts): Tune whitespace. * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Fix style.
2024-06-20ada: Remove Max_Entry_Queue_Depth pragma/aspectEric Botcazou8-47/+6
It was implemented apparently because a very early version of AI12-0164 that standardizes GNAT's Max_Queue_Length opted for the subtly different moniker, but later versions of the AI use Max_Entry_Queue_Length instead. gcc/ada/ * aspects.ads (Aspect_Id): Remove Aspect_Max_Entry_Queue_Depth. (global arrays): Remove entry for it. * exp_ch9.adb (Expand_N_Protected_Type_Declaration): Remove reference to pragma Max_Entry_Queue_Depth in comment. * par-prag.adb (Prag): Remove handling of Pragma_Max_Entry_Queue_Depth. * sem_ch13.adb (Analyze_Aspect_Specifications): Remove reference to aspect Max_Entry_Queue_Depth in comment. (Analyze_Aspect_Specifications): Remove processing of aspect Max_Entry_Queue_Depth. (Check_Aspect_At_Freeze_Point): Likewise. * sem_prag.ads (Find_Related_Declaration_Or_Body): Remove reference to pragma Max_Entry_Queue_Depth in comment. * sem_prag.adb (Analyze_Pragma): Remove processing of pragma Max_Entry_Queue_Depth. (Sig_Flags): Remove entry for Pragma_Max_Entry_Queue_Depth. * sem_util.adb (Get_Max_Queue_Length): Remove handling of pragma Max_Entry_Queue_Depth. (Has_Max_Queue_Length): Likewise. * snames.ads-tmpl (Name_Max_Entry_Queue_Depth): Move back from pragmas section to others section. (Pragma_Id): Remove Pragma_Max_Entry_Queue_Depth.