aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2022-07-12[Ada] Fix inconsistent comment about expansion of exception declarationsPiotr Trojanek1-1/+1
Code cleanup. gcc/ada/ * exp_ch11.adb (Expand_N_Exception_Declaration): Sync comment with declaration in System.Standard_Library.
2022-07-12[Ada] Fix 0-sized secondary stack allocationsMarc Poulhiès1-1/+6
The Has_Enough_Free_Memory was not correctly reporting a completely full chunk in the case of a 0-sized allocation. gcc/ada/ * libgnat/s-secsta.adb (Has_Enough_Free_Memory): Check for full chunk before computing the available size.
2022-07-12[Ada] Use right implementation type for nonbinary-modulus opsSteve Baird1-31/+70
If the flag Opt.Expand_Nonbinary_Modular_Ops is set (which occurs if -gnateg is specified) then we implement predefined operations for a modular type whose modulus is not a power of two by converting the operands to some other type (either a signed integer type or a modular type with a power-of-two modulus), doing the operation in that representation, and converting back. If the bounds of the chosen type are too narrow, then problems with intermediate overflow can result. But there are performance advantages to choosing narrower bounds (and to prefering an unsigned choice over a signed choice of the same size) when multiple safe choices are available. gcc/ada/ * exp_ch4.adb (Expand_Nonbinary_Modular_Op.Expand_Modular_Op): Reimplement choice of which predefined type to use for the implementation of a predefined operation of a modular type with a non-power-of-two modulus.
2022-07-12[Ada] Spurious use_type clause warningJustin Squirek2-3/+18
This patch corrects an error in the compiler whereby a spurious redundant use_type_clause warning gets issued when the clause appears in the context_clause of a package preceding a with_clause for a package with an identical use_clause in its specification. gcc/ada/ * einfo.ads: Modify documentation for In_Use flag to include scope stack manipulation. * sem_ch8.adb (Use_One_Type): Add condition to return when attempting to detect redundant use_type_clauses in child units in certain cases.
2022-07-12[Ada] Extend No_Dependence restriction to code generationEric Botcazou4-21/+87
This makes it possible to report violations of the No_Dependence restriction during code generation, in other words outside of the Ada front-end proper. These violations are supposed to be only for child units of System, so the implementation is restricted to these cases. gcc/ada/ * restrict.ads (type ND_Entry): Add System_Child component. (Check_Restriction_No_Dependence_On_System): Declare. * restrict.adb (Global_Restriction_No_Tasking): Move around. (Violation_Of_No_Dependence): New procedure. (Check_Restriction_No_Dependence): Call Violation_Of_No_Dependence to report a violation. (Check_Restriction_No_Dependence_On_System): New procedure. (Set_Restriction_No_Dependenc): Set System_Child component if the unit is a child of System. * snames.ads-tmpl (Name_Arith_64): New package name. (Name_Arith_128): Likewise. (Name_Memory): Likewise. (Name_Stack_Checking): Likewise. * fe.h (Check_Restriction_No_Dependence_On_System): Declare.
2022-07-12[Ada] Ada 2020: Allow declarative items mixed with statementsBob Duff5-124/+354
This patch implements a syntactic language extension that allows declarative items to appear in a sequence of statements. For example: for X in S'Range loop Item : Character renames S (X); Item := Transform (Item); end loop; Previously, declare/begin/end was required, which is just noise. gcc/ada/ * par.adb (P_Declarative_Items): New function to parse a sequence of declarative items. (P_Sequence_Of_Statements): Add Handled flag, to indicate whether to wrap the result in a block statement. * par-ch3.adb (P_Declarative_Item): Rename P_Declarative_Items to be P_Declarative_Item, because it really only parses a single declarative item, and to avoid conflict with the new P_Declarative_Items. Add In_Statements. We keep the old error-recovery mechanisms in place when In_Statements is False. When True, we don't want to complain about statements, because we are parsing a sequence of statements. (P_Identifier_Declarations): If In_Statements, and we see what looks like a statement, we no longer give an error. We return to P_Sequence_Of_Statements with Done = True, so it can parse the statement. * par-ch5.adb (P_Sequence_Of_Statements): Call P_Declarative_Items to parse declarative items that appear in the statement list. Remove error handling code that complained about such items. Check some errors conservatively. Wrap the result in a block statement when necessary. * par-ch11.adb (P_Handled_Sequence_Of_Statements): Pass Handled => True to P_Sequence_Of_Statements. * types.ads (No, Present): New functions for querying Source_Ptrs (equal, not equal No_Location).
2022-07-12[Ada] Don't check for misspelling of Not_A_Restriction_IdPiotr Trojanek1-1/+1
When looking for a misspelling of a restriction identifier we should ignore the Not_A_Restriction_Id literal, because it doesn't represent any restriction. gcc/ada/ * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Fix range of iteration.
2022-07-12[Ada] Fix confusing error expression on an unknown restrictionPiotr Trojanek1-2/+4
When pragma Restriction is used with an unknown restriction identifier, it is better to not process the restriction expression, as it will likely produce confusing error message. In particular, an odd message appeared when there was a typo in the restriction identifier whose expression requires special processing (e.g. No_Dependence_On instead of No_Dependence). gcc/ada/ * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Do not process expression of unknown restrictions.
2022-07-12[Ada] Make it clear that gnatmake passes the ball to gprbuild if -P is setVasiliy Fofanov3-28/+34
Also move -P switch description to the top of the switches list. gcc/ada/ * makeusg.adb, doc/gnat_ugn/building_executable_programs_with_gnat.rst: Move -P to the top of switches list and make it clear that gnatmake passes the ball to gprbuild if -P is set. * gnat_ugn.texi: Regenerate.
2022-07-12[Ada] Suppress warning in g-socthi__vxworks.adbBob Duff1-1/+3
Follow-on to previous change, which missed the vxworks version of this package. gcc/ada/ * libgnat/g-socthi__vxworks.adb (C_Connect): Suppress new warning.
2022-07-12[Ada] Simplify rewriting of attributes into Boolean literalsPiotr Trojanek1-6/+1
Code cleanup; semantics is unaffected. gcc/ada/ * sem_attr.adb (Set_Boolean_Result): Simplify using Boolean_Literals.
2022-07-12[Ada] Ignore switches for controlling frontend warnings in GNATprove modeYannick Moy3-42/+15
In the special mode for GNATprove, ignore switches controlling frontend warnings, like already done for the control of style checks warnings. Also remove special handling of warning mode in Errout to make up for the previous division of control between -gnatw (GNAT) and --warnings (GNATprove). gcc/ada/ * errout.adb (Record_Compilation_Errors): Remove global variable. (Compilation_Errors): Simplify. (Initialize): Inline Reset_Warnings. (Reset_Warnings): Remove. * errout.ads (Reset_Warnings): Remove. (Compilation_Errors): Update comment. * gnat1drv.adb (Adjust_Global_Switches): Ignore all frontend warnings in GNATprove mode, except regarding elaboration and suspicious contracts.
2022-07-12[Ada] Do not create large objects for indefinite protected typesEric Botcazou1-9/+26
This plugs a small loophole in the Needs_Secondary_Stack predicate for some protected types and record types containing protected components. gcc/ada/ * sem_util.adb (Caller_Known_Size_Record): Make entry assertion more robust and add guard for null argument. For protected types, invoke Caller_Known_Size_Record on Corresponding_Record_Type. (Needs_Secondary_Stack): Likewise.
2022-07-12[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanup - remove unused filesDoug Rupp2-327/+0
Only smp runtimes are built for vxworks7*, even though the -smp suffix is removed during install. This change removes unused system packages for rtp runtimes. gcc/ada/ * libgnat/system-vxworks7-ppc-rtp.ads: Remove * libgnat/system-vxworks7-x86-rtp.ads: Likewise.
2022-07-12[Ada] Fix spurious warning on unreferenced internal generic instancePiotr Trojanek1-1/+0
This patch removes a spurious warning, saying that an internal entity of a generic formal package is unreferenced. The immediate cause of this warning is that the internal entity is explicitly flagged as coming from source. The explicit flagging was added decades ago to fix a missing cross-reference in the ALI file. Apparently these days the cross-references work fine without this flag. gcc/ada/ * sem_ch12.adb (Analyze_Package_Instantiation): Remove dubious call to Set_Comes_From_Source.
2022-07-12[Ada] Refine heuristics for unreachable-code warningsBob Duff3-17/+26
This patch refines the heuristics for when we warn about unreachable code, to avoid common false alarms. gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Refine heuristics. * sem_util.ads, sem_util.adb (Is_Static_Constant_Name): Remove this; instead we have a new function Is_Simple_Case in Sem_Ch5.Check_Unreachable_Code.
2022-07-12[Ada] Remove out-of-range warning in unreachable codeBob Duff8-64/+117
This patch removes a warning in examples like this: if cond then return; -- or other jump end if; X := ...; -- where the value is out of range where cond is known at compile time. It could, for example, be a generic formal parameter that is known to be True in some instances. As a side effect, this patch adds new warnings about unreachable code. gcc/ada/ * gnatls.adb (Output_License_Information): Remove pragma No_Return; call sites deal with Exit_Program. * libgnat/g-socthi.adb (C_Connect): Suppress warning about unreachable code. * sem_ch5.adb (Check_Unreachable_Code): Special-case if statements with static conditions. If we remove unreachable code (including the return statement) from a function, add "raise Program_Error", so we won't warn about missing returns. Remove Original_Node in test for N_Raise_Statement; it's not needed. Remove test for CodePeer_Mode; if Operating_Mode = Generate_Code, then CodePeer_Mode can't be True. Misc cleanup. Do not reuse Nxt variable for unrelated purpose (the usage in the Kill_Dead_Code loop is entirely local to the loop). * sem_ch6.adb: Add check for Is_Transfer. Misc cleanup. * sem_prag.adb: Minor. * sem_res.adb: Minor. * sem_util.adb: Minor cleanup. (Is_Trivial_Boolean): Move to nonnested place, so it can be called from elsewhere. (Is_Static_Constant_Boolean): New function. * sem_util.ads (Is_Trivial_Boolean): Export. (Is_Static_Constant_Boolean): New function.
2022-07-12[Ada] Add one more leading underscore to couple of exported symbolsEric Botcazou1-2/+2
For the sake of consistency with other runtime units. gcc/ada/ * libgnat/s-stchop.ads: Use a double underscore prefix for symbols.
2022-07-12[Ada] Proper freezing for dispatching expression functions.Ed Schonberg2-2/+47
In the case of an expression function that is a primitive function of a tagged type, freezing the tagged type needs to freeze the function (and its return expression). A bug in this area could result in incorrect behavior both at compile time and at run time. At compile time, freezing rule violations could go undetected so that an illegal program could be incorrectly accepted. At run time, a dispatching call to the primitive function could end up dispatching through a not-yet-initialized slot in the dispatch table, typically (although not always) resulting in a segmentation fault. gcc/ada/ * freeze.adb (Check_Expression_Function.Find_Constant): Add a check that a type that is referenced as the prefix of an attribute is fully declared. (Freeze_And_Append): Do not freeze the profile when freezing an expression function. (Freeze_Entity): When a tagged type is frozen, also freeze any primitive operations of the type that are expression functions. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not prevent freezing associated with an expression function body if the function is a dispatching op.
2022-07-12[Ada] Warn on unset objects in packages with no bodiesPiotr Trojanek1-0/+7
Fix an inconsistency, where GNAT was warning about references to unset objects inside generic packages with no bodies but not inside ordinary packages with no bodies. gcc/ada/ * sem_ch7.adb (Analyze_Package_Declaration): Check references to unset objects. gcc/testsuite/ * gnat.dg/specs/discr5.ads: Expect new warnings. * gnat.dg/specs/empty_variants.ads: Likewise. * gnat.dg/specs/pack13.ads: Likewise.
2022-07-12[Ada] Accept aspect Yield on subprogram bodies acting as specsPiotr Trojanek1-6/+4
A small fix for the aspect Yield defined in AI12-0279 for Ada 2022, to accept aspect given for a subprogram body which acts as its own spec. For example: procedure Switch with Yield => True is begin ... end Switch; gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Yield): Look at the entity kind, not at the declaration kind.
2022-07-12[Ada] Annotate libraries with returning annotationJoffrey Huguet38-258/+443
This patch annotates SPARK-annotated libraries with returning annotations (Always_Return, Might_Not_Return) to remove the warnings raised by GNATprove about missing annotations. gcc/ada/ * libgnarl/a-reatim.ads, libgnat/a-cfdlli.ads, libgnat/a-cfhama.ads, libgnat/a-cfhase.ads, libgnat/a-cfinse.ads, libgnat/a-cfinve.ads, libgnat/a-cforma.ads, libgnat/a-cforse.ads, libgnat/a-chahan.ads, libgnat/a-cofove.ads, libgnat/a-cofuma.ads, libgnat/a-cofuse.ads, libgnat/a-cofuve.ads, libgnat/a-nbnbin.ads, libgnat/a-nbnbre.ads, libgnat/a-ngelfu.ads, libgnat/a-nlelfu.ads, libgnat/a-nllefu.ads, libgnat/a-nselfu.ads, libgnat/a-nuelfu.ads, libgnat/a-strbou.ads, libgnat/a-strfix.ads, libgnat/a-strmap.ads, libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads, libgnat/a-strsea.ads, libgnat/a-textio.ads, libgnat/a-tideio.ads, libgnat/a-tienio.ads, libgnat/a-tifiio.ads, libgnat/a-tiflio.ads, libgnat/a-tiinio.ads, libgnat/a-timoio.ads, libgnat/i-c.ads, libgnat/interfac.ads, libgnat/interfac__2020.ads, libgnat/s-atacco.ads, libgnat/s-stoele.ads: Annotate packages and subprograms with returning annotations.
2022-07-12[Ada] Fix buffer overrun for small string concatenation at -O0Eric Botcazou17-246/+19
The concatenation routines may read too much data on the source side when the destination buffer is larger than the final result. This change makes sure that this does not happen any more and also removes obsolete stuff. gcc/ada/ * rtsfind.ads (RE_Id): Remove RE_Str_Concat_Bounds_N values. (RE_Unit_Table): Remove RE_Str_Concat_Bounds_N entries. * libgnat/s-conca2.ads (Str_Concat_2): Adjust head comment. (Str_Concat_Bounds_2): Delete. * libgnat/s-conca2.adb (Str_Concat_2): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_2): Delete. * libgnat/s-conca3.ads (Str_Concat_3): Adjust head comment. (Str_Concat_Bounds_3): Delete. * libgnat/s-conca3.adb (Str_Concat_3): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_3): Delete. * libgnat/s-conca4.ads (Str_Concat_4): Adjust head comment. (Str_Concat_Bounds_4): Delete. * libgnat/s-conca4.adb (Str_Concat_4): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_4): Delete. * libgnat/s-conca5.ads (Str_Concat_5): Adjust head comment. (Str_Concat_Bounds_5): Delete. * libgnat/s-conca5.adb (Str_Concat_5): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_5): Delete. * libgnat/s-conca6.ads (Str_Concat_6): Adjust head comment. (Str_Concat_Bounds_6): Delete. * libgnat/s-conca6.adb (Str_Concat_6): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_6): Delete. * libgnat/s-conca7.ads (Str_Concat_7): Adjust head comment. (Str_Concat_Bounds_7): Delete. * libgnat/s-conca7.adb (Str_Concat_7): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_7): Delete. * libgnat/s-conca8.ads (Str_Concat_8): Adjust head comment. (Str_Concat_Bounds_8): Delete. * libgnat/s-conca8.adb (Str_Concat_8): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_8): Delete. * libgnat/s-conca9.ads (Str_Concat_9): Adjust head comment. (Str_Concat_Bounds_9): Delete. * libgnat/s-conca9.adb (Str_Concat_9): Use the length of the last input to size the last assignment. (Str_Concat_Bounds_9): Delete.
2022-07-12[Ada] Avoid namespace pollution for Next and PreviousBob Duff24-104/+106
This patch renames Next and Previous in a-convec.ads and other containers to be _Next and _Previous, to avoid namespace pollution. The compiler now uses the leading-underscore names to look them up. The scanner is changed to allow this. gcc/ada/ * exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Use _Next and _Previous in the optimized expansion of "for ... of". No longer need to check parameter profiles for these, because the leading-underscore names are unique. * libgnat/a-convec.ads (_Next, _Previous): Renamings of Next and Previous, to avoid namespace pollution. * libgnat/a-cbdlli.ads, libgnat/a-cbhama.ads, libgnat/a-cbhase.ads, libgnat/a-cbmutr.ads, libgnat/a-cborma.ads, libgnat/a-cborse.ads, libgnat/a-cdlili.ads, libgnat/a-cidlli.ads, libgnat/a-cihama.ads, libgnat/a-cihase.ads, libgnat/a-cimutr.ads, libgnat/a-ciorma.ads, libgnat/a-ciorse.ads, libgnat/a-cobove.ads, libgnat/a-cohama.ads, libgnat/a-cohase.ads, libgnat/a-coinve.ads, libgnat/a-comutr.ads, libgnat/a-coorma.ads, libgnat/a-coorse.ads: Likewise. Also, remove duplicated comments -- refer to one comment about _Next, _Previous, Pseudo_Reference in libgnat/a-convec.ads. DRY. * scng.adb (Scan): Allow leading underscores in identifiers in the run-time library. * snames.ads-tmpl (Name_uNext, Name_uPrevious): New names with leading underscores.
2022-07-12[Ada] Warn about unreachable code after calls with No_ReturnPiotr Trojanek2-6/+23
GNAT was already warning about unreachable code after raise/goto/exit statements, but not after calls to procedures with No_Return. Now this warning is extended. Also, previously the warning was suppressed for unreachable RETURN after RAISE statements. Now this suppression is narrowed to functions, because only in function such a RETURN statement might be indeed needed (where it is the only RETURN statement of a function). gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Extend suppression to calls with No_Return aspect, but narrow it to functions. * sem_res.adb (Resolve_Call): Warn about unreachable code after calls with No_Return.
2022-07-12[Ada] Clean up scannerBob Duff6-183/+37
This patch removes some obsolete code in the scanner and related files, and corrects some comments. Tok_Special is used only by the preprocessor, and uses only the two characters '#' and '$'. It might be simpler to have a single flag indicating we're scanning for preprocessing, instead of the Special_Characters array and the End_Of_Line_Is_Token flag, but that's for another day. gcc/ada/ * scans.ads: Fix obsolete comments about Tok_Special, and give Special_Character a predicate assuring it is one of the two characters used in preprocessing. * scng.ads: Clean up comments. * scng.adb: Clean up handling of Tok_Special. Remove comment about '@' (target_name), which doesn't seem very helpful. Set_Special_Character will now blow up if given anything other than '#' and '$', because of the predicate on Special_Character; it's not clear why it used to say "when others => null;". Remove Comment_Is_Token, which is not used. * scn.ads: Remove commented-out use clause. Remove redundant comment. * ali-util.adb: Use "is null" for do-nothing procedures. * gprep.adb (Post_Scan): Use "is null".
2022-07-12[Ada] Ignore exceptions in task termination handlersBob Duff3-5/+10
This patch fixes a bug in which if the environment task has a specific termination handler, and that handler raises an exception, the handler is called recursively, causing infinite recursion. The RM requires such exceptions to be ignored. gcc/ada/ * libgnarl/s-solita.adb (Task_Termination_Handler_T): Ignore all exceptions propagated by Specific_Handler. * libgnarl/s-tassta.adb, libgnarl/s-taskin.ads: Minor.
2022-07-12[Ada] Fix missing Overflow and Range checksMarc Poulhiès3-7/+17
While doing Preanalysis (as is the case during ghost code handling), some range and/or overflow checks can be saved (see Saved_Checks in checks.adb) and later one omitted as they would be redundant (see Find_Check in checks.adb). In the case of ghost code, the node being Preanalyzed is a temporary copy that is discarded, so its corresponding check is not expanded later. The node that gets expanded later is not having any checks expanded as it is wrongly assumed it has already been done before. As is already the case in Preanalyze_And_Resolve, this change suppresses all checks during Preanalyze except for GNATprove mode. gcc/ada/ * sem.adb (Preanalyze): Suppress checks when not in GNATprove mode. * sem_res.adb (Preanalyze_And_Resolve): Add cross reference in comment to above procedure. * sinfo.ads: Typo fix in comment.
2022-07-12[Ada] Add new unbounded and indefinite formal doubly linked listJulien Bortolussi4-0/+3726
Before this patch, the only formal doubly linked lists were bounded and definite. This means that it is necessary to provide their maximum length or capacity at instantiation and that they can only be used with definite element types. The formal lists added by this patch are unbounded and indefinite. Their length grows dynamically until Count_Type'Last. This makes them easier to use but requires the use of dynamic allocation and controlled types. gcc/ada/ * libgnat/a-cfidll.adb, libgnat/a-cfidll.ads: Implementation files of the formal unbounded indefinite list. * Makefile.rtl, impunit.adb: Take into account the add of the new files.
2022-07-12[Ada] Remove excessive guard in detection of access-to-variable objectsPiotr Trojanek1-1/+0
It is safe to call Is_Access_Variable without calling Is_Access_Object_Type before. Compiler cleanup only; semantics is unaffected. gcc/ada/ * sem_util.adb (Is_Variable): Remove excessive guard.
2022-07-07Daily bump.GCC Administrator1-0/+171
2022-07-06[Ada] Simplify regular expression that matches 8 consecutive digitsPiotr Trojanek1-1/+1
Makefile cleanup; behaviour is unaffected. gcc/ada/ * gcc-interface/Make-lang.in (ada/generated/gnatvsn.ads): Simplify regular expression. The "interval expression", i.e. \{8\} is part of the POSIX regular expressions, so it should not be a problem for modern implementations of sed.
2022-07-06[Ada] Update comment after recent changes wrt. secondary stack & tagged typesEric Botcazou1-3/+1
gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu): Update comment.
2022-07-06[Ada] Improve code generated for aggregates of VFA typeEric Botcazou3-4/+29
This avoids using a full access for constants internally generated from assignments of aggregates with a Volatile_Full_Access type. gcc/ada/ * gcc-interface/gigi.h (simple_constant_p): Declare. * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Strip the qualifiers from the type of a simple constant. (simple_constant_p): New predicate. * gcc-interface/trans.cc (node_is_atomic): Return true for objects with atomic type except for simple constants. (node_is_volatile_full_access): Return false for simple constants with VFA type.
2022-07-06[Ada] Fix crash on aliased renaming of unconstrained arrayEric Botcazou1-5/+7
gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Create a local constant holding the underlying GNAT type of the object. Do not fiddle with the object size for an unconstrained array.
2022-07-06[Ada] Small tweak to gnat_to_gnu_subprog_typeEric Botcazou1-3/+3
No functional changes. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Constify a local variable and move a couple of others around.
2022-07-06[Ada] Do not give warnings for compiler-generated entities by defaultEric Botcazou1-0/+11
gcc/ada/ * gcc-interface/trans.cc (gnat_gimplify_expr) <SAVE_EXPR>: New case.
2022-07-06[Ada] Document the various function return mechanismsEric Botcazou1-1/+42
gcc/ada/ * exp_ch6.adb (Function return mechanisms): New paragraph.
2022-07-06[Ada] Deferred constant considered as not preelaborableYannick Moy1-2/+3
Fix detection of non-preelaborable constructs for checking SPARK elaboration rules, which was tagging deferred constant declarations as not preelaborable. gcc/ada/ * sem_util.adb (Is_Non_Preelaborable_Construct): Fix for deferred constants.
2022-07-06[Ada] Indexing error when calling GNAT.Regpat.MatchJustin Squirek2-20/+42
This patch corrects an error in the compiler whereby a buffer sizing error fails to get raised when compiling a regex expression with an insufficiently sized Pattern_Matcher as the documentation indicated. This, in turn, could lead to indexing errors when attempting to call Match with the malformed regex program buffer. gcc/ada/ * libgnat/s-regpat.adb, libgnat/s-regpat.ads (Compile): Add a new defaulted parameter Error_When_Too_Small to trigger an error, if specified true, when Matcher is too small to hold the compiled regex program.
2022-07-06[Ada] Spurious non-callable warning on prefixed call in class conditionJustin Squirek1-4/+19
This patch corrects an error in the compiler whereby a function call in prefix notation within a class condition causes a spurious error claiming the name in the call is a non-callable entity when there exists a type extension in the same unit extended with a component featuring the same name as the function in question. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Add condition to avoid interpreting derived type components as candidates for selected components in preanalysis of inherited class conditions.
2022-07-06[Ada] Support ghost generic formal parametersYannick Moy9-63/+347
This adds support in GNAT for ghost generic formal parameters, as included in SPARK RM 6.9. gcc/ada/ * ghost.adb (Check_Ghost_Context): Delay checking for generic associations. (Check_Ghost_Context_In_Generic_Association): Perform ghost checking in analyzed generic associations. (Check_Ghost_Formal_Procedure_Or_Package): Check SPARK RM 6.9(13-14) for formal procedures and packages. (Check_Ghost_Formal_Variable): Check SPARK RM 6.9(13-14) for variables. * ghost.ads: Declarations for the above. * sem_ch12.adb (Analyze_Associations): Apply delayed checking for generic associations. (Analyze_Formal_Object_Declaration): Same. (Analyze_Formal_Subprogram_Declaration): Same. (Instantiate_Formal_Package): Same. (Instantiate_Formal_Subprogram): Same. (Instantiate_Object): Same. Copy ghost aspect to newly declared object for actual for IN formal object. Use new function Get_Enclosing_Deep_Object to retrieve root object. (Instantiate_Type): Copy ghost aspect to declared subtype for actual for formal type. * sem_prag.adb (Analyze_Pragma): Recognize new allowed declarations. * sem_util.adb (Copy_Ghost_Aspect): Copy the ghost aspect between nodes. (Get_Enclosing_Deep_Object): New function to return enclosing deep object (or root for reachable part). * sem_util.ads (Copy_Ghost_Aspect): Same. (Get_Enclosing_Deep_Object): Same. * libgnat/s-imageu.ads: Declare formal subprograms as ghost. * libgnat/s-valuei.ads: Same. * libgnat/s-valuti.ads: Same.
2022-07-06[Ada] Missing error on tagged type conversionJavier Miranda1-34/+102
The compiler does not report an error on a type conversion to/from a tagged type whose parent type is an interface type and there is no relationship between the source and target types. This bug has been dormant since January/2016. This patch also improves the text of errors reported on interface type conversions suggesting how to fix these errors. gcc/ada/ * sem_res.adb (Resolve_Type_Conversion): Code cleanup since the previous static check has been moved to Valid_Tagged_Conversion. (Valid_Tagged_Conversion): Fix the code checking conversion to/from interface types since incorrectly returns True when the parent type of the operand type (or the target type) is an interface type; add missing static checks on interface type conversions.
2022-07-06[Ada] Handle secondary stack memory allocations alignmentMarc Poulhiès3-35/+74
To accomodate cases where objects allocated on the secondary stack needed a more constrained alignement than Standard'Maximum_Alignement, the alignment for all allocations in the full runtime were forced on to be aligned on Standard'Maximum_Alignement*2. This changes removes this workaround and correctly handles the over-alignment in all runtimes. This change modifies the SS_Allocate procedure to accept a new Alignment parameter and to dynamically realign the pointer returned by the memory allocation (Allocate_* functions or dedicated stack allocations for zfp/cert). It also simplifies the 0-sized allocations by not allocating any memory if pointer is already correctly aligned (already the case in cert and zfp runtimes). gcc/ada/ * libgnat/s-secsta.ads (SS_Allocate): Add new Alignment parameter. (Memory_Alignment): Remove. * libgnat/s-secsta.adb (Align_Addr): New. (SS_Allocate): Add new Alignment parameter. Realign pointer if needed. Don't allocate anything for 0-sized allocations. * gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Add allocated object's alignment as last parameter to allocation invocation.
2022-07-06[Ada] Cleanup use of local scalars in GNAT.Socket.Get_Address_InfoPiotr Trojanek1-4/+4
A cleanup opportunity spotted while working on improved detection of uninitialised local scalar objects. gcc/ada/ * libgnat/g-socket.adb (Get_Address_Info): Reduce scope of the Found variable; avoid repeated assignment inside the loop.
2022-07-06[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanupDoug Rupp1-49/+25
Only smp runtimes are built for vxworks7*, even though the -smp suffix is removed during install. Therefore, in general, the build macros for the non-smp runtimes are superfluous except on the legacy ppc-vxworks6 target where both the smp and non-smp runtime are built. Lastly, an error message is added if a runtime build is commanded that doesn't exist, rather then letting the build mysteriously fail. gcc/ada/ * Makefile.rtl [arm,aarch64 vxworks7]: Remove rtp and kernel build macros and set an error variable if needed. [x86,x86_vxworks7]: Likewise. [ppc,ppc64]: Set an error variable if needed. (rts-err): New phony Makefile target. (setup-rts): Depend on rts-err.
2022-07-06[Ada] Fix incorrect itype sharing for case expression in limited type returnEric Botcazou1-72/+76
The compiler aborts with an internal error in gigi, but the problem is an itype incorrectly shared between several branches of an if_statement that has been created for a Build-In-Place return. Three branches of this if_statement contain an allocator statement and the latter two have been obtained as the result of calling New_Copy_Tree on the first; now the initialization expression of the first had also been obtained as the result of calling New_Copy_Tree on the original tree, and these chained calls to New_Copy_Tree run afoul of an issue with the copy of itypes after the rewrite of an aggregate as an expression with actions. Fixing this issue looks quite delicate, so this fixes the incorrect sharing by replacing the chained calls to New_Copy_Tree with repeated calls on the original expression, which is more elegant in any case. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_BIP_Return): New local function. (Expand_N_Object_Declaration): Use it to build the three allocators for a Build-In-Place return with an unconstrained type. Update the head comment after other recent changes.
2022-07-06[Ada] Remove old vxworks from Makefile.rtl - e500 port.Doug Rupp3-489/+0
The powerpc e500 port has been LTS'd gcc/ada/ * libgnat/system-vxworks7-e500-kernel.ads: Remove. * libgnat/system-vxworks7-e500-rtp-smp.ads: Likewise. * libgnat/system-vxworks7-e500-rtp.ads: Likewise.
2022-07-06[Ada] Incorrect emptying of CUDA global subprogramsJustin Squirek1-3/+6
This patch corrects an error in the compiler whereby no Corresponding_Spec was set for emptied CUDA global subprograms - leading to a malformed tree. gcc/ada/ * gnat_cuda.adb (Empty_CUDA_Global_Subprogram): Set Specification and Corresponding_Spec to match the original Kernel_Body.
2022-07-06[Ada] Remove explicit call to Make_Unchecked_Type_ConversionPiotr Trojanek2-5/+3
Respect a comment in sinfo.ads, which says: "Unchecked type conversion nodes should be created by calling Tbuild.Unchecked_Convert_To, rather than by directly calling Nmake.Make_Unchecked_Type_Conversion." No test appears to be affected by this change, so this is just a cleanup. gcc/ada/ * exp_ch6.adb (Build_Static_Check_Helper_Call): Replace explicit call to Make_Unchecked_Type_Conversion with a call to Unchecked_Convert_To. * tbuild.adb (Unchecked_Convert_To): Fix whitespace.