aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
AgeCommit message (Collapse)AuthorFilesLines
2022-11-21ada: Move warnings switchesBob Duff37-1113/+700
This patch moves warning switches from Opt into Warnsw, fixes some minor discrepancies, and cleans up the code. No change in behavior. gcc/ada/ * warnsw.ads, warnsw.adb: Move warning flags here from package Opt. Rename Warning_Record to be Warnings_State. Use an array instead of a record; this simplifies the code. Add renamings of all the array components for easy reference outside this package. Pass the "Family" to Set_Warning_Switch. Use more table-driven code. Misc cleanup and comment fixes. * opt.ads: Move warning switches to Warnsw. * gnat1drv.adb (Adjust_Global_Switches): Expanded names needed. * inline.ads: Rename Warning_Record to be Warnings_State. * sem_ch12.adb: Likewise. * sem_prag.adb: Use new Set_Warning_Switch. * contracts.adb, errout.adb, exp_aggr.adb, exp_ch11.adb: Adjust imports for move to Warnsw. * exp_ch5.adb, exp_prag.adb, exp_util.adb, frontend.adb: Likewise. * layout.adb, lib-xref.adb, restrict.adb, scn.adb, sem_aggr.adb: Likewise. * sem_attr.adb, sem_case.adb, sem_ch10.adb, sem_ch11.adb: Likewise. * sem_ch13.adb, sem_ch3.adb, sem_ch4.adb, sem_ch5.adb: Likewise. * sem_ch6.adb, sem_ch7.adb, sem_ch8.adb, sem_elab.adb: Likewise. * sem_eval.adb, sem_res.adb, sem_util.adb, sem_warn.adb: Likewise. * switch-c.adb: Likewise.
2022-11-21ada: Improve documentation for -gnatw.h warningsSteve Baird2-5/+15
The -gnatw.h option enables warnings about "gaps" in record layout specifications. In the case of a "partial" layout specification, where the locations of some components are left unspecified, the resulting warnings may be incomplete or incorrect. Document this implementation limitation. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Improve the description of how the -gnatw.h switch interacts with "partial" record layout specifications (i.e., specifications where the locations of some components are left unspecified). * gnat_ugn.texi: Regenerate.
2022-11-21ada: Reject nonconfirming Size attribute value for aliased objectMarc Poulhiès1-0/+15
Only confirming Size must be supported for aliased object of elementary type (see RM 13.1 in the "Implementation Advice"). -- size is 1-byte type Y is range 0 .. 20; type Ay is access all Y; -- Var size is 8-bytes Var : aliased Y := 5 with Size => 64; -- JP.all is a 1-byte reference to an 8-bytes objects. JP : Ay := Var'Access; The above JP.all references the first byte of the 8-byte Var object, which is, for example, not correct on little-endian systems. This change rejects nonconfirming Size attribute on such objects instead of miscompiling it. gcc/ada/ * sem_ch13.adb (Check_One_Attr): produce error when Size attribute used on aliased object of elementary types with nonconfirming value.
2022-11-21ada: Fix gnatmake's parsing of adc filesRonan Desplanques1-0/+1
Before this patch, gnatmake's parser for adc files failed to ignore semicolons located inside comments. This patch fixes that behavior. gcc/ada/ * sfn_scan.adb (Scan_SFN_Pragmas): Improve handling of comments.
2022-11-21ada: Tweak error messages on misplaced with keywordsRonan Desplanques1-1/+1
Before this patch, with clauses placed in declarative sections were interpreted by the compiler as incorrect aspect specifications, which led to confusing error messages. This patch makes it so more syntax errors involving the with keyword are diagnosed as intended with clauses instead of aspect specifications. gcc/ada/ * par-ch3.adb (P_Declarative_Item): Tweak handling of with keyword.
2022-11-21changelog: Fix extra space after tab.Martin Liska1-3/+3
2022-11-15Daily bump.GCC Administrator1-0/+141
2022-11-14ada: Silence CodePeer false positiveBoris Yakobowski1-0/+2
gcc/ada/ * sem_case.adb: silence false positive warning emitted by CodePeer on predefined equality for type Choice_Range_Info.
2022-11-14ada: Remove incorrect comments about initializationBob Duff6-44/+25
Cleanup only; no change in behavior. This patch removes and rewrites some comments regarding initialization. These initializions are needed, so there's no need to apologize for initializing these variables. Note that -gnatVa is not relevant; reads of uninitialized variables are wrong, whether or not we get caught. gcc/ada/ * atree.ads: Remove some comments. * err_vars.ads: Likewise. * scans.ads: Likewise. * sinput.ads: Likewise. * checks.ads: Likewise. Also add a "???" comment indicating an obsolete comment that is too difficult to correct at this time. * sem_attr.adb: Minor comment rewrite.
2022-11-14ada: Flag unsupported dispatching constructor callsJavier Miranda2-3/+9
gcc/ada/ * exp_intr.adb (Expand_Dispatching_Constructor_Call): Improve warning message. * freeze.adb (Check_No_Parts_Violations): Improve error message.
2022-11-14ada: hardcfr docs: add optional checkpointsAlexandre Oliva3-14/+240
Previously, control flow redundancy only checked the visited bitmap against the control flow graph at return points and before mandatory tail calls, missing various other possibilities of exiting a subprogram, such as by raising or propagating exceptions, and calling noreturn functions. The checks inserted before returns also prevented potential tail-call optimizations. This incremental change introduces options to control checking at each of these previously-missed checkpoints. Unless disabled, a cleanup is introduced to check when an exceptions escapes a subprogram. To avoid disrupting sibcall optimizations, when they are enabled, checks are introduced before calls whose results are immediately returned, whether or not they are ultimately optimized. If enabled, checks are introduced before noreturn calls and exception raises, or only before nothrow noreturn calls. Add examples of code transformations to the GNAT RM. gcc/ada/ * doc/gnat_rm/security_hardening_features.rst: Document optional hardcfr checkpoints. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
2022-11-14ada: Crash on applying 'Pos to expression of a type derived from a formal typeGary Dismukes1-3/+4
The compiler crashes when trying to do a static check for a range violation in a type conversion of a Pos attribute applied to a prefix of a type derived from a generic formal discrete type. This optimization was suppressed in the case of formal types, because the upper bound may not be known, but it also needs to be suppressed for types derived from formal types. gcc/ada/ * checks.adb (Apply_Type_Conversion_Checks): Apply Root_Type to the type of the prefix of a Pos attribute when checking whether the type is a formal discrete type.
2022-11-14ada: Fix non-capturing parentheses handlingRonan Desplanques1-5/+3
Before this patch, non-capturingly parenthesized expressions with more than one branch were processed incorrectly when part of a branch followed by another branch. This patch fixes this by aligning the handling of non-capturing parentheses with the handling of regular parentheses. gcc/ada/ * libgnat/s-regpat.adb (Parse): Fix handling of non-capturing parentheses.
2022-11-14ada: Fix error on SPARK_Mode on library-level separate bodyYannick Moy1-3/+7
When applying explicitly SPARK_Mode on a separate library-level spec and body for which a contract needs to be checked, compilation with -gnata was failing on a spurious error related to SPARK_Mode placement. Now fixed. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Add special case for the special local subprogram created for contracts.
2022-11-14ada: Adjust locations in aspects on generic formal subprogramsPiotr Trojanek1-0/+20
When instantiating a generic that has formal subprogram parameter with contracts, e.g.: generic with procedure P with Pre => ..., Post => ...; ... we create a wrapper that executes Pre/Post contracts before/after calling the actual subprogram. Errors emitted for these contracts will now have locations of the instance and not just of the generic. gcc/ada/ * sem_ch12.adb (Build_Subprogram_Wrappers): Adjust slocs of the copied aspects, just like we do in Build_Class_Wide_Expression for inherited class-wide contracts.
2022-11-14ada: Fix style in code for generic formal subprograms with contractsPiotr Trojanek3-20/+20
Code cleanup related to expansion generic formal subprograms with contracts for GNATprove. gcc/ada/ * inline.adb (Replace_Formal): Tune whitespace. * sem_ch12.adb (Check_Overloaded_Formal_Subprogram): Refine type of a formal parameter and local variable; this routine operates on nodes and not entities. * sem_ch12.ads: Tune whitespace.
2022-11-14ada: Expand generic formal subprograms with contracts for GNATprovePiotr Trojanek1-1/+1
In GNATprove mode generic formal subprograms with Pre/Post contracts are now expanded into wrappers, just like in ordinary compilation. gcc/ada/ * sem_ch12.adb (Analyze_Associations): Expand wrappers for GNATprove.
2022-11-14ada: Enable Support_Atomic_Primitives on QNX and RTEMSPatrick Bernardi2-1/+2
QNX and RTEMS support 64-bit atomic primitives. gcc/ada/ * libgnat/system-qnx-arm.ads: Set Support_Atomic_Primitives to True. * libgnat/system-rtems.ads: Add Support_Atomic_Primitives.
2022-11-14ada: Improve location of error messages in instantiationsYannick Moy4-12/+13
When flag -gnatdF is used, source code lines are displayed to point the location of errors. The code of the instantiation was displayed in case of errors inside generic instances, which was not precise. Now the code inside the generic is displayed. gcc/ada/ * errout.adb (Error_Msg_Internal): Store span for Optr field, and adapt to new type of Optr. (Finalize. Output_JSON_Message, Remove_Warning_Messages): Adapt to new type of Optr. (Output_Messages): Use Optr instead of Sptr to display code snippet closer to error. * erroutc.adb (dmsg): Adapt to new type of Optr. * erroutc.ads (Error_Msg_Object): Make Optr a span like Sptr. * errutil.adb (Error_Msg): Likewise.
2022-11-14ada: Remove gnatcheck referenceArnaud Charlet1-22/+0
Since gnatcheck is no longer bundled with gnat gcc/ada/ * doc/gnat_ugn/gnat_utility_programs.rst: Remove gnatcheck reference.
2022-11-14Revert "sphinx: ada: port to Sphinx"Martin Liska20-247/+62000
This reverts commit 0a543515957ff47feba739e6f71062fb2fb99125.
2022-11-14Revert "sphinx: add --with-sphinx-build"Martin Liska1-12/+12
This reverts commit 1f5a932e89b0c2c4a7af7f849ca2e2e3dbf329e0.
2022-11-14Revert "sphinx: fix cross manual references"Martin Liska1-2/+1
This reverts commit 72318642439703bba8c83423d4706e06444254d6.
2022-11-14Revert "sphinx: support installation if sphinx-build is missing"Martin Liska1-3/+6
This reverts commit e5821d3f62b5bf532db1be661459b7553a956fa2.
2022-11-10Daily bump.GCC Administrator1-0/+41
2022-11-09sphinx: support installation if sphinx-build is missingMartin Liska1-6/+3
gcc/ChangeLog: * Makefile.in: Support installation if sphinx-build is missing. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support installation if sphinx-build is missing. gcc/cp/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/d/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/fortran/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/go/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. Support installation if sphinx-build is missing. gcc/jit/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing.
2022-11-09sphinx: fix cross manual referencesMartin Liska1-1/+2
gcc/ada/ChangeLog: * doc/gnat_rm/index.rst: Fix cross manual refs. gcc/ChangeLog: * doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst: Fix cross manual refs. * doc/gcc/language-standards-supported-by-gcc/references-for-other-languages.rst: Likewise. gcc/jit/ChangeLog: * doc/internals/index.rst: Fix cross manual refs. * doc/topics/contexts.rst: Likewise.
2022-11-09sphinx: add --with-sphinx-buildMartin Liska1-12/+12
gcc/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: * configure: Regenerate. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support --with-sphinx-build. gcc/d/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/fortran/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/go/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/jit/ChangeLog: * Make-lang.in: Support --with-sphinx-build. libgomp/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise.. * configure: Regenerate. libiberty/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libitm/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libquadmath/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate.
2022-11-09sphinx: ada: port to SphinxMartin Liska20-62000/+247
gcc/ada/ChangeLog: * doc/gnat-style.rst: Moved to... * doc/gnat-style/index.rst: ...here. * doc/gnat_rm.rst: Moved to... * doc/gnat_rm/index.rst: ...here. * doc/gnat_ugn.rst: Moved to... * doc/gnat_ugn/index.rst: ...here. * doc/share/latex_elements.py: Moved to... * doc/share/ada_latex_elements.py: ...here. * gcc-interface/Make-lang.in: * doc/Makefile: Removed. * doc/share/conf.py: Removed. * doc/share/gnu_free_documentation_license.rst: Removed. * gnat-style.texi: Removed. * gnat_rm.texi: Removed. * gnat_ugn.texi: Removed. * doc/gnat-style/conf.py: New file. * doc/gnat-style/gnu_free_documentation_license.rst: New file. * doc/gnat_rm/conf.py: New file. * doc/gnat_rm/gnu_free_documentation_license.rst: New file. * doc/gnat_ugn/conf.py: New file. * doc/gnat_ugn/gnu_free_documentation_license.rst: New file. * doc/share/adabaseconf.py: New file. * doc/gnat_rm/security_hardening_features.rst: Add role. * doc/gnat_ugn/platform_specific_information.rst: Remove duplicate definition of |nbsp|.
2022-11-09Daily bump.GCC Administrator1-0/+296
2022-11-08ada: Fix oversight in implementation of allocators for storage modelsEric Botcazou1-7/+26
When the allocator is of an unconstrained array type and has an initializing expression, the copy of the initializing expression must be done separately from that of the bounds. gcc/ada/ * gcc-interface/utils2.cc (build_allocator): For unconstrained array types with a storage model and an initializing expression, copy the initialization expression separately from the bounds. In all cases with a storage model, pass the locally computed size for the store.
2022-11-08ada: Compile-time simplification of 'Image incorrectly ignores Put_ImageSteve Baird1-1/+3
In the case of Some_Enumeration_Type'Image (<some static value>), the compiler will replace this expression in its internal program representation with a corresponding string literal. This is incorrect if the Put_Image aspect has been specified (directly or via inheritance) for the enumeration type. gcc/ada/ * sem_attr.adb (Eval_Attribute): Don't simplify 'Image call if Put_Image has been specified.
2022-11-08ada: Clean up call to check if aspects are presentPiotr Trojanek7-16/+14
Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch6.adb, exp_put_image.adb, sem_aggr.adb, sem_attr.adb, sem_ch5.adb, sem_type.adb, sem_util.adb: Replace "Present (Find_Aspect (...))" with "Has_Aspect".
2022-11-08ada: Adjust classwide contract expression preanalysisRonan Desplanques3-232/+267
Before this patch, a classwide contract expression was preanalyzed only when its primitive operation's type was frozen. It caused name resolution to be off in the cases where the freezing took place after the end of the declaration list the primitive operation was declared in. This patch makes it so that if the compiler gets to the end of the declaration list before the type is frozen, it preanalyzes the classwide contract expression, so that the names are resolved in the right context. gcc/ada/ * contracts.adb (Preanalyze_Class_Conditions): New procedure. (Preanalyze_Condition): Moved out from Merge_Class_Conditions in order to be spec-visible. * contracts.ads (Preanalyze_Class_Conditions): New procedure. * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Call Preanalyze_Class_Conditions when necessary.
2022-11-08ada: Set Support_Atomic_Primitives for VxWorks 7 runtimesJohannes Kliemann12-8/+12
gcc/ada/ * libgnat/system-vxworks7-aarch64-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-aarch64.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-arm-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-arm.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-ppc-kernel.ads: Set Support_Atomic_Primitives to False. * libgnat/system-vxworks7-ppc-rtp-smp.ads: Set Support_Atomic_Primitives to False. * libgnat/system-vxworks7-ppc64-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-ppc64-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86-rtp-smp.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86_64-kernel.ads: Set Support_Atomic_Primitives to True. * libgnat/system-vxworks7-x86_64-rtp-smp.ads: Set Support_Atomic_Primitives to True.
2022-11-08ada: Small consistency fixEric Botcazou1-1/+1
gcc/ada/ * fe.h (Get_Warn_On_Questionable_Layout): Add void parameter.
2022-11-08ada: Propagate aspect Ghost when instantiating null formal proceduresPiotr Trojanek1-0/+2
When instantiating generic package that includes a formal subprogram declaration with Ghost aspect and a subprogram_default of null, e.g.: generic with procedure Proc is null with Ghost; package P is ... the Ghost aspect should be propagated to the internally generated null subprogram, so this null subprogram can be used in contexts that require ghost entities. gcc/ada/ * sem_ch12.adb (Instantiate_Formal_Subprogram): Copy aspect Ghost from formal subprogram declaration to the internally generated procedure.
2022-11-08ada: Implement RM 4.5.7(10/3) name resolution ruleEric Botcazou2-82/+156
This rule deals with the specific case of a conditional expression that is the operand of a type conversion and effectively distributes the conversion to the dependent expressions with the help of the dynamic semantics. gcc/ada/ * sem_ch4.adb (Analyze_Case_Expression): Compute the interpretations of the expression only at the end of the analysis, but skip doing it if it is the operand of a type conversion. (Analyze_If_Expression): Likewise. * sem_res.adb (Resolve): Deal specially with conditional expression that is the operand of a type conversion. (Resolve_Dependent_Expression): New procedure. (Resolve_Case_Expression): Call Resolve_Dependent_Expression. (Resolve_If_Expression): Likewise. (Resolve_If_Expression.Apply_Check): Take result type as parameter. (Resolve_Type_Conversion): Do not warn about a redundant conversion when the operand is a conditional expression.
2022-11-08ada: Enforce matching of extra formalsJavier Miranda13-458/+1437
This patch enforces matching of extra formals in overridden subprograms, subprogram renamings, and subprograms to which attributes 'Access, 'Unchecked_Access, or 'Unrestricted_Access is applied (for these access cases the subprogram is checked against its corresponding subprogram type). This enforcement is an internal consistency check, not an implementation of some language legality rule. gcc/ada/ * debug.adb (Debug_Flag_Underscore_XX): Switch -gnatd_X used temporarily to allow disabling extra formal checks. * exp_attr.adb (Expand_N_Attribute_Reference [access types]): Add extra formals to the subprogram referenced in the prefix of 'Unchecked_Access, 'Unrestricted_Access or 'Access; required to check that its extra formals match the extra formals of the corresponding subprogram type. * exp_ch3.adb (Stream_Operation_OK): Declaration moved to the public part of the package. (Validate_Tagged_Type_Extra_Formals): New subprogram. (Expand_Freeze_Record_Type): Improve the code that takes care of adding the extra formals of dispatching primitives; extended to add also the extra formals to renamings of dispatching primitives. * exp_ch3.ads (Stream_Operation_OK): Declaration moved from the package body. * exp_ch6.adb (Check_BIP_Actuals): Complete documentation. (Has_BIP_Extra_Formal): Subprogram declaration moved to the public part of the package. In addition, a parameter has been added to disable an assertion that requires its use with frozen entities. (Duplicate_Params_Without_Extra_Actuals): New subprogram. (Check_Subprogram_Variant): Emit the call without duplicating the extra formals since they will be added when the call is analyzed. (Expand_Call_Helper): Ensure that the called subprogram has all its extra formals, enforce assertion checking extra formals on thunks, and mark calls from thunks as processed-BIP-calls to avoid adding their extra formals twice. (Is_Build_In_Place_Function): Return False for entities with foreign convention. (Is_Build_In_Place_Function_Call): Return True also for not BIP functions that have BIP formals since the extra actuals are required. (Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of Is_Return_Object replaced by the local variable Is_OK_Return_Object that evaluates to False for scopes with foreign convention. (Might_Have_Tasks): Fix check of class-wide limited record types. (Needs_BIP_Task_Actuals): Remove assertion to allow calling this function in more contexts; in addition it returns False for functions returning objects with foreign convention. (Needs_BIP_Finalization_Master): Likewise. (Needs_BIP_Alloc_Form): Likewise. (Validate_Subprogram_Calls): Check that the number of actuals (including extra actuals) of calls in the subtree N match their corresponding formals. * exp_ch6.ads (Has_BIP_Extra_Formal): Subprogram declaration moved to the public part of the package. In addition, a parameter has been added to disable an assertion that requires its use with frozen entities. (Is_Build_In_Place_Function_Call): Complete documentation. (Validate_Subprogram_Calls): Check that the number of actuals (including extra actuals) of calls in the subtree N match their corresponding formals. * freeze.adb (Check_Itype): Add extra formals to anonymous access subprogram itypes. (Freeze_Expression): Improve code that disables the addition of extra formals to functions with foreign convention. (Check_Extra_Formals): Moved to package Sem_Ch6 as Extra_Formals_OK. (Freeze_Subprogram): Add extra formals to non-dispatching subprograms. * frontend.adb (Frontend): Validate all the subprogram calls; it can be disabled using switch -gnatd_X * sem_ch3.adb (Access_Subprogram_Declaration): Defer the addition of extra formals to the freezing point so that we know the convention. (Check_Anonymous_Access_Component): Likewise. (Derive_Subprogram): Fix documentation. * sem_ch6.adb (Has_Reliable_Extra_Formals): New subprogram. (Check_Anonymous_Return): Fix check of access to class-wide limited record types. (Check_Untagged_Equality): Placed in alphabetical order. (Extra_Formals_OK): Subprogram moved from freeze.adb. (Extra_Formals_Match_OK): New subprogram. (Has_BIP_Formals): New subprogram. (Has_Extra_Formals): New subprograms. (Needs_Accessibility_Check_Extra): New subprogram. (Parent_Subprogram): New subprogram. (Add_Extra_Formal): Minor code cleanup. (Create_Extra_Formals): Enforce matching extra formals on overridden and aliased entities. * sem_ch6.ads (Extra_Formals_Match_OK): New subprogram. (Extra_Formals_OK): Subprogram moved from freeze.adb. * sem_eval.adb (Compile_Time_Known_Value): Improve predicate to avoid assertion failure; found working on this ticket; this change does not affect the behavior of the compiler because this subprogram has an exception handler that returns False when the assertion fails. * sem_util.adb (Needs_Result_Accessibility_Level): Do not return False for dispatching operations compiled with Ada_Version < 2012 since they they may be overridden by primitives compiled with Ada_Version >= Ada_2012.
2022-11-08ada: Move warnings switches -- initial workBob Duff11-23/+20
This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed).
2022-11-08ada: Align -gnatwc's documentation with its behaviorRonan Desplanques2-2/+2
Shortly after the -gnatwc flag was introduced, its behavior was tweaked, but its documentation was not updated accordingly. gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst (-gnatwc): Fix flag documentation. * gnat_ugn.texi: Regenerate.
2022-11-08ada: Improve handling of declare expressions in deferred-freezing contextsSteve Baird1-0/+20
In some cases where a declare expression occurs in a deferred-freezing context (e.g., within the default value for a discriminant or for a formal parameter, or within the expression of an expression function), the compiler generates a bugbox. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Do not perform expansion actions if In_Spec_Expression is true.
2022-11-08ada: Minor consistency tweaks in Sem_Ch4Eric Botcazou1-15/+24
This ensures that, during the analysis of the qualified expressions, type conversions and unchecked type conversions, the determination of the type of the node and the analysis of its expression are done in the same order. No functional changes. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Analyze the expression only after setting the type. (Analyze_Unchecked_Type_Conversion): Likewise. (Analyze_Short_Circuit): Likewise for the operands. (Analyze_Type_Conversion): Minor tweaks. (Analyze_Unchecked_Expression): Likewise.
2022-11-08ada: Remove redundant line in Analyze_Qualified_ExpressionEric Botcazou1-2/+0
The same statement is present a few lines above. gcc/ada/ * sem_ch4.adb (Analyze_Qualified_Expression): Remove redundant line.
2022-11-08ada: Preanalyze classwide contracts as spec expressionsRonan Desplanques1-2/+2
Classwide contracts are "spec expressions" as defined in the documentation in sem.ads. Before this patch, the instances of classwide contracts that are destined to class conditions merging were not preanalyzed as spec expressions. That caused preanalysis to emit spurious errors in some cases. gcc/ada/ * contracts.adb (Preanalyze_Condition): Use Preanalyze_Spec_Expression.
2022-11-08ada: Fix expansion of 'Wide_Image and 'Wide_Wide_Image on composite typesPiotr Trojanek4-7/+51
Attributes Wide_Image and Wide_Wide_Image applied to composite types are now expanded just like attribute Image. gcc/ada/ * exp_imgv.adb (Expand_Wide_Image_Attribute): Handle just like attribute Image. (Expand_Wide_Wide_Image_Attribute): Likewise. * exp_put_image.adb (Build_Image_Call): Adapt to also work for Wide and Wide_Wide attributes. * exp_put_image.ads (Build_Image_Call): Update comment. * rtsfind.ads (RE_Id): Support wide variants of Get. (RE_Unit_Table): Likewise.
2022-11-08ada: Fix inconsistent whitespace in Ada.Numerics.Generic_Complex_ArraysPiotr Trojanek2-4/+4
Cleanup only. gcc/ada/ * libgnat/a-ngcoar.ads, libgnat/a-ngcoar.adb: Remove extra spaces.
2022-11-08ada: Remove unneeded code in handling formal type defaultsPiotr Trojanek1-4/+2
Unneeded code found while experimenting with improved detection of unreferenced objects. gcc/ada/ * sem_ch12.adb (Validate_Formal_Type_Default): Remove call to Collect_Interfaces, which had no effect apart from populating a list that was not used; fix style.
2022-11-08ada: Cleanup local variable that is only set as an out parameterPiotr Trojanek2-10/+10
Minor improvements; found experimenting with improved detection of unreferenced objects. gcc/ada/ * exp_spark.adb (SPARK_Freeze_Type): Refine type of a local object. * sem_ch3.adb (Derive_Subprograms): Remove initial value for New_Subp, which is in only written as an out parameter and never read.
2022-11-08ada: Remove obsolete code in Resolve_If_ExpressionEric Botcazou1-12/+1
gcc/ada/ * sem_res.adb (Resolve_If_Expression): Remove obsolete special case.