aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2023-12-19ada: Optimize performance and remove dynamic frame requirement.Vasiliy Fofanov1-7/+10
gcc/ada/ * libgnat/i-cstrin.adb (Value): Optimize.
2023-12-19ada: Ignore unconstrained components as inputs for DependsPiotr Trojanek1-36/+2
The current wording of SPARK RM 6.1.5(5) about the inputs for the Depends contract doesn't mention "a record with at least one unconstrained component". gcc/ada/ * sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Update comment and body.
2023-12-19ada: Rename Is_Constr_Subt_For_UN_Aliased flagEric Botcazou9-57/+55
The flag is set on the constructed subtype of an object with unconstrained nominal subtype that is aliased and is used by the code generator to adjust the layout of the object. But it is actually only used for array subtypes, where it determines whether the object is allocated with its bounds, and this usage could be extended to other cases than the original case. gcc/ada/ * einfo.ads (Is_Constr_Subt_For_UN_Aliased): Rename into... (Is_Constr_Array_Subt_With_Bounds): ...this. * exp_ch3.adb (Expand_N_Object_Declaration): Adjust to above renaming and remove now redundant test. * sem_ch3.adb (Analyze_Object_Declaration): Likewise, but set Is_Constr_Array_Subt_With_Bounds only on arrays. * gen_il-fields.ads (Opt_Field_Enum): Apply same renaming. * gen_il-gen-gen_entities.adb (Entity_Kind): Likewise. * gen_il-internals.adb (Image): Remove specific processing for Is_Constr_Subt_For_UN_Aliased. * treepr.adb (Image): Likewise. * gcc-interface/decl.cc (gnat_to_gnu_entity): Adjust to renaming and remove now redundant tests. * gcc-interface/trans.cc (Identifier_to_gnu): Likewise. (Call_to_gnu): Likewise.
2023-12-19ada: Remove No_Dynamic_Priorities from Restricted_TaskingJohannes Kliemann1-1/+0
Some of our restricted runtimes support dynamic priorities. The binder needs to generate code for a restricted runtime even if the restriction No_Dynamic_Priorities is not in place. gcc/ada/ * libgnat/s-rident.ads: Remove No_Dynamic_Priorities from Restricted_Tasking.
2023-12-19ada: Adapt Ada.Command_Line to work on configurable runtimesPatrick Bernardi3-54/+28
The behaviour of the binder when handling command line arguments and exit codes is simplified so that references to the corresponding runtime symbols are always generated when the runtime is configured with command line argument and exit code support. This allows Ada.Command_Line to work with all runtimes, which was not the case previously. As a result of this change, configurable runtimes that do not include Ada.Command_Line and it support files, but are configured with Command_Line_Args and/or Exit_Status_Supported set to True will need to provide the symbols required by the binder, as these symbols will no longer be defined in the binder generated file. argv.c includes a small change to exclude adaint.h when compiling for a light runtime, since this header is not required. gcc/ada/ * argv.c: Do not include adaint.h if LIGHT_RUNTIME is defined. * bindgen.adb (Gen_Main): Simplify command line argument and exit handling by requiring the runtime to always provide the required symbols if command line argument and exit code is enabled. * targparm.ads: Update comments to reflect changes to gnatbind.
2023-12-19ada: Fix crash on concurrent type aggregateRonan Desplanques2-5/+18
Before this patch, the compiler would fail to examine the corresponding record types of concurrent types when building aggregate components. This patch fixes this, and adds a precondition and additional documentation on the subprogram that triggered the crash, as it never makes sense to call it with a concurrent type. gcc/ada/ * exp_aggr.adb (Initialize_Component): Use corresponding record types of concurrent types. * exp_util.ads (Make_Tag_Assignment_From_Type): Add precondition and extend documentation. Co-authored-by: Javier Miranda <miranda@adacore.com>
2023-12-19ada: Further cleanup in finalization machineryEric Botcazou8-211/+158
This removes the setting of the Is_Ignored_Transient flag on the temporaries needing finalization created by Expand_Ctrl_Function_Call when invoked from within the dependent expressions of conditional expressions. This flag tells the general finalization machinery to disregard the object. But temporaries needing finalization present in action lists of dependent expressions are picked up by Process_Transients_In_Expression, which deals with their finalization and sets the Is_Finalized_Transient flag on them. Now this latter flag has exactly the same effect as Is_Ignored_Transient as far as the general finalization machinery is concerned, so setting the flag is unnecessary. In the end, the flag can be decoupled entirely from transient objects and renamed into Is_Ignored_For_Finalization. This also moves around the declaration of a local variable and turns a library-level procedure into a nested procedure. gcc/ada/ * einfo.ads (Is_Ignored_Transient): Rename into... (Is_Ignored_For_Finalization): ...this. * gen_il-fields.ads (Opt_Field_Enum): Adjust to above renaming. * gen_il-gen-gen_entities.adb (Object_Kind): Likewise. * exp_aggr.adb (Expand_Array_Aggregate): Likewise. * exp_ch7.adb (Build_Finalizer.Process_Declarations): Likewise. * exp_util.adb (Requires_Cleanup_Actions): Likewise. * exp_ch4.adb (Expand_N_If_Expression): Move down declaration of variable Optimize_Return_Stmt. (Process_Transient_In_Expression): Turn procedure into a child of... (Process_Transients_In_Expression): ...this procedure. * exp_ch6.adb (Expand_Ctrl_Function_Call): Remove obsolete setting of Is_Ignored_Transient flag on the temporary if within a dependent expression of a conditional expression.
2023-12-19ada: Fix SPARK expansion of container aggregatesYannick Moy2-8/+155
GNATprove supports container aggregates, except for indexed aggregates. It needs all expressions to have suitable target types and Do_Range_Check flags, which are added by the special expansion for GNATprove. There is no impact on code generation. gcc/ada/ * exp_spark.adb (Expand_SPARK_N_Aggregate): New procedure for the special expansion. (Expand_SPARK): Call the new expansion procedure. * sem_util.adb (Is_Container_Aggregate): Implement missing test.
2023-12-19ada: Add missing guard to previous changeEric Botcazou1-1/+3
Ancestor_Type is overloaded with Aggregate_Bounds on N_Aggregate nodes so its access needs to be guarded in Copy_Generic_Node. gcc/ada/ * sem_ch12.adb (Copy_Generic_Node): Add guard for Ancestor_Type.
2023-12-19ada: Fix spurious visibility error on parent's component in instanceEric Botcazou6-35/+107
This occurs for an aggregate of a derived tagged type in the body of the instance, because the full view of the parent type, which was visible in the generic construct (otherwise the aggregate would have been illegal), is not restored in the body of the instance. Copy_Generic_Node already contains code to restore the full view in this case, but it works only if the derived tagged type is itself global to the generic construct, and not if the derived tagged type is local but the parent type global, as is the case here. gcc/ada/ * gen_il-fields.ads (Aggregate_Bounds): Rename to Aggregate_Bounds_Or_Ancestor_Type. * gen_il-gen-gen_nodes.adb (Aggregate_Bounds): Likewise. * sem_aggr.adb (Resolve_Record_Aggregate): Remove obsolete bypass. * sem_ch12.adb (Check_Generic_Actuals): Add decoration. (Copy_Generic_Node): For an extension aggregate, restore only the full view, if any. For a full aggregate, restore the full view as well as that of its Ancestor_Type, if any, and up to the root type. (Save_References_In_Aggregate): For a full aggregate of a local derived tagged type with a global ancestor, set Ancestor_Type to this ancestor. For a full aggregate of a global derived tagged type, set Ancestor_Type to the parent type. * sinfo-utils.ads (Aggregate_Bounds): New function renaming. (Ancestor_Type): Likewise. (Set_Aggregate_Bounds): New procedure renaming. (Set_Ancestor_Type): Likewise. * sinfo.ads (Ancestor_Type): Document new field.
2023-12-19ada: Plug small loophole in finalization machineryEric Botcazou1-0/+8
The path in Expand_N_If_Expression implementing the special optimization for an unidimensional array type and dependent expressions with static bounds fails to call Process_Transients_In_Expression on their list of actions. gcc/ada/ * exp_ch4.adb (Expand_N_If_Expression): Also add missing calls to Process_Transients_In_Expression on the code path implementing the special optimization for an unidimensional array type and dependent expressions with static bounds.
2023-12-19ada: Cope with Sem_Util.Enclosing_Declaration oddness.Steve Baird1-1/+11
Sem_Util.Enclosing_Declaration can return a non-empty result which is not a declaration; clients may need to compensate for the case where an N_Subprogram_Specification node is returned. One such client is the function Is_Actual_Subp_Of_Inst. gcc/ada/ * sem_ch8.adb (Is_Actual_Subp_Of_Inst): After calling Enclosing_Declaration, add a check for the case where one more Parent call is needed to get the enclosing declaration.
2023-12-19ada: Restore object constraint optimizationRonan Desplanques2-63/+5
This patch relaxes the requirement that discriminants values should be known at compile time for a particular optimization to be applied. That optimization is the one that treats an unconstrained object as constrained when the object is of a limited type, in order to reduce the size of the object. What makes it possible to relax this requirement is that the set of cases where the optimization is applied was narrowed in a previous patch. gcc/ada/ * sem_util.adb (Build_Default_Subtype_OK): Relax known-at-compile-time requirement. * sem_util.ads (Build_Default_Subtype_OK): Bring documentation comment up-to-date.
2023-12-19ada: Do not issue SPARK legality error if SPARK_Mode ignoredYannick Moy5-1275/+1308
When pragma Ignore_Pragma(SPARK_Mode) is used, do not issue error messages related to SPARK legality checking. This facilitates the instrumentation of code by GNATcoverage. gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Fix doc for pragma Ignore_Pragma, in the case where it follows another configuration pragma that it names, which causes the preceding pragma to be ignored after parsing. * errout.adb (Should_Ignore_Pragma_SPARK_Mode): New query. (SPARK_Msg_N): Do nothing if SPARK_Mode is ignored. (SPARK_Msg_NE): Same. * gnat-style.texi: Regenerate. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2023-12-19ada: Cleanup SPARK legality checkingYannick Moy3-112/+10
Move one SPARK legality check from GNAT to GNATprove, and cleanup other uses of SPARK_Mode for legality checking. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Check correct mode variable for GNATprove. * sem_prag.adb (Refined_State): Call SPARK_Msg_NE which checks value of SPARK_Mode before issuing a message. * sem_res.adb (Resolve_Entity_Name): Remove legality check for SPARK RM 6.1.9(1), moved to GNATprove.
2023-12-19ada: Illegal instance of Generic_1.Generic_2 incorrectly acceptedSteve Baird1-11/+85
If G1 is a generic package and G1.G2 is a child unit (also a generic package) then it would be illegal if some third generic unit (declared outside of G1) takes a formal instance of G1.G2, as in "with package I2 is new G1.G2;". This construct was incorrectly accepted in some cases. gcc/ada/ * sem_ch12.adb (Check_Generic_Child_Unit): Introduce a new nested function Adjusted_Inst_Par_Ekind to cope with cases where either a- the visibility of a compiler-generated renaming is incorrect; or b- we are inside of a generic parent unit G1 that has a child unit G1.G2, so instantiation of G1.G2 is permitted.
2023-12-19ada: Further cleanup in finalization machineryEric Botcazou1-88/+66
This streamlines the submachinery that makes it so that the finalization of temporaries created for EWAs and conditional expressions is deferred to the enclosing context. The original implementation was using a deep tree traversal for EWAs, which was later restricted to immediate subexpressions; this further flattens it to the traversal of the immediate list of actions of the EWA in keeping with the implementation for conditional expressions. This should not change anything because the enclosing context found by the machinery is the same, whatever the starting position in a nest of EWAs or conditional expressions. gcc/ada/ * exp_ch4.adb (Process_If_Case_Statements): Rename into... (Process_Transients_In_Expression): ...this and beef up comment. (Expand_N_Case_Expression): Call Process_Transients_In_Expression unconditionally on the list of actions of each alternative. (Expand_N_Expression_With_Actions): Do not deal with actions in nested subexpressions, but call Process_Transients_In_Expression on the list of actions only. (Expand_N_If_Expression): Adjust to above renaming. Add missing calls to Process_Transients_In_Expression in the case when an EWA is not used because of Minimize_Expression_With_Actions.
2023-12-17Daily bump.GCC Administrator1-0/+17
2023-12-16Add support for target_version attributeAndrew Carlotti1-2/+4
This patch adds support for the "target_version" attribute to the middle end and the C++ frontend, which will be used to implement function multiversioning in the aarch64 backend. On targets that don't use the "target" attribute for multiversioning, there is no conflict between the "target" and "target_clones" attributes. This patch therefore makes the mutual exclusion in C-family, D and Ada conditonal upon the value of the expanded_clones_attribute target hook. The "target_version" attribute is only added to C++ in this patch, because this is currently the only frontend which supports multiversioning using the "target" attribute. Support for the "target_version" attribute will be extended to C at a later date. Targets that currently use the "target" attribute for function multiversioning (i.e. i386 and rs6000) are not affected by this patch. gcc/ChangeLog: * attribs.cc (decl_attributes): Pass attribute name to target. (is_function_default_version): Update comment to specify incompatibility with target_version attributes. * cgraphclones.cc (cgraph_node::create_version_clone_with_body): Call valid_version_attribute_p for target_version attributes. * defaults.h (TARGET_HAS_FMV_TARGET_ATTRIBUTE): New macro. * target.def (valid_version_attribute_p): New hook. * doc/tm.texi.in: Add new hook. * doc/tm.texi: Regenerate. * multiple_target.cc (create_dispatcher_calls): Remove redundant is_function_default_version check. (expand_target_clones): Use target macro to pick attribute name. * targhooks.cc (default_target_option_valid_version_attribute_p): New. * targhooks.h (default_target_option_valid_version_attribute_p): New. * tree.h (DECL_FUNCTION_VERSIONED): Update comment to include target_version attributes. gcc/c-family/ChangeLog: * c-attribs.cc (attr_target_exclusions): Make target/target_clones exclusion target-dependent. (attr_target_clones_exclusions): Ditto, and add target_version. (attr_target_version_exclusions): New. (c_common_attribute_table): Add target_version. (handle_target_version_attribute): New. (handle_target_attribute): Amend comment. (handle_target_clones_attribute): Ditto. gcc/ada/ChangeLog: * gcc-interface/utils.cc (attr_target_exclusions): Make target/target_clones exclusion target-dependent. (attr_target_clones_exclusions): Ditto. gcc/d/ChangeLog: * d-attribs.cc (attr_target_exclusions): Make target/target_clones exclusion target-dependent. (attr_target_clones_exclusions): Ditto. gcc/cp/ChangeLog: * decl2.cc (check_classfn): Update comment to include target_version attributes.
2023-12-16ada: Improve attribute exclusion handlingAndrew Carlotti1-37/+33
Change the handling of some attribute mutual exclusions to use the generic attribute exclusion lists, and fix some asymmetric exclusions by adding the exclusions for always_inline after noinline or target_clones. Aside from the new always_inline exclusions, the only change is functionality is the choice of warning message displayed. All warnings about attribute mutual exclusions now use the same message. gcc/ada/ChangeLog: * gcc-interface/utils.cc (attr_noinline_exclusions): New. (attr_always_inline_exclusions): Ditto. (attr_target_exclusions): Ditto. (attr_target_clones_exclusions): Ditto. (gnat_internal_attribute_table): Add new exclusion lists. (handle_noinline_attribute): Remove custom exclusion handling. (handle_target_attribute): Ditto. (handle_target_clones_attribute): Ditto.
2023-12-12Daily bump.GCC Administrator1-0/+5
2023-12-11ada: Fix Ada bootstrap on FreeBSDRainer Orth1-1/+6
Ada bootstrap on FreeBSD/amd64 was also broken by the recent warning changes: terminals.c: In function 'allocate_pty_desc': terminals.c:1200:12: error: implicit declaration of function 'openpty'; did you mean 'openat'? [-Wimplicit-function-declaration] 1200 | status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); | ^~~~~~~ | openat terminals.c: At top level: terminals.c:1268:9: warning: "TABDLY" redefined 1268 | #define TABDLY 0 | ^~~~~~ In file included from /usr/include/termios.h:38, from terminals.c:1109: /usr/include/sys/_termios.h:111:9: note: this is the location of the previous definition 111 | #define TABDLY 0x00000004 /* tab delay mask */ | ^~~~~~ make[7]: *** [../gcc-interface/Makefile:302: terminals.o] Error 1 Fixed by including the necessary header and guarding the fallback definition of TABDLY. This allowed a 64-bit-only bootstrap on x86_64-unknown-freebsd14.0 to complete successfully. 2023-12-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc/ada: * terminals.c [__FreeBSD__]: Include <libutil.h>. (TABDLY): Only define if missing.
2023-12-06Daily bump.GCC Administrator1-0/+20
2023-12-05Introduce strub: machine-independent stack scrubbingAlexandre Oliva2-2/+89
This patch adds the strub attribute for function and variable types, command-line options, passes and adjustments to implement it, documentation, and tests. Stack scrubbing is implemented in a machine-independent way: functions with strub enabled are modified so that they take an extra stack watermark argument, that they update with their stack use, and the caller can then zero it out once it regains control, whether by return or exception. There are two ways to go about it: at-calls, that modifies the visible interface (signature) of the function, and internal, in which the body is moved to a clone, the clone undergoes the interface change, and the function becomes a wrapper, preserving its original interface, that calls the clone and then clears the stack used by it. Variables can also be annotated with the strub attribute, so that functions that read from them get stack scrubbing enabled implicitly, whether at-calls, for functions only usable within a translation unit, or internal, for functions whose interfaces must not be modified. There is a strict mode, in which functions that have their stack scrubbed can only call other functions with stack-scrubbing interfaces, or those explicitly marked as callable from strub contexts, so that an entire call chain gets scrubbing, at once or piecemeal depending on optimization levels. In the default mode, relaxed, this requirement is not enforced by the compiler. The implementation adds two IPA passes, one that assigns strub modes early on, another that modifies interfaces and adds calls to the builtins that jointly implement stack scrubbing. Another builtin, that obtains the stack pointer, is added for use in the implementation of the builtins, whether expanded inline or called in libgcc. There are new command-line options to change operation modes and to force the feature disabled; it is enabled by default, but it has no effect and is implicitly disabled if the strub attribute is never used. There are also options meant to use for testing the feature, enabling different strubbing modes for all (viable) functions. for gcc/ChangeLog * Makefile.in (OBJS): Add ipa-strub.o. (GTFILES): Add ipa-strub.cc. * builtins.def (BUILT_IN_STACK_ADDRESS): New. (BUILT_IN___STRUB_ENTER): New. (BUILT_IN___STRUB_UPDATE): New. (BUILT_IN___STRUB_LEAVE): New. * builtins.cc: Include ipa-strub.h. (STACK_STOPS, STACK_UNSIGNED): Define. (expand_builtin_stack_address): New. (expand_builtin_strub_enter): New. (expand_builtin_strub_update): New. (expand_builtin_strub_leave): New. (expand_builtin): Call them. * common.opt (fstrub=*): New options. * doc/extend.texi (strub): New type attribute. (__builtin_stack_address): New function. (Stack Scrubbing): New section. * doc/invoke.texi (-fstrub=*): New options. (-fdump-ipa-*): New passes. * gengtype-lex.l: Ignore multi-line pp-directives. * ipa-inline.cc: Include ipa-strub.h. (can_inline_edge_p): Test strub_inlinable_to_p. * ipa-split.cc: Include ipa-strub.h. (execute_split_functions): Test strub_splittable_p. * ipa-strub.cc, ipa-strub.h: New. * passes.def: Add strub_mode and strub passes. * tree-cfg.cc (gimple_verify_flow_info): Note on debug stmts. * tree-pass.h (make_pass_ipa_strub_mode): Declare. (make_pass_ipa_strub): Declare. (make_pass_ipa_function_and_variable_visibility): Fix formatting. * tree-ssa-ccp.cc (optimize_stack_restore): Keep restores before strub leave. * attribs.cc: Include ipa-strub.h. (decl_attributes): Support applying attributes to function type, rather than pointer type, at handler's request. (comp_type_attributes): Combine strub_comptypes and target comp_type results. * doc/tm.texi.in (TARGET_STRUB_USE_DYNAMIC_ARRAY): New. (TARGET_STRUB_MAY_USE_MEMSET): New. * doc/tm.texi: Rebuilt. * cgraph.h (symtab_node::reset): Add preserve_comdat_group param, with a default. * cgraphunit.cc (symtab_node::reset): Use it. for gcc/c-family/ChangeLog * c-attribs.cc: Include ipa-strub.h. (handle_strub_attribute): New. (c_common_attribute_table): Add strub. for gcc/ada/ChangeLog * gcc-interface/trans.cc: Include ipa-strub.h. (gigi): Make internal decls for targets of compiler-generated calls strub-callable too. (build_raise_check): Likewise. * gcc-interface/utils.cc: Include ipa-strub.h. (handle_strub_attribute): New. (gnat_internal_attribute_table): Add strub. for gcc/testsuite/ChangeLog * c-c++-common/strub-O0.c: New. * c-c++-common/strub-O1.c: New. * c-c++-common/strub-O2.c: New. * c-c++-common/strub-O2fni.c: New. * c-c++-common/strub-O3.c: New. * c-c++-common/strub-O3fni.c: New. * c-c++-common/strub-Og.c: New. * c-c++-common/strub-Os.c: New. * c-c++-common/strub-all1.c: New. * c-c++-common/strub-all2.c: New. * c-c++-common/strub-apply1.c: New. * c-c++-common/strub-apply2.c: New. * c-c++-common/strub-apply3.c: New. * c-c++-common/strub-apply4.c: New. * c-c++-common/strub-at-calls1.c: New. * c-c++-common/strub-at-calls2.c: New. * c-c++-common/strub-defer-O1.c: New. * c-c++-common/strub-defer-O2.c: New. * c-c++-common/strub-defer-O3.c: New. * c-c++-common/strub-defer-Os.c: New. * c-c++-common/strub-internal1.c: New. * c-c++-common/strub-internal2.c: New. * c-c++-common/strub-parms1.c: New. * c-c++-common/strub-parms2.c: New. * c-c++-common/strub-parms3.c: New. * c-c++-common/strub-relaxed1.c: New. * c-c++-common/strub-relaxed2.c: New. * c-c++-common/strub-short-O0-exc.c: New. * c-c++-common/strub-short-O0.c: New. * c-c++-common/strub-short-O1.c: New. * c-c++-common/strub-short-O2.c: New. * c-c++-common/strub-short-O3.c: New. * c-c++-common/strub-short-Os.c: New. * c-c++-common/strub-strict1.c: New. * c-c++-common/strub-strict2.c: New. * c-c++-common/strub-tail-O1.c: New. * c-c++-common/strub-tail-O2.c: New. * c-c++-common/torture/strub-callable1.c: New. * c-c++-common/torture/strub-callable2.c: New. * c-c++-common/torture/strub-const1.c: New. * c-c++-common/torture/strub-const2.c: New. * c-c++-common/torture/strub-const3.c: New. * c-c++-common/torture/strub-const4.c: New. * c-c++-common/torture/strub-data1.c: New. * c-c++-common/torture/strub-data2.c: New. * c-c++-common/torture/strub-data3.c: New. * c-c++-common/torture/strub-data4.c: New. * c-c++-common/torture/strub-data5.c: New. * c-c++-common/torture/strub-indcall1.c: New. * c-c++-common/torture/strub-indcall2.c: New. * c-c++-common/torture/strub-indcall3.c: New. * c-c++-common/torture/strub-inlinable1.c: New. * c-c++-common/torture/strub-inlinable2.c: New. * c-c++-common/torture/strub-ptrfn1.c: New. * c-c++-common/torture/strub-ptrfn2.c: New. * c-c++-common/torture/strub-ptrfn3.c: New. * c-c++-common/torture/strub-ptrfn4.c: New. * c-c++-common/torture/strub-pure1.c: New. * c-c++-common/torture/strub-pure2.c: New. * c-c++-common/torture/strub-pure3.c: New. * c-c++-common/torture/strub-pure4.c: New. * c-c++-common/torture/strub-run1.c: New. * c-c++-common/torture/strub-run2.c: New. * c-c++-common/torture/strub-run3.c: New. * c-c++-common/torture/strub-run4.c: New. * c-c++-common/torture/strub-run4c.c: New. * c-c++-common/torture/strub-run4d.c: New. * c-c++-common/torture/strub-run4i.c: New. * g++.dg/strub-run1.C: New. * g++.dg/torture/strub-init1.C: New. * g++.dg/torture/strub-init2.C: New. * g++.dg/torture/strub-init3.C: New. * gnat.dg/strub_attr.adb, gnat.dg/strub_attr.ads: New. * gnat.dg/strub_ind.adb, gnat.dg/strub_ind.ads: New. for libgcc/ChangeLog * Makefile.in (LIB2ADD): Add strub.c. * libgcc2.h (__strub_enter, __strub_update, __strub_leave): Declare. * strub.c: New. * libgcc-std.ver.in (__strub_enter): Add to GCC_14.0.0. (__strub_update, __strub_leave): Likewise.
2023-12-05Restore build with GCC 4.8 to GCC 5Richard Sandiford1-1/+1
GCC 5 and earlier applied array-to-pointer decay too early, which affected the new attribute namespace code. A reduced example of the construct that the attribute code uses is: struct S { template<__SIZE_TYPE__ N> S(int (&)[N]); }; struct T { int a; S b; }; int a[] = { 1 }; T t = { 1, a }; This was fixed by f85e1317f8ea933f5c615680353bd646f480f7d3 (PR 16333 et al). This patch tries to add a minimally-invasive workaround. gcc/ada/ * gcc-interface/utils.cc (gnat_internal_attribute_table): Add extra braces to work around PR 16333 in older compilers. gcc/ * attribs.cc (handle_ignored_attributes_option): Add extra braces to work around PR 16333 in older compilers. * config/aarch64/aarch64.cc (aarch64_gnu_attribute_table): Likewise. (aarch64_arm_attribute_table): Likewise. * config/arm/arm.cc (arm_gnu_attribute_table): Likewise. * config/i386/i386-options.cc (ix86_gnu_attribute_table): Likewise. * config/ia64/ia64.cc (ia64_gnu_attribute_table): Likewise. * config/rs6000/rs6000.cc (rs6000_gnu_attribute_table): Likewise. * target-def.h (TARGET_GNU_ATTRIBUTES): Likewise. * genhooks.cc (emit_init_macros): Likewise, when emitting the instantiation of TARGET_ATTRIBUTE_TABLE. * langhooks-def.h (LANG_HOOKS_INITIALIZER): Likewise, when instantiating LANG_HOOKS_ATTRIBUTE_TABLE. (LANG_HOOKS_ATTRIBUTE_TABLE): Define to be empty by default. * target.def (attribute_table): Likewise. gcc/c-family/ * c-attribs.cc (c_common_gnu_attribute_table): Add extra braces to work around PR 16333 in older compilers. gcc/c/ * c-decl.cc (std_attribute_table): Add extra braces to work around PR 16333 in older compilers. gcc/cp/ * tree.cc (cxx_gnu_attribute_table): Add extra braces to work around PR 16333 in older compilers. gcc/d/ * d-attribs.cc (d_langhook_common_attribute_table): Add extra braces to work around PR 16333 in older compilers. (d_langhook_gnu_attribute_table): Likewise. gcc/fortran/ * f95-lang.cc (gfc_gnu_attribute_table): Add extra braces to work around PR 16333 in older compilers. gcc/jit/ * dummy-frontend.cc (jit_gnu_attribute_table): Add extra braces to work around PR 16333 in older compilers. (jit_format_attribute_table): Likewise. gcc/lto/ * lto-lang.cc (lto_gnu_attribute_table): Add extra braces to work around PR 16333 in older compilers. (lto_format_attribute_table): Likewise.
2023-12-05ada: Fix Ada bootstrap on SolarisRainer Orth2-0/+2
The recent warning patches broke Ada bootstrap on Solaris: adaint.c: In function '__gnat_kill': adaint.c:3597:3: error: implicit declaration of function 'kill' [-Wimplicit-function-declaration] 3597 | kill (pid, sig); | ^~~~ expect.c: In function '__gnat_expect_poll': expect.c:409:5: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 409 | FD_ZERO (&rset); | ^~~~~~~ expect.c:55:1: note: include '<string.h>' or provide a declaration of 'memset' 54 | #include <sys/wait.h> +++ |+#include <string.h> 55 | #endif I'm now including the necessary headers: <signal.h> for kill and <string.h> for memset. Bootstrapped without regressions on i386-pc-solaris2.11, sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and x86_64-apple-darwin23.1.0. 2023-12-03 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc/ada: * adaint.c: Include <signal.h>. * expect.c: Include <string.h>.
2023-12-03Daily bump.GCC Administrator1-0/+10
2023-12-02Allow target attributes in non-gnu namespacesRichard Sandiford3-5/+12
Currently there are four static sources of attributes: - LANG_HOOKS_ATTRIBUTE_TABLE - LANG_HOOKS_COMMON_ATTRIBUTE_TABLE - LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE - TARGET_ATTRIBUTE_TABLE All of the attributes in these tables go in the "gnu" namespace. This means that they can use the traditional GNU __attribute__((...)) syntax and the standard [[gnu::...]] syntax. Standard attributes are registered dynamically with a null namespace. There are no supported attributes in other namespaces (clang, vendor namespaces, etc.). This patch tries to generalise things by making the namespace part of the attribute specification. It's usual for multiple attributes to be defined in the same namespace, so rather than adding the namespace to each individual definition, it seemed better to group attributes in the same namespace together. This would also allow us to reuse the same table for clang attributes that are written with the GNU syntax, or other similar situations where the attribute can be accessed via multiple "spellings". The patch therefore adds a scoped_attribute_specs that contains a namespace and a list of attributes in that namespace. It's still possible to have multiple scoped_attribute_specs for the same namespace. E.g. it makes sense to keep the C++-specific, C/C++-common, and format-related attributes in separate tables, even though they're all GNU attributes. Current lists of attributes are terminated by a null name. Rather than keep that for the new structure, it seemed neater to use an array_slice. This also makes the tables slighly more compact. In general, a target might want to support attributes in multiple namespaces. Rather than have a separate hook for each possibility (like the three langhooks above), it seemed better to make TARGET_ATTRIBUTE_TABLE a table of tables. Specifically, it's an array_slice of scoped_attribute_specs. We can do the same thing for langhooks, which allows the three hooks above to be merged into a single LANG_HOOKS_ATTRIBUTE_TABLE. It also allows the standard attributes to be registered statically and checked by the usual attribs.cc checks. The patch adds a TARGET_GNU_ATTRIBUTES helper for the common case in which a target wants a single table of gnu attributes. It can only be used if the table is free of preprocessor directives. There are probably other things we need to do to make vendor namespaces work smoothly. E.g. in principle it would be good to make exclusion sets namespace-aware. But to some extent we have that with standard vs. gnu attributes too. This patch is just supposed to be a first step. gcc/ * attribs.h (scoped_attribute_specs): New structure. (register_scoped_attributes): Take a reference to a scoped_attribute_specs instead of separate namespace and array parameters. * plugin.h (register_scoped_attributes): Likewise. * attribs.cc (register_scoped_attributes): Likewise. (attribute_tables): Change into an array of scoped_attribute_specs pointers. Reduce to 1 element for frontends and 1 element for targets. (empty_attribute_table): Delete. (check_attribute_tables): Update for changes to attribute_tables. Use a hash_set to identify duplicates. (handle_ignored_attributes_option): Update for above changes. (init_attributes): Likewise. (excl_pair): Delete. (test_attribute_exclusions): Update for above changes. Don't enforce symmetry for standard attributes in the top-level namespace. * langhooks-def.h (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Likewise. (LANG_HOOKS_INITIALIZER): Update accordingly. (LANG_HOOKS_ATTRIBUTE_TABLE): Define to an empty constructor. * langhooks.h (lang_hooks::common_attribute_table): Delete. (lang_hooks::format_attribute_table): Likewise. (lang_hooks::attribute_table): Redefine to an array of scoped_attribute_specs pointers. * target-def.h (TARGET_GNU_ATTRIBUTES): New macro. * target.def (attribute_spec): Redefine to return an array of scoped_attribute_specs pointers. * tree-inline.cc (function_attribute_inlinable_p): Update accordingly. * doc/tm.texi: Regenerate. * config/aarch64/aarch64.cc (aarch64_attribute_table): Define using TARGET_GNU_ATTRIBUTES. * config/alpha/alpha.cc (vms_attribute_table): Likewise. * config/avr/avr.cc (avr_attribute_table): Likewise. * config/bfin/bfin.cc (bfin_attribute_table): Likewise. * config/bpf/bpf.cc (bpf_attribute_table): Likewise. * config/csky/csky.cc (csky_attribute_table): Likewise. * config/epiphany/epiphany.cc (epiphany_attribute_table): Likewise. * config/gcn/gcn.cc (gcn_attribute_table): Likewise. * config/h8300/h8300.cc (h8300_attribute_table): Likewise. * config/loongarch/loongarch.cc (loongarch_attribute_table): Likewise. * config/m32c/m32c.cc (m32c_attribute_table): Likewise. * config/m32r/m32r.cc (m32r_attribute_table): Likewise. * config/m68k/m68k.cc (m68k_attribute_table): Likewise. * config/mcore/mcore.cc (mcore_attribute_table): Likewise. * config/microblaze/microblaze.cc (microblaze_attribute_table): Likewise. * config/mips/mips.cc (mips_attribute_table): Likewise. * config/msp430/msp430.cc (msp430_attribute_table): Likewise. * config/nds32/nds32.cc (nds32_attribute_table): Likewise. * config/nvptx/nvptx.cc (nvptx_attribute_table): Likewise. * config/riscv/riscv.cc (riscv_attribute_table): Likewise. * config/rl78/rl78.cc (rl78_attribute_table): Likewise. * config/rx/rx.cc (rx_attribute_table): Likewise. * config/s390/s390.cc (s390_attribute_table): Likewise. * config/sh/sh.cc (sh_attribute_table): Likewise. * config/sparc/sparc.cc (sparc_attribute_table): Likewise. * config/stormy16/stormy16.cc (xstormy16_attribute_table): Likewise. * config/v850/v850.cc (v850_attribute_table): Likewise. * config/visium/visium.cc (visium_attribute_table): Likewise. * config/arc/arc.cc (arc_attribute_table): Likewise. Move further down file. * config/arm/arm.cc (arm_attribute_table): Update for above changes, using... (arm_gnu_attributes, arm_gnu_attribute_table): ...these new globals. * config/i386/i386-options.h (ix86_attribute_table): Delete. (ix86_gnu_attribute_table): Declare. * config/i386/i386-options.cc (ix86_attribute_table): Replace with... (ix86_gnu_attributes, ix86_gnu_attribute_table): ...these two globals. * config/i386/i386.cc (ix86_attribute_table): Define as an array of scoped_attribute_specs pointers. * config/ia64/ia64.cc (ia64_attribute_table): Update for above changes, using... (ia64_gnu_attributes, ia64_gnu_attribute_table): ...these new globals. * config/rs6000/rs6000.cc (rs6000_attribute_table): Update for above changes, using... (rs6000_gnu_attributes, rs6000_gnu_attribute_table): ...these new globals. gcc/ada/ * gcc-interface/gigi.h (gnat_internal_attribute_table): Change type to scoped_attribute_specs. * gcc-interface/utils.cc (gnat_internal_attribute_table): Likewise, using... (gnat_internal_attributes): ...this as the underlying array. * gcc-interface/misc.cc (gnat_attribute_table): New global. (LANG_HOOKS_ATTRIBUTE_TABLE): Use it. gcc/c-family/ * c-common.h (c_common_attribute_table): Replace with... (c_common_gnu_attribute_table): ...this. (c_common_format_attribute_table): Change type to scoped_attribute_specs. * c-attribs.cc (c_common_attribute_table): Replace with... (c_common_gnu_attributes, c_common_gnu_attribute_table): ...these new globals. (c_common_format_attribute_table): Change type to scoped_attribute_specs, using... (c_common_format_attributes): ...this as the underlying array. gcc/c/ * c-tree.h (std_attribute_table): Declare. * c-decl.cc (std_attribute_table): Change type to scoped_attribute_specs, using... (std_attributes): ...this as the underlying array. (c_init_decl_processing): Remove call to register_scoped_attributes. * c-objc-common.h (c_objc_attribute_table): New global. (LANG_HOOKS_ATTRIBUTE_TABLE): Use it. (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Delete. gcc/cp/ * cp-tree.h (cxx_attribute_table): Delete. (cxx_gnu_attribute_table, std_attribute_table): Declare. * cp-objcp-common.h (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Delete. (cp_objcp_attribute_table): New table. (LANG_HOOKS_ATTRIBUTE_TABLE): Redefine. * tree.cc (cxx_attribute_table): Replace with... (cxx_gnu_attributes, cxx_gnu_attribute_table): ...these globals. (std_attribute_table): Change type to scoped_attribute_specs, using... (std_attributes): ...this as the underlying array. (init_tree): Remove call to register_scoped_attributes. gcc/d/ * d-tree.h (d_langhook_attribute_table): Replace with... (d_langhook_gnu_attribute_table): ...this. (d_langhook_common_attribute_table): Change type to scoped_attribute_specs. * d-attribs.cc (d_langhook_common_attribute_table): Change type to scoped_attribute_specs, using... (d_langhook_common_attributes): ...this as the underlying array. (d_langhook_attribute_table): Replace with... (d_langhook_gnu_attributes, d_langhook_gnu_attribute_table): ...these new globals. (uda_attribute_p): Update accordingly, and update for new targetm.attribute_table type. * d-lang.cc (d_langhook_attribute_table): New global. (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. gcc/fortran/ * f95-lang.cc: Include attribs.h. (gfc_attribute_table): Change to an array of scoped_attribute_specs pointers, using... (gfc_gnu_attributes, gfc_gnu_attribute_table): ...these new globals. gcc/jit/ * dummy-frontend.cc (jit_format_attribute_table): Change type to scoped_attribute_specs, using... (jit_format_attributes): ...this as the underlying array. (jit_attribute_table): Change to an array of scoped_attribute_specs pointers, using... (jit_gnu_attributes, jit_gnu_attribute_table): ...these new globals for the original array. Include the format attributes. (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_ATTRIBUTE_TABLE): Define. gcc/lto/ * lto-lang.cc (lto_format_attribute_table): Change type to scoped_attribute_specs, using... (lto_format_attributes): ...this as the underlying array. (lto_attribute_table): Change to an array of scoped_attribute_specs pointers, using... (lto_gnu_attributes, lto_gnu_attribute_table): ...these new globals for the original array. Include the format attributes. (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Delete. (LANG_HOOKS_ATTRIBUTE_TABLE): Define.
2023-12-02Daily bump.GCC Administrator1-0/+7
2023-12-01ada: Fix Ada bootstrap on macOSRainer Orth2-2/+8
The recent warning changes broke Ada bootstrap on macOS: adaint.c: In function '__gnat_copy_attribs': adaint.c:3336:10: error: implicit declaration of function 'utimes'; did you mean 'utime'? [-Wimplicit-function-declaration] 3336 | if (utimes (to, tbuf) == -1) { | ^~~~~~ | utime adaint.c: In function '__gnat_kill': adaint.c:3597:3: error: implicit declaration of function 'kill' [-Wimplicit-function-declaration] 3597 | kill (pid, sig); | ^~~~ terminals.c: In function 'allocate_pty_desc': terminals.c:1196:12: error: implicit declaration of function 'openpty'; did you mean 'openat'? [-Wimplicit-function-declaration] 1196 | status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); | ^~~~~~~ | openat terminals.c: In function '__gnat_setup_winsize': terminals.c:1392:6: error: implicit declaration of function 'kill' [-Wimplicit-function-declaration] 1392 | kill (desc->child_pid, SIGWINCH); | ^~~~ This patch fixes this by including the necessary headers: <sys/time.h> for utimes, <signal.h> for kill, and <util.h> for openpty. With those changes, the build completed on x86_64-apple-darwin2[0-3] (make check still running). 2023-12-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc/ada: * adaint.c [__APPLE__]: Include <signal.h>, <sys/time.h>. * terminals.c [!_WIN32]: Include <signal.h>. [__APPLE__]: Include <util.h>. Fix typos.
2023-12-01Daily bump.GCC Administrator1-0/+124
2023-11-30ada: Rework fix for wrong finalization of qualified aggregate in allocatorEric Botcazou4-63/+63
The problem is that there is no easy method to insert an action after an arbitrary node in the tree, so the original fix does not correctly work when the allocator is nested in another expression. Therefore this moves the burden of the insertion from Apply_Predicate_Check to Expand_Allocator_Expression and restricts the new processing to the case where it is really required. gcc/ada/ * checks.ads (Apply_Predicate_Check): Add Deref boolean parameter. * checks.adb (Apply_Predicate_Check): Revert latest change. Use Loc local variable to hold the source location. Use a common code path for the generic processing and make a dereference if Deref is True. * exp_ch4.adb (Expand_Allocator_Expression): Compute Aggr_In_Place earlier. If it is true, do not call Apply_Predicate_Check on the expression on entry but on the temporary on exit with a dereference. * sem_res.adb (Resolve_Actuals): Add explicit parameter association in call to Apply_Predicate_Check.
2023-11-30ada: Support Put_Image for types in user-defined instances of predefined ↵Steve Baird1-1/+1
generics. Predefined units do not generally support the Put_Image attribute. There are good reasons for this in most cases. But if a user-defined instantiation of a predefined generic occurs in Ada 2022 code, then Put_Image can be supported for types declared therein. Add this support. gcc/ada/ * exp_put_image.adb (Put_Image_Enabled): Return True in more cases. In particular, when testing to see if a type occurs in a predefined unit, test the type's code unit (obtained by calling Get_Code_Unit). In the case of type within a user-defined instance of a predefined generic, Is_Predefined_Unit will return True for the type and False for the type's code unit.
2023-11-30ada: Remove SPARK legality checksYannick Moy11-645/+13
SPARK legality checks apply only to code with SPARK_Mode On, and are performed again in GNATprove for detecting SPARK-compatible declarations in code with SPARK_Mode Auto. Remove this duplication, to only perform SPARK legality checking in GNATprove. After this patch, only a few special SPARK legality checks are performed in the frontend, which could be moved to GNATprove later. gcc/ada/ * contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract): Remove checking on volatility. Remove handling of SPARK_Mode, not needed anymore. (Analyze_Entry_Or_Subprogram_Contract): Remove checking on volatility. (Check_Type_Or_Object_External_Properties): Same. (Analyze_Object_Contract): Same. * freeze.adb (Freeze_Record_Type): Same. Also remove checking on synchronized types and ghost types. * sem_ch12.adb (Instantiate_Object): Remove checking on volatility. (Instantiate_Type): Same. * sem_ch3.adb (Access_Type_Declaration): Same. (Derived_Type_Declaration): Remove checking related to untagged partial view. (Process_Discriminants): Remove checking on volatility. * sem_ch5.adb (Analyze_Loop_Parameter_Specification): Same. * sem_ch6.adb (Analyze_Procedure_Call): Fix use of SPARK_Mode where GNATprove_Mode was intended. * sem_disp.adb (Inherited_Subprograms): Protect against Empty node. * sem_prag.adb (Analyze_Global_In_Decl_Part): Remove checking on volatility. (Analyze_Pragma): Same. * sem_res.adb (Flag_Effectively_Volatile_Objects): Remove. (Resolve_Actuals): Remove checking on volatility. (Resolve_Entity_Name): Same. * sem_util.adb (Check_Nonvolatile_Function_Profile): Remove. (Check_Volatility_Compatibility): Remove. * sem_util.ads: Same.
2023-11-30ada: Remove GNATcheck violationsSheri Bernstein1-5/+19
Remove GNATcheck violations by refactoring code and also using pragma Annotate to exempt them. gcc/ada/ * libgnat/i-cstrin.adb (Free): Rewrite code so there is only one return, to remove Improper_Returns violation. (Position_Of_Nul): Add pragma to exempt Improper_Returns violation. (To_Chars_Ptr): Likewise. (Value): Likewise
2023-11-30ada: Ignore defered compile time errors without backendViljar Indus1-0/+10
We defer some compile time warnings and errors until the backend has added the extra information needed. However it is not guaranteed that the backend has run by this point. Avoid checking these errors if the backend has not been activated and no code has been generated. gcc/ada/ * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Avoid checking compile time warnings and errors if backend has not been activated.
2023-11-30ada: Fix spelling of functions with(out) "side effects"Yannick Moy12-64/+64
Correct spelling does not include an hyphen. Fix comments and one error message. Also fix other mispellings of "side-effect" or "side effect" depending on the case (adjective should have hyphen), and "side-effect-free" with double hyphen as an adjective. gcc/ada/ * checks.adb, exp_aggr.adb, exp_ch4.ads, exp_ch5.adb, exp_util.adb, exp_util.ads, inline.adb, sem_ch13.adb, sem_ch6.adb, sem_ch8.adb, sem_prag.adb, sem_util.ads: Fix comments and typos.
2023-11-30ada: Crash initializing component of private record typeJavier Miranda1-85/+89
The compiler may crash processing the full type declaration of a private record type that initializes a component with a call to a function instantiated in the private part of the package. gcc/ada/ * freeze.adb (Declared_In_Expanded_Body): New subprogram. (In_Expanded_Body): Minor code cleanup. (Freeze_Expression): Code cleanup plus factorize in a new function the code that identifies entities declared in the body of expander generated subprograms, since such case must be checked also for other node kinds when climbing the tree to locate the place to insert the freezing node.
2023-11-30ada: Name resolution in expanded instancesSteve Baird1-0/+338
In building the tree for an instance of a generic, expansion sets entity fields on names that refer to things declared outside of the instance, but leaves the entity field unset on names that should end up referring to things declared within the instance. These will instead be set by analysis - the idea is that if a name resolves a certain way in the generic, then we should get corresponding results if we resolve the corresponding name in an instance. For this to work, we have to prevent unrelated declarations that happen to be visible at the point of the instantiation from participating in resolution. Add code to filter out such unwanted name resolution candidates. gcc/ada/ * sem_ch8.adb (Find_Direct_Name): In the case of a resolving a name that occurs within an instantiation, add code to detect and filter out unwanted candidate resolutions. The filtering is performed via a call to Remove_Interp.
2023-11-30ada: Add comment describing Partition_Elaboration_Policy dependency.Steve Baird1-0/+6
Add a comment in the spec for the default (as opposed to hie) version of Ada.Real_Time.Timing_Events indicating that it is incompatible with a a Partition_Elaboration_Policy specification specifying a policy other than Concurrent. gcc/ada/ * libgnarl/a-rttiev.ads: add a comment
2023-11-30ada: Too-strict conformance checking for formal discriminated typeSteve Baird1-5/+12
The discriminant subtype conformance check for an actual parameter corresponding to a generic formal discriminated type was too strict and could incorrectly reject legal instantiations. gcc/ada/ * sem_ch12.adb (Validate_Discriminated_Formal_Type): Replace Entity_Id equality test with a call to Subtypes_Match. Distinct subtypes which are statically matching should pass this test. (Check_Discriminated_Formal): Replace Entity_Id equality test with a call to Subtypes_Statically_Match (preceded by a check that the preconditions for the call are satisfied).
2023-11-30ada: Fix predicate check failure in Expand_Allocator_ExpressionEric Botcazou1-8/+9
The For_Special_Return_Object flag needs to be accessed on entry of the procedure in case the allocator is rewritten during the processing. gcc/ada/ * exp_ch4.adb (Expand_Allocator_Expression): Add Special_Return boolean constant to hold the value of For_Special_Return_Object for the allocator and use it throughout the procedure.
2023-11-30ada: Fix wrong finalization for qualified aggregate of limited type in allocatorEric Botcazou1-0/+21
This happens with -gnata when the limited type has controlled components and a predicate, because the predicate check generated for the aggregate causes the creation of a temporary that is used as the expression of the allocator. Now this combination is illegal for a limited type, so the compiler does not generate the deep adjustment that would be necessary for the access value, which ultimately results in a wrong finalization. gcc/ada/ * checks.adb (Apply_Predicate_Check): Also deal specifically with an expression that is a qualified aggregate in an allocator.
2023-11-30ada: Constant_Indexing used when context requires a variableSteve Baird1-3/+15
In the case of a call with a formal parameter of mode other than "IN" where the corresponding actual parameter is a generalized indexing and the indexable container has both Constant_Indexing and Variable_Indexing aspects specified, the generalized indexing must be interpreted as a variable indexing, not as a constant indexing. In some cases involving a call to a prefixed view of a subprogram, this was not handled correctly. This error results in spurious compile-time error messages saying that the actual parameter in the call "must be a variable". gcc/ada/ * sem_ch4.adb (Constant_Indexing_OK): As a temporary stopgap, return False in the case of an unanalyzed prefixed-view call.
2023-11-29Daily bump.GCC Administrator1-0/+120
2023-11-28Fix PR ada/111909 On Darwin, determine filesystem case sensitivity at runtimeSimon Wright1-3/+11
In gcc/ada/adaint.c(__gnat_get_file_names_case_sensitive), the current assumption for __APPLE__ is that file names are case-insensitive unless __arm__ or __arm64__ are defined, in which case file names are declared case-sensitive. The associated comment is "By default, we suppose filesystems aren't case sensitive on Windows and Darwin (but they are on arm-darwin)." This means that on aarch64-apple-darwin, file names are treated as case-sensitive, which is not the default case. The true default position is that macOS file systems are case-insensitive, iOS file systems are case-sensitive. Apple provide a header file <TargetConditionals.h> which permits a compile-time check for the compiler target (e.g. OSX vs IOS); if TARGET_OS_IOS is defined as 1, this is a build for iOS. 2023-11-22 Simon Wright <simon@pushface.org> gcc/ada/ PR ada/111909 * adaint.c (__gnat_get_file_names_case_sensitive): Split out the __APPLE__ check and remove the checks for __arm__, __arm64__. For Apple, file names are by default case-insensitive unless TARGET_OS_IOS is set. Signed-off-by: Simon Wright <simon@pushface.org>
2023-11-28ada: Fix wrong size value output with -gnatR -gnatcEric Botcazou1-0/+1
This happens when a parameter is involved in the computation. gcc/ada/ * gcc-interface/decl.cc (annotate_value): Apply the same processing for parameters as for variables.
2023-11-28ada: Add comment for assertionMarc Poulhiès1-1/+4
Add possible cause for a failed assertion. gcc/ada/ * gcc-interface/utils2.cc (build_simple_component_ref): Add comment on assertion.
2023-11-28ada: Error compiling reduction expression with overloaded reducer subprogramSteve Baird1-43/+34
In some cases involving a reduction expression with an overloaded reducer subprogram, the accumulator type is not determined correctly. This can lead to spurious compile-time errors. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): In the case of a Reduce attribute reference, fix bugs in initializing Accum_Typ. The previous version was incorrect in the case where E1 refers to the first of multiple possible overload resolution candidates and that candidate does not turn out to be the right one. The previous version also had code to compute Accum_Typ via a different method if the initial computation turned out to yield a universal numeric type. Delete that initial computation and use the second method in all cases.
2023-11-28ada: Errors on instance of Multiway_Trees with discriminated typeGary Dismukes1-270/+4
The compiler may report various type conflicts on an instantiation of the generic package Ada.Containers.Multiway_Trees with an actual for Element_Type that is a nonprivate actual type with discriminants that has a discriminant-dependent component of a private type (such as a Bounded_Vector type). The type errors occur on an aggregate of the implementation type Tree_Node_Type within the body of Multiway_Trees, where the aggregate has a box-defaulted association for the Element component. (Such type errors could of course arise in other cases of generic instantiations that follow a similar type model.) In the case where the discriminant-dependent component type has a default-initialization procedure (init proc), the compiler was handling box associations for such components by expanding the topmost box association into subaggregates that themselves have box associations, and didn't properly account for discriminant-dependent subcomponents of private types. This could be fixed internally in Propagate_Discriminants, but it seems that the entire machinery for dealing with such subcomponent associations is unnecessary, and the topmost component association can be handled directly as a default-initialized box association. gcc/ada/ * sem_aggr.adb (Add_Discriminant_Values): Remove this procedure. (Propagate_Discriminants): Remove this procedure. (Resolve_Record_Aggregate): Remove code (the Capture_Discriminants block statement) related to propagating discriminants and generating initializations for subcomponents of a discriminant-dependent box-defaulted subcomponent of a nonprivate record type with discriminants, and handle all top-level components that have a non-null base init proc directly, by calling Add_Association with "Is_Box_Present => True". Also, combine that elsif clause with the immediately preceding elsif clause, since they now both contain the same statement (calls to Add_Association with the same actuals).