aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-06-09ada: Support fixed-lower-bound array types as generic actual parametersGary Dismukes2-1/+13
Attempting to use a fixed-lower-bound array type (or subtype) as an actual parameter for a formal unconstrained array type was being rejected by the compiler (complaining about the index type of the actual not matching the index type of the formal type). The compiler was improperly testing the actual's FLB range and finding that it didn't statically match the index type of the formal array type; it should instead test the underlying index type of the FLB type or subtype. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index): In the case of a fixed-lower-bound index, set Etype of the newly created itype's Scalar_Range from the index's Etype. * sem_ch12.adb (Validate_Array_Type_Instance): If the actual subtype is a fixed-lower-bound type, then check again the Etype of its Scalar_Range.
2025-06-09ada: Reject component-related aspects on formal non-array typesPiotr Trojanek1-7/+4
In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified for a formal array type, but they were wrongly accepted on any formal type. Also, we don't need to check if the corresponding pragmas appear in Ada 2022 mode, because generic formal parameters can't have explicit representation pragmas in any Ada version and can only have aspects since Ada 2022. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): Fix conditions for legality checks on formal type declarations.
2025-06-09ada: Fix glitch in handling of Atomic_Components on generic formal typePiotr Trojanek1-1/+3
In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified for a formal array type, but then they need to be set on the base type entity. Otherwise we get an assertion failure in debug build and wrong legality errors in production builds. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): If pragmas apply to a formal array type, then set the flags on the base type.
2025-06-09ada: Missing discriminant check on assignment of Bounded_Vector aggregateGary Dismukes1-1/+10
When a container aggregate for a Bounded_Vector type involves an iterated association that is assigned to a vector object whose capacity (as defined by the Capacity discriminant) is less than the number of elements of the aggregate, Constraint_Error should be raised due to failing a discriminant check on the assignment. But the compiler fails to do proper expansion, plus omits the check, and instead creates a temporary whose capacity is bounded by that of the target vector of the assignment. It attempts to assign all elements of the aggregate to the temporary, resulting in a failure on a call to the Replace_Element operation that assigns past the length of the temporary vector (which can result in a Storage_Error due to a segment violation). This is fixed by ensuring that the temporary object is declared with an unconstrained base subtype rather than the assignment target's constrained subtype. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Container_Aggregate): Use the Base_Type of the subtype provided by the context as the subtype of the temporary object initialized by the aggregate.
2025-06-09ada: Check validity using signedness from the type and not its base typePiotr Trojanek1-3/+2
When attribute Valid is applied to a private type, we used the signedness of its implementation base type which wrongly included negative values. gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): When expanding attribute Valid, use signedness from the validated view, not from its base type.
2025-06-09ada: Incorrect creation of corresponding expression of class-wide contractsGary Dismukes2-95/+121
GNAT was incorrectly implementing the Ada rules for resolving calls to primitive functions within inherited class-wide pre- and postconditions, as specified in RM22 6.1.1 (relating to AI12-0113). Only function calls that involve formals of the associated primitive subprogram should be treated using the "(notional) formal derived type" rules. In particular, calls that are tag-indeterminate (for example, "F(G)") should not be mapped to call the corresponding primitives of the derived type (they should still call the primitives of the ancestor type). The fix for this involves a new predicate function that recursively traverses calls to determine the calls that satisfy the criteria for mapping. These changes also completely remove the mapping of formals that was done in Contracts.Merge_Class_Conditions (in Inherit_Condition), since the mapping will be done later anyway by Build_Class_Wide_Expression, and the earlier mapping interferes with that. Note: The utility function Sem_Util.Check_Parents is no longer called after removal of the single call to it from contracts.adb, but it's being retained (along with the generic subprograms in Atree that it depends on) for possible use in VAST. gcc/ada/ChangeLog: * contracts.adb (Inherit_Condition): Remove Assoc_List and its uses along with function Check_Condition, since mapping of formals will effectively be done in Build_Class_Wide_Expression (by Replace_Entity). * exp_util.adb (Replace_Entity): Only rewrite entity references in function calls that qualify according to the result of calling the new function Call_To_Parent_Dispatching_Op_Must_Be_Mapped. (Call_To_Parent_Dispatching_Op_Must_Be_Mapped): New function that determines whether a function call to a primitive of Par_Subp associated tagged type needs to be mapped (according to whether it has any actuals that reference controlling formals of the primitive).
2025-06-09ada: Fix spurious error on anonymous array initialized by conditional expressionEric Botcazou1-22/+21
Even though the actual subtype of the anonymous array is not yet set on the object itself by the time Insert_Conditional_Object_Declaration is called, it is set on its initialization expression, so it can simply be forwarded to Insert_Conditional_Object_Declaration from there, which avoids creating a new one for each new object and triggering a subtype mismatch later. gcc/ada/ChangeLog: * exp_ch4.adb (Insert_Conditional_Object_Declaration): Remove Decl formal parameter, add Typ and Const formal parameters. (Expand_N_Case_Expression): Fix pasto in comment. Adjust call to Insert_Conditional_Object_Declaration and tidy up surrounding code. (Expand_N_If_Expression): Adjust couple of calls to Insert_Conditional_Object_Declaration.
2025-06-09Daily bump.GCC Administrator1-1/+1
2025-06-08Daily bump.GCC Administrator1-1/+1
2025-06-07Daily bump.GCC Administrator4-1/+219
2025-06-06ChangeLog.omp bumpTobias Burnus4-1/+45
2025-06-06ada: Constant_Indexing used when context requires a variableJavier Miranda1-219/+667
In the case of an assignment where the type of its left hand side is an indexable container that has indexable container components (for example a container vector of container vectors), and both indexable containers have Constant_Indexing and Variable_Indexing aspects, the left hand side of the assignment is erroneously interpreted as constant indexing. The error results in spurious compile-time error messages saying that the left hand side of the assignment must be a variable. gcc/ada/ChangeLog: * sem_ch4.adb (Constant_Indexing_OK): Add missing support for RM 4.1.6(13/3), and improve performance to avoid climbing more than needed. Add documentation. (Try_Indexing_Function): New subprogram. (Expr_Matches_In_Formal): Added new formals. (Handle_Selected_Component): New subprogram. (Has_IN_Mode): New subprogram. (Try_Container_Indexing): Add documentation, code reorganization and extend its functionality to improve its support for prefixed notation calls.
2025-06-06ada: Fix libgpr2 build failure with compiler built with assertionsEric Botcazou1-0/+2
The problem is that the Entity field is accessed for a node without one. gcc/ada/ChangeLog: * sem_ch10.adb (Install_Siblings.In_Context): Add missing guard.
2025-06-06ada: Fix wrong initialization of library-level object by conditional expressionEric Botcazou1-1/+8
At library level the object must be allocated statically and with its bounds when its nominal subtype is an unconstrained array type. gcc/ada/ChangeLog: * exp_ch4.adb (Insert_Conditional_Object_Declaration): Make sure the object is allocated properly by the code generator at library level.
2025-06-06ada: Incorrect unresolved operator name in an instantiationSteve Baird1-23/+2
In some cases, a generic containing a use of a unary operator successfully compiles but the compiler incorrectly rejects the corresponding use in an instantiation. gcc/ada/ChangeLog: * sem_ch4.adb (Find_Unary_Types): Because we reanalyze names in an instance, we sometimes have to take steps to filter out extraneous name resolution candidates that happen to be visible at the point of the instance declaration. Remove some code that appears to have been written with this in mind. This is done for two reasons. First, the code sometimes doesn't work (possibly because the In_Instance test is not specific enough - it probably should be testing to see whether we are in an instance of the particular generic in which the result of calling Corresponding_Generic_Type was declared) and causes correct code to be rejected. Second, the code seems to no longer be necessary (possibly because of subsequent fixes in this area which are not specific to unary operators).
2025-06-06ada: Fix internal error on allocator involving interface typeEric Botcazou5-33/+51
The problem is that an itype duplicated through Duplicate_Subexpr_No_Checks ends up in a different scope than its source. It is fixed by adding a new formal parameter New_Scope to the function and forwarding it in the call to the New_Copy_Tree function. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Record_Aggregate): Use the named form for the second actual parameter in the call to Duplicate_Subexpr. * exp_attr.adb (Expand_Size_Attribute): Likewise. * exp_ch5.adb (Expand_Assign_Array): Likewise. (Expand_Assign_Array_Bitfield): Likewise. (Expand_Assign_Array_Bitfield_Fast): Likewise. * exp_util.ads (Duplicate_Subexpr): Add New_Scope formal parameter. (Duplicate_Subexpr_No_Checks): Likewise. (Duplicate_Subexpr_Move_Checks): Likewise. * exp_util.adb (Build_Allocate_Deallocate_Proc): Pass Proc_Id as the actual for New_Scope in the calls to Duplicate_Subexpr_No_Checks. (Duplicate_Subexpr): Add New_Scope formal parameter and forward it in the call to New_Copy_Tree. (Duplicate_Subexpr_No_Checks): Likewise. (Duplicate_Subexpr_Move_Checks): Likewise.
2025-06-06ada: Fix for validity checking of limited scalar typesPiotr Trojanek1-3/+12
With a recent change we are now validity checking objects of private scalar types, but need to handle private scalar types whose public view is limited. gcc/ada/ChangeLog: * checks.adb (Insert_Valid_Check): Set flag Assignment_OK in the object declaration inserted for the validity checks.
2025-06-06OpenMP: Add omp_get_initial_device/omp_get_num_devices builtinsTobias Burnus10-6/+172
By adding omp_get_initial_device and omp_get_num_devices builtins for C, C++, and Fortran, the following can be achieved: * By making them pure, multiple calls can be avoiding in some cases. * Some comparisons can be optimized at compile time. omp_get_initial_device will be converted to omp_get_num_devices for consistency; note that OpenMP 6 also permits omp_initial_device (== -1) as value. If GCC has not been configure for offloading, either intrinsic will leads to 0 - and on the offload side, -1 (= omp_initial_device) is returned for omp_initial_device. gcc/fortran/ChangeLog: * f95-lang.cc (ATTR_PURE_NOTHROW_LIST): Define. * trans-expr.cc (get_builtin_fn): Handle omp_get_num_devices and omp_get_intrinsic_device. * gfortran.h (gfc_option_t): Add disable_omp_... for them. * options.cc (gfc_handle_option): Handle them with -fno-builtin-. gcc/ChangeLog: * gimple-fold.cc (gimple_fold_builtin_omp_get_initial_device, gimple_fold_builtin_omp_get_num_devices): New. (gimple_fold_builtin): Call them. * omp-builtins.def (BUILT_IN_OMP_GET_INITIAL_DEVICE): Add (BUILT_IN_OMP_GET_NUM_DEVICES): Make uservisible + pure. libgomp/ChangeLog: * libgomp.texi (omp_get_num_devices, omp_get_intrinsic_device): Document builtin handling. gcc/testsuite/ChangeLog: * c-c++-common/gomp/omp_get_num_devices_initial_device-2.c: New test. * c-c++-common/gomp/omp_get_num_devices_initial_device.c: New test. * gfortran.dg/gomp/omp_get_num_devices_initial_device-2.f90: New test. * gfortran.dg/gomp/omp_get_num_devices_initial_device.f90: New test. Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com> (cherry picked from commit 387209938d2c476a67966c6ddbdbf817626f24a2)
2025-06-06builtins.def: Enable OpenMP/OpenACC builtins also with -fno-nonansi-builtinsTobias Burnus1-1/+5
The flags -std=c.. and -std=c++.. imply -fno-nonansi-builtins, which disabled the OpenMP/OpenACC intrinsics - but -fopenmp/-fopenacc builtin use should be rather othogonal to the user's choice between -std=c... and -std=gnuc... gcc/ChangeLog: * builtins.def (DEF_GOACC_BUILTIN_COMPILER, DEF_GOMP_BUILTIN_COMPILER): Set NONANSI_P = false to enable those also with -fno-nonansi-builtins. (cherry picked from commit 214b5d66c54613463a96aa2c7202bc32f628dad6)
2025-06-06Merge branch 'releases/gcc-15' into devel/omp/gcc-15Tobias Burnus54-436/+1621
Merge up to r15-9790-ga69ab79c1abaa4 (June 6, 2025)
2025-06-06gcn: Update --with-arch= for newer archsTobias Burnus2-10/+12
Replace hard-coded list of supported devices by directly checking config/gcn/gcn-devices.def. gcc/ChangeLog: * config.gcc (--with-{arch,tune}): Use .def file to validate gcn processor names. * doc/install.texi (amdgcn*-*-*): Update list of devices supported by --with-arch/--with-tune. (cherry picked from commit 61a6430cf663e3c980c2ee966f094fea7d99f8e7)
2025-06-06tree-optimization/120357 - ICE with early break vectorizationRichard Biener2-1/+15
When doing early break vectorization of a loop with a conditional reduction the epilog creation code is confused as to before which exit to insert the conditional reduction induction IV update. The following make sure this is done before the main IV exit. PR tree-optimization/120357 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Create the conditional reduction induction IV increment before the main IV exit. * gcc.dg/vect/vect-early-break_136-pr120357.c: New testcase. (cherry picked from commit dce4da51ab66c3abb84448326910cd42f6fe2499)
2025-06-06tree-optimization/120341 - stores into STRING_CSTs can trapRichard Biener4-3/+29
The following fixes conditional store elimination and store motion so they consider stores to STRING_CSTs as trapping. PR tree-optimization/120341 * tree-ssa-loop-im.cc (can_sm_ref_p): STRING_CSTs are readonly. * tree-ssa-phiopt.cc (cond_store_replacement): Likewise. * gcc.dg/torture/pr120341-1.c: New testcase. * gcc.dg/torture/pr120341-2.c: Likewise. (cherry picked from commit 02c58bc4b0885f5b6f50033da35768ebe6c4a030)
2025-06-06rtl-optimization/120182 - wrong-code with RTL DSE and constant addressesRichard Biener2-1/+46
RTL DSE forms store groups from unique invariant bases but that is confused when presented with constant addresses where it assigns one store group per unique address. That causes it to not consider 0x101:QI to alias 0x100:SI. Constant accesses can really alias to every object, in practice they appear for I/O and for access to objects fixed via linker scripts for example. So simply avoid registering a store group for them. PR rtl-optimization/120182 * dse.cc (canon_address): Constant addresses have no separate store group. * gcc.dg/torture/pr120182.c: New testcase. (cherry picked from commit b9434c3db900d5d037fdf2f64149b82800ceadf8)
2025-06-06Fix gcc.dg/tree-ssa/ssa-dom-thread-7.c for aarch64Richard Biener1-1/+1
So on another machine with a cross I see 17 jumps threaded, so adjusted like that. PR tree-optimization/120003 * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust aarch64 expected thread2 number of threads. (cherry picked from commit aa6f1df4ec46a20d2292291b192d3331e51b59f8)
2025-06-06tree-optimization/120003 - missed jump threadingRichard Biener3-7/+24
The following allows the entry and exit block of a jump thread path to be equal, which can easily happen when there isn't a forwarder on the interesting edge for an FSM thread conditional. We just don't want to enlarge the path from such a block. PR tree-optimization/120003 * tree-ssa-threadbackward.cc (back_threader::find_paths_to_names): Allow block re-use but do not enlarge the path beyond such a re-use. * gcc.dg/tree-ssa/ssa-thread-23.c: New testcase. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust. (cherry picked from commit 1a13684dfc7286139064f7d7341462c9995cbd1c)
2025-06-06tree-optimization/119960 - failed external SLP promotionRichard Biener2-7/+71
The following addresses a too conservative sanity check of SLP nodes we want to promote external. The issue lies in code generation for such external which relies on get_later_stmt to figure an insert location. But get_later_stmt relies on the ability to totally order stmts, specifically implementation-wise that they are all from the same BB, which is what is verified at the moment. The patch changes this to require stmts to be orderable by dominance queries. For simplicity and seemingly enough for the testcase in PR119960, this handles the case of two distinct BBs. PR tree-optimization/119960 * tree-vect-slp.cc (vect_slp_can_convert_to_external): Handle cases where defs from multiple BBs are ordered by their dominance relation. * gcc.dg/vect/bb-slp-pr119960-1.c: New testcase. (cherry picked from commit cc74e2f2b39b6debbef1787a087abad2108e95dd)
2025-06-06tree-optimization/116352 - amend previous fixRichard Biener1-1/+10
The previous fix restricted external vector builds to defs from the same basic-block. That turns out too restrictive so we have to mitigate the original issue in a different way which is restricting it to the original case where all defs are in the same basic-block. PR tree-optimization/116352 * tree-vect-slp.cc (vect_build_slp_tree_2): When compressing operands from a two-operator node make sure the resulting operation does not mix defs from different basic-blocks. (cherry picked from commit 1e8bd720b1a618a39e2a41eec05e935c32d295f3)
2025-06-06tree-optimization/119960 - add validity checking to SLP schedulingRichard Biener1-8/+28
The following adds checks that when we search for a vector stmt insert location we arrive at one where all required operand defs are dominating the insert location. At the moment any such failure only blows up during SSA verification. There's the long-standing issue that we do not verify there exists a valid schedule of the SLP graph from BB vectorization into the existing CFG. We do not have the ability to insert vector stmts on the dominance frontier "end", nor to insert LC PHIs that would be eventually required. This should be done all differently, computing the schedule during analysis and failing if we can't schedule. PR tree-optimization/119960 * tree-vect-slp.cc (vect_schedule_slp_node): Sanity check dominance check on operand defs. (cherry picked from commit 5f44fcdfe18e72f2900d2757375843e88d32c535)
2025-06-06tree-optimization/119960 - fix and guard get_later_stmtRichard Biener1-3/+17
The following makes get_later_stmt handle stmts from different basic-blocks in the case they are orderd and otherwise asserts. * tree-vectorizer.h (get_later_stmt): Robustify against stmts in different BBs, assert when they are unordered. (cherry picked from commit a6cfde60d8c744b31b147022e797bbcc371ae092)
2025-06-06Fix regression from x86 multi-epilogue tuningRichard Biener6-7/+73
With the avx512_two_epilogues tuning enabled for zen4 and zen5 the gcc.target/i386/vect-epilogues-5.c testcase below regresses and ends up using AVX2 sized vectors for the masked epilogue rather than AVX512 sized vectors. The following patch rectifies this and adds coverage for the intended behavior. * config/i386/i386.cc (ix86_vector_costs::finish_cost): Do not suggest a first epilogue mode for AVX512 sized main loops with X86_TUNE_AVX512_TWO_EPILOGUES as that interferes with using a masked epilogue. * gcc.target/i386/vect-epilogues-1.c: New testcase. * gcc.target/i386/vect-epilogues-2.c: Likewise. * gcc.target/i386/vect-epilogues-3.c: Likewise. * gcc.target/i386/vect-epilogues-4.c: Likewise. * gcc.target/i386/vect-epilogues-5.c: Likewise. (cherry picked from commit 75c7f90bfe6fa8e6c1a70b784e98a3412861646d)
2025-06-06Daily bump.GCC Administrator4-1/+100
2025-06-05ChangeLog.omp bumpSandra Loosemore5-1/+44
2025-06-05OpenMP: Fix regressions in metadirective-target-device-2.c [PR120518]Sandra Loosemore1-4/+10
My previous patch that added a CLEANUP_POINT_EXPR around the device_num selector expression in the C++ front end broke the testcase c-c++-common/gomp/metadirective-target-device-2.c on offload targets. It confused the code in omp_device_num_check that tries to bypass error checking and do early resolution when the expression is a call to one of the OpenMP library functions. The solution is to make that code smart enough to look inside a CLEANUP_POINT_EXPR. gcc/ChangeLog PR c++/120518 * omp-general.cc (omp_device_num_check): Look inside a CLEANUP_POINT_EXPR when trying to optimize special cases. (cherry picked from commit 9788a1e24822226b55dd1ab521e34bfaf9f4974d)
2025-06-05OpenMP: Handle more cases in user/condition selectorSandra Loosemore11-19/+188
Tobias had noted that the C front end was not treating C23 constexprs as constant in the user/condition selector property, which led to missed opportunities to resolve metadirectives at parse time. Additionally neither C nor C++ was permitting the expression to have pointer or floating-point type -- the former being a common idiom in other C/C++ conditional expressions. By using the existing front-end hooks for the implicit conversion to bool in conditional expressions, we also get free support for using a C++ class object that has a bool conversion operator in the user/condition selector. gcc/c/ChangeLog * c-parser.cc (c_parser_omp_context_selector): Call convert_lvalue_to_rvalue and c_objc_common_truthvalue_conversion on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR. gcc/cp/ChangeLog * cp-tree.h (maybe_convert_cond): Declare. * parser.cc (cp_parser_omp_context_selector): Call maybe_convert_cond and fold_build_cleanup_point_expr on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR. * pt.cc (tsubst_omp_context_selector): Likewise. * semantics.cc (maybe_convert_cond): Remove static declaration. gcc/testsuite/ChangeLog * c-c++-common/gomp/declare-variant-2.c: Update expected output. * c-c++-common/gomp/metadirective-condition-constexpr.c: New. * c-c++-common/gomp/metadirective-condition.c: New. * c-c++-common/gomp/metadirective-error-recovery.c: Update expected output. * g++.dg/gomp/metadirective-condition-class.C: New. * g++.dg/gomp/metadirective-condition-template.C: New. (cherry picked from commit 08c299a410b9314957e48a87f5bf50a4c034b744)
2025-06-05ada: Spurious compilation error with repeated loop indexJavier Miranda1-0/+15
When multiple for-loop statements in the same scope use the same index name to iterate through container elements, the compiler reports a spurious error indicating a conflict between index names. gcc/ada/ChangeLog: * exp_ch7.adb (Process_Object_Declaration): Avoid generating duplicate names for master nodes.
2025-06-05ada: Exception-raising loop incorrectly eliminatedSteve Baird1-1/+6
If the body of a loop includes a raise statement then the loop should not be considered to be free of side-effects and therefore eligible for elimination by the compiler. gcc/ada/ChangeLog: * sem_util.adb (Side_Effect_Free_Statements): Return False if the statement list includes an explicit (i.e. Comes_From_Source) raise statement.
2025-06-05ada: Fix crash on access to protected returnRonan Desplanques1-2/+3
The generation of the check mandated by Ada issue AI05-0073 was not done handled properly for protected types when used through subtypes. This patch fixes the issue. gcc/ada/ChangeLog: * exp_ch4.adb (Tagged_Membership): Fix for protected types.
2025-06-05ada: Tweak caching of streaming subprogramsRonan Desplanques1-2/+2
gcc/ada/ChangeLog: * exp_attr.adb (Interunit_Ref_OK): Tweak categorization of compilation units.
2025-06-05ada: Implement built-in-place expansion of two-pass array aggregatesEric Botcazou5-216/+324
These are array aggregates containing only component associations that are iterated with iterator specifications, as per RM 4.3.3(20.2/5-20.4/5). It is implemented for the array aggregates that are used to initialize an object, as specified by RM 7.6(17.2/3-17.3/3) for immutably limited types and types that need finalization, but for all types like other aggregates. gcc/ada/ChangeLog: * exp_aggr.adb (Build_Two_Pass_Aggr_Code): New function containing most of the code initially present in Two_Pass_Aggregate_Expansion. (Two_Pass_Aggregate_Expansion): Remove redundant N parameter. Implement built-in-place expansion for (static) object declarations and allocators, using Build_Two_Pass_Aggr_Code for the main work. (Expand_Array_Aggregate): Adjust Two_Pass_Aggregate_Expansion call. Replace Etype (N) by Typ in a couple of places. * exp_ch3.adb (Expand_Freeze_Array_Type): Remove special case for two-pass array aggregates. (Expand_N_Object_Declaration): Do not adjust the object when it is initialized by a two-pass array aggregate. * exp_ch4.adb (Expand_Allocator_Expression): Apply the processing used for container aggregates to two-pass array aggregates. * exp_ch6.adb (Validate_Subprogram_Calls): Skip calls present in initialization expressions of N_Object_Declaration nodes that have No_Initialization set. * sem_ch3.adb (Analyze_Object_Declaration): Detect the cases of an array originally initialized by an aggregate consistently.
2025-06-05ada: Reject Valid_Value arguments originating from StandardViljar Indus3-8/+9
The constraint for Valid_Value not applying to types from Standard should also apply to all types derived from those types. gcc/ada/ChangeLog: * doc/gnat_rm/implementation_defined_attributes.rst: Update the documentation for Valid_Value. * sem_attr.adb (Analyze_Attribute): Reject types where the root type originates from Standard. * gnat_rm.texi: Regenerate.
2025-06-05ada: Error about assignment to limited target on aggregate with "for of" ↵Gary Dismukes1-1/+1
iterator The compiler reports a spurious error about an assignment to a limited object on an aggregate of a array type with limited components that has an association with a "for of" iterator. This is fixed by arranging to have the Assignment_OK flag set on the indexed_names generated by the expander for initializing the aggregate object. gcc/ada/ChangeLog: * exp_aggr.adb (Two_Pass_Aggregate_Expansion): Change call to Make_Assignment for the indexed aggregate object to call Change_Make_OK_Assignment instead.
2025-06-05ada: Fix buffer overflow for function call returning discriminated limited ↵Eric Botcazou2-85/+33
record This occurs when the discriminated limited record type is declared with default values for its discriminants, is not controlled, and the context of the call is anonymous, i.e. the result of the call is not assigned to an object. In this case, a temporary is created to hold the result of the call, with the default values of the discriminants, but the result may have different values for the discriminants and, in particular, may be larger than the temporary, which leads to a buffer overflow. This problem does not occur when the context is an object declaration, so the fix just makes sure that the expansion in an anonymous context always uses the model of an object declaration. It requires a minor tweak to the helper function Entity_Of of the Sem_Util package. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_Actuals): Remove obsolete comment. (Make_Build_In_Place_Call_In_Anonymous_Context): Always use a proper object declaration initialized with the function call in the cases where a temporary is needed, with Assignment_OK set on it. * sem_util.adb (Entity_Of): Deal with rewritten function call first.
2025-06-05ada: Fix compile-time failure due to duplicated attribute subprograms.Steve Baird1-15/+24
For a given type, and for certain attributes (the 4 streaming attributes and, for Ada2022, the Put_Image attribute), the compiler needs to keep track of whether a subprogram has already been generated for the given type/attribute pair. In some cases this was being done incorrectly; the compiler ended up generating duplicate subprograms (with the same name), resulting in compilation failures. This could occur if the prefix of an attribute reference denoted a subtype (more precisely, a non-first subtype). This includes the case of a subtype declaration that is implicitly introduced by the compiler to capture the binding between a formal type in a generic and the corresponding actual type in an instantiation. gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): When accessing the maps declared in package Cached_Attribute_Ops, the key value passed to Get or to Set should never be the entity node for a subtype. Use the entity of the corresponding type declaration instead.
2025-06-05ada: Avoid calling Resolve with Stand.Any_Fixed as the expected typeSteve Baird1-0/+2
When we call Resolve for an expression, we pass in the expected type for that expression. In the absence of semantic errors, that expected type should never be any of the "Any_xxx" types declared in stand.ads (e.g., Any_Array, Any_Numeric, Any_Real). In particular, it should never be Any_Fixed. Fix a case in which this rule was being violated. gcc/ada/ChangeLog: * sem_res.adb (Set_Mixed_Mode_Operand): If we are about to call Resolve passing in Any_Fixed as the expected type, then instead pass in the fixed point type of the other operand (i.e., B_Typ).
2025-06-05ada: Compiler crash on array aggregate association iterating over function ↵Gary Dismukes1-29/+86
result The compiler triggers a bug box when compiling an array aggregate with an iterated_component_association that iterates over another array object, failing when trying to retrieve a Choices field, which isn't an allowed field for N_Iterated_Component_Association nodes. This occurs in procedure Check_Function_Writable_Actuals, which wasn't accounting for the iterated association forms. gcc/ada/ChangeLog: * sem_util.adb (Check_Function_Writable_Actuals): Add handling for N_Iterated_Component_Association and N_Iterated_Element_Association. Fix a typo in an RM reference (6.4.1(20/3) => 6.4.1(6.20/3)). (Collect_Expression_Ids): New procedure factoring code for collecting identifiers from expressions of aggregate associations. (Handle_Association_Choices): New procedure factoring code for handling id collection for expressions of aggregate associations with multiple choices. Removed redundant test of Box_Present from original code.
2025-06-05Fix crash with constant initializer caused by IPAEric Botcazou4-1/+41
The testcase compiled with -O2 -gnatn makes the compiler crash in vect_can_force_dr_alignment_p during SLP vectorization: if (decl_in_symtab_p (decl) && !symtab_node::get (decl)->can_increase_alignment_p ()) return false; because symtab_node::get (decl) returns a null node. The phenomenon occurs for a pair of twin symbols listed like so in .cgraph: Opt7_Pkg.T12b/17 (Opt7_Pkg.T12b) Type: variable definition analyzed Visibility: semantic_interposition external public artificial Aux: @0x44d45e0 References: Referring: opt7_pkg__enum_name_table/13 (addr) opt7_pkg__enum_name_table/13 (addr) Availability: not-ready Varpool flags: initialized read-only const-value-known Opt7_Pkg.T8b/16 (Opt7_Pkg.T8b) Type: variable definition analyzed Visibility: semantic_interposition external public artificial Aux: @0x7f9fda3fff00 References: Referring: opt7_pkg__enum_name_table/13 (addr) opt7_pkg__enum_name_table/13 (addr) Availability: not-ready Varpool flags: initialized read-only const-value-known with: opt7_pkg__enum_name_table/13 (Opt7_Pkg.Enum_Name_Table) Type: variable definition analyzed Visibility: semantic_interposition external public Aux: @0x44d45e0 References: Opt7_Pkg.T8b/16 (addr) Opt7_Pkg.T8b/16 (addr) Opt7_Pkg.T12b/17 (addr) Opt7_Pkg.T12b/17 (addr) Referring: opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) Availability: not-ready Varpool flags: initialized read-only const-value-known being the crux of the matter. What happens is that symtab_remove_unreachable_nodes leaves the last symbol in kind of a limbo state: in .remove_symbols, we have: opt7_pkg__enum_name_table/13 (Opt7_Pkg.Enum_Name_Table) Type: variable Body removed by symtab_remove_unreachable_nodes Visibility: externally_visible semantic_interposition external public References: Referring: opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) Availability: not_available Varpool flags: initialized read-only const-value-known This means that the "body" (DECL_INITIAL) of the symbol has been disregarded during reachability analysis, causing the first two symbols to be discarded: Reclaiming variables: Opt7_Pkg.T12b/17 Opt7_Pkg.T8b/16 but the DECL_INITIAL is explicitly preserved for later constant folding, which makes it possible to retrofit the DECLs corresponding to the first two symbols in the GIMPLE IR and ultimately leads to the crash. gcc/ * tree-vect-data-refs.cc (vect_can_force_dr_alignment_p): Return false if the variable has no symtab node. gcc/testsuite/ * gnat.dg/specs/opt7.ads: New test. * gnat.dg/specs/opt7_pkg.ads: New helper. * gnat.dg/specs/opt7_pkg.adb: Likewise.
2025-06-05Daily bump.GCC Administrator3-1/+18
2025-06-04ChangeLog.omp bumpThomas Schwinge2-1/+9
2025-06-04Avoid SIGSEGV in nvptx 'mkoffload' for voluminous PTX codeThomas Schwinge1-3/+9
In commit 50be486dff4ea2676ed022e9524ef190b92ae2b1 "nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup", some additional tracking of the PTX code was added, and this assumes that potentially every single character of PTX code needs to be tracked as a new chunk of PTX code. That's problematic if we're dealing with voluminous PTX code (for example, non-trivial C++ code), and the 'file_idx' 'alloca'tion then causes stack overflow. For example: FAIL: libgomp.c++/target-std__valarray-1.C (test for excess errors) UNRESOLVED: libgomp.c++/target-std__valarray-1.C compilation failed to produce executable lto-wrapper: fatal error: [...]/build-gcc/gcc//accel/nvptx-none/mkoffload terminated with signal 11 [Segmentation fault], core dumped gcc/ * config/nvptx/mkoffload.cc (process): Use an 'auto_vec' for 'file_idx'. (cherry picked from commit 01044e0ee27093a3990996578b15f6ab69ed3395)